cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
eb5a2f
From 3a5fadc2341be9efd129aed5cd04ebdba2cdc36d Mon Sep 17 00:00:00 2001
eb5a2f
From: Michael S. Tsirkin <mst@redhat.com>
eb5a2f
Date: Wed, 14 May 2014 08:07:58 +0200
eb5a2f
Subject: [PATCH 07/30] virtio: validate config_len on load
eb5a2f
eb5a2f
RH-Author: Michael S. Tsirkin <mst@redhat.com>
eb5a2f
Message-id: <1400054498-4366-17-git-send-email-mst@redhat.com>
eb5a2f
Patchwork-id: 58845
eb5a2f
O-Subject: [PATCH qemu-kvm RHEL7.0] virtio: validate config_len on load
eb5a2f
Bugzilla: 1095782
eb5a2f
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
eb5a2f
RH-Acked-by: Juan Quintela <quintela@redhat.com>
eb5a2f
RH-Acked-by: Vlad Yasevich <vyasevic@redhat.com>
eb5a2f
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
eb5a2f
eb5a2f
Malformed input can have config_len in migration stream
eb5a2f
exceed the array size allocated on destination, the
eb5a2f
result will be heap overflow.
eb5a2f
eb5a2f
To fix, that config_len matches on both sides.
eb5a2f
eb5a2f
CVE-2014-0182
eb5a2f
eb5a2f
Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
eb5a2f
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
eb5a2f
Signed-off-by: Juan Quintela <quintela@redhat.com>
eb5a2f
(cherry picked from commit a890a2f9137ac3cf5b607649e66a6f3a5512d8dc)
eb5a2f
eb5a2f
Tested: lightly on developer's box
eb5a2f
Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7450401
eb5a2f
Bugzilla:1095782
eb5a2f
---
eb5a2f
 hw/virtio/virtio.c | 8 +++++++-
eb5a2f
 1 file changed, 7 insertions(+), 1 deletion(-)
eb5a2f
eb5a2f
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
eb5a2f
---
eb5a2f
 hw/virtio/virtio.c |    8 +++++++-
eb5a2f
 1 files changed, 7 insertions(+), 1 deletions(-)
eb5a2f
eb5a2f
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
eb5a2f
index 9600a12..686dfbb 100644
eb5a2f
--- a/hw/virtio/virtio.c
eb5a2f
+++ b/hw/virtio/virtio.c
eb5a2f
@@ -852,6 +852,7 @@ int virtio_set_features(VirtIODevice *vdev, uint32_t val)
eb5a2f
 int virtio_load(VirtIODevice *vdev, QEMUFile *f)
eb5a2f
 {
eb5a2f
     int i, ret;
eb5a2f
+    int32_t config_len;
eb5a2f
     uint32_t num;
eb5a2f
     uint32_t features;
eb5a2f
     uint32_t supported_features;
eb5a2f
@@ -878,7 +879,12 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
eb5a2f
                      features, supported_features);
eb5a2f
         return -1;
eb5a2f
     }
eb5a2f
-    vdev->config_len = qemu_get_be32(f);
eb5a2f
+    config_len = qemu_get_be32(f);
eb5a2f
+    if (config_len != vdev->config_len) {
eb5a2f
+        error_report("Unexpected config length 0x%x. Expected 0x%zx",
eb5a2f
+                     config_len, vdev->config_len);
eb5a2f
+        return -1;
eb5a2f
+    }
eb5a2f
     qemu_get_buffer(f, vdev->config, vdev->config_len);
eb5a2f
 
eb5a2f
     num = qemu_get_be32(f);
eb5a2f
-- 
eb5a2f
1.7.1
eb5a2f