diff options
| author | Armin Kuster <akuster@mvista.com> | 2016-09-19 20:01:16 -0700 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-09-23 23:22:04 +0100 |
| commit | 6998a3c1e64869b720c49f45af37862646ac5dff (patch) | |
| tree | 2291e336f36f7ea3cc224985aeb00f0e2b6f946e /meta | |
| parent | 6057d0aa47c9c72e506403ad0b646a1c0e53190d (diff) | |
| download | poky-6998a3c1e64869b720c49f45af37862646ac5dff.tar.gz | |
qemu: Secuirty fix for CVE-2016-5403
affects qemu < 2.7.0-rc0
(From OE-Core rev: 2f3f09dfbff21fb74e50e4e3ce90c252d32ebf61)
Signed-off-by: Armin Kuster <akuster@mvista.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/recipes-devtools/qemu/qemu/CVE-2016-5403.patch | 67 | ||||
| -rw-r--r-- | meta/recipes-devtools/qemu/qemu_2.4.0.bb | 1 |
2 files changed, 68 insertions, 0 deletions
diff --git a/meta/recipes-devtools/qemu/qemu/CVE-2016-5403.patch b/meta/recipes-devtools/qemu/qemu/CVE-2016-5403.patch new file mode 100644 index 0000000000..fe084f5b08 --- /dev/null +++ b/meta/recipes-devtools/qemu/qemu/CVE-2016-5403.patch | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | From afd9096eb1882f23929f5b5c177898ed231bac66 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Stefan Hajnoczi <stefanha@redhat.com> | ||
| 3 | Date: Tue, 19 Jul 2016 13:07:13 +0100 | ||
| 4 | Subject: [PATCH] virtio: error out if guest exceeds virtqueue size | ||
| 5 | |||
| 6 | A broken or malicious guest can submit more requests than the virtqueue | ||
| 7 | size permits, causing unbounded memory allocation in QEMU. | ||
| 8 | |||
| 9 | The guest can submit requests without bothering to wait for completion | ||
| 10 | and is therefore not bound by virtqueue size. This requires reusing | ||
| 11 | vring descriptors in more than one request, which is not allowed by the | ||
| 12 | VIRTIO 1.0 specification. | ||
| 13 | |||
| 14 | In "3.2.1 Supplying Buffers to The Device", the VIRTIO 1.0 specification | ||
| 15 | says: | ||
| 16 | |||
| 17 | 1. The driver places the buffer into free descriptor(s) in the | ||
| 18 | descriptor table, chaining as necessary | ||
| 19 | |||
| 20 | and | ||
| 21 | |||
| 22 | Note that the above code does not take precautions against the | ||
| 23 | available ring buffer wrapping around: this is not possible since the | ||
| 24 | ring buffer is the same size as the descriptor table, so step (1) will | ||
| 25 | prevent such a condition. | ||
| 26 | |||
| 27 | This implies that placing more buffers into the virtqueue than the | ||
| 28 | descriptor table size is not allowed. | ||
| 29 | |||
| 30 | QEMU is missing the check to prevent this case. Processing a request | ||
| 31 | allocates a VirtQueueElement leading to unbounded memory allocation | ||
| 32 | controlled by the guest. | ||
| 33 | |||
| 34 | Exit with an error if the guest provides more requests than the | ||
| 35 | virtqueue size permits. This bounds memory allocation and makes the | ||
| 36 | buggy guest visible to the user. | ||
| 37 | |||
| 38 | This patch fixes CVE-2016-5403 and was reported by Zhenhao Hong from 360 | ||
| 39 | Marvel Team, China. | ||
| 40 | |||
| 41 | Reported-by: Zhenhao Hong <hongzhenhao@360.cn> | ||
| 42 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
| 43 | |||
| 44 | Upstream-Status: Backport | ||
| 45 | CVE: CVE-2106-5403 | ||
| 46 | Signed-off-by: Armin Kuster <akuster@mvista.com> | ||
| 47 | |||
| 48 | --- | ||
| 49 | hw/virtio/virtio.c | 5 +++++ | ||
| 50 | 1 file changed, 5 insertions(+) | ||
| 51 | |||
| 52 | Index: qemu-2.4.0/hw/virtio/virtio.c | ||
| 53 | =================================================================== | ||
| 54 | --- qemu-2.4.0.orig/hw/virtio/virtio.c | ||
| 55 | +++ qemu-2.4.0/hw/virtio/virtio.c | ||
| 56 | @@ -483,6 +483,11 @@ int virtqueue_pop(VirtQueue *vq, VirtQue | ||
| 57 | |||
| 58 | max = vq->vring.num; | ||
| 59 | |||
| 60 | + if (vq->inuse >= vq->vring.num) { | ||
| 61 | + error_report("Virtqueue size exceeded"); | ||
| 62 | + exit(1); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | i = head = virtqueue_get_head(vq, vq->last_avail_idx++); | ||
| 66 | if (virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { | ||
| 67 | vring_set_avail_event(vq, vq->last_avail_idx); | ||
diff --git a/meta/recipes-devtools/qemu/qemu_2.4.0.bb b/meta/recipes-devtools/qemu/qemu_2.4.0.bb index c33eb66c89..ad5ca89b96 100644 --- a/meta/recipes-devtools/qemu/qemu_2.4.0.bb +++ b/meta/recipes-devtools/qemu/qemu_2.4.0.bb | |||
| @@ -29,6 +29,7 @@ SRC_URI += "file://configure-fix-Darwin-target-detection.patch \ | |||
| 29 | file://CVE-2016-6351_p1.patch \ | 29 | file://CVE-2016-6351_p1.patch \ |
| 30 | file://CVE-2016-6351_p2.patch \ | 30 | file://CVE-2016-6351_p2.patch \ |
| 31 | file://CVE-2016-4002.patch \ | 31 | file://CVE-2016-4002.patch \ |
| 32 | file://CVE-2016-5403.patch \ | ||
| 32 | " | 33 | " |
| 33 | SRC_URI_prepend = "http://wiki.qemu-project.org/download/${BP}.tar.bz2" | 34 | SRC_URI_prepend = "http://wiki.qemu-project.org/download/${BP}.tar.bz2" |
| 34 | SRC_URI[md5sum] = "186ee8194140a484a455f8e3c74589f4" | 35 | SRC_URI[md5sum] = "186ee8194140a484a455f8e3c74589f4" |
