summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Madani <tristan@talencesecurity.com>2026-05-01 11:02:03 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-07-04 13:44:19 +0200
commitb85ef03f726b15047a6fa6d11b639bdf6c0ee4f0 (patch)
tree5d2cc667a2508fd448c688cb55b144d3d2be695f
parent8d8507a457667f23477a15496b91908a5b5b7cf3 (diff)
downloadlinux-b85ef03f726b15047a6fa6d11b639bdf6c0ee4f0.tar.gz
linux-b85ef03f726b15047a6fa6d11b639bdf6c0ee4f0.zip
gfs2: fix use-after-free in gfs2_qd_dealloc
commit f9c9ec2c319f843b70ecdf939d48b52d189bc081 upstream. gfs2_qd_dealloc(), called as an RCU callback from gfs2_qd_dispose(), accesses the superblock object sdp through qd->qd_sbd after freeing qd. It does so to decrement sd_quota_count and wake up sd_kill_wait. However, by the time the RCU callback runs, gfs2_put_super() may have already freed sdp via free_sbd(). This can happen when gfs2_quota_cleanup() is called during unmount: it disposes of quota objects via call_rcu() and then waits on sd_kill_wait with a 60-second timeout. If the timeout expires, or if gfs2_gl_hash_clear() triggers additional qd_put() calls that schedule more RCU callbacks after the wait completes, gfs2_put_super() will proceed to free the superblock while RCU callbacks referencing it are still pending. Add an rcu_barrier() before free_sbd() in gfs2_put_super() to ensure all pending RCU callbacks (including gfs2_qd_dealloc) have completed before the superblock is freed. Fixes: a475c5dd16e5 ("gfs2: Free quota data objects synchronously") Reported-by: syzbot+42a37bf8045847d8f9d2@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=42a37bf8045847d8f9d2 Tested-by: syzbot+42a37bf8045847d8f9d2@syzkaller.appspotmail.com Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani <tristan@talencesecurity.com> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/gfs2/super.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 54c6f2098f01..7b5fcd78a3a1 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -640,6 +640,7 @@ restart:
gfs2_delete_debugfs_file(sdp);
gfs2_sys_fs_del(sdp);
+ rcu_barrier();
free_sbd(sdp);
}