cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-virtio-avoid-buffer-overrun-on-incoming-migration.patch

9ae3a8
From 790375122726ecafec569bb31bbc68df7400f3b9 Mon Sep 17 00:00:00 2001
9ae3a8
From: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
Date: Wed, 14 May 2014 08:32:06 +0200
9ae3a8
Subject: [PATCH 13/31] virtio: avoid buffer overrun on incoming migration
9ae3a8
9ae3a8
RH-Author: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
Message-id: <1400056285-6688-10-git-send-email-mst@redhat.com>
9ae3a8
Patchwork-id: 58859
9ae3a8
O-Subject: [PATCH qemu-kvm RHEL7.1] virtio: avoid buffer overrun on incoming migration
9ae3a8
Bugzilla: 1095738
9ae3a8
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
9ae3a8
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
9ae3a8
RH-Acked-by: Amos Kong <akong@redhat.com>
9ae3a8
9ae3a8
CVE-2013-6399
9ae3a8
9ae3a8
vdev->queue_sel is read from the wire, and later used in the
9ae3a8
emulation code as an index into vdev->vq[]. If the value of
9ae3a8
vdev->queue_sel exceeds the length of vdev->vq[], currently
9ae3a8
allocated to be VIRTIO_PCI_QUEUE_MAX elements, subsequent PIO
9ae3a8
operations such as VIRTIO_PCI_QUEUE_PFN can be used to overrun
9ae3a8
the buffer with arbitrary data originating from the source.
9ae3a8
9ae3a8
Fix this by failing migration if the value from the wire exceeds
9ae3a8
VIRTIO_PCI_QUEUE_MAX.
9ae3a8
9ae3a8
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
9ae3a8
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9ae3a8
Signed-off-by: Juan Quintela <quintela@redhat.com>
9ae3a8
(cherry picked from commit 4b53c2c72cb5541cf394033b528a6fe2a86c0ac1)
9ae3a8
9ae3a8
Tested: lightly on developer's box
9ae3a8
Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7452039
9ae3a8
Bugzilla:1095738
9ae3a8
---
9ae3a8
 hw/virtio/virtio.c | 3 +++
9ae3a8
 1 file changed, 3 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/virtio/virtio.c |    3 +++
9ae3a8
 1 files changed, 3 insertions(+), 0 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
9ae3a8
index 070d64e..9600a12 100644
9ae3a8
--- a/hw/virtio/virtio.c
9ae3a8
+++ b/hw/virtio/virtio.c
9ae3a8
@@ -867,6 +867,9 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
9ae3a8
     qemu_get_8s(f, &vdev->status);
9ae3a8
     qemu_get_8s(f, &vdev->isr);
9ae3a8
     qemu_get_be16s(f, &vdev->queue_sel);
9ae3a8
+    if (vdev->queue_sel >= VIRTIO_PCI_QUEUE_MAX) {
9ae3a8
+        return -1;
9ae3a8
+    }
9ae3a8
     qemu_get_be32s(f, &features);
9ae3a8
 
9ae3a8
     if (virtio_set_features(vdev, features) < 0) {
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8