Skip to content

Commit bdcb8aa

Browse files
juntongdengAndreas Gruenbacher
authored andcommitted
gfs2: Fix slab-use-after-free in gfs2_qd_dealloc
In gfs2_put_super(), whether withdrawn or not, the quota should be cleaned up by gfs2_quota_cleanup(). Otherwise, struct gfs2_sbd will be freed before gfs2_qd_dealloc (rcu callback) has run for all gfs2_quota_data objects, resulting in use-after-free. Also, gfs2_destroy_threads() and gfs2_quota_cleanup() is already called by gfs2_make_fs_ro(), so in gfs2_put_super(), after calling gfs2_make_fs_ro(), there is no need to call them again. Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=29c47e9e51895928698c Signed-off-by: Juntong Deng <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 074d730 commit bdcb8aa

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

fs/gfs2/super.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -602,13 +602,15 @@ static void gfs2_put_super(struct super_block *sb)
602602
}
603603
spin_unlock(&sdp->sd_jindex_spin);
604604

605-
if (!sb_rdonly(sb)) {
605+
if (!sb_rdonly(sb))
606606
gfs2_make_fs_ro(sdp);
607-
}
608-
if (gfs2_withdrawn(sdp)) {
609-
gfs2_destroy_threads(sdp);
607+
else {
608+
if (gfs2_withdrawn(sdp))
609+
gfs2_destroy_threads(sdp);
610+
610611
gfs2_quota_cleanup(sdp);
611612
}
613+
612614
WARN_ON(gfs2_withdrawing(sdp));
613615

614616
/* At this point, we're through modifying the disk */

0 commit comments

Comments
 (0)