Skip to content

Commit

Permalink
partitions/efi: check pmbr record's starting lba
Browse files Browse the repository at this point in the history
Per the UEFI Specs 2.4, June 2013, the starting lba of the partition that
has the EFI GPT (0xEE) must be set to 0x00000001 - this is obviously the
LBA of the GPT Partition Header.

[[email protected]: coding-style fixes]
Signed-off-by: Davidlohr Bueso <[email protected]>
Reviewed-by: Karel Zak <[email protected]>
Acked-by: Matt Fleming <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Davidlohr Bueso authored and torvalds committed Sep 11, 2013
1 parent c2ebdc2 commit 33afd7a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions block/partitions/efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,19 @@ static u64 last_lba(struct block_device *bdev)

static inline int pmbr_part_valid(gpt_mbr_record *part)
{
if (part->os_type == EFI_PMBR_OSTYPE_EFI_GPT &&
le32_to_cpu(part->start_sector) == 1UL)
return 1;
return 0;
if (part->os_type != EFI_PMBR_OSTYPE_EFI_GPT)
goto invalid;

/* set to 0x00000001 (i.e., the LBA of the GPT Partition Header) */
if (le32_to_cpu(part->starting_lba) != GPT_PRIMARY_PARTITION_TABLE_LBA)
goto invalid;

if (le32_to_cpu(part->start_sector) != 1UL)
goto invalid;

return 1;
invalid:
return 0;
}

/**
Expand Down

0 comments on commit 33afd7a

Please sign in to comment.