Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753570Ab3HFF2w (ORCPT ); Tue, 6 Aug 2013 01:28:52 -0400 Received: from g6t0184.atlanta.hp.com ([15.193.32.61]:46905 "EHLO g6t0184.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752233Ab3HFF2s (ORCPT ); Tue, 6 Aug 2013 01:28:48 -0400 From: Davidlohr Bueso To: Andrew Morton , Jens Axboe Cc: Matt Domsch , Jim Hull , Karel Zak , Peter Jones , Chegu Vinod , Aswin Chandramouleeswaran , linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: [PATCH 2/8] partitions/efi: check pmbr record's starting lba Date: Mon, 5 Aug 2013 22:21:10 -0700 Message-Id: <1375766476-4204-3-git-send-email-davidlohr@hp.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1375766476-4204-1-git-send-email-davidlohr@hp.com> References: <1375766476-4204-1-git-send-email-davidlohr@hp.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1420 Lines: 43 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. Signed-off-by: Davidlohr Bueso --- block/partitions/efi.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/block/partitions/efi.c b/block/partitions/efi.c index 3ebd3d8..6a997b1 100644 --- a/block/partitions/efi.c +++ b/block/partitions/efi.c @@ -151,9 +151,18 @@ static u64 last_lba(struct block_device *bdev) static inline int pmbr_part_valid(gpt_record *part) { - if (part->os_type == EFI_PMBR_OSTYPE_EFI_GPT && - le32_to_cpu(part->start_sector) == 1UL) - return 1; + 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; } -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/