]> Pileus Git - ~andy/linux/blobdiff - block/partitions/efi.c
Merge branch 'for-john' of git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi...
[~andy/linux] / block / partitions / efi.c
index b62fb88b87118956e81a30884c086b30956ac61d..ff5804e2f1d2ffeb40d7d7446af9867e0b48bd03 100644 (file)
@@ -310,15 +310,23 @@ static int is_gpt_valid(struct parsed_partitions *state, u64 lba,
                goto fail;
        }
 
-       /* Check the GUID Partition Table header size */
+       /* Check the GUID Partition Table header size is too big */
        if (le32_to_cpu((*gpt)->header_size) >
                        bdev_logical_block_size(state->bdev)) {
-               pr_debug("GUID Partition Table Header size is wrong: %u > %u\n",
+               pr_debug("GUID Partition Table Header size is too large: %u > %u\n",
                        le32_to_cpu((*gpt)->header_size),
                        bdev_logical_block_size(state->bdev));
                goto fail;
        }
 
+       /* Check the GUID Partition Table header size is too small */
+       if (le32_to_cpu((*gpt)->header_size) < sizeof(gpt_header)) {
+               pr_debug("GUID Partition Table Header size is too small: %u < %zu\n",
+                       le32_to_cpu((*gpt)->header_size),
+                       sizeof(gpt_header));
+               goto fail;
+       }
+
        /* Check the GUID Partition Table CRC */
        origcrc = le32_to_cpu((*gpt)->header_crc32);
        (*gpt)->header_crc32 = 0;