diff options
| author | Zizhi Wo <wozizhi@huawei.com> | 2026-11-02 16:04:42 +0800 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2026-11-03 07:08:33 -0700 |
| commit | 7e3801d12ebabaa3db6e2685ccc80b6e6f6d1ff7 (patch) | |
| tree | 5142c81e7550764344d6de04a96d38eca8eb030c /scripts/livepatch/init.c | |
| parent | 08a6572441a4e646c96c2b8d8ead9eea0e458332 (diff) | |
block: partitions: reject GPT entries with starting_lba > ending_lba
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.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Zizhi Wo <wozizhi@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20261102080442.3775061-1-wozizhi@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'scripts/livepatch/init.c')
0 files changed, 0 insertions, 0 deletions
