Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752615Ab3HFFWB (ORCPT ); Tue, 6 Aug 2013 01:22:01 -0400 Received: from g5t0008.atlanta.hp.com ([15.192.0.45]:7157 "EHLO g5t0008.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752123Ab3HFFVm (ORCPT ); Tue, 6 Aug 2013 01:21:42 -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 6/8] partitions/efi: compare first and last usable LBAs Date: Mon, 5 Aug 2013 22:21:14 -0700 Message-Id: <1375766476-4204-7-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: 1283 Lines: 34 When verifying GPT header integrity, make sure that first usable LBA is smaller than last usable LBA. Signed-off-by: Davidlohr Bueso --- block/partitions/efi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block/partitions/efi.c b/block/partitions/efi.c index ab6cd08..9a81c3b 100644 --- a/block/partitions/efi.c +++ b/block/partitions/efi.c @@ -409,7 +409,12 @@ static int is_gpt_valid(struct parsed_partitions *state, u64 lba, (unsigned long long)lastlba); goto fail; } - + if (le64_to_cpu((*gpt)->last_usable_lba) < le64_to_cpu((*gpt)->first_usable_lba)) { + pr_debug("GPT: last_usable_lba incorrect: %lld > %lld\n", + (unsigned long long)le64_to_cpu((*gpt)->last_usable_lba), + (unsigned long long)le64_to_cpu((*gpt)->first_usable_lba)); + goto fail; + } /* Check that sizeof_partition_entry has the correct value */ if (le32_to_cpu((*gpt)->sizeof_partition_entry) != sizeof(gpt_entry)) { pr_debug("GUID Partitition Entry Size check failed.\n"); -- 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/