From: sashiko-bot@kernel.org
To: "Mauricio Faria de Oliveira" <mfo@igalia.com>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvme: reject completions for requests that are not in flight
Date: Tue, 03 Nov 2026 19:26:56 +0000 [thread overview]
Message-ID: <sashiko-outbox-195914@kernel.org> (raw)
In-Reply-To: <20261103-nvme-double-cmpl-uaf-blk-mq-v1-1-b10fea474423@igalia.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] nvme: unratelimited dev_err() in nvme_find_rq() on completion irq path
--
commit 2696cd6e7dfab32aa750573cdd163f831092e123
Author: Chao Shi <coshi036@gmail.com>
nvme: reject completions for requests that are not in flight
This commit checks that a request looked up in nvme_find_rq() is in the
MQ_RQ_IN_FLIGHT state before returning it for completion, avoiding a NULL
pointer dereference on rq->mq_hctx when a spurious completion matches an
idle request.
Link: https://lore.kernel.org/linux-nvme/20260522153034.2168862-1-coshi036@gmail.com/
Link: https://lore.kernel.org/linux-nvme/20260715005105.1115958-1-coshi036@gmail.com/
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index 2d8f681079e85..3ba0666da7be6 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -708,6 +708,11 @@ static inline struct request *nvme_find_rq(struct blk_mq_tags *tags,
> tag, genctr, nvme_genctr_mask(nvme_req(rq)->genctr));
> return NULL;
> }
> + if (unlikely(blk_mq_rq_state(rq) != MQ_RQ_IN_FLIGHT)) {
> + dev_err(nvme_req(rq)->ctrl->device,
> + "completion for request %#x not in flight\n", tag);
> + return NULL;
> + }
[Severity: Medium]
Should this use dev_err_ratelimited() instead of dev_err()?
Commit c05c86681170 ("nvme: ratelimit the completion-path messages driven
by device data") switched the existing error messages in nvme_find_rq() and
nvme_handle_cqe() to ratelimited variants because device-supplied command
IDs are processed directly in interrupt context via
nvme_irq()->nvme_poll_cq()->nvme_handle_cqe()->nvme_find_rq() (as well as
in the apple, rdma, tcp, and loop completion handlers):
drivers/nvme/host/nvme.h:nvme_find_rq() {
...
rq = blk_mq_tag_to_rq(tags, tag);
if (unlikely(!rq)) {
pr_err_ratelimited("could not locate request for tag %#x\n",
tag);
return NULL;
}
if (unlikely(nvme_genctr_mask(nvme_req(rq)->genctr) != genctr)) {
dev_err_ratelimited(nvme_req(rq)->ctrl->device,
"request %#x genctr mismatch (got %#x expected %#x)\n",
tag, genctr, nvme_genctr_mask(nvme_req(rq)->genctr));
return NULL;
}
}
Because nvme_find_rq() returns NULL before nvme_try_complete_req()
increments nvme_req(rq)->genctr, a malfunctioning controller or remote
Fabrics target sending repeated completions for an idle request with a
matching tag and generation counter will hit this path on every completion
and flood the kernel log from interrupt context.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261103-nvme-double-cmpl-uaf-blk-mq-v1-1-b10fea474423@igalia.com?part=1
next prev parent reply other threads:[~2026-11-03 19:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 19:18 [PATCH] nvme: reject completions for requests that are not in flight Mauricio Faria de Oliveira
2026-11-03 19:21 ` K
2026-11-03 19:41 ` Mauricio Faria de Oliveira
2026-11-03 19:26 ` sashiko-bot [this message]
2026-11-03 19:43 ` Keith Busch
2026-11-03 19:47 ` Jens Axboe
2026-11-03 19:54 ` Mauricio Faria de Oliveira
2026-11-03 19:59 ` Jens Axboe
2026-11-03 20:06 ` Keith Busch
2026-11-04 19:46 ` Mauricio Faria de Oliveira
2026-11-04 20:01 ` Jens Axboe
2026-11-04 20:08 ` Mauricio Faria de Oliveira
2026-11-04 20:11 ` Keith Busch
2026-11-04 20:21 ` Mauricio Faria de Oliveira
-- strict thread matches above, loose matches on Subject: below --
2026-05-22 15:30 Chao Shi
2026-05-25 20:27 ` Chao S
2026-05-27 14:19 ` Christoph Hellwig
2026-05-27 15:02 ` Jens Axboe
2026-07-15 0:03 ` Chao S
2026-05-27 15:00 ` Keith Busch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-195914@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=mfo@igalia.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.