* [PATCH 6.6.y 0/2] CVE-2026-64017: backport fix series
@ 2026-10-16 18:47 Artem Dinaburg
2026-10-16 18:47 ` [PATCH 6.6.y 1/2] blk-mq: pop cached request if it is usable Artem Dinaburg
2026-10-16 18:47 ` [PATCH 6.6.y 2/2] blk-mq: reinsert cached request to the list Artem Dinaburg
0 siblings, 2 replies; 3+ messages in thread
From: Artem Dinaburg @ 2026-10-16 18:47 UTC (permalink / raw)
To: stable; +Cc: axboe, kbusch, kch, linux-block, linux-kernel
Hi,
Please consider this backport series for CVE-2026-64017 to 6.6.y.
Apply the patches in this order:
1. blk-mq: pop cached request if it is usable (fix)
2. blk-mq: reinsert cached request to the list (correction)
Patch 1 removes a compatible request from the older cached_rq list before
preparation and QoS throttling, then initializes it after preparation. A
plug flush can therefore no longer reuse the request while submission is
in progress.
Patch 2 returns that request to the single cached_rq list with
rq_list_add() on each of the target's three preparation or merge exits,
replacing upstream's shared-exit handling.
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).
This backport is considerably more involved than usual.
We performed runtime testing to check validity and stability,
but would still greatly apprciate another set of eyes on it.
It was runtime-tested on v6.6.158 in a QEMU/KVM guest (KASAN, lockdep,
hung-task detection) against an unpatched baseline: blktests block
group and fio on null_blk (none, mq-deadline, bfq), virtio-blk and
ext4. No new blktests failures and no kernel warnings on the patched
kernel; no small sequential write throughput drop over 5%.
An LLM assisted with preparing these backports.
Thanks,
Artem Dinaburg
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 6.6.y 1/2] blk-mq: pop cached request if it is usable
2026-10-16 18:47 [PATCH 6.6.y 0/2] CVE-2026-64017: backport fix series Artem Dinaburg
@ 2026-10-16 18:47 ` Artem Dinaburg
2026-10-16 18:47 ` [PATCH 6.6.y 2/2] blk-mq: reinsert cached request to the list Artem Dinaburg
1 sibling, 0 replies; 3+ messages in thread
From: Artem Dinaburg @ 2026-10-16 18:47 UTC (permalink / raw)
To: stable; +Cc: axboe, kbusch, linux-block, linux-kernel
From: Keith Busch <kbusch@kernel.org>
[ Upstream commit dc278e9bf2b9513a763353e6b9cc21e0f532954e ]
When submitting a bio to blk-mq, if the task should sleep after peeking
a cached request, but before it pops it, the plug flushes and calls
blk_mq_free_plug_rqs, freeing the cached_rqs. This creates a
use-after-free bug. Fix this by popping the cached request before any
possible blocking calls if it is suitable for use.
Popping this request first holds a queue reference, so avoid any
serialization races with queue freezes and can safely proceed with
dispatching that request to the driver. This potentially increases a
timing window from when a driver wants to freeze its queue to when
requests stop being dispatched. That scenario is off the fast path
though, and drivers need to appropriately handle requests during a
freeze request anyway.
The downside is the popped element needs to be individually freed when
we performed a bio plug merge. The cached request would have had to be
freed later anyway, but this patch does it inline with building the plug
list instead of after flushing it.
Fixes: b0077e269f6c1 ("blk-mq: make sure active queue usage is held for bio_integrity_prep()")
Fixes: 7b4f36cd22a65 ("block: ensure we hold a queue reference when using queue limits")
Signed-off-by: Keith Busch <kbusch@kernel.org>
Link: https://patch.msgid.link/20260521190253.242065-1-kbusch@meta.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Assisted-by: LLM
[ Backport to 6.6.y: Pop a suitable request from the older cached_rq list
before fallible preparation, then initialize it after preparation. The
target has three preparation or merge exits; the following correction
restores the request on each exit. ]
Signed-off-by: Artem Dinaburg <artem@trailofbits.com>
---
Hi,
Please consider this backport of the fix for CVE-2026-64017 to 6.6.y.
The backport separates suitability and popping from initialization in the
older cached_rq implementation. 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 | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 4c1c5a261d0cf002d9f87f0f1330182eb4158cfc..1ad77737b27d3233489b4d9f690c9e6ab77d2130 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2984,17 +2984,7 @@ static bool blk_mq_can_use_cached_rq(struct request *rq, struct blk_plug *plug,
if (op_is_flush(rq->cmd_flags) != op_is_flush(bio->bi_opf))
return false;
- /*
- * If any qos ->throttle() end up blocking, we will have flushed the
- * plug and hence killed the cached_rq list as well. Pop this entry
- * before we throttle.
- */
plug->cached_rq = rq_list_next(rq);
- rq_qos_throttle(rq->q, bio);
-
- blk_mq_rq_time_init(rq, 0);
- rq->cmd_flags = bio->bi_opf;
- INIT_LIST_HEAD(&rq->queuelist);
return true;
}
@@ -3027,20 +3017,30 @@ void blk_mq_submit_bio(struct bio *bio)
rq = rq_list_peek(&plug->cached_rq);
if (rq && rq->q != q)
rq = NULL;
+ if (rq && !blk_mq_can_use_cached_rq(rq, plug, bio))
+ rq = NULL;
}
if (rq) {
if (unlikely(bio_may_exceed_limits(bio, &q->limits))) {
bio = __bio_split_to_limits(bio, &q->limits, &nr_segs);
- if (!bio)
+ if (!bio) {
+ blk_mq_free_request(rq);
return;
+ }
}
- if (!bio_integrity_prep(bio))
+ if (!bio_integrity_prep(bio)) {
+ blk_mq_free_request(rq);
return;
- if (blk_mq_attempt_bio_merge(q, bio, nr_segs))
+ }
+ if (blk_mq_attempt_bio_merge(q, bio, nr_segs)) {
+ blk_mq_free_request(rq);
return;
- if (blk_mq_can_use_cached_rq(rq, plug, bio))
- goto done;
- percpu_ref_get(&q->q_usage_counter);
+ }
+ rq_qos_throttle(rq->q, bio);
+ blk_mq_rq_time_init(rq, 0);
+ rq->cmd_flags = bio->bi_opf;
+ INIT_LIST_HEAD(&rq->queuelist);
+ goto done;
} else {
if (unlikely(bio_queue_enter(bio)))
return;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 6.6.y 2/2] blk-mq: reinsert cached request to the list
2026-10-16 18:47 [PATCH 6.6.y 0/2] CVE-2026-64017: backport fix series Artem Dinaburg
2026-10-16 18:47 ` [PATCH 6.6.y 1/2] blk-mq: pop cached request if it is usable Artem Dinaburg
@ 2026-10-16 18:47 ` Artem Dinaburg
1 sibling, 0 replies; 3+ messages in thread
From: Artem Dinaburg @ 2026-10-16 18:47 UTC (permalink / raw)
To: stable; +Cc: axboe, kbusch, kch, linux-block, linux-kernel
From: Keith Busch <kbusch@kernel.org>
[ 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@gmail.com>
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://patch.msgid.link/20260526153531.2365935-1-kbusch@meta.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
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@trailofbits.com>
---
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);
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-16 18:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-16 18:47 [PATCH 6.6.y 0/2] CVE-2026-64017: backport fix series Artem Dinaburg
2026-10-16 18:47 ` [PATCH 6.6.y 1/2] blk-mq: pop cached request if it is usable Artem Dinaburg
2026-10-16 18:47 ` [PATCH 6.6.y 2/2] blk-mq: reinsert cached request to the list Artem Dinaburg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox