[Devel] [PATCH RH9] dm: Fix use-after-free in dm_cleanup_zoned_dev()
Kirill Tkhai
ktkhai at virtuozzo.com
Tue Feb 1 11:43:36 MSK 2022
dm_cleanup_zoned_dev() uses queue, so it must be called
before blk_cleanup_disk() starts its killing:
blk_cleanup_disk->blk_cleanup_queue()->kobject_put()->blk_release_queue()->
->...RCU...->blk_free_queue_rcu()->kmem_cache_free()
Otherwise, RCU callback may be executed first, and dm_cleanup_zoned_dev()
touches freed memory. See full KASAN trace in #PSBM-138227.
https://jira.sw.ru/browse/PSBM-138227
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/md/dm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 2c5f9e5852117..a678556c3da18 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1699,6 +1699,7 @@ static void cleanup_mapped_device(struct mapped_device *md)
if (md->queue)
dm_queue_destroy_keyslot_manager(md->queue);
+ dm_cleanup_zoned_dev(md);
if (md->disk)
blk_cleanup_disk(md->disk);
@@ -1710,7 +1711,6 @@ static void cleanup_mapped_device(struct mapped_device *md)
mutex_destroy(&md->swap_bios_lock);
dm_mq_cleanup_mapped_device(md);
- dm_cleanup_zoned_dev(md);
}
/*
More information about the Devel
mailing list