lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aS4yhAhZYjvHOqtD@kbusch-mbp>
Date: Mon, 1 Dec 2025 17:27:48 -0700
From: Keith Busch <kbusch@...nel.org>
To: Eugene Korenevsky <ekorenevsky@...yun.com>
Cc: 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 v3] nvme: nvme_identify_ns_descs: prevent oob

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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