mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] partitions: efi: reject partitions with negative size
@ 2026-09-09 15:29 Stefan Kerkmann
  2026-09-11 14:11 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Kerkmann @ 2026-09-09 15:29 UTC (permalink / raw)
  To: Sascha Hauer, Bruno Produit, open list:BAREBOX; +Cc: Stefan Kerkmann

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>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-11 14:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-09 15:29 [PATCH master] partitions: efi: reject partitions with negative size Stefan Kerkmann
2026-09-11 14:11 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox