Blob Blame Raw
From 586e92b335a98dcfbb4a797eb744753038da4374 Mon Sep 17 00:00:00 2001
From: Michael S. Tsirkin <mst@redhat.com>
Date: Wed, 14 May 2014 08:26:14 +0200
Subject: [PATCH 14/30] usb: sanity check setup_index+setup_len in post_load

RH-Author: Michael S. Tsirkin <mst@redhat.com>
Message-id: <1400055942-6418-1-git-send-email-mst@redhat.com>
Patchwork-id: 58853
O-Subject: [PATCH qemu-kvm RHEL7.0.z 1/2] usb: sanity check setup_index+setup_len in post_load
Bugzilla: 1095746
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>

From: Gerd Hoffmann <kraxel@redhat.com>

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit c60174e847082ab9f70720f86509a3353f816fad)

Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7450401
Tested: lightly on developer's box
Bugzilla: 1095743
---
 hw/usb/bus.c | 4 ++++
 1 file changed, 4 insertions(+)

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 hw/usb/bus.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index fe6bd13..e0c3a77 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -49,6 +49,10 @@ static int usb_device_post_load(void *opaque, int version_id)
     } else {
         dev->attached = 1;
     }
+    if (dev->setup_index >= sizeof(dev->data_buf) ||
+        dev->setup_len >= sizeof(dev->data_buf)) {
+        return -EINVAL;
+    }
     return 0;
 }
 
-- 
1.7.1