Validate size of EFI GUID partition entries.
Otherwise corrupted EFI partition tables can cause total confusion.
Signed-off-by: Timo Warns <warns@pre-sense.de>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/fs/partitions/efi.c b/fs/partitions/efi.c
index 8ae4908..5f3ab44 100644
--- a/fs/partitions/efi.c
+++ b/fs/partitions/efi.c
@@ -378,6 +378,14 @@
return 0;
}
+ /* Check that sizeof_partition_entry has the correct value */
+ if (le32_to_cpu((*gpt)->sizeof_partition_entry) != sizeof(gpt_entry)) {
+ Dprintk("GUID Partitition Entry Size check failed.\n");
+ kfree(*gpt);
+ *gpt = NULL;
+ return 0;
+ }
+
if (!(*ptes = alloc_read_gpt_entries(hd, bdev, *gpt))) {
kfree(*gpt);
*gpt = NULL;