|
|
958e1b |
From 798f06c3737233a836584a72565f8076907365d9 Mon Sep 17 00:00:00 2001
|
|
|
eb5a2f |
From: Michael S. Tsirkin <mst@redhat.com>
|
|
|
958e1b |
Date: Wed, 14 May 2014 08:31:36 +0200
|
|
|
958e1b |
Subject: [PATCH 09/31] virtio-net: fix buffer overflow on invalid state load
|
|
|
eb5a2f |
|
|
|
eb5a2f |
RH-Author: Michael S. Tsirkin <mst@redhat.com>
|
|
|
958e1b |
Message-id: <1400056285-6688-1-git-send-email-mst@redhat.com>
|
|
|
958e1b |
Patchwork-id: 58855
|
|
|
958e1b |
O-Subject: [PATCH qemu-kvm RHEL7.1] virtio-net: fix buffer overflow on invalid state load
|
|
|
958e1b |
Bugzilla: 1095678
|
|
|
eb5a2f |
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
|
|
|
eb5a2f |
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
|
|
|
eb5a2f |
RH-Acked-by: Amos Kong <akong@redhat.com>
|
|
|
eb5a2f |
|
|
|
eb5a2f |
CVE-2013-4148 QEMU 1.0 integer conversion in
|
|
|
eb5a2f |
virtio_net_load()@hw/net/virtio-net.c
|
|
|
eb5a2f |
|
|
|
eb5a2f |
Deals with loading a corrupted savevm image.
|
|
|
eb5a2f |
|
|
|
eb5a2f |
> n->mac_table.in_use = qemu_get_be32(f);
|
|
|
eb5a2f |
|
|
|
eb5a2f |
in_use is int so it can get negative when assigned 32bit unsigned value.
|
|
|
eb5a2f |
|
|
|
eb5a2f |
> /* MAC_TABLE_ENTRIES may be different from the saved image */
|
|
|
eb5a2f |
> if (n->mac_table.in_use <= MAC_TABLE_ENTRIES) {
|
|
|
eb5a2f |
|
|
|
eb5a2f |
passing this check ^^^
|
|
|
eb5a2f |
|
|
|
eb5a2f |
> qemu_get_buffer(f, n->mac_table.macs,
|
|
|
eb5a2f |
> n->mac_table.in_use * ETH_ALEN);
|
|
|
eb5a2f |
|
|
|
eb5a2f |
with good in_use value, "n->mac_table.in_use * ETH_ALEN" can get
|
|
|
eb5a2f |
positive and bigger than mac_table.macs. For example 0x81000000
|
|
|
eb5a2f |
satisfies this condition when ETH_ALEN is 6.
|
|
|
eb5a2f |
|
|
|
eb5a2f |
Fix it by making the value unsigned.
|
|
|
eb5a2f |
For consistency, change first_multi as well.
|
|
|
eb5a2f |
|
|
|
eb5a2f |
Note: all call sites were audited to confirm that
|
|
|
eb5a2f |
making them unsigned didn't cause any issues:
|
|
|
eb5a2f |
it turns out we actually never do math on them,
|
|
|
eb5a2f |
so it's easy to validate because both values are
|
|
|
eb5a2f |
always <= MAC_TABLE_ENTRIES.
|
|
|
eb5a2f |
|
|
|
eb5a2f |
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
|
|
eb5a2f |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
eb5a2f |
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
eb5a2f |
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
|
eb5a2f |
(cherry picked from commit 71f7fe48e10a8437c9d42d859389f37157f59980)
|
|
|
eb5a2f |
|
|
|
958e1b |
Bugzilla: 1095678
|
|
|
eb5a2f |
Tested: on developer's box
|
|
|
958e1b |
Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7452039
|
|
|
eb5a2f |
---
|
|
|
eb5a2f |
include/hw/virtio/virtio-net.h | 4 ++--
|
|
|
eb5a2f |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
eb5a2f |
|
|
|
eb5a2f |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
eb5a2f |
---
|
|
|
eb5a2f |
include/hw/virtio/virtio-net.h | 4 ++--
|
|
|
eb5a2f |
1 files changed, 2 insertions(+), 2 deletions(-)
|
|
|
eb5a2f |
|
|
|
eb5a2f |
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
|
|
|
eb5a2f |
index 75723a8..a02fc50 100644
|
|
|
eb5a2f |
--- a/include/hw/virtio/virtio-net.h
|
|
|
eb5a2f |
+++ b/include/hw/virtio/virtio-net.h
|
|
|
eb5a2f |
@@ -174,8 +174,8 @@ typedef struct VirtIONet {
|
|
|
eb5a2f |
uint8_t nobcast;
|
|
|
eb5a2f |
uint8_t vhost_started;
|
|
|
eb5a2f |
struct {
|
|
|
eb5a2f |
- int in_use;
|
|
|
eb5a2f |
- int first_multi;
|
|
|
eb5a2f |
+ uint32_t in_use;
|
|
|
eb5a2f |
+ uint32_t first_multi;
|
|
|
eb5a2f |
uint8_t multi_overflow;
|
|
|
eb5a2f |
uint8_t uni_overflow;
|
|
|
eb5a2f |
uint8_t *macs;
|
|
|
eb5a2f |
--
|
|
|
eb5a2f |
1.7.1
|
|
|
eb5a2f |
|