Skip to contentSkip to conversation

Fix qemu cve issues

PATCH New [email protected] 1 participant 3 messages Oct 26, 2016

lore
Share & tools
lore
#0 lore raw

cover Fix qemu cve issues

From: Kai Kang <[email protected]>

Fix
* complementary fix of CVE-2016-5403
* CVE-2016-7423
* CVE-2016-7908

The following changes since commit 30d1af89ce2a2fb30f32a898ec12c9a51db57013:

image_types: Use softer setting of WKS_FILE (2016-10-25 17:58:59 +0100)

are available in the git repository at:

git://git.pokylinux.org/poky-contrib kangkai/qemu-cves
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=kangkai/qemu-cves

Kai Kang (2):
qemu: supplementary fix of CVE-2016-5403
qemu: fix CVE-2016-7423 and CVE-2016-7908

 ...0001-virtio-zero-vq-inuse-in-virtio_reset.patch | 57 ++++++++++++++++++++
 .../qemu/qemu/0002-fix-CVE-2016-7423.patch         | 45 ++++++++++++++++
 .../qemu/qemu/0003-fix-CVE-2016-7908.patch         | 62 ++++++++++++++++++++++
 meta/recipes-devtools/qemu/qemu_2.7.0.bb           |  3 ++
 4 files changed, 167 insertions(+)
 create mode 100644 meta/recipes-devtools/qemu/qemu/0001-virtio-zero-vq-inuse-in-virtio_reset.patch
 create mode 100644 meta/recipes-devtools/qemu/qemu/0002-fix-CVE-2016-7423.patch
 create mode 100644 meta/recipes-devtools/qemu/qemu/0003-fix-CVE-2016-7908.patch
Signature · 1 line
2.10.1
#1 lore raw

PATCH 1/2 qemu: supplementary fix of CVE-2016-5403

From: Kai Kang <[email protected]>

Issue: LIN9-1439

It is reported in qemu community that VM always exits with:

| 2016-10-17T07:33:40.393592Z qemu-kvm: Virtqueue size exceede

when VM is suspend and resume. Solution from the maintainer of virtio is to merge following 3 commits:

http://git.qemu.org/?p=qemu.git;a=commit;h=bccdef6
http://git.qemu.org/?p=qemu.git;a=commit;h=58a83c6
http://git.qemu.org/?p=qemu.git;a=commit;h=4b7f91e

The first 2 commits have been merged in qemu 2.7.0. Then apply the third one.

(LOCAL REV: NOT UPSTREAM) -- Will send to oe-core on 20161026

---
 ...0001-virtio-zero-vq-inuse-in-virtio_reset.patch | 57 ++++++++++++++++++++++
 meta/recipes-devtools/qemu/qemu_2.7.0.bb           |  1 +
 2 files changed, 58 insertions(+)
 create mode 100644 meta/recipes-devtools/qemu/qemu/0001-virtio-zero-vq-inuse-in-virtio_reset.patch
meta/recipes-devtools/qemu/qemu/0001-virtio-zero-vq-inuse-in-virtio_reset.patch new file +57 -0
new file mode 100644
index 0000000..86955d0
@@ -0,0 +1,57 @@
+Upstream-Status: Backport
+
+Supplementary fix of CVE-2016-5403 which is backported from:
+
+http://git.qemu.org/?p=qemu.git;a=commit;h=4b7f91e
+
+Signed-off-by: Kai Kang <[email protected]>
+---
+From 4b7f91ed0270a371e1933efa21ba600b6da23ab9 Mon Sep 17 00:00:00 2001
+From: Stefan Hajnoczi <[email protected]>
+Date: Wed, 7 Sep 2016 11:51:25 -0400
+Subject: [PATCH] virtio: zero vq->inuse in virtio_reset()
+
+vq->inuse must be zeroed upon device reset like most other virtqueue
+fields.
+
+In theory, virtio_reset() just needs assert(vq->inuse == 0) since
+devices must clean up in-flight requests during reset (requests cannot
+not be leaked!).
+
+In practice, it is difficult to achieve vq->inuse == 0 across reset
+because balloon, blk, 9p, etc implement various different strategies for
+cleaning up requests.  Most devices call g_free(elem) directly without
+telling virtio.c that the VirtQueueElement is cleaned up.  Therefore
+vq->inuse is not decremented during reset.
+
+This patch zeroes vq->inuse and trusts that devices are not leaking
+VirtQueueElements across reset.
+
+I will send a follow-up series that refactors request life-cycle across
+all devices and converts vq->inuse = 0 into assert(vq->inuse == 0) but
+this more invasive approach is not appropriate for stable trees.
+
+Signed-off-by: Stefan Hajnoczi <[email protected]>
+Cc: qemu-stable <[email protected]>
+Reviewed-by: Michael S. Tsirkin <[email protected]>
+Signed-off-by: Michael S. Tsirkin <[email protected]>
+Reviewed-by: Ladi Prosek <[email protected]>
+---
+ hw/virtio/virtio.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
+index 74c085c..e8a13a5 100644
+--- a/hw/virtio/virtio.c
++++ b/hw/virtio/virtio.c
+@@ -822,6 +822,7 @@ void virtio_reset(void *opaque)
+         vdev->vq[i].signalled_used_valid = false;
+         vdev->vq[i].notification = true;
+         vdev->vq[i].vring.num = vdev->vq[i].vring.num_default;
++        vdev->vq[i].inuse = 0;
+     }
+ }
+ 
+-- 
+2.9.3
+
meta/recipes-devtools/qemu/qemu_2.7.0.bb +1 -0
index 619b8ed..90e4eec 100644
@@ -9,6 +9,7 @@ SRC_URI += "file://configure-fix-Darwin-target-detection.patch \
             file://no-valgrind.patch \
             file://pathlimit.patch \
             file://qemu-2.5.0-cflags.patch \
+            file://0001-virtio-zero-vq-inuse-in-virtio_reset.patch \
 "
 
 SRC_URI_prepend = "http://wiki.qemu-project.org/download/${BP}.tar.bz2"
