Skip to content

Commit d22f69a

Browse files
AstralBobAndreas Gruenbacher
authored andcommitted
gfs2: Fix use-after-free in gfs2_logd after withdraw
When the gfs2_logd daemon withdrew, the withdraw sequence called into make_fs_ro() to make the file system read-only. That caused the journal descriptors to be freed. However, those journal descriptors were used by gfs2_logd's call to gfs2_ail_flush_reqd(). This caused a use-after free and NULL pointer dereference. This patch changes function gfs2_logd() so that it stops all logd work until the thread is told to stop. Once a withdraw is done, it only does an interruptible sleep. Signed-off-by: Bob Peterson <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 53af80c commit d22f69a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/gfs2/log.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,10 @@ int gfs2_logd(void *data)
11311131

11321132
while (!kthread_should_stop()) {
11331133

1134+
if (gfs2_withdrawn(sdp)) {
1135+
msleep_interruptible(HZ);
1136+
continue;
1137+
}
11341138
/* Check for errors writing to the journal */
11351139
if (sdp->sd_log_error) {
11361140
gfs2_lm(sdp,
@@ -1139,6 +1143,7 @@ int gfs2_logd(void *data)
11391143
"prevent further damage.\n",
11401144
sdp->sd_fsname, sdp->sd_log_error);
11411145
gfs2_withdraw(sdp);
1146+
continue;
11421147
}
11431148

11441149
did_flush = false;

0 commit comments

Comments
 (0)