Re: [syzbot] [gfs2?] KASAN: slab-use-after-free Read in gfs2_invalidate_folio

From: Edward Adam Davis
Date: Sat Apr 13 2024 - 21:48:34 EST


please test uaf in gfs2_invalidate_folio

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git e8c39d0f57f3

diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c
index 192213c7359a..8d169b389dc1 100644
--- a/fs/gfs2/trans.c
+++ b/fs/gfs2/trans.c
@@ -202,16 +202,8 @@ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh)
}
gfs2_log_lock(sdp);
bd = bh->b_private;
- if (bd == NULL) {
- gfs2_log_unlock(sdp);
- unlock_buffer(bh);
- if (bh->b_private == NULL)
- bd = gfs2_alloc_bufdata(gl, bh);
- else
- bd = bh->b_private;
- lock_buffer(bh);
- gfs2_log_lock(sdp);
- }
+ if (bd == NULL)
+ bd = gfs2_alloc_bufdata(gl, bh);
gfs2_assert(sdp, bd->bd_gl == gl);
set_bit(TR_TOUCHED, &tr->tr_flags);
if (list_empty(&bd->bd_list)) {