diff options
author | Timo Warns <Warns@pre-sense.de> | 2011-05-26 19:25:57 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-26 20:12:37 -0400 |
commit | 3eb8e74ec72736b9b9d728bad30484ec89c91dde (patch) | |
tree | 851f9165816e28ce43594a562698dd234e53d486 /fs/partitions | |
parent | 658c74cf3c98b1c9bc21e26731052db66251dfd8 (diff) |
fs/partitions/efi.c: corrupted GUID partition tables can cause kernel oops
The kernel automatically evaluates partition tables of storage devices.
The code for evaluating GUID partitions (in fs/partitions/efi.c) contains
a bug that causes a kernel oops on certain corrupted GUID partition
tables.
This bug has security impacts, because it allows, for example, to
prepare a storage device that crashes a kernel subsystem upon connecting
the device (e.g., a "USB Stick of (Partial) Death").
crc = efi_crc32((const unsigned char *) (*gpt), le32_to_cpu((*gpt)->header_size));
computes a CRC32 checksum over gpt covering (*gpt)->header_size bytes.
There is no validation of (*gpt)->header_size before the efi_crc32 call.
A corrupted partition table may have large values for (*gpt)->header_size.
In this case, the CRC32 computation access memory beyond the memory
allocated for gpt, which may cause a kernel heap overflow.
Validate value of GUID partition table header size.
[akpm@linux-foundation.org: fix layout and indenting]
Signed-off-by: Timo Warns <warns@pre-sense.de>
Cc: Matt Domsch <Matt_Domsch@dell.com>
Cc: Eugene Teo <eugeneteo@kernel.sg>
Cc: Dave Jones <davej@codemonkey.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/partitions')
-rw-r--r-- | fs/partitions/efi.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/partitions/efi.c b/fs/partitions/efi.c index 19d6750d1d6c..6296b403c67a 100644 --- a/fs/partitions/efi.c +++ b/fs/partitions/efi.c | |||
@@ -310,6 +310,15 @@ 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 */ | ||
314 | if (le32_to_cpu((*gpt)->header_size) > | ||
315 | bdev_logical_block_size(state->bdev)) { | ||
316 | pr_debug("GUID Partition Table Header size is wrong: %u > %u\n", | ||
317 | le32_to_cpu((*gpt)->header_size), | ||
318 | bdev_logical_block_size(state->bdev)); | ||
319 | goto fail; | ||
320 | } | ||
321 | |||
313 | /* Check the GUID Partition Table CRC */ | 322 | /* Check the GUID Partition Table CRC */ |
314 | origcrc = le32_to_cpu((*gpt)->header_crc32); | 323 | origcrc = le32_to_cpu((*gpt)->header_crc32); |
315 | (*gpt)->header_crc32 = 0; | 324 | (*gpt)->header_crc32 = 0; |