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