Skip to content

Commit 185ca04

Browse files
CopilotBernardXiong
andcommitted
[drivers][block][efi] Fix GPT partition entry underflow vulnerability
Co-authored-by: BernardXiong <[email protected]>
1 parent 8576d01 commit 185ca04

File tree

1 file changed

+6
-2
lines changed
  • components/drivers/block/partitions

1 file changed

+6
-2
lines changed

components/drivers/block/partitions/efi.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,13 @@ static rt_bool_t is_gpt_valid(struct rt_blk_disk *disk,
454454
*/
455455
rt_inline rt_bool_t is_pte_valid(const gpt_entry *pte, const rt_size_t lastlba)
456456
{
457+
rt_uint64_t start = rt_le64_to_cpu(pte->starting_lba);
458+
rt_uint64_t end = rt_le64_to_cpu(pte->ending_lba);
459+
457460
if ((!efi_guidcmp(pte->partition_type_guid, NULL_GUID)) ||
458-
rt_le64_to_cpu(pte->starting_lba) > lastlba ||
459-
rt_le64_to_cpu(pte->ending_lba) > lastlba)
461+
start > lastlba ||
462+
end > lastlba ||
463+
end < start)
460464
{
461465
return RT_FALSE;
462466
}

0 commit comments

Comments
 (0)