[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 006/108] virtio-net: fix buffer overflow on invalid
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 006/108] virtio-net: fix buffer overflow on invalid state load |
Date: |
Wed, 6 Aug 2014 15:38:16 -0500 |
From: "Michael S. Tsirkin" <address@hidden>
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 <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Laszlo Ersek <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
(cherry picked from commit 71f7fe48e10a8437c9d42d859389f37157f59980)
Signed-off-by: Michael Roth <address@hidden>
---
include/hw/virtio/virtio-net.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index df60f16..4b32440 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -176,8 +176,8 @@ typedef struct VirtIONet {
uint8_t nobcast;
uint8_t vhost_started;
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.9.1
- [Qemu-stable] [000/108] Patch Round-up for stable 2.0.1, freeze on 2014-08-12, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 002/108] hw/net/stellaris_enet: Correct handling of packet padding, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 001/108] hw/net/stellaris_enet: Restructure tx_fifo code to avoid buffer overrun, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 004/108] vmstate: add VMS_MUST_EXIST, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 003/108] vmstate: reduce code duplication, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 009/108] ahci: fix buffer overrun on invalid state load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 006/108] virtio-net: fix buffer overflow on invalid state load,
Michael Roth <=
- [Qemu-stable] [PATCH 007/108] virtio-net: out-of-bounds buffer write on invalid state load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 005/108] vmstate: add VMSTATE_VALIDATE, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 011/108] hw/pci/pcie_aer.c: fix buffer overruns on invalid state load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 010/108] hpet: fix buffer overrun on invalid state load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 008/108] virtio-net: out-of-bounds buffer write on load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 013/108] vmstate: fix buffer overflow in target-arm/machine.c, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 012/108] pl022: fix buffer overun on invalid state load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 015/108] virtio: validate num_sg when mapping, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 017/108] pxa2xx: avoid buffer overrun on incoming migration, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 020/108] tsc210x: fix buffer overrun on invalid state load, Michael Roth, 2014/08/06