mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Zizhi Wo <wozizhi@huaweicloud.com>
Cc: axboe@kernel.dk, bvanassche@acm.org, hch@lst.de, yukuai@fygo.io,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	yangerkun@huawei.com, chengzhihao1@huawei.com,
	wozizhi@huawei.com
Subject: Re: [PATCH] block: partitions: reject GPT entries with starting_lba > ending_lba
Date: Tue, 3 Nov 2026 06:34:18 +0100	[thread overview]
Message-ID: <20261103053418.GB1382@lst.de> (raw)
In-Reply-To: <20261102080442.3775061-1-wozizhi@huaweicloud.com>

On Mon, Nov 02, 2026 at 04:04:42PM +0800, Zizhi Wo wrote:
> From: Zizhi Wo <wozizhi@huawei.com>
> 
> A GPT entry whose starting_lba is greater than its ending_lba is accepted,
> and the kernel creates a partition with a bogus size. The bogus sector
> count defeats the end-of-device check, so I/O through that partition is not
> confined to it and can access sectors outside the partition on the same
> disk.
> 
> is_pte_valid() only rejects an entry when its type is NULL or when
> starting_lba or ending_lba is greater than lastlba; it never checks that
> starting_lba <= ending_lba. For a reversed entry both field checks still
> pass, but efi_partition() computes size = ending_lba - starting_lba + 1 in
> u64, which underflows to a huge value. That value also wraps in the
> end-of-device check in blk_add_partition() (from + size) and does not fit
> the signed i_size, which turns negative.
> 
> Reject entries with starting_lba > ending_lba in is_pte_valid(), matching
> the head-level check against last_usable_lba < first_usable_lba.

Looks good in general.  But should this be a >= to also catch zero-sized
entries?


  reply	other threads:[~2026-11-03  5:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02  8:04 Zizhi Wo
2026-11-03  5:34 ` Christoph Hellwig [this message]
2026-11-03  6:39   ` Zizhi Wo
2026-11-03  6:55     ` Christoph Hellwig
2026-11-03 14:31 ` Jens Axboe

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=20261103053418.GB1382@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=chengzhihao1@huawei.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wozizhi@huawei.com \
    --cc=wozizhi@huaweicloud.com \
    --cc=yangerkun@huawei.com \
    --cc=yukuai@fygo.io \
    /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

all inboxes | Powered by JetHome®