Update qemu package to mitigate CVE-2015-3456
[packages/centos6/qemu.git] / 0012-virtio-avoid-buffer-overrun-on-incoming-migration.patch
1 From 9b5cc034e1ed5b2ebc133029d4f865f186c6b895 Mon Sep 17 00:00:00 2001
2 From: Michael Roth <mdroth@linux.vnet.ibm.com>
3 Date: Thu, 3 Apr 2014 19:51:46 +0300
4 Subject: [PATCH] virtio: avoid buffer overrun on incoming migration
5
6 CVE-2013-6399
7
8 vdev->queue_sel is read from the wire, and later used in the
9 emulation code as an index into vdev->vq[]. If the value of
10 vdev->queue_sel exceeds the length of vdev->vq[], currently
11 allocated to be VIRTIO_PCI_QUEUE_MAX elements, subsequent PIO
12 operations such as VIRTIO_PCI_QUEUE_PFN can be used to overrun
13 the buffer with arbitrary data originating from the source.
14
15 Fix this by failing migration if the value from the wire exceeds
16 VIRTIO_PCI_QUEUE_MAX.
17
18 Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
19 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
20 Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
21 Signed-off-by: Juan Quintela <quintela@redhat.com>
22 (cherry picked from commit 4b53c2c72cb5541cf394033b528a6fe2a86c0ac1)
23 ---
24  hw/virtio/virtio.c | 3 +++
25  1 file changed, 3 insertions(+)
26
27 diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
28 index 05f05e7..0072542 100644
29 --- a/hw/virtio/virtio.c
30 +++ b/hw/virtio/virtio.c
31 @@ -907,6 +907,9 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
32      qemu_get_8s(f, &vdev->status);
33      qemu_get_8s(f, &vdev->isr);
34      qemu_get_be16s(f, &vdev->queue_sel);
35 +    if (vdev->queue_sel >= VIRTIO_PCI_QUEUE_MAX) {
36 +        return -1;
37 +    }
38      qemu_get_be32s(f, &features);
39  
40      if (virtio_set_features(vdev, features) < 0) {