Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: ZHOU Jiaxiang <me@fxti.xyz>, Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org,
	"Martin K . Petersen" <mkp@kernel.org>,
	linux-scsi@vger.kernel.org
Subject: Re: [PATCH v4 1/2] block: fix zones_cond out-of-bounds write on zone report
Date: Thu, 17 Sep 2026 09:49:28 +0700	[thread overview]
Message-ID: <c724c4ac-b447-45fc-869c-0eb8d10a702a@kernel.org> (raw)
In-Reply-To: <7815D1B293A8F55E+20260916135822.32584-2-me@fxti.xyz>

On 2026/09/16 20:58, ZHOU Jiaxiang wrote:
> blk_revalidate_disk_zones() sizes the zones_cond array from the disk
> capacity and zone size, but the index used by blk_revalidate_zone_cond()
> comes from the device-driven report_zones() walk and is never checked
> against the array size. A device reporting more zones than fit the
> array makes blk_zone_set_cond() write out of bounds.
> 
> One way to reach this is a zone count exceeding 32 bits: both
> blk_revalidate_zone_args.nr_zones and struct zoned_disk_info.nr_zones
> are unsigned int, so a disk advertising more than UINT_MAX zones (e.g.
> 2^32 + 1024 zones of one 512-byte logical block) gets its zone count
> truncated to a small value, undersizing the array while the report
> walk keeps counting upward.
> 
> Check the index against the array size before storing the zone
> condition, and refuse to revalidate when the zone count does not fit
> 32 bits.
> 
> Fixes: 6e945ffb6555 ("block: use zone condition to determine conventional zones")
> Signed-off-by: ZHOU Jiaxiang <me@fxti.xyz>
> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>

This review stands if this is applied as a fix to the current code. However,
applying this will create a conflict with the changes in this area that are
queued in block/for-bext.

Jens,

How do you want to proceed? Applying this as a fix and do a rebase of
block/for-next? Or rebase this on block/for-next ?

-- 
Damien Le Moal
Western Digital Research

  parent reply	other threads:[~2026-09-17  2:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260916135822.32584-1-me@fxti.xyz>
2026-09-16 13:58 ` [PATCH v4 1/2] block: fix zones_cond out-of-bounds write on zone report ZHOU Jiaxiang
2026-09-17  2:28   ` Martin K. Petersen (Oracle)
2026-09-17  2:50     ` Damien Le Moal
2026-09-17  2:49   ` Damien Le Moal [this message]
2026-09-16 13:58 ` [PATCH v4 2/2] scsi: sd_zbc: reject disks with too many zones ZHOU Jiaxiang

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=c724c4ac-b447-45fc-869c-0eb8d10a702a@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=me@fxti.xyz \
    --cc=mkp@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox