[34-longterm 172/196] Validate size of EFI GUID partition entries.

From: Paul Gortmaker
Date: Mon Mar 12 2012 - 20:32:49 EST


From: Timo Warns <Warns@xxxxxxxxxxxx>

-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
If you see a problem with using this for longterm, please comment.
-------------------

commit fa039d5f6b126fbd65eefa05db2f67e44df8f121 upstream.

Otherwise corrupted EFI partition tables can cause total confusion.

Signed-off-by: Timo Warns <warns@xxxxxxxxxxxx>
Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Paul Gortmaker <paul.gortmaker@xxxxxxxxxxxxx>
---
fs/partitions/efi.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/fs/partitions/efi.c b/fs/partitions/efi.c
index 91babda..ee59684 100644
--- a/fs/partitions/efi.c
+++ b/fs/partitions/efi.c
@@ -350,6 +350,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;

--
1.7.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/