summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcopilot-swe-agent[bot] <[email protected]>2026-03-19 12:22:26 +0000
committercopilot-swe-agent[bot] <[email protected]>2026-03-19 12:22:26 +0000
commit185ca043d94c9ed762c72003cc158fcb5c9c4779 (patch)
tree734d15040f2148345e26bd00a5494afe001c8687
parent8576d0177fb3b5eaf8500f0bcd41d8ccf6992e33 (diff)
[drivers][block][efi] Fix GPT partition entry underflow vulnerabilitycopilot/fix-gpt-partition-underflow-issue
Co-authored-by: BernardXiong <[email protected]>
-rw-r--r--components/drivers/block/partitions/efi.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/components/drivers/block/partitions/efi.c b/components/drivers/block/partitions/efi.c
index 22f6ba1659..a2947bdeda 100644
--- a/components/drivers/block/partitions/efi.c
+++ b/components/drivers/block/partitions/efi.c
@@ -454,9 +454,13 @@ _fail:
*/
rt_inline rt_bool_t is_pte_valid(const gpt_entry *pte, const rt_size_t lastlba)
{
+ rt_uint64_t start = rt_le64_to_cpu(pte->starting_lba);
+ rt_uint64_t end = rt_le64_to_cpu(pte->ending_lba);
+
if ((!efi_guidcmp(pte->partition_type_guid, NULL_GUID)) ||
- rt_le64_to_cpu(pte->starting_lba) > lastlba ||
- rt_le64_to_cpu(pte->ending_lba) > lastlba)
+ start > lastlba ||
+ end > lastlba ||
+ end < start)
{
return RT_FALSE;
}