From: Eugene Korenevsky <ekorenevsky@aliyun.com>
To: Keith Busch <kbusch@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>,
Sagi Grimberg <sagi@grimberg.me>,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nvme: nvme_identify_ns_descs: prevent oob
Date: Thu, 27 Nov 2025 00:45:08 +0300 [thread overview]
Message-ID: <aSd05K1Mkx8ZEARF@localhost.localdomain> (raw)
In-Reply-To: <aSdoeEX_L2-3ccpF@kbusch-mbp>
On Wed, Nov 26, 2025 at 01:52:08PM -0700, Keith Busch wrote:
> Is this simpler check not sufficient?
> @@ -1566,7 +1566,7 @@ static int nvme_identify_ns_descs(struct nvme_ctrl *ctrl,
> for (pos = 0; pos < NVME_IDENTIFY_DATA_SIZE; pos += len) {
Alas size of ns id header+data may be 4+1=5 if .nidt == NVME_NIDT_CSI.
`pos` may be not aligned to 4 (size of `struct nvme_ns_id_desc` header).
It can be NVME_IDENTIFY_DATA_SIZE-1 here.
And when cur->nidl (i.e. pos+1) is referenced later, we'll get a problem.
> struct nvme_ns_id_desc *cur = data + pos;
>
> - if (cur->nidl == 0)
> + if (cur->nidl == 0 || cur->nidl + pos > NVME_IDENTIFY_DATA_SIZE)
> break;
>
> len = nvme_process_ns_desc(ctrl, &info->ids, cur, &csi_seen);
> --
next prev parent reply other threads:[~2025-11-26 21:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 20:27 [PATCH] nvme: nvme_identify_ns_descs: prevent oob Eugene Korenevsky
2025-11-26 20:52 ` Keith Busch
2025-11-26 21:45 ` Eugene Korenevsky [this message]
2025-11-27 14:49 ` Christoph Hellwig
2025-11-29 19:57 ` Eugene Korenevsky
2025-11-30 22:20 ` Sagi Grimberg
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=aSd05K1Mkx8ZEARF@localhost.localdomain \
--to=ekorenevsky@aliyun.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 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.