Commit 6be6d11
blk-mq: fix tags UAF when shrinking q->nr_hw_queues
When nr_hw_queues shrink, we free the excess tags before realloc'ing
hw_ctxs for each queue. During that resize, we may need to access those
tags, like blk_mq_tag_idle(hctx) will access queue shared tags.
This can cause a slab use-after-free, as reported by KASAN. Fix it by
moving the releasing of excess tags to the end.
Fixes: e1dd7bc ("blk-mq: fix tags leak when shrink nr_hw_queues")
Reported-by: Yi Zhang <yi.zhang@redhat.com>
Closes: https://lore.kernel.org/all/CAHj4cs_CK63uoDpGBGZ6DN4OCTpzkR3UaVgK=LX8Owr8ej2ieQ@mail.gmail.com/
Cc: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20230908005702.2183908-1-chengming.zhou@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk>1 parent 0bb80ec commit 6be6d11
1 file changed
+7
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4405 | 4405 | | |
4406 | 4406 | | |
4407 | 4407 | | |
4408 | | - | |
4409 | | - | |
4410 | | - | |
| 4408 | + | |
4411 | 4409 | | |
4412 | | - | |
4413 | 4410 | | |
4414 | 4411 | | |
4415 | 4412 | | |
| |||
4719 | 4716 | | |
4720 | 4717 | | |
4721 | 4718 | | |
4722 | | - | |
| 4719 | + | |
| 4720 | + | |
4723 | 4721 | | |
4724 | 4722 | | |
4725 | 4723 | | |
| |||
4746 | 4744 | | |
4747 | 4745 | | |
4748 | 4746 | | |
4749 | | - | |
4750 | 4747 | | |
4751 | 4748 | | |
4752 | 4749 | | |
| |||
4781 | 4778 | | |
4782 | 4779 | | |
4783 | 4780 | | |
| 4781 | + | |
| 4782 | + | |
| 4783 | + | |
| 4784 | + | |
4784 | 4785 | | |
4785 | 4786 | | |
4786 | 4787 | | |
| |||
0 commit comments