From 2ee9e44be6e9a3c0b3c89c0bbff01d07bb656f37 Mon Sep 17 00:00:00 2001 From: Michael S. Tsirkin Date: Wed, 14 May 2014 09:43:03 -0500 Subject: [PATCH 18/20] virtio-net: fix buffer overflow on invalid state load RH-Author: Michael S. Tsirkin Message-id: <1400060570-8142-1-git-send-email-mst@redhat.com> Patchwork-id: 58875 O-Subject: [PATCH qemu-kvm RHEL6.6] virtio-net: fix buffer overflow on invalid state load Bugzilla: 1066430 RH-Acked-by: Amos Kong RH-Acked-by: Dr. David Alan Gilbert (git) RH-Acked-by: Xiao Wang CVE-2013-4148 QEMU 1.0 integer conversion in virtio_net_load()@hw/net/virtio-net.c Deals with loading a corrupted savevm image. > n->mac_table.in_use = qemu_get_be32(f); in_use is int so it can get negative when assigned 32bit unsigned value. > /* MAC_TABLE_ENTRIES may be different from the saved image */ > if (n->mac_table.in_use <= MAC_TABLE_ENTRIES) { passing this check ^^^ > qemu_get_buffer(f, n->mac_table.macs, > n->mac_table.in_use * ETH_ALEN); with good in_use value, "n->mac_table.in_use * ETH_ALEN" can get positive and bigger than mac_table.macs. For example 0x81000000 satisfies this condition when ETH_ALEN is 6. Fix it by making the value unsigned. For consistency, change first_multi as well. Note: all call sites were audited to confirm that making them unsigned didn't cause any issues: it turns out we actually never do math on them, so it's easy to validate because both values are always <= MAC_TABLE_ENTRIES. Reviewed-by: Michael Roth Signed-off-by: Michael S. Tsirkin Reviewed-by: Laszlo Ersek Signed-off-by: Juan Quintela (cherry picked from commit 71f7fe48e10a8437c9d42d859389f37157f59980) Bugzilla: 1066430 Tested: lightly on developer's box Brew build: --- hw/virtio-net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Signed-off-by: Jeff E. Nelson --- hw/virtio-net.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 2173428..35b3a07 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -56,8 +56,8 @@ typedef struct VirtIONet uint8_t vhost_started; bool macvtap_rhel620_compat; struct { - int in_use; - int first_multi; + uint32_t in_use; + uint32_t first_multi; uint8_t multi_overflow; uint8_t uni_overflow; uint8_t *macs; -- 1.7.1