Validate size of EFI GUID partition entries.
authorTimo Warns <Warns@pre-sense.de>
Fri, 6 May 2011 11:47:35 +0000 (13:47 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 11 Feb 2012 14:37:26 +0000 (15:37 +0100)
commit fa039d5f6b126fbd65eefa05db2f67e44df8f121 upstream.

Otherwise corrupted EFI partition tables can cause total confusion.

Signed-off-by: Timo Warns <warns@pre-sense.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Willy Tarreau <w@1wt.eu>
fs/partitions/efi.c

index 038a6022152fd15d84fb48b70fab816b971a8f7e..20b583e37c575401a5a4acaa42f50fc26fcdb150 100644 (file)
@@ -343,6 +343,12 @@ is_gpt_valid(struct block_device *bdev, u64 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");
+               goto fail;
+       }
+
        if (!(*ptes = alloc_read_gpt_entries(bdev, *gpt)))
                goto fail;