Skip to content

block: fix q->blkg_list corruption during disk rebind

JIRA: https://issues.redhat.com/browse/RHEL-33577

commit 8b8ace080319a866f5dfe9da8e665ae51d971c54
Author: Ming Lei ming.lei@redhat.com
Date: Sun Apr 7 20:59:10 2024 +0800

block: fix q->blkg_list corruption during disk rebind  

Multiple gendisk instances can allocated/added for single request queue  
in case of disk rebind. blkg may still stay in q->blkg_list when calling  
blkcg_init_disk() for rebind, then q->blkg_list becomes corrupted.  

Fix the list corruption issue by:  

- add blkg_init_queue() to initialize q->blkg_list & q->blkcg_mutex only  
- move calling blkg_init_queue() into blk_alloc_queue()  

The list corruption should be started since commit f1c006f1c685 ("blk-cgroup:  
synchronize pd_free_fn() from blkg_free_workfn() and blkcg_deactivate_policy()")  
which delays removing blkg from q->blkg_list into blkg_free_workfn().  

Fixes: f1c006f1c685 ("blk-cgroup: synchronize pd_free_fn() from blkg_free_workfn() and blkcg_deactivate_policy()")  
Fixes: 1059699f87eb ("block: move blkcg initialization/destroy into disk allocation/release handler")  
Cc: Yu Kuai <yukuai3@huawei.com>  
Cc: Tejun Heo <tj@kernel.org>  
Signed-off-by: Ming Lei <ming.lei@redhat.com>  
Reviewed-by: Yu Kuai <yukuai3@huawei.com>  
Link: https://lore.kernel.org/r/20240407125910.4053377-1-ming.lei@redhat.com  
Signed-off-by: Jens Axboe <axboe@kernel.dk>  

Signed-off-by: Ming Lei ming.lei@redhat.com

Merge request reports