From: liuxixin <gliuxen@gmail.com>
To: linux-nvme@lists.infradead.org
Cc: kbusch@kernel.org, axboe@kernel.dk, hch@lst.de, sagi@grimberg.me,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/1] nvme: fix FDP configuration log parsing
Date: Wed, 27 May 2026 10:29:45 +0800 [thread overview]
Message-ID: <a989258938de2d1fb01e70fd5ea2e50185cc6899.1779848573.git.gliuxen@gmail.com> (raw)
In-Reply-To: <cover.1779848573.git.gliuxen@gmail.com>
<cover.1779848573.git.gliuxen@gmail.com>
From: liuxixin <gliuxen@gmail.com>
Date: Wed, 27 May 2026 10:22:32 +0800
Subject: [PATCH v2 1/1] nvme: fix FDP configuration log parsing
The fdpcidx bounds check sets n = NUMFDPC + 1 but used > instead of >=,
incorrectly accepting fdp_idx when it equals n (i.e. NUMFDPC + 1).
Also validate descriptor sizes while walking the list so dsze == 0 or a
descriptor past the log end cannot cause unbounded iteration or reads past
the buffer.
Fixes: 30b5f20bb2ddab013035399e5c7e6577da49320a ("nvme: register fdp parameters with the block layer")
Signed-off-by: liuxixin <gliuxen@gmail.com>
---
drivers/nvme/host/core.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index c3032d6ad..40e87b563 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2263,7 +2263,7 @@ static int nvme_query_fdp_granularity(struct nvme_ctrl *ctrl,
}
n = le16_to_cpu(h->numfdpc) + 1;
- if (fdp_idx > n) {
+ if (fdp_idx >= n) {
dev_warn(ctrl->device, "FDP index:%d out of range:%d\n",
fdp_idx, n);
/* Proceed without registering FDP streams */
@@ -2275,7 +2275,15 @@ static int nvme_query_fdp_granularity(struct nvme_ctrl *ctrl,
desc = log;
end = log + size - sizeof(*h);
for (i = 0; i < fdp_idx; i++) {
- log += le16_to_cpu(desc->dsze);
+ u16 dsze = le16_to_cpu(desc->dsze);
+
+ if (!dsze || log + dsze > end) {
+ dev_warn(ctrl->device,
+ "FDP invalid config descriptor at index %d\n", i);
+ ret = 0;
+ goto out;
+ }
+ log += dsze;
desc = log;
if (log >= end) {
dev_warn(ctrl->device,
--
2.43.0
next prev parent reply other threads:[~2026-05-27 2:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 7:52 [PATCH v1 " liuxixin
2026-05-26 14:41 ` Keith Busch
2026-05-27 2:22 ` [PATCH v2 0/1] " liuxixin
2026-05-27 2:29 ` liuxixin [this message]
[not found] ` <CGME20260527090026epcas5p301bb017af42ab37a1e69e50b30df387e@epcas5p3.samsung.com>
2026-05-27 8:53 ` [PATCH v2 1/1] " Nitesh Shetty
2026-05-27 13:32 ` Christoph Hellwig
2026-05-28 1:01 ` [PATCH v3 0/2] " liuxixin
2026-05-28 1:43 ` [PATCH v3 1/2] nvme: fix FDP fdpcidx bounds check liuxixin
2026-05-28 8:30 ` Christoph Hellwig
2026-05-28 1:43 ` [PATCH v3 2/2] nvme: validate FDP configuration descriptor sizes liuxixin
2026-05-28 8:30 ` Christoph Hellwig
2026-05-28 10:00 ` [PATCH v4 0/2] nvme: fix FDP configuration log parsing liuxixin
2026-05-28 10:00 ` [PATCH v4 1/2] nvme: fix FDP fdpcidx bounds check liuxixin
2026-06-02 12:27 ` Keith Busch
2026-05-28 10:00 ` [PATCH v4 2/2] nvme: validate FDP configuration descriptor sizes liuxixin
2026-06-02 12:19 ` Keith Busch
2026-06-02 14:00 ` [PATCH v5 0/1] " liuxixin
2026-06-02 14:00 ` [PATCH v5 1/1] " liuxixin
2026-06-03 9:42 ` 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=a989258938de2d1fb01e70fd5ea2e50185cc6899.1779848573.git.gliuxen@gmail.com \
--to=gliuxen@gmail.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®