]> xenbits.xensource.com Git - qemu-upstream-4.4-testing.git/commitdiff
usb: sanity check setup_index+setup_len in post_load
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 3 Apr 2014 16:52:25 +0000 (19:52 +0300)
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>
Thu, 5 Mar 2015 13:21:37 +0000 (13:21 +0000)
CVE-2013-4541

s->setup_len and s->setup_index are fed into usb_packet_copy as
size/offset into s->data_buf, it's possible for invalid state to exploit
this to load arbitrary data.

setup_len and setup_index should be checked to make sure
they are not negative.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
hw/usb/bus.c

index f83d1de6cd49c7636b5e4cf9a20e84e26c903314..c6c200593b54f87e4277fa7da3cf4755ea2badbb 100644 (file)
@@ -47,6 +47,12 @@ static int usb_device_post_load(void *opaque, int version_id)
     } else {
         dev->attached = 1;
     }
+    if (dev->setup_index < 0 ||
+        dev->setup_len < 0 ||
+        dev->setup_index >= sizeof(dev->data_buf) ||
+        dev->setup_len >= sizeof(dev->data_buf)) {
+        return -EINVAL;
+    }
     return 0;
 }