From: Damien Le Moal <dlemoal@kernel.org>
To: ZHOU Jiaxiang <26066541r@connect.polyu.hk>, 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 1/2] block: fix zones_cond out-of-bounds write on zone report
Date: Fri, 11 Sep 2026 17:13:07 +0900 [thread overview]
Message-ID: <afd41898-4f4b-41fd-a852-e97032773eab@kernel.org> (raw)
In-Reply-To: <20260911041129.128280-2-26066541r@connect.polyu.hk>
On 9/11/26 13:11, 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 <26066541r@connect.polyu.hk>
Looks OK.
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2026-09-11 8:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 4:11 [PATCH 0/2] block/scsi: fix zones_cond out-of-bounds write on zone report ZHOU Jiaxiang
2026-09-11 4:11 ` [PATCH 1/2] block: " ZHOU Jiaxiang
2026-09-11 8:13 ` Damien Le Moal [this message]
2026-09-11 4:11 ` [PATCH 2/2] scsi: sd_zbc: reject disks with too many zones ZHOU Jiaxiang
2026-09-11 8:11 ` 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=afd41898-4f4b-41fd-a852-e97032773eab@kernel.org \
--to=dlemoal@kernel.org \
--cc=26066541r@connect.polyu.hk \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--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