* [PATCH] gfs2: fix use-after-free in gfs2_qd_dealloc
@ 2026-05-01 11:02 Tristan Madani
2026-05-04 11:33 ` Andreas Gruenbacher
0 siblings, 1 reply; 3+ messages in thread
From: Tristan Madani @ 2026-05-01 11:02 UTC (permalink / raw)
To: Andreas Gruenbacher
Cc: gfs2, linux-kernel, stable, Tristan Madani,
syzbot+42a37bf8045847d8f9d2
From: Tristan Madani <tristan@talencesecurity.com>
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>
---
fs/gfs2/super.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index a2ea121331f18..4d854556b5299 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -643,6 +643,7 @@ static void gfs2_put_super(struct super_block *sb)
gfs2_delete_debugfs_file(sdp);
gfs2_sys_fs_del(sdp);
+ rcu_barrier();
free_sbd(sdp);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] gfs2: fix use-after-free in gfs2_qd_dealloc
2026-05-01 11:02 [PATCH] gfs2: fix use-after-free in gfs2_qd_dealloc Tristan Madani
@ 2026-05-04 11:33 ` Andreas Gruenbacher
2026-05-04 18:58 ` Tristan Madani
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Gruenbacher @ 2026-05-04 11:33 UTC (permalink / raw)
To: Tristan Madani
Cc: gfs2, linux-kernel, stable, Tristan Madani,
syzbot+42a37bf8045847d8f9d2
On Fri, May 1, 2026 at 1:02 PM Tristan Madani <tristmd@gmail.com> wrote:
> From: Tristan Madani <tristan@talencesecurity.com>
>
> 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>
> ---
> fs/gfs2/super.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
> index a2ea121331f18..4d854556b5299 100644
> --- a/fs/gfs2/super.c
> +++ b/fs/gfs2/super.c
> @@ -643,6 +643,7 @@ static void gfs2_put_super(struct super_block *sb)
> gfs2_delete_debugfs_file(sdp);
>
> gfs2_sys_fs_del(sdp);
> + rcu_barrier();
> free_sbd(sdp);
> }
>
> --
> 2.47.3
>
Applied, thanks.
Andreas
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gfs2: fix use-after-free in gfs2_qd_dealloc
2026-05-04 11:33 ` Andreas Gruenbacher
@ 2026-05-04 18:58 ` Tristan Madani
0 siblings, 0 replies; 3+ messages in thread
From: Tristan Madani @ 2026-05-04 18:58 UTC (permalink / raw)
To: Andreas Gruenbacher
Cc: gfs2, linux-kernel, stable, tristan, syzbot+42a37bf8045847d8f9d2
Thanks, Andreas.
Thanks,
Tristan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-04 18:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-01 11:02 [PATCH] gfs2: fix use-after-free in gfs2_qd_dealloc Tristan Madani
2026-05-04 11:33 ` Andreas Gruenbacher
2026-05-04 18:58 ` Tristan Madani
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox