[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251201062106.GA19164@lst.de>
Date: Mon, 1 Dec 2025 07:21:06 +0100
From: Christoph Hellwig <hch@....de>
To: Eugene Korenevsky <ekorenevsky@...yun.com>
Cc: Keith Busch <kbusch@...nel.org>, Jens Axboe <axboe@...nel.dk>,
Christoph Hellwig <hch@....de>, Sagi Grimberg <sagi@...mberg.me>,
linux-nvme@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] nvme: nvme_identify_ns_descs: prevent oob
On Sat, Nov 29, 2025 at 11:03:05PM +0300, Eugene Korenevsky wrote:
> - int status, pos, len;
> + int status, len, remain;
Pre-existing issue, but all but len here should be unsigned.
> + remain = NVME_IDENTIFY_DATA_SIZE;
> + cur = data;
> + while (remain >= sizeof(*cur)) {
> if (cur->nidl == 0)
> break;
> + if (sizeof(*cur) + cur->nidl > remain)
> + break;
>
> len = nvme_process_ns_desc(ctrl, &info->ids, cur, &csi_seen);
> if (len < 0)
> break;
>
> len += sizeof(*cur);
> + remain -= len;
> + cur += len;
> }
I don't think this works, cur is a nvme_ns_id_desc pointer, so it will
be increased by len multiplied by the size of it.
I think this would work muc heasier if you'd do away with remain,
use and just use cur locally, and instead maintain an offet; Something
like:
offset = 0;
do {
cur = data + offset;
...
offset += len;
} while (offset < NVME_IDENTIFY_DATA_SIZE - sizeof(*cur));
Powered by blists - more mailing lists