diff options
author | Peter Jones <pjones@redhat.com> | 2013-02-27 20:05:17 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:21 -0500 |
commit | 8b8a6e1881be8d73b7a98f84ccec61e624ec5cac (patch) | |
tree | 4e5e883aeee2ee9371b97e52a053d07c24939f2d /block/partitions | |
parent | 86ee8ba64daf5e09a71e4c216f81fae8d1c937f3 (diff) |
block/partitions/efi.c: ensure that the GPT header is at least the size of the structure.
UEFI 2.3.1D will include a change to the spec language mandating that a
GPT header must be greater than *or equal to* the size of the defined
structure. While verifying that this would work on Linux, I discovered
that we're not actually checking the minimum bound at all.
The result of this is that when we verify the checksum, it's possible that
on a malformed header (with header_size of 0), we won't actually verify
any data.
[akpm@linux-foundation.org: fix printk warning]
Signed-off-by: Peter Jones <pjones@redhat.com>
Acked-by: Matt Fleming <matt.fleming@intel.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'block/partitions')
-rw-r--r-- | block/partitions/efi.c | 12 |
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; |