rockbox/firmware/usbstack
Aidan MacDonald 24294bda15 usb: ensure RX buffers are a multiple of the packet size
When performing an OUT transfer which is not a multiple of the
max packet size, the last packet of the OUT transfer should be
a short packet. However, there's no guarantee the host sends
the expected amount of data in the final packet.

The DWC2 USB controller handles this case by accepting any size
packet and copying it out to memory. So if the packet is bigger
than expected, it'll overrun the caller's buffer and Bad Things
will happen.

The USB 2.0 spec seems to endorse this behavior. Section 8.5.1
says "an ACK handshake indicates the endpoint has space for a
wMaxPacketSize data payload." So it is possible that other USB
controllers share the DWC2's behavior.

The simplest solution is to force all USB RX buffers to be big
enough to hold the transfer size, rounded up to a multiple of
the max packet size. For example, a transfer of 700 bytes would
require a 1024-byte buffer if the MPS = 512 bytes.

Change-Id: Ibb84d2b2d53aec8800a3a7c2449f7a17480acbcf
2021-10-16 21:14:42 +01:00
..
usb_charging_only.c usb PACK_DATA: use a static inline to enable type checking 2011-12-29 21:58:34 +00:00
usb_charging_only.h USB retweaking: Take out the USB_REQUEST/RELEASE_DISK scheme and simply ask the USB core whether or not any drivers require exclusive access at the moment of connect. Doing anthing else just produces nasty effects on Windows because it expects some communication just for enabling the PHY and not allowing it to mount volumes if a thread doesn't ack causes annoying error message boxes. Make behavior of each USB type identical from the system perspective. Some miscellaneous changes (simplify, ata->storage naming, define only used USB_* enums values were possible). 2009-01-13 16:27:35 +00:00
usb_class_driver.h usb: add request data argument to all control request handlers 2021-10-16 21:14:42 +01:00
usb_core.c usb: port usb_core control request handling to new API 2021-10-16 21:14:42 +01:00
usb_hid.c usb: ensure RX buffers are a multiple of the packet size 2021-10-16 21:14:42 +01:00
usb_hid.h usb: add request data argument to all control request handlers 2021-10-16 21:14:42 +01:00
usb_hid_usage_tables.h usb_hid: add support for Battery Strength 2021-03-06 04:15:02 +00:00
usb_serial.c usb: ensure RX buffers are a multiple of the packet size 2021-10-16 21:14:42 +01:00
usb_serial.h usb: add request data argument to all control request handlers 2021-10-16 21:14:42 +01:00
usb_storage.c usb: ensure RX buffers are a multiple of the packet size 2021-10-16 21:14:42 +01:00
usb_storage.h usb: add request data argument to all control request handlers 2021-10-16 21:14:42 +01:00