|
|
9ae3a8 |
From caaae46a54a676914cc3725b7fe892874825302d Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 14 May 2014 08:32:21 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 15/31] virtio: validate config_len on load
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1400056285-6688-17-git-send-email-mst@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 58861
|
|
|
9ae3a8 |
O-Subject: [PATCH qemu-kvm RHEL7.1] virtio: validate config_len on load
|
|
|
9ae3a8 |
Bugzilla: 1095783
|
|
|
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 |
Malformed input can have config_len in migration stream
|
|
|
9ae3a8 |
exceed the array size allocated on destination, the
|
|
|
9ae3a8 |
result will be heap overflow.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
To fix, that config_len matches on both sides.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
CVE-2014-0182
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit a890a2f9137ac3cf5b607649e66a6f3a5512d8dc)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Tested: lightly on developer's box
|
|
|
9ae3a8 |
Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7452039
|
|
|
9ae3a8 |
Bugzilla:1095783
|
|
|
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 9600a12..686dfbb 100644
|
|
|
9ae3a8 |
--- a/hw/virtio/virtio.c
|
|
|
9ae3a8 |
+++ b/hw/virtio/virtio.c
|
|
|
9ae3a8 |
@@ -852,6 +852,7 @@ int virtio_set_features(VirtIODevice *vdev, uint32_t val)
|
|
|
9ae3a8 |
int virtio_load(VirtIODevice *vdev, QEMUFile *f)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
int i, ret;
|
|
|
9ae3a8 |
+ int32_t config_len;
|
|
|
9ae3a8 |
uint32_t num;
|
|
|
9ae3a8 |
uint32_t features;
|
|
|
9ae3a8 |
uint32_t supported_features;
|
|
|
9ae3a8 |
@@ -878,7 +879,12 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
|
|
|
9ae3a8 |
features, supported_features);
|
|
|
9ae3a8 |
return -1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
- vdev->config_len = qemu_get_be32(f);
|
|
|
9ae3a8 |
+ config_len = qemu_get_be32(f);
|
|
|
9ae3a8 |
+ if (config_len != vdev->config_len) {
|
|
|
9ae3a8 |
+ error_report("Unexpected config length 0x%x. Expected 0x%zx",
|
|
|
9ae3a8 |
+ config_len, vdev->config_len);
|
|
|
9ae3a8 |
+ return -1;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
qemu_get_buffer(f, vdev->config, vdev->config_len);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
num = qemu_get_be32(f);
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|