[Devel] [PATCH RHEL9 COMMIT] dm: Fix use-after-free in dm_cleanup_zoned_dev()
Konstantin Khorenko
khorenko at virtuozzo.com
Tue Feb 1 19:26:11 MSK 2022
The commit is pushed to "branch-rh9-5.14.0-4.vz9.12.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-4.vz9.12.4
------>
commit 9e6cb851d44811975e6317d0b738603418082d9d
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Tue Feb 1 19:26:10 2022 +0300
dm: Fix use-after-free in dm_cleanup_zoned_dev()
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>
Tested-by: Cyrill Gorcunov <gorcunov 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 2c5f9e585211..a678556c3da1 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