[PATCH 6.6.y 2/2] blk-mq: reinsert cached request to the list

From: Artem Dinaburg

Date: Fri Oct 16 2026 - 14:48:29 EST


From: Keith Busch <kbusch@xxxxxxxxxx>

[ Upstream commit b051bb6bf0a231117036aa607cadf55be8e63910 ]

A previous commit removed an optimization out of caution for a scenario
that turns out not to be real: all the "queue_exit" goto's are safe to
reinsert the request into the cached_rq's plug list as they are either
from a non-blocking path, or a successful merge that already holds the
queue reference. This optimization is most needed for small sequential
workloads that successfully merge into larger requests.

Fixes: dc278e9bf2b9 ("blk-mq: pop cached request if it is usable")
Suggested-by: Ming Lei <tom.leiming@xxxxxxxxx>
Suggested-by: Christoph Hellwig <hch@xxxxxx>
Signed-off-by: Keith Busch <kbusch@xxxxxxxxxx>
Reviewed-by: Chaitanya Kulkarni <kch@xxxxxxxxxx>
Link: https://patch.msgid.link/20260526153531.2365935-1-kbusch@xxxxxxxx
Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
Assisted-by: LLM
[ Backport to 6.6.y: Reinsert with rq_list_add() on each of the three
target preparation or merge exits; the target has a single cached_rq
list and no shared queue_exit label. ]
Signed-off-by: Artem Dinaburg <artem@xxxxxxxxxxxxxxx>
---
Hi,

Please consider this backport of the corrective follow-up for
CVE-2026-64017 to 6.6.y.

The backport reinserts the cached request at each of the three older
preparation or merge exits. See the bracketed backport note above.

The complete fix is already present in 6.12.y, 6.18.y and 7.2.y.

Build-tested as part of a cumulative 6.6.y series on x86_64
(allmodconfig, CONFIG_WERROR=y).

Thanks,
Artem Dinaburg

block/blk-mq.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 1ad77737b27d3233489b4d9f690c9e6ab77d2130..e3fb9222c5ee00c1fa2105e1194d5f9eba831092 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3024,16 +3024,16 @@ void blk_mq_submit_bio(struct bio *bio)
if (unlikely(bio_may_exceed_limits(bio, &q->limits))) {
bio = __bio_split_to_limits(bio, &q->limits, &nr_segs);
if (!bio) {
- blk_mq_free_request(rq);
+ rq_list_add(&plug->cached_rq, rq);
return;
}
}
if (!bio_integrity_prep(bio)) {
- blk_mq_free_request(rq);
+ rq_list_add(&plug->cached_rq, rq);
return;
}
if (blk_mq_attempt_bio_merge(q, bio, nr_segs)) {
- blk_mq_free_request(rq);
+ rq_list_add(&plug->cached_rq, rq);
return;
}
rq_qos_throttle(rq->q, bio);