Re: [syzbot] [mm?] KASAN: slab-use-after-free Read in folio_evictable (3)

From: Edward Adam Davis
Date: Sat Dec 14 2024 - 23:54:03 EST


#syz test

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 8c4c1f871a88..8f851ecd1625 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -267,6 +267,7 @@ static void __gfs2_glock_put(struct gfs2_glock *gl)
lockref_mark_dead(&gl->gl_lockref);
spin_unlock(&gl->gl_lockref.lock);
gfs2_glock_remove_from_lru(gl);
+ cancel_delayed_work(&gl->gl_work);
GLOCK_BUG_ON(gl, !list_empty(&gl->gl_holders));
if (mapping) {
truncate_inode_pages_final(mapping);
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 042329b74c6e..3dcef4bb0427 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -222,6 +222,7 @@ static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev,
bool need_free = false;
int ret;
struct sbitmap sb_backup;
+ unsigned int flags;

depth = min_t(unsigned int, depth, scsi_device_max_queue_depth(sdev));

@@ -243,10 +244,12 @@ static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev,
blk_mq_freeze_queue(sdev->request_queue);
sb_backup = sdev->budget_map;
}
+ flags = memalloc_nofs_save();
ret = sbitmap_init_node(&sdev->budget_map,
scsi_device_max_queue_depth(sdev),
new_shift, GFP_KERNEL,
sdev->request_queue->node, false, true);
+ memalloc_nofs_restore(flags);
if (!ret)
sbitmap_resize(&sdev->budget_map, depth);