From: Keith Busch <kbusch@kernel.org>
To: Eugene Korenevsky <ekorenevsky@aliyun.com>
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 v3] nvme: nvme_identify_ns_descs: prevent oob
Date: Mon, 1 Dec 2025 17:27:48 -0700 [thread overview]
Message-ID: <aS4yhAhZYjvHOqtD@kbusch-mbp> (raw)
In-Reply-To: <aS3v2_VcV8IwsT6g@localhost.localdomain>
On Mon, Dec 01, 2025 at 10:43:23PM +0300, Eugene Korenevsky wrote:
> - for (pos = 0; pos < NVME_IDENTIFY_DATA_SIZE; pos += len) {
> - struct nvme_ns_id_desc *cur = data + pos;
> + pos = 0;
> + do {
> + cur = data + pos;
>
> if (cur->nidl == 0)
> break;
> + /* check ns id desc does not exceed remaining buffer by size */
> + if (cur->nidl + sizeof(*cur) > NVME_IDENTIFY_DATA_SIZE - pos)
> + break;
>
> len = nvme_process_ns_desc(ctrl, &info->ids, cur, &csi_seen);
> if (len < 0)
> break;
>
> - len += sizeof(*cur);
> - }
> + pos += sizeof(*cur);
> + pos += len;
> + } while (pos < NVME_IDENTIFY_DATA_SIZE - sizeof(*cur));
I don't want bikeshed this, but I thought this looked better as a
for-loop. You can just modify the continuing condition instead of
changing the loop type to do-while.
next prev parent reply other threads:[~2025-12-02 0:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 19:43 [PATCH v3] nvme: nvme_identify_ns_descs: prevent oob Eugene Korenevsky
2025-12-02 0:27 ` Keith Busch [this message]
2025-12-02 5:57 ` Christoph Hellwig
2025-12-02 20:30 ` Eugene Korenevsky
2025-12-02 20:34 ` 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=aS4yhAhZYjvHOqtD@kbusch-mbp \
--to=kbusch@kernel.org \
--cc=axboe@kernel.dk \
--cc=ekorenevsky@aliyun.com \
--cc=hch@lst.de \
--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.