From: Michael S. Tsirkin Date: Tue, 13 May 2014 09:33:16 +0000 (+0300) Subject: usb: fix up post load checks X-Git-Tag: qemu-xen-4.5.1-rc1~9 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=bedbc31c141f712716ddc8933bd0a52abd0b1c8a;p=qemu-upstream-4.5-testing.git usb: fix up post load checks Correct post load checks: 1. dev->setup_len == sizeof(dev->data_buf) seems fine, no need to fail migration 2. When state is DATA, passing index > len will cause memcpy with negative length, resulting in heap overflow First of the issues was reported by dgilbert. Reported-by: "Dr. David Alan Gilbert" Signed-off-by: Michael S. Tsirkin Signed-off-by: Juan Quintela --- diff --git a/hw/usb/bus.c b/hw/usb/bus.c index e48b19fc2..ff1dfe6a6 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -51,8 +51,8 @@ static int usb_device_post_load(void *opaque, int version_id) } if (dev->setup_index < 0 || dev->setup_len < 0 || - dev->setup_index >= sizeof(dev->data_buf) || - dev->setup_len >= sizeof(dev->data_buf)) { + dev->setup_index > dev->setup_len || + dev->setup_len > sizeof(dev->data_buf)) { return -EINVAL; } return 0;