Blame SOURCES/kvm-usb-sanity-check-setup_index-setup_len-in-post_l2.patch

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