|
|
9ae3a8 |
From abf79316045a3c634e9633553942763fd358f9b2 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 25 Mar 2014 14:23:18 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 11/49] bochs: Use unsigned variables for offsets and sizes (CVE-2014-0147)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1395753835-7591-12-git-send-email-kwolf@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: n/a
|
|
|
9ae3a8 |
O-Subject: [virt-devel] [EMBARGOED RHEL-7.0 qemu-kvm PATCH 11/48] bochs: Use unsigned variables for offsets and sizes (CVE-2014-0147)
|
|
|
9ae3a8 |
Bugzilla: 1079339
|
|
|
9ae3a8 |
RH-Acked-by: Jeff Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1079339
|
|
|
9ae3a8 |
Upstream status: Embargoed
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Gets us rid of integer overflows resulting in negative sizes which
|
|
|
9ae3a8 |
aren't correctly checked.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/bochs.c | 16 ++++++++--------
|
|
|
9ae3a8 |
tests/qemu-iotests/078 | 8 ++++++++
|
|
|
9ae3a8 |
tests/qemu-iotests/078.out | 4 ++++
|
|
|
9ae3a8 |
3 files changed, 20 insertions(+), 8 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/bochs.c b/block/bochs.c
|
|
|
9ae3a8 |
index 708780d..04cca71 100644
|
|
|
9ae3a8 |
--- a/block/bochs.c
|
|
|
9ae3a8 |
+++ b/block/bochs.c
|
|
|
9ae3a8 |
@@ -67,13 +67,13 @@ struct bochs_header {
|
|
|
9ae3a8 |
typedef struct BDRVBochsState {
|
|
|
9ae3a8 |
CoMutex lock;
|
|
|
9ae3a8 |
uint32_t *catalog_bitmap;
|
|
|
9ae3a8 |
- int catalog_size;
|
|
|
9ae3a8 |
+ uint32_t catalog_size;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- int data_offset;
|
|
|
9ae3a8 |
+ uint32_t data_offset;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- int bitmap_blocks;
|
|
|
9ae3a8 |
- int extent_blocks;
|
|
|
9ae3a8 |
- int extent_size;
|
|
|
9ae3a8 |
+ uint32_t bitmap_blocks;
|
|
|
9ae3a8 |
+ uint32_t extent_blocks;
|
|
|
9ae3a8 |
+ uint32_t extent_size;
|
|
|
9ae3a8 |
} BDRVBochsState;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int bochs_probe(const uint8_t *buf, int buf_size, const char *filename)
|
|
|
9ae3a8 |
@@ -97,7 +97,7 @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
9ae3a8 |
Error **errp)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
BDRVBochsState *s = bs->opaque;
|
|
|
9ae3a8 |
- int i;
|
|
|
9ae3a8 |
+ uint32_t i;
|
|
|
9ae3a8 |
struct bochs_header bochs;
|
|
|
9ae3a8 |
int ret;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -152,8 +152,8 @@ fail:
|
|
|
9ae3a8 |
static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
BDRVBochsState *s = bs->opaque;
|
|
|
9ae3a8 |
- int64_t offset = sector_num * 512;
|
|
|
9ae3a8 |
- int64_t extent_index, extent_offset, bitmap_offset;
|
|
|
9ae3a8 |
+ uint64_t offset = sector_num * 512;
|
|
|
9ae3a8 |
+ uint64_t extent_index, extent_offset, bitmap_offset;
|
|
|
9ae3a8 |
char bitmap_entry;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
// seek to sector
|
|
|
9ae3a8 |
diff --git a/tests/qemu-iotests/078 b/tests/qemu-iotests/078
|
|
|
9ae3a8 |
index f55f46d..73b573a 100755
|
|
|
9ae3a8 |
--- a/tests/qemu-iotests/078
|
|
|
9ae3a8 |
+++ b/tests/qemu-iotests/078
|
|
|
9ae3a8 |
@@ -42,11 +42,19 @@ _supported_fmt bochs
|
|
|
9ae3a8 |
_supported_proto generic
|
|
|
9ae3a8 |
_supported_os Linux
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+catalog_size_offset=$((0x48))
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
echo
|
|
|
9ae3a8 |
echo "== Read from a valid image =="
|
|
|
9ae3a8 |
_use_sample_img empty.bochs.bz2
|
|
|
9ae3a8 |
{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+echo
|
|
|
9ae3a8 |
+echo "== Negative catalog size =="
|
|
|
9ae3a8 |
+_use_sample_img empty.bochs.bz2
|
|
|
9ae3a8 |
+poke_file "$TEST_IMG" "$catalog_size_offset" "\xff\xff\xff\xff"
|
|
|
9ae3a8 |
+{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
# success, all done
|
|
|
9ae3a8 |
echo "*** done"
|
|
|
9ae3a8 |
rm -f $seq.full
|
|
|
9ae3a8 |
diff --git a/tests/qemu-iotests/078.out b/tests/qemu-iotests/078.out
|
|
|
9ae3a8 |
index 25d37c5..ef8c42d 100644
|
|
|
9ae3a8 |
--- a/tests/qemu-iotests/078.out
|
|
|
9ae3a8 |
+++ b/tests/qemu-iotests/078.out
|
|
|
9ae3a8 |
@@ -3,4 +3,8 @@ QA output created by 078
|
|
|
9ae3a8 |
== Read from a valid image ==
|
|
|
9ae3a8 |
read 512/512 bytes at offset 0
|
|
|
9ae3a8 |
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+== Negative catalog size ==
|
|
|
9ae3a8 |
+qemu-io: can't open device TEST_DIR/empty.bochs: Could not open 'TEST_DIR/empty.bochs': Interrupted system call
|
|
|
9ae3a8 |
+no file open, try 'help open'
|
|
|
9ae3a8 |
*** done
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|