]> git.baikalelectronics.ru Git - kernel.git/commit
block: let blkcg_gq grab request queue's refcnt
authorMing Lei <ming.lei@redhat.com>
Fri, 18 Mar 2022 13:01:43 +0000 (21:01 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 18 Mar 2022 15:57:56 +0000 (09:57 -0600)
commit26a6d00e530f2dfc2e3b61e7749c8b8e5af8e08d
treef5e4003404e754f63212e1ed349f7812e5af709c
parent74e520296a26afaeca98da0f29016c31dcad625c
block: let blkcg_gq grab request queue's refcnt

In the whole lifetime of blkcg_gq instance, ->q will be referred, such
as, ->pd_free_fn() is called in blkg_free, and throtl_pd_free() still
may touch the request queue via &tg->service_queue.pending_timer which
is handled by throtl_pending_timer_fn(), so it is reasonable to grab
request queue's refcnt by blkcg_gq instance.

Previously blkcg_exit_queue() is called from blk_release_queue, and it
is hard to avoid the use-after-free. But recently commit 10ef9e4eaec6 ("block:
move blkcg initialization/destroy into disk allocation/release handler")
is merged to for-5.18/block, it becomes simple to fix the issue by simply
grabbing request queue's refcnt.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20220318130144.1066064-3-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-cgroup.c