aboutsummaryrefslogtreecommitdiffstats
path: root/block/partitions
diff options
context:
space:
mode:
Diffstat (limited to 'block/partitions')
-rw-r--r--block/partitions/efi.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index b62fb88b8711..ff5804e2f1d2 100644
--- a/block/partitions/efi.c
+++ b/block/partitions/efi.c
@@ -310,15 +310,23 @@ static int is_gpt_valid(struct parsed_partitions *state, u64 lba,
310 goto fail; 310 goto fail;
311 } 311 }
312 312
313 /* Check the GUID Partition Table header size */ 313 /* Check the GUID Partition Table header size is too big */
314 if (le32_to_cpu((*gpt)->header_size) > 314 if (le32_to_cpu((*gpt)->header_size) >
315 bdev_logical_block_size(state->bdev)) { 315 bdev_logical_block_size(state->bdev)) {
316 pr_debug("GUID Partition Table Header size is wrong: %u > %u\n", 316 pr_debug("GUID Partition Table Header size is too large: %u > %u\n",
317 le32_to_cpu((*gpt)->header_size), 317 le32_to_cpu((*gpt)->header_size),
318 bdev_logical_block_size(state->bdev)); 318 bdev_logical_block_size(state->bdev));
319 goto fail; 319 goto fail;
320 } 320 }
321 321
322 /* Check the GUID Partition Table header size is too small */
323 if (le32_to_cpu((*gpt)->header_size) < sizeof(gpt_header)) {
324 pr_debug("GUID Partition Table Header size is too small: %u < %zu\n",
325 le32_to_cpu((*gpt)->header_size),
326 sizeof(gpt_header));
327 goto fail;
328 }
329
322 /* Check the GUID Partition Table CRC */ 330 /* Check the GUID Partition Table CRC */
323 origcrc = le32_to_cpu((*gpt)->header_crc32); 331 origcrc = le32_to_cpu((*gpt)->header_crc32);
324 (*gpt)->header_crc32 = 0; 332 (*gpt)->header_crc32 = 0;