1
0
Fork 0
alistair23-linux/drivers/usb/gadget
Chris Dickens 5d6ae4f0da usb: gadget: composite: fix incorrect handling of OS desc requests
When handling an OS descriptor request, one of the first operations is
to zero out the request buffer using the wLength from the setup packet.
There is no bounds checking, so a wLength > 4096 would clobber memory
adjacent to the request buffer. Fix this by taking the min of wLength
and the request buffer length prior to the memset. While at it, define
the buffer length in a header file so that magic numbers don't appear
throughout the code.

When returning data to the host, the data length should be the min of
the wLength and the valid data we have to return. Currently we are
returning wLength, thus requests for a wLength greater than the amount
of data in the OS descriptor buffer would return invalid (albeit zero'd)
data following the valid descriptor data. Fix this by counting the
number of bytes when constructing the data and using this when
determining the length of the request.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-03-08 15:12:01 +02:00
..
function USB: gadget: function: remove redundant initialization of 'tv_nexus' 2018-03-08 15:12:01 +02:00
legacy vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
udc usb: gadget: udc: atmel: Use devm_ioremap_resource() 2018-03-08 15:12:01 +02:00
Kconfig Revert "usb: gadget: allow to enable legacy drivers without USB_ETH" 2017-12-12 12:48:30 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
composite.c usb: gadget: composite: fix incorrect handling of OS desc requests 2018-03-08 15:12:01 +02:00
config.c USB: gadget: Remove redundant license text 2017-11-07 15:45:02 +01:00
configfs.c A couple of configfs cleanups: 2017-11-14 14:44:04 -08:00
configfs.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
epautoconf.c USB: gadget: Remove redundant license text 2017-11-07 15:45:02 +01:00
functions.c USB: add SPDX identifiers to all remaining files in drivers/usb/ 2017-11-04 11:48:02 +01:00
u_f.c USB: gadget: Remove redundant license text 2017-11-07 15:45:02 +01:00
u_f.h USB: gadget: Remove redundant license text 2017-11-07 15:45:02 +01:00
u_os_desc.h USB: gadget: Remove redundant license text 2017-11-07 15:45:02 +01:00
usbstring.c USB: gadget: Remove redundant license text 2017-11-07 15:45:02 +01:00