From: Philippe De Muyter <phdm@macqel.be>
To: Ren Wei <n05ec@lzu.edu.cn>
Cc: linux-block@vger.kernel.org, kees@kernel.org, axboe@kernel.dk,
objecting@objecting.org, akpm@linux-foundation.org,
yuantan098@gmail.com, zcliangcn@gmail.com, bird@lzu.edu.cn,
zzhan461@ucr.edu
Subject: Re: [PATCH 1/1] block: partitions: bound sysv68 slice table count
Date: Tue, 16 Jun 2026 12:44:46 +0200 [thread overview]
Message-ID: <20260616104446.GA20822@frolo.corp.macq.eu> (raw)
In-Reply-To: <f16321f7378d613d81af13f288de82217fc7d934.1781036698.git.zzhan461@ucr.edu>
Hi Ren Wei,
On Thu, Jun 11, 2026 at 12:58:13AM +0800, Ren Wei wrote:
> From: Zhao Zhang <zzhan461@ucr.edu>
>
> sysv68_partition() reads a single sector for the slice table, but it
> trusts ios_slccnt from disk and walks that many entries after skipping
> the synthetic whole-disk slice. A crafted image can set ios_slccnt
> larger than the 64 struct slice records that fit in one sector and
> trigger an out-of-bounds read while scanning partitions.
>
> Limit the slice count to the number of records that fit in the sector
> returned by read_part_sector(), then drop the whole-disk entry only
> when the bounded count is non-zero.
>
> Fixes: 19d0e8ce856a ("partition: add support for sysv68 partitions")
> Cc: stable@vger.kernel.org
> Reported-by: Yuan Tan <yuantan098@gmail.com>
> Reported-by: Zhengchuan Liang <zcliangcn@gmail.com>
> Reported-by: Xin Liu <bird@lzu.edu.cn>
> Assisted-by: Codex:GPT-5.4
> Signed-off-by: Zhao Zhang <zzhan461@ucr.edu>
> Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
> ---
> block/partitions/sysv68.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/block/partitions/sysv68.c b/block/partitions/sysv68.c
> index 470e0f9de7be..5110ed83c541 100644
> --- a/block/partitions/sysv68.c
> +++ b/block/partitions/sysv68.c
> @@ -48,7 +48,8 @@ struct slice {
>
> int sysv68_partition(struct parsed_partitions *state)
> {
> - int i, slices;
> + sector_t slice_sector;
> + unsigned int i, slices;
> int slot = 1;
> Sector sect;
> unsigned char *data;
> @@ -65,14 +66,16 @@ int sysv68_partition(struct parsed_partitions *state)
> return 0;
> }
> slices = be16_to_cpu(b->dk_ios.ios_slccnt);
> - i = be32_to_cpu(b->dk_ios.ios_slcblk);
> + slice_sector = be32_to_cpu(b->dk_ios.ios_slcblk);
> put_dev_sector(sect);
>
> - data = read_part_sector(state, i, §);
> + data = read_part_sector(state, slice_sector, §);
> if (!data)
> return -1;
>
> - slices -= 1; /* last slice is the whole disk */
> + slices = min_t(unsigned int, slices, SECTOR_SIZE / sizeof(*slice));
> + if (slices)
> + slices -= 1; /* last slice is the whole disk */
> seq_buf_printf(&state->pp_buf, "sysV68: %s(s%u)", state->name, slices);
> slice = (struct slice *)data;
> for (i = 0; i < slices; i++, slice++) {
> --
> 2.47.3
That does the job. IIRC 'last slice' had number 7, so ios_slccnt had to be
8. I do not have such a partition handy at the moment, so
Reviewed-by: Philippe De Muyter <phdm@macqel.be>
Best regards
Philippe
prev parent reply other threads:[~2026-06-16 10:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1781036698.git.zzhan461@ucr.edu>
2026-06-10 16:58 ` [PATCH 1/1] block: partitions: bound sysv68 slice table count Ren Wei
2026-06-16 10:44 ` Philippe De Muyter [this message]
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=20260616104446.GA20822@frolo.corp.macq.eu \
--to=phdm@macqel.be \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=bird@lzu.edu.cn \
--cc=kees@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=n05ec@lzu.edu.cn \
--cc=objecting@objecting.org \
--cc=yuantan098@gmail.com \
--cc=zcliangcn@gmail.com \
--cc=zzhan461@ucr.edu \
/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