All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Yingjie Wang <x-professor@outlook.com>,
	"axboe@kernel.dk" <axboe@kernel.dk>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v3 3/4] null_blk: reject zone counts that overflow unsigned int
Date: Mon, 30 Nov 2026 13:54:23 +0900	[thread overview]
Message-ID: <d5b7823c-caa0-4b64-8b35-ad5ea71af9fe@kernel.org> (raw)
In-Reply-To: <20261127125738.1654012-4-x-professor@outlook.com>

On 11/27/26 21:58, Yingjie Wang wrote:
> null_init_zoned_dev() calculates the zone count from sector_t values but
> stores it in the unsigned int nr_zones field without checking the range.
> For example, a size of 2^40 MiB with the default 256 MiB zone size
> requires 2^32 zones. This count is truncated to zero when stored in
> nr_zones.
> 
> The resulting zero-length allocation returns ZERO_SIZE_PTR. Adjusting the
> number of conventional zones then underflows zone_nr_conv to UINT_MAX,
> and initializing those zones accesses invalid memory. This happens even
> when the device capacity itself fits in a signed 64-bit byte count.
> 
> Keep the calculated zone count in an unsigned long long temporary and
> reject values above UINT_MAX before assigning nr_zones or allocating the
> zone array.
> 
> This bug was found by a fuzzer.
> 
> Fixes: ca4b2a011948 ("null_blk: add zone support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yingjie Wang <x-professor@outlook.com>

Looks good.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org.

-- 
Damien Le Moal
Western Digital Research

  reply	other threads:[~2026-11-30  4:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 12:57 [PATCH v3 0/4] null_blk: validate configfs values before power-on Yingjie Wang
2026-11-27 12:58 ` [PATCH v3 1/4] block: move BLK_DEV_MAX_SECTORS to <linux/blkdev.h> Yingjie Wang
2026-11-30  4:50   ` Damien Le Moal
2026-11-27 12:58 ` [PATCH v3 2/4] null_blk: reject device size overflow Yingjie Wang
2026-11-30  4:52   ` Damien Le Moal
2026-11-27 12:58 ` [PATCH v3 3/4] null_blk: reject zone counts that overflow unsigned int Yingjie Wang
2026-11-30  4:54   ` Damien Le Moal [this message]
2026-11-27 12:59 ` [PATCH v3 4/4] null_blk: validate the configfs home_node attribute Yingjie Wang
2026-11-30  4:54   ` Damien Le Moal

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=d5b7823c-caa0-4b64-8b35-ad5ea71af9fe@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=x-professor@outlook.com \
    /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.