Update qemu package to mitigate CVE-2015-3456
[packages/centos6/qemu.git] / 0004-virtio-net-fix-buffer-overflow-on-invalid-state-load.patch
1 From ea96c6a9c91da1923aa922a781fd7abbf9f51b6c Mon Sep 17 00:00:00 2001
2 From: "Michael S. Tsirkin" <mst@redhat.com>
3 Date: Thu, 3 Apr 2014 19:50:39 +0300
4 Subject: [PATCH] virtio-net: fix buffer overflow on invalid state load
5
6 CVE-2013-4148 QEMU 1.0 integer conversion in
7 virtio_net_load()@hw/net/virtio-net.c
8
9 Deals with loading a corrupted savevm image.
10
11 >         n->mac_table.in_use = qemu_get_be32(f);
12
13 in_use is int so it can get negative when assigned 32bit unsigned value.
14
15 >         /* MAC_TABLE_ENTRIES may be different from the saved image */
16 >         if (n->mac_table.in_use <= MAC_TABLE_ENTRIES) {
17
18 passing this check ^^^
19
20 >             qemu_get_buffer(f, n->mac_table.macs,
21 >                             n->mac_table.in_use * ETH_ALEN);
22
23 with good in_use value, "n->mac_table.in_use * ETH_ALEN" can get
24 positive and bigger than mac_table.macs. For example 0x81000000
25 satisfies this condition when ETH_ALEN is 6.
26
27 Fix it by making the value unsigned.
28 For consistency, change first_multi as well.
29
30 Note: all call sites were audited to confirm that
31 making them unsigned didn't cause any issues:
32 it turns out we actually never do math on them,
33 so it's easy to validate because both values are
34 always <= MAC_TABLE_ENTRIES.
35
36 Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
37 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
38 Reviewed-by: Laszlo Ersek <lersek@redhat.com>
39 Signed-off-by: Juan Quintela <quintela@redhat.com>
40 (cherry picked from commit 71f7fe48e10a8437c9d42d859389f37157f59980)
41 ---
42  include/hw/virtio/virtio-net.h | 4 ++--
43  1 file changed, 2 insertions(+), 2 deletions(-)
44
45 diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
46 index df60f16..4b32440 100644
47 --- a/include/hw/virtio/virtio-net.h
48 +++ b/include/hw/virtio/virtio-net.h
49 @@ -176,8 +176,8 @@ typedef struct VirtIONet {
50      uint8_t nobcast;
51      uint8_t vhost_started;
52      struct {
53 -        int in_use;
54 -        int first_multi;
55 +        uint32_t in_use;
56 +        uint32_t first_multi;
57          uint8_t multi_overflow;
58          uint8_t uni_overflow;
59          uint8_t *macs;