Commit 33afd7a7df1a1f82675857a75572cdf4a8599e9f
Committed by
Linus Torvalds
1 parent
c2ebdc2439
Exists in
smarc-imx_3.14.28_1.0.0_ga
and in
1 other branch
partitions/efi: check pmbr record's starting lba
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. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Davidlohr Bueso <davidlohr@hp.com> Reviewed-by: Karel Zak <kzak@redhat.com> Acked-by: Matt Fleming <matt.fleming@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 13 additions and 4 deletions Side-by-side Diff
block/partitions/efi.c
... | ... | @@ -151,10 +151,19 @@ |
151 | 151 | |
152 | 152 | static inline int pmbr_part_valid(gpt_mbr_record *part) |
153 | 153 | { |
154 | - if (part->os_type == EFI_PMBR_OSTYPE_EFI_GPT && | |
155 | - le32_to_cpu(part->start_sector) == 1UL) | |
156 | - return 1; | |
157 | - return 0; | |
154 | + if (part->os_type != EFI_PMBR_OSTYPE_EFI_GPT) | |
155 | + goto invalid; | |
156 | + | |
157 | + /* set to 0x00000001 (i.e., the LBA of the GPT Partition Header) */ | |
158 | + if (le32_to_cpu(part->starting_lba) != GPT_PRIMARY_PARTITION_TABLE_LBA) | |
159 | + goto invalid; | |
160 | + | |
161 | + if (le32_to_cpu(part->start_sector) != 1UL) | |
162 | + goto invalid; | |
163 | + | |
164 | + return 1; | |
165 | +invalid: | |
166 | + return 0; | |
158 | 167 | } |
159 | 168 | |
160 | 169 | /** |