From: Stefan Kerkmann <s.kerkmann@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
Bruno Produit <bruno.produit@trailofbits.com>,
"open list:BAREBOX" <barebox@lists.infradead.org>
Cc: Stefan Kerkmann <s.kerkmann@pengutronix.de>
Subject: [PATCH master] partitions: efi: reject partitions with negative size
Date: Wed, 09 Sep 2026 17:29:34 +0200 [thread overview]
Message-ID: <20260909-fix-gpt-parser-v1-1-ce1758be604a@pengutronix.de> (raw)
From: "Bruno Produit (Patch the Planet in collaboration with OpenAI)" <bruno.produit@trailofbits.com>
Previously the GPT parser accepted a partition whose ending LBA is
smaller than its starting LBA. The sector-count calculation then wraped
and registered a partition with a negative file size. This is invalid
and caused out of bounds reads in the bootm 4-KiB image probe on 32-bit
systems.
Fixes: 760689e5ccf1 ("disk: partitions: add EFI GUID Partition Table")
Assisted-by: gpt-5.6-sol-cyber
Signed-off-by: Bruno Produit <bruno.produit@trailofbits.com>
Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
---
common/partitions/efi.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/common/partitions/efi.c b/common/partitions/efi.c
index 9a04b7014d..d3bda96b05 100644
--- a/common/partitions/efi.c
+++ b/common/partitions/efi.c
@@ -248,9 +248,13 @@ static int is_gpt_valid(struct block_device *blk, u64 lba,
static inline int
is_pte_valid(const gpt_entry *pte, const u64 lastlba)
{
+ u64 start = le64_to_cpu(pte->starting_lba);
+ u64 end = le64_to_cpu(pte->ending_lba);
+
if (guid_is_null(&pte->partition_type_guid) ||
- le64_to_cpu(pte->starting_lba) > lastlba ||
- le64_to_cpu(pte->ending_lba) > lastlba)
+ start > lastlba ||
+ end > lastlba ||
+ start > end)
return 0;
return 1;
}
---
base-commit: e55e492573e33823f25935ee00fe7fa7bf2c5c90
change-id: 20260909-fix-gpt-parser-92d361d6d384
Best regards,
--
Stefan Kerkmann <s.kerkmann@pengutronix.de>
reply other threads:[~2026-09-09 15:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260909-fix-gpt-parser-v1-1-ce1758be604a@pengutronix.de \
--to=s.kerkmann@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=bruno.produit@trailofbits.com \
--cc=s.hauer@pengutronix.de \
/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