[PATCH next] gfs2: Add sanity check for sd_jdesc

From: Edward Adam Davis

Date: Wed Oct 15 2025 - 05:56:15 EST


Asynchronous withdraw, when sd_withdraw_work is scheduled later than
put_super, will set sd_jdesc to NULL when clearing all journal index
information, triggering the syz report uaf.

Reported-by: syzbot+6b156e132970e550194c@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=6b156e132970e550194c
Signed-off-by: Edward Adam Davis <eadavis@xxxxxx>
---
fs/gfs2/log.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 8312cd2cdae4..433a3a11a2f5 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -427,7 +427,8 @@ static void ail2_empty(struct gfs2_sbd *sdp, unsigned int new_tail)
*/

bool gfs2_log_is_empty(struct gfs2_sbd *sdp) {
- return atomic_read(&sdp->sd_log_blks_free) == sdp->sd_jdesc->jd_blocks;
+ return sdp->sd_jdesc &&
+ atomic_read(&sdp->sd_log_blks_free) == sdp->sd_jdesc->jd_blocks;
}

static bool __gfs2_log_try_reserve_revokes(struct gfs2_sbd *sdp, unsigned int revokes)
--
2.43.0