Signature · 1 line
2.10.1
#2 lore raw

PATCH 2/2 qemu: fix CVE-2016-7423 and CVE-2016-7908

In reply to [email protected]

From: Kai Kang <[email protected]>

Issue: LIN9-1716
Issue: LIN9-1722

Backport patches to fix CVE-2016-7423 and CVE-2016-7908 of qemu.

(LOCAL REV: NOT UPSTREAM) -- Will send to oe-core on 20161026

---
 .../qemu/qemu/0002-fix-CVE-2016-7423.patch         | 45 ++++++++++++++++
 .../qemu/qemu/0003-fix-CVE-2016-7908.patch         | 62 ++++++++++++++++++++++
 meta/recipes-devtools/qemu/qemu_2.7.0.bb           |  2 +
 3 files changed, 109 insertions(+)
 create mode 100644 meta/recipes-devtools/qemu/qemu/0002-fix-CVE-2016-7423.patch
 create mode 100644 meta/recipes-devtools/qemu/qemu/0003-fix-CVE-2016-7908.patch
meta/recipes-devtools/qemu/qemu/0002-fix-CVE-2016-7423.patch new file +45 -0
new file mode 100644
index 0000000..fdf58a3
@@ -0,0 +1,45 @@
+Upstream-Status: Backport
+
+Backport patch to fix CVE-2016-7423 from:
+
+http://git.qemu.org/?p=qemu.git;a=commit;h=670e56d3ed
+
+CVE: CVE-2016-7423
+
+Signed-off-by: Kai Kang <[email protected]>
+---
+From 670e56d3ed2918b3861d9216f2c0540d9e9ae0d5 Mon Sep 17 00:00:00 2001
+From: Li Qiang <[email protected]>
+Date: Mon, 12 Sep 2016 18:14:11 +0530
+Subject: [PATCH] scsi: mptsas: use g_new0 to allocate MPTSASRequest object
+
+When processing IO request in mptsas, it uses g_new to allocate
+a 'req' object. If an error occurs before 'req->sreq' is
+allocated, It could lead to an OOB write in mptsas_free_request
+function. Use g_new0 to avoid it.
+
+Reported-by: Li Qiang <[email protected]>
+Signed-off-by: Prasad J Pandit <[email protected]>
+Message-Id: <[email protected]>
+Cc: [email protected]
+Signed-off-by: Paolo Bonzini <[email protected]>
+---
+ hw/scsi/mptsas.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
+index 0e0a22f..eaae1bb 100644
+--- a/hw/scsi/mptsas.c
++++ b/hw/scsi/mptsas.c
+@@ -304,7 +304,7 @@ static int mptsas_process_scsi_io_request(MPTSASState *s,
+         goto bad;
+     }
+ 
+-    req = g_new(MPTSASRequest, 1);
++    req = g_new0(MPTSASRequest, 1);
+     QTAILQ_INSERT_TAIL(&s->pending, req, next);
+     req->scsi_io = *scsi_io;
+     req->dev = s;
+-- 
+2.9.3
+
meta/recipes-devtools/qemu/qemu/0003-fix-CVE-2016-7908.patch new file +62 -0

62 lines not on this page · raw message

meta/recipes-devtools/qemu/qemu_2.7.0.bb +2 -0
index 90e4eec..a75bcdf 100644
@@ -10,6 +10,8 @@ SRC_URI += "file://configure-fix-Darwin-target-detection.patch \
             file://pathlimit.patch \
             file://qemu-2.5.0-cflags.patch \
             file://0001-virtio-zero-vq-inuse-in-virtio_reset.patch \
+            file://0002-fix-CVE-2016-7423.patch \
+            file://0003-fix-CVE-2016-7908.patch \
 "
 
 SRC_URI_prepend = "http://wiki.qemu-project.org/download/${BP}.tar.bz2"
Signature · 1 line
2.10.1