From: John Garry Date: Fri, 22 Oct 2021 08:12:20 +0000 (+0800) Subject: blk-mq-sched: Don't reference queue tagset in blk_mq_sched_tags_teardown() X-Git-Tag: v6.6.17~8868^2~40 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8bdf7b3fe1f48a2c1c212d4685903bba01409c0e;p=platform%2Fkernel%2Flinux-rpi.git blk-mq-sched: Don't reference queue tagset in blk_mq_sched_tags_teardown() We should not reference the queue tagset in blk_mq_sched_tags_teardown() (see function comment) for the blk-mq flags, so use the passed flags instead. This solves a use-after-free, similarly fixed earlier (and since broken again) in commit f0c1c4d2864e ("blk-mq: fix use-after-free in blk_mq_exit_sched"). Reported-by: Linux Kernel Functional Testing Reported-by: Naresh Kamboju Tested-by: Anders Roxell Fixes: e155b0c238b2 ("blk-mq: Use shared tags for shared sbitmap support") Signed-off-by: John Garry Link: https://lore.kernel.org/r/1634890340-15432-1-git-send-email-john.garry@huawei.com Signed-off-by: Jens Axboe --- diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index 5b259fd..c62b966 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -541,7 +541,7 @@ static void blk_mq_sched_tags_teardown(struct request_queue *q, unsigned int fla queue_for_each_hw_ctx(q, hctx, i) { if (hctx->sched_tags) { - if (!blk_mq_is_shared_tags(q->tag_set->flags)) + if (!blk_mq_is_shared_tags(flags)) blk_mq_free_rq_map(hctx->sched_tags); hctx->sched_tags = NULL; }