linux/drivers/usb/core
Alan Stern 647d61aef1 USB: core: Fix duplicate endpoint bug by clearing reserved bits in the descriptor
commit a368ecde8a upstream.

Syzbot has identified a bug in usbcore (see the Closes: tag below)
caused by our assumption that the reserved bits in an endpoint
descriptor's bEndpointAddress field will always be 0.  As a result of
the bug, the endpoint_is_duplicate() routine in config.c (and possibly
other routines as well) may believe that two descriptors are for
distinct endpoints, even though they have the same direction and
endpoint number.  This can lead to confusion, including the bug
identified by syzbot (two descriptors with matching endpoint numbers
and directions, where one was interrupt and the other was bulk).

To fix the bug, we will clear the reserved bits in bEndpointAddress
when we parse the descriptor.  (Note that both the USB-2.0 and USB-3.1
specs say these bits are "Reserved, reset to zero".)  This requires us
to make a copy of the descriptor earlier in usb_parse_endpoint() and
use the copy instead of the original when checking for duplicates.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-and-tested-by: syzbot+8693a0bb9c10b554272a@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-usb/0000000000003d868e061bc0f554@google.com/
Fixes: 0a8fd13462 ("USB: fix problems with duplicate endpoint addresses")
CC: Oliver Neukum <oneukum@suse.com>
CC: stable@vger.kernel.org
Link: https://lore.kernel.org/r/205a5edc-7fef-4159-b64a-80374b6b101a@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-07-18 13:21:19 +02:00
..
buffer.c
config.c USB: core: Fix duplicate endpoint bug by clearing reserved bits in the descriptor 2024-07-18 13:21:19 +02:00
devices.c USB: Remove remnants of Wireless USB and UWB 2023-08-09 14:17:06 +02:00
devio.c usb: convert to ctime accessor functions 2023-07-13 10:28:03 +02:00
driver.c
endpoint.c
file.c USB: make usb class a const structure 2023-07-25 17:49:30 +02:00
generic.c
hcd-pci.c
hcd.c USB: Remove remnants of Wireless USB and UWB 2023-08-09 14:17:06 +02:00
hub.c usb: Fix regression caused by invalid ep0 maxpacket in virtual SuperSpeed device 2024-05-17 12:02:28 +02:00
hub.h USB: core: Add hub_get() and hub_put() routines 2024-04-03 15:29:00 +02:00
Kconfig
ledtrig-usbport.c usb: core: Use module_led_trigger macro to simplify the code 2023-08-22 14:44:23 +02:00
Makefile
message.c USB: core: Change usb_get_device_descriptor() API 2023-08-08 10:45:32 +02:00
notify.c
of.c usb: Explicitly include correct DT includes 2023-07-25 18:20:02 +02:00
otg_productlist.h
phy.c
phy.h
port.c USB: core: Fix access violation during port device removal 2024-05-17 12:02:28 +02:00
quirks.c USB: Add USB_QUIRK_NO_SET_INTF quirk for START BP-850k 2024-07-18 13:21:19 +02:00
sysfs.c USB: core: Fix deadlock in usb_deauthorize_interface() 2024-04-03 15:28:59 +02:00
urb.c USB: Remove remnants of Wireless USB and UWB 2023-08-09 14:17:06 +02:00
usb-acpi.c
usb.c USB: core: Fix unused variable warning in usb_alloc_dev() 2023-08-12 10:03:37 +02:00
usb.h USB: core: Change usb_get_device_descriptor() API 2023-08-08 10:45:32 +02:00