|
|
9ae3a8 |
From 9dfb93fc21a678858e95e604339d95829f405724 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 14 May 2014 08:31:53 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 12/31] virtio: out-of-bounds buffer write on invalid state load
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1400056285-6688-4-git-send-email-mst@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 58858
|
|
|
9ae3a8 |
O-Subject: [PATCH qemu-kvm RHEL7.1] virtio: out-of-bounds buffer write on invalid state load
|
|
|
9ae3a8 |
Bugzilla: 1095695
|
|
|
9ae3a8 |
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Juan Quintela <quintela@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
CVE-2013-4151 QEMU 1.0 out-of-bounds buffer write in
|
|
|
9ae3a8 |
virtio_load@hw/virtio/virtio.c
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
So we have this code since way back when:
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
num = qemu_get_be32(f);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
for (i = 0; i < num; i++) {
|
|
|
9ae3a8 |
vdev->vq[i].vring.num = qemu_get_be32(f);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
array of vqs has size VIRTIO_PCI_QUEUE_MAX, so
|
|
|
9ae3a8 |
on invalid input this will write beyond end of buffer.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
|
|
9ae3a8 |
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit cc45995294b92d95319b4782750a3580cabdbc0c)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Tested: lightly on developer's box
|
|
|
9ae3a8 |
Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7452039
|
|
|
9ae3a8 |
Bugzilla: 1095695
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/virtio/virtio.c | 8 +++++++-
|
|
|
9ae3a8 |
1 file changed, 7 insertions(+), 1 deletion(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/virtio/virtio.c | 8 +++++++-
|
|
|
9ae3a8 |
1 files changed, 7 insertions(+), 1 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
|
|
|
9ae3a8 |
index b5bb0b6..070d64e 100644
|
|
|
9ae3a8 |
--- a/hw/virtio/virtio.c
|
|
|
9ae3a8 |
+++ b/hw/virtio/virtio.c
|
|
|
9ae3a8 |
@@ -851,7 +851,8 @@ int virtio_set_features(VirtIODevice *vdev, uint32_t val)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
int virtio_load(VirtIODevice *vdev, QEMUFile *f)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- int num, i, ret;
|
|
|
9ae3a8 |
+ int i, ret;
|
|
|
9ae3a8 |
+ uint32_t num;
|
|
|
9ae3a8 |
uint32_t features;
|
|
|
9ae3a8 |
uint32_t supported_features;
|
|
|
9ae3a8 |
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
|
|
|
9ae3a8 |
@@ -879,6 +880,11 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
num = qemu_get_be32(f);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ if (num > VIRTIO_PCI_QUEUE_MAX) {
|
|
|
9ae3a8 |
+ error_report("Invalid number of PCI queues: 0x%x", num);
|
|
|
9ae3a8 |
+ return -1;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
for (i = 0; i < num; i++) {
|
|
|
9ae3a8 |
vdev->vq[i].vring.num = qemu_get_be32(f);
|
|
|
9ae3a8 |
vdev->vq[i].pa = qemu_get_be64(f);
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|