|
|
9ae3a8 |
From 89ada787b7d4c950c8bf95932c8c420d90c31c3c Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 14 May 2014 08:33:08 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 16/31] virtio: validate num_sg when mapping
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1400056377-6802-1-git-send-email-mst@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 58862
|
|
|
9ae3a8 |
O-Subject: [PATCH qemu-kvm RHEL7.1 1/2] virtio: validate num_sg when mapping
|
|
|
9ae3a8 |
Bugzilla: 1095766
|
|
|
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-4535
|
|
|
9ae3a8 |
CVE-2013-4536
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Both virtio-block and virtio-serial read,
|
|
|
9ae3a8 |
VirtQueueElements are read in as buffers, and passed to
|
|
|
9ae3a8 |
virtqueue_map_sg(), where num_sg is taken from the wire and can force
|
|
|
9ae3a8 |
writes to indicies beyond VIRTQUEUE_MAX_SIZE.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
To fix, validate num_sg.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reported-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
|
|
9ae3a8 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Cc: Amit Shah <amit.shah@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 36cf2a37132c7f01fa9adb5f95f5312b27742fd4)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Tested: lightly on developer's box
|
|
|
9ae3a8 |
Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7452039
|
|
|
9ae3a8 |
Bugzilla:1095766
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/virtio/virtio.c | 6 ++++++
|
|
|
9ae3a8 |
1 file changed, 6 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/virtio/virtio.c | 6 ++++++
|
|
|
9ae3a8 |
1 files changed, 6 insertions(+), 0 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
|
|
|
9ae3a8 |
index 686dfbb..2667390 100644
|
|
|
9ae3a8 |
--- a/hw/virtio/virtio.c
|
|
|
9ae3a8 |
+++ b/hw/virtio/virtio.c
|
|
|
9ae3a8 |
@@ -423,6 +423,12 @@ void virtqueue_map_sg(struct iovec *sg, hwaddr *addr,
|
|
|
9ae3a8 |
unsigned int i;
|
|
|
9ae3a8 |
hwaddr len;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ if (num_sg >= VIRTQUEUE_MAX_SIZE) {
|
|
|
9ae3a8 |
+ error_report("virtio: map attempt out of bounds: %zd > %d",
|
|
|
9ae3a8 |
+ num_sg, VIRTQUEUE_MAX_SIZE);
|
|
|
9ae3a8 |
+ exit(1);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
for (i = 0; i < num_sg; i++) {
|
|
|
9ae3a8 |
len = sg[i].iov_len;
|
|
|
9ae3a8 |
sg[i].iov_base = cpu_physical_memory_map(addr[i], &len, is_write);
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|