aboutsummaryrefslogtreecommitdiffstats
path: root/block/partitions
diff options
context:
space:
mode:
authorDavidlohr Bueso <davidlohr@hp.com>2013-09-11 17:24:56 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 18:59:15 -0400
commit33afd7a7df1a1f82675857a75572cdf4a8599e9f (patch)
tree468b6d88bba5f2e517215f0da6f84d87a6f6814d /block/partitions
parentc2ebdc2439f50c049fd362bb225aaf78fe8e4cb8 (diff)
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>
Diffstat (limited to 'block/partitions')
-rw-r--r--block/partitions/efi.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index bd8fb22b2109..7a2b74f0d06f 100644
--- a/block/partitions/efi.c
+++ b/block/partitions/efi.c
@@ -151,10 +151,19 @@ static u64 last_lba(struct block_device *bdev)
151 151
152static inline int pmbr_part_valid(gpt_mbr_record *part) 152static inline int pmbr_part_valid(gpt_mbr_record *part)
153{ 153{
154 if (part->os_type == EFI_PMBR_OSTYPE_EFI_GPT && 154 if (part->os_type != EFI_PMBR_OSTYPE_EFI_GPT)
155 le32_to_cpu(part->start_sector) == 1UL) 155 goto invalid;
156 return 1; 156
157 return 0; 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;
165invalid:
166 return 0;
158} 167}
159 168
160/** 169/**