]> xenbits.xensource.com Git - qemu-xen-4.6-testing.git/commit
usb-linux.c: fix buffer overflow
authorJim Paris <jim@jtan.com>
Wed, 22 Apr 2015 11:29:21 +0000 (12:29 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 16 Oct 2015 15:52:06 +0000 (16:52 +0100)
commit3c1e883f6c41b15690f6f466aeaa87362723bcb4
treea0e82ff05cb05fe69d1ae360c3d3bb0e9574b481
parentaf9e620745434868b0aeebc00c6ca1cadd9a01c9
usb-linux.c: fix buffer overflow

In usb-linux.c:usb_host_handle_control, we pass a 1024-byte buffer and
length to the kernel.  However, the length was provided by the caller
of dev->handle_packet, and is not checked, so the kernel might provide
too much data and overflow our buffer.

For example, hw/usb-uhci.c could set the length to 2047.
hw/usb-ohci.c looks like it might go up to 4096 or 8192.

This causes a qemu crash, as reported here:
  http://www.mail-archive.com/kvm@vger.kernel.org/msg18447.html

This patch increases the usb-linux.c buffer size to 2048 to fix the
specific device reported, and adds a check to avoid the overflow in
any case.

Signed-off-by: Jim Paris <jim@jtan.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
usb-linux.c