]> Git Repo - linux.git/commit
blk-mq: always free hctx after request queue is freed
authorMing Lei <[email protected]>
Tue, 30 Apr 2019 01:52:27 +0000 (09:52 +0800)
committerJens Axboe <[email protected]>
Sat, 4 May 2019 13:24:08 +0000 (07:24 -0600)
commit2f8f1336a48bd5186de3476da0a3e2ec06d0533a
tree1bc1ee8510442e16f00ba1cf82ebfb0dfb926017
parent7c6c5b7c9186e3fb5b10afb8e5f710ae661144c6
blk-mq: always free hctx after request queue is freed

In normal queue cleanup path, hctx is released after request queue
is freed, see blk_mq_release().

However, in __blk_mq_update_nr_hw_queues(), hctx may be freed because
of hw queues shrinking. This way is easy to cause use-after-free,
because: one implicit rule is that it is safe to call almost all block
layer APIs if the request queue is alive; and one hctx may be retrieved
by one API, then the hctx can be freed by blk_mq_update_nr_hw_queues();
finally use-after-free is triggered.

Fixes this issue by always freeing hctx after releasing request queue.
If some hctxs are removed in blk_mq_update_nr_hw_queues(), introduce
a per-queue list to hold them, then try to resuse these hctxs if numa
node is matched.

Cc: Dongli Zhang <[email protected]>
Cc: James Smart <[email protected]>
Cc: Bart Van Assche <[email protected]>
Cc: [email protected],
Cc: Martin K . Petersen <[email protected]>,
Cc: Christoph Hellwig <[email protected]>,
Cc: James E . J . Bottomley <[email protected]>,
Reviewed-by: Hannes Reinecke <[email protected]>
Tested-by: James Smart <[email protected]>
Signed-off-by: Ming Lei <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
block/blk-mq.c
include/linux/blk-mq.h
include/linux/blkdev.h
This page took 0.043772 seconds and 4 git commands to generate.