[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/22] vmdk: Fix overflow if l1_size is 0x20000000
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 04/22] vmdk: Fix overflow if l1_size is 0x20000000 |
Date: |
Fri, 22 May 2015 17:26:22 +0200 |
From: Fam Zheng <address@hidden>
Richard Jones caught this bug with afl fuzzer.
In fact, that's the only possible value to overflow (extent->l1_size =
0x20000000) l1_size:
l1_size = extent->l1_size * sizeof(long) => 0x80000000;
g_try_malloc returns NULL because l1_size is interpreted as negative
during type casting from 'int' to 'gsize', which yields a enormous
value. Hence, by coincidence, we get a "not too bad" behavior:
qemu-img: Could not open '/tmp/afl6.img': Could not open
'/tmp/afl6.img': Cannot allocate memory
Values larger than 0x20000000 will be refused by the validation in
vmdk_add_extent.
Values smaller than 0x20000000 will not overflow l1_size.
Cc: address@hidden
Reported-by: Richard W.M. Jones <address@hidden>
Signed-off-by: Fam Zheng <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Tested-by: Richard W.M. Jones <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/vmdk.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index 4b4a862..b66745d 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -451,7 +451,8 @@ static int vmdk_init_tables(BlockDriverState *bs,
VmdkExtent *extent,
Error **errp)
{
int ret;
- int l1_size, i;
+ size_t l1_size;
+ int i;
/* read the L1 table */
l1_size = extent->l1_size * sizeof(uint32_t);
--
1.8.3.1
- [Qemu-devel] [PULL 00/22] Block layer core and image format patches, Kevin Wolf, 2015/05/22
- [Qemu-devel] [PULL 02/22] nvme: support NVME_VOLATILE_WRITE_CACHE feature, Kevin Wolf, 2015/05/22
- [Qemu-devel] [PULL 04/22] vmdk: Fix overflow if l1_size is 0x20000000,
Kevin Wolf <=
- [Qemu-devel] [PULL 03/22] vmdk: Fix next_cluster_sector for compressed write, Kevin Wolf, 2015/05/22
- [Qemu-devel] [PULL 01/22] qcow2: Flush pending discards before allocating cluster, Kevin Wolf, 2015/05/22
- [Qemu-devel] [PULL 06/22] qcow2: simplify qcow2_cache_put() and qcow2_cache_entry_mark_dirty(), Kevin Wolf, 2015/05/22
- [Qemu-devel] [PULL 05/22] qcow2: use one single memory block for the L2/refcount cache tables, Kevin Wolf, 2015/05/22
- [Qemu-devel] [PULL 07/22] qcow2: use an LRU algorithm to replace entries from the L2 cache, Kevin Wolf, 2015/05/22
- [Qemu-devel] [PULL 08/22] qcow2: remove qcow2_cache_find_entry_to_replace(), Kevin Wolf, 2015/05/22
- [Qemu-devel] [PULL 11/22] qcow2: style fixes in qcow2-cache.c, Kevin Wolf, 2015/05/22
- [Qemu-devel] [PULL 09/22] qcow2: use a hash to look for entries in the L2 cache, Kevin Wolf, 2015/05/22
- [Qemu-devel] [PULL 12/22] qemu-io: Use getopt() correctly, Kevin Wolf, 2015/05/22
- [Qemu-devel] [PULL 10/22] qcow2: make qcow2_cache_put() a void function, Kevin Wolf, 2015/05/22