diff options
author | Timo Warns <Warns@pre-sense.de> | 2011-05-26 16:25:57 -0700 |
---|---|---|
committer | Willy Tarreau <w@1wt.eu> | 2012-04-09 15:00:58 +0200 |
commit | eb7da49420e6f3e726078ec2611a7a26b0006a6d (patch) | |
tree | ef52c854f92cdb1cc7061dcbac88177763d65c94 | |
parent | a3ca2b51a25f871082ea4b93956074feb9ea4823 (diff) | |
download | linux-2.4-eb7da49420e6f3e726078ec2611a7a26b0006a6d.tar.gz |
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>
[ WT: no bdev_logical_block_size() in 2.4, use get_hardsect_size() instead ]
Signed-off-by: Willy Tarreau <w@1wt.eu>
-rw-r--r-- | fs/partitions/efi.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/partitions/efi.c b/fs/partitions/efi.c index 5f3ab446c546bc..c869f47c88528a 100644 --- a/fs/partitions/efi.c +++ b/fs/partitions/efi.c @@ -337,6 +337,7 @@ is_gpt_valid(struct gendisk *hd, struct block_device *bdev, u64 lba, gpt_header **gpt, gpt_entry **ptes) { u32 crc, origcrc; + int blocksize; if (!hd || !bdev || !gpt || !ptes) return 0; @@ -353,6 +354,19 @@ is_gpt_valid(struct gendisk *hd, struct block_device *bdev, u64 lba, return 0; } + /* Check the GUID Partition Table header size */ + blocksize = get_hardsect_size(to_kdev_t(bdev->bd_dev)); + if (!blocksize) + blocksize = 512; + + if (le32_to_cpu((*gpt)->header_size) > blocksize) { + Dprintk("GUID Partition Table Header size is wrong: %u > %u\n", + le32_to_cpu((*gpt)->header_size), blocksize); + kfree(*gpt); + *gpt = NULL; + return 0; + } + /* Check the GUID Partition Table CRC */ origcrc = le32_to_cpu((*gpt)->header_crc32); (*gpt)->header_crc32 = 0; |