|
|
0a122b |
From 8d0f3218313c74d2e9df015385b809a7cb03734e Mon Sep 17 00:00:00 2001
|
|
|
0a122b |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
0a122b |
Date: Tue, 25 Mar 2014 14:23:55 +0100
|
|
|
0a122b |
Subject: [PATCH 48/49] parallels: Sanity check for s->tracks (CVE-2014-0142)
|
|
|
0a122b |
|
|
|
0a122b |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
0a122b |
Message-id: <1395753835-7591-49-git-send-email-kwolf@redhat.com>
|
|
|
0a122b |
Patchwork-id: n/a
|
|
|
0a122b |
O-Subject: [virt-devel] [EMBARGOED RHEL-7.0 qemu-kvm PATCH 48/48] parallels: Sanity check for s->tracks (CVE-2014-0142)
|
|
|
0a122b |
Bugzilla: 1079315
|
|
|
0a122b |
RH-Acked-by: Jeff Cody <jcody@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
0a122b |
|
|
|
0a122b |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1079315
|
|
|
0a122b |
Upstream status: Embargoed
|
|
|
0a122b |
|
|
|
0a122b |
This avoids a possible division by zero.
|
|
|
0a122b |
|
|
|
0a122b |
Convert s->tracks to unsigned as well because it feels better than
|
|
|
0a122b |
surviving just because the results of calculations with s->tracks are
|
|
|
0a122b |
converted to unsigned anyway.
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
0a122b |
---
|
|
|
0a122b |
block/parallels.c | 7 ++++++-
|
|
|
0a122b |
tests/qemu-iotests/076 | 7 +++++++
|
|
|
0a122b |
tests/qemu-iotests/076.out | 4 ++++
|
|
|
0a122b |
3 files changed, 17 insertions(+), 1 deletions(-)
|
|
|
0a122b |
|
|
|
0a122b |
diff --git a/block/parallels.c b/block/parallels.c
|
|
|
0a122b |
index 5d1c0af..d83cde4 100644
|
|
|
0a122b |
--- a/block/parallels.c
|
|
|
0a122b |
+++ b/block/parallels.c
|
|
|
0a122b |
@@ -51,7 +51,7 @@ typedef struct BDRVParallelsState {
|
|
|
0a122b |
uint32_t *catalog_bitmap;
|
|
|
0a122b |
unsigned int catalog_size;
|
|
|
0a122b |
|
|
|
0a122b |
- int tracks;
|
|
|
0a122b |
+ unsigned int tracks;
|
|
|
0a122b |
} BDRVParallelsState;
|
|
|
0a122b |
|
|
|
0a122b |
static int parallels_probe(const uint8_t *buf, int buf_size, const char *filename)
|
|
|
0a122b |
@@ -92,6 +92,11 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
0a122b |
bs->total_sectors = le32_to_cpu(ph.nb_sectors);
|
|
|
0a122b |
|
|
|
0a122b |
s->tracks = le32_to_cpu(ph.tracks);
|
|
|
0a122b |
+ if (s->tracks == 0) {
|
|
|
0a122b |
+ error_setg(errp, "Invalid image: Zero sectors per track");
|
|
|
0a122b |
+ ret = -EINVAL;
|
|
|
0a122b |
+ goto fail;
|
|
|
0a122b |
+ }
|
|
|
0a122b |
|
|
|
0a122b |
s->catalog_size = le32_to_cpu(ph.catalog_entries);
|
|
|
0a122b |
if (s->catalog_size > INT_MAX / 4) {
|
|
|
0a122b |
diff --git a/tests/qemu-iotests/076 b/tests/qemu-iotests/076
|
|
|
0a122b |
index 6028ac5..b614a7d 100755
|
|
|
0a122b |
--- a/tests/qemu-iotests/076
|
|
|
0a122b |
+++ b/tests/qemu-iotests/076
|
|
|
0a122b |
@@ -42,6 +42,7 @@ _supported_fmt parallels
|
|
|
0a122b |
_supported_proto generic
|
|
|
0a122b |
_supported_os Linux
|
|
|
0a122b |
|
|
|
0a122b |
+tracks_offset=$((0x1c))
|
|
|
0a122b |
catalog_entries_offset=$((0x20))
|
|
|
0a122b |
nb_sectors_offset=$((0x24))
|
|
|
0a122b |
|
|
|
0a122b |
@@ -63,6 +64,12 @@ poke_file "$TEST_IMG" "$nb_sectors_offset" "\xff\xff\xff\xff"
|
|
|
0a122b |
poke_file "$TEST_IMG" "$catalog_entries_offset" "\x01\x00\x00\x40"
|
|
|
0a122b |
{ $QEMU_IO -c "read 64M 64M" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
|
|
|
0a122b |
|
|
|
0a122b |
+echo
|
|
|
0a122b |
+echo "== Zero sectors per track =="
|
|
|
0a122b |
+_use_sample_img fake.parallels.bz2
|
|
|
0a122b |
+poke_file "$TEST_IMG" "$tracks_offset" "\x00\x00\x00\x00"
|
|
|
0a122b |
+{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
|
|
|
0a122b |
+
|
|
|
0a122b |
# success, all done
|
|
|
0a122b |
echo "*** done"
|
|
|
0a122b |
rm -f $seq.full
|
|
|
0a122b |
diff --git a/tests/qemu-iotests/076.out b/tests/qemu-iotests/076.out
|
|
|
0a122b |
index 12af42a..f7745d8 100644
|
|
|
0a122b |
--- a/tests/qemu-iotests/076.out
|
|
|
0a122b |
+++ b/tests/qemu-iotests/076.out
|
|
|
0a122b |
@@ -11,4 +11,8 @@ no file open, try 'help open'
|
|
|
0a122b |
== Overflow in catalog allocation ==
|
|
|
0a122b |
qemu-io: can't open device TEST_DIR/fake.parallels: Catalog too large
|
|
|
0a122b |
no file open, try 'help open'
|
|
|
0a122b |
+
|
|
|
0a122b |
+== Zero sectors per track ==
|
|
|
0a122b |
+qemu-io: can't open device TEST_DIR/fake.parallels: Invalid image: Zero sectors per track
|
|
|
0a122b |
+no file open, try 'help open'
|
|
|
0a122b |
*** done
|
|
|
0a122b |
--
|
|
|
0a122b |
1.7.1
|
|
|
0a122b |
|