[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1626275195-215652-10-git-send-email-john.garry@huawei.com>
Date: Wed, 14 Jul 2021 23:06:35 +0800
From: John Garry <john.garry@...wei.com>
To: <axboe@...nel.dk>
CC: <linux-block@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<ming.lei@...hat.com>, <linux-scsi@...r.kernel.org>,
<kashyap.desai@...adcom.com>, <hare@...e.de>,
John Garry <john.garry@...wei.com>
Subject: [PATCH 9/9] blk-mq: Clear mappings for shared sbitmap sched static rqs
To avoid use-after-free in accessing stale requests in the driver tags
rqs[], clear the mappings for the request queue static rqs.
Signed-off-by: John Garry <john.garry@...wei.com>
---
block/blk-mq-sched.c | 1 +
block/blk-mq.h | 2 ++
2 files changed, 3 insertions(+)
diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index 7b5c46647820..f1cea7f3bc68 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -711,6 +711,7 @@ void blk_mq_sched_free_requests(struct request_queue *q)
queue_for_each_hw_ctx(q, hctx, i) {
if (hctx->sched_tags) {
if (blk_mq_is_sbitmap_shared(q->tag_set->flags)) {
+ blk_mq_clear_rq_mapping(q->tag_set, i, &q->page_list);
} else {
blk_mq_free_rqs(q->tag_set, hctx->sched_tags, i);
}
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 1e0fbb06412b..a5b7aa7a07b9 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -69,6 +69,8 @@ int blk_mq_alloc_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags,
int __blk_mq_alloc_rqs(struct blk_mq_tag_set *set, unsigned int hctx_idx,
unsigned int depth, struct list_head *page_list,
struct request **static_rqs);
+void blk_mq_clear_rq_mapping(struct blk_mq_tag_set *set, unsigned int hctx_idx,
+ struct list_head *page_list);
/*
* Internal helpers for request insertion into sw queues
--
2.26.2
Powered by blists - more mailing lists