From: Michael S. Tsirkin Date: Thu, 3 Apr 2014 16:52:25 +0000 (+0300) Subject: usb: sanity check setup_index+setup_len in post_load X-Git-Tag: qemu-xen-4.5.0-rc1^2~97 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=15c35dfd9299733e5391b65efd3e0356a01d01ad;p=qemu-upstream-4.5-testing.git usb: sanity check setup_index+setup_len in post_load 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 Signed-off-by: Michael S. Tsirkin Reviewed-by: Gerd Hoffmann Signed-off-by: Juan Quintela (cherry picked from commit 9f8e9895c504149d7048e9fc5eb5cbb34b16e49a) Signed-off-by: Michael Roth --- diff --git a/hw/usb/bus.c b/hw/usb/bus.c index fe7042930..e48b19fc2 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -49,7 +49,9 @@ static int usb_device_post_load(void *opaque, int version_id) } else { dev->attached = 1; } - if (dev->setup_index >= sizeof(dev->data_buf) || + 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; }