9ae3a8
From 66f0fbb6a54ab1110afd12eb9a25d8966b60c7fa Mon Sep 17 00:00:00 2001
9ae3a8
From: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
Date: Wed, 14 May 2014 08:36:01 +0200
9ae3a8
Subject: [PATCH 19/31] usb: sanity check setup_index+setup_len in post_load
9ae3a8
9ae3a8
RH-Author: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
Message-id: <1400056525-6869-2-git-send-email-mst@redhat.com>
9ae3a8
Patchwork-id: 58865
9ae3a8
O-Subject: [PATCH qemu-kvm RHEL7.1 2/2] usb: sanity check setup_index+setup_len in post_load
9ae3a8
Bugzilla: 1095747
9ae3a8
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
9ae3a8
CVE-2013-4541
9ae3a8
9ae3a8
s->setup_len and s->setup_index are fed into usb_packet_copy as
9ae3a8
size/offset into s->data_buf, it's possible for invalid state to exploit
9ae3a8
this to load arbitrary data.
9ae3a8
9ae3a8
setup_len and setup_index should be checked to make sure
9ae3a8
they are not negative.
9ae3a8
9ae3a8
Cc: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Signed-off-by: Juan Quintela <quintela@redhat.com>
9ae3a8
(cherry picked from commit 9f8e9895c504149d7048e9fc5eb5cbb34b16e49a)
9ae3a8
9ae3a8
Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7452039
9ae3a8
Tested: lightly on developer's box
9ae3a8
Bugzilla: 1095743
9ae3a8
9ae3a8
Note: the fix isn't complete upstream. there's a separate bugzilla to
9ae3a8
fix more issues upstream and in rhel.
9ae3a8
---
9ae3a8
 hw/usb/bus.c | 4 +++-
9ae3a8
 1 file changed, 3 insertions(+), 1 deletion(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/usb/bus.c |    4 +++-
9ae3a8
 1 files changed, 3 insertions(+), 1 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
9ae3a8
index e0c3a77..9766b7f 100644
9ae3a8
--- a/hw/usb/bus.c
9ae3a8
+++ b/hw/usb/bus.c
9ae3a8
@@ -49,7 +49,9 @@ static int usb_device_post_load(void *opaque, int version_id)
9ae3a8
     } else {
9ae3a8
         dev->attached = 1;
9ae3a8
     }
9ae3a8
-    if (dev->setup_index >= sizeof(dev->data_buf) ||
9ae3a8
+    if (dev->setup_index < 0 ||
9ae3a8
+        dev->setup_len < 0 ||
9ae3a8
+        dev->setup_index >= sizeof(dev->data_buf) ||
9ae3a8
         dev->setup_len >= sizeof(dev->data_buf)) {
9ae3a8
         return -EINVAL;
9ae3a8
     }
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8