Skip to content

partitions/efi: reject GPT entries with starting_lba > ending_lba - #1043

Open
blktests-ci[bot] wants to merge 1 commit into
linus-master_basefrom
series/1134859=>linus-master
Open

partitions/efi: reject GPT entries with starting_lba > ending_lba#1043
blktests-ci[bot] wants to merge 1 commit into
linus-master_basefrom
series/1134859=>linus-master

Conversation

@blktests-ci

@blktests-ci blktests-ci Bot commented Aug 2, 2026

Copy link
Copy Markdown

Pull request for series with
subject: partitions/efi: reject GPT entries with starting_lba > ending_lba
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1134859

@blktests-ci

blktests-ci Bot commented Aug 2, 2026

Copy link
Copy Markdown
Author

Upstream branch: 2d2338c
series: https://patchwork.kernel.org/project/linux-block/list/?series=1134859
version: 1

@blktests-ci

blktests-ci Bot commented Aug 6, 2026

Copy link
Copy Markdown
Author

Upstream branch: 0d83957
series: https://patchwork.kernel.org/project/linux-block/list/?series=1134859
version: 1

@blktests-ci
blktests-ci Bot force-pushed the series/1134859=>linus-master branch from 1206188 to f43a58c Compare August 6, 2026 10:11
@blktests-ci
blktests-ci Bot force-pushed the linus-master_base branch 2 times, most recently from 612ae31 to 863d43a Compare August 9, 2026 07:24
@blktests-ci

blktests-ci Bot commented Aug 9, 2026

Copy link
Copy Markdown
Author

Upstream branch: 06cf618
series: https://patchwork.kernel.org/project/linux-block/list/?series=1134859
version: 1

@blktests-ci
blktests-ci Bot force-pushed the series/1134859=>linus-master branch from f43a58c to c2c5e98 Compare August 9, 2026 08:48
@blktests-ci
blktests-ci Bot force-pushed the linus-master_base branch from 863d43a to 29ac21d Compare August 10, 2026 22:28
@blktests-ci

blktests-ci Bot commented Aug 10, 2026

Copy link
Copy Markdown
Author

Upstream branch: d58772d
series: https://patchwork.kernel.org/project/linux-block/list/?series=1134859
version: 1

@blktests-ci
blktests-ci Bot force-pushed the series/1134859=>linus-master branch from c2c5e98 to 100ed63 Compare August 10, 2026 23:18
@blktests-ci
blktests-ci Bot force-pushed the linus-master_base branch from 29ac21d to ea2c39d Compare August 12, 2026 13:27
@blktests-ci

blktests-ci Bot commented Aug 12, 2026

Copy link
Copy Markdown
Author

Upstream branch: f5bbbfe
series: https://patchwork.kernel.org/project/linux-block/list/?series=1134859
version: 1

@blktests-ci
blktests-ci Bot force-pushed the series/1134859=>linus-master branch from 100ed63 to d3f02b5 Compare August 12, 2026 14:54
@blktests-ci
blktests-ci Bot force-pushed the linus-master_base branch from ea2c39d to 4082a30 Compare August 12, 2026 18:56
@blktests-ci

blktests-ci Bot commented Aug 12, 2026

Copy link
Copy Markdown
Author

Upstream branch: 3d6d817
series: https://patchwork.kernel.org/project/linux-block/list/?series=1134859
version: 1

@blktests-ci
blktests-ci Bot force-pushed the series/1134859=>linus-master branch from d3f02b5 to f6c395a Compare August 12, 2026 20:07
@blktests-ci
blktests-ci Bot force-pushed the linus-master_base branch from 4082a30 to 36bd7eb Compare August 13, 2026 19:18
@blktests-ci

blktests-ci Bot commented Aug 13, 2026

Copy link
Copy Markdown
Author

Upstream branch: 3aa1dca
series: https://patchwork.kernel.org/project/linux-block/list/?series=1134859
version: 1

@blktests-ci
blktests-ci Bot force-pushed the series/1134859=>linus-master branch from f6c395a to 28f102e Compare August 13, 2026 21:03
@blktests-ci
blktests-ci Bot force-pushed the linus-master_base branch 2 times, most recently from d89ab11 to fdba928 Compare August 16, 2026 18:34
@blktests-ci

blktests-ci Bot commented Aug 16, 2026

Copy link
Copy Markdown
Author

Upstream branch: fd923b3
series: https://patchwork.kernel.org/project/linux-block/list/?series=1134859
version: 1

@blktests-ci
blktests-ci Bot force-pushed the series/1134859=>linus-master branch from 28f102e to 52f3b2f Compare August 16, 2026 21:12
@blktests-ci
blktests-ci Bot force-pushed the linus-master_base branch from fdba928 to 60442a3 Compare August 17, 2026 14:10
@blktests-ci

blktests-ci Bot commented Aug 17, 2026

Copy link
Copy Markdown
Author

Upstream branch: 8d3ae59
series: https://patchwork.kernel.org/project/linux-block/list/?series=1134859
version: 1

@blktests-ci
blktests-ci Bot force-pushed the series/1134859=>linus-master branch from 52f3b2f to 0cfa40f Compare August 17, 2026 20:36
@blktests-ci
blktests-ci Bot force-pushed the linus-master_base branch from 60442a3 to 3df366e Compare August 19, 2026 05:25
is_pte_valid() checks that both LBAs of a GPT partition entry are within
the device, but never that the entry describes a forward range:

	if ((!efi_guidcmp(pte->partition_type_guid, NULL_GUID)) ||
	    le64_to_cpu(pte->starting_lba) > lastlba         ||
	    le64_to_cpu(pte->ending_lba)   > lastlba)
		return 0;

EndingLBA is defined as the last LBA of the partition, so a conforming
entry always has StartingLBA <= EndingLBA.  A crafted table can invert
the two while keeping both within the device, and efi_partition() then
computes the length as

	u64 size = le64_to_cpu(ptes[i].ending_lba) -
		   le64_to_cpu(ptes[i].starting_lba) + 1ULL;

which underflows to a value close to U64_MAX.

The "extends beyond EOD" clamp in blk_add_partition() does not contain
this, because it tests

	if (from + size > get_capacity(disk))

and from + size wraps for a size of that magnitude, so the sum comes out
small, the clamp is skipped and the partition is registered with the
underflowed length.  From then on bio_check_eod() is evaluated against
bdev_nr_sectors() of that partition, i.e. against the bogus length, so
I/O submitted through the partition device is no longer confined to the
partition and reaches sectors owned by other partitions of the same
disk.

This was verified on 6.8.12 with a crafted two partition image: the
inverted entry is registered as a partition of nearly 2^64 sectors
with no "extends beyond EOD" warning, and BLKZEROOUT issued on
that partition overwrote known marker data belonging to the other,
unrelated partition on the same disk.  No privileged step is
needed on the victim side beyond getting the table parsed, which happens
automatically for removable media on a typical desktop.

Reject the inverted range in is_pte_valid(), the single place every GPT
entry is gated on.  The code has been this way since the beginning of
git history.

Fixes: 1da177e ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Nguyen Le Thanh Tung <nguyenlethanhtung555@gmail.com>
@blktests-ci

blktests-ci Bot commented Aug 19, 2026

Copy link
Copy Markdown
Author

Upstream branch: bd5f485
series: https://patchwork.kernel.org/project/linux-block/list/?series=1134859
version: 1

@blktests-ci
blktests-ci Bot force-pushed the series/1134859=>linus-master branch from 0cfa40f to b852501 Compare August 19, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant