linux/drivers/usb/core
Alan Stern 2bd8534a1b 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>
History 2024-07-18 13:07:41 +02:00
..
buffer.c usb: usbfs: Enforce page requirements for mmap 2023-06-14 11:13:07 +02:00
config.c USB: core: Fix duplicate endpoint bug by clearing reserved bits in the descriptor 2024-07-18 13:07:41 +02:00
devices.c usb: common: add function to get interval expressed in us unit 2021-03-10 09:37:17 +01:00
devio.c usb: hide unused usbfs_notify_suspend/resume functions 2023-07-23 13:47:23 +02:00
driver.c USB: core: rename usb_driver_claim_interface() data parameter 2021-03-23 12:39:39 +01:00
endpoint.c usb: common: add function to get interval expressed in us unit 2021-03-10 09:37:17 +01:00
file.c USB: core: Fix races in character device registration and deregistraion 2019-08-12 22:47:24 +02:00
generic.c usbcore: Check both id_table and match() when both available 2020-10-28 13:24:58 +01:00
hcd-pci.c USB: hcd-pci: Fully suspend across freeze/thaw cycle 2022-06-14 18:36:21 +02:00
hcd.c USB: core: Change usb_get_device_descriptor() API 2023-09-19 12:22:53 +02:00
hub.c usb: Fix regression caused by invalid ep0 maxpacket in virtual SuperSpeed device 2024-05-17 11:51:02 +02:00
hub.h USB: core: Add hub_get() and hub_put() routines 2024-04-10 16:19:32 +02:00
Kconfig USB: hub: Add Kconfig option to reduce number of port initialization retries 2020-10-02 11:29:02 +02:00
ledtrig-usbport.c usb: core: ledtrig-usbport: Demote obvious misuse of kerneldoc to standard comment blocks 2020-07-09 16:46:57 +02:00
Makefile usb: core: add a wrapper for the USB PHYs on the HCD 2018-03-09 09:43:53 -08:00
message.c USB: core: Change usb_get_device_descriptor() API 2023-09-19 12:22:53 +02:00
notify.c USB: core: Remove usbfs_mutex 2019-06-26 10:28:09 +08:00
of.c drivers: usb: Fix trivial spelling 2020-06-18 10:13:16 +02:00
otg_productlist.h USB: OTG: rename product list of devices 2020-06-19 08:58:55 +02:00
phy.c usb: core: phy: add support for PHY calibration 2019-09-03 15:54:55 +02:00
phy.h usb: core: phy: add support for PHY calibration 2019-09-03 15:54:55 +02:00
port.c usb: Disable USB3 LPM at shutdown 2024-04-27 17:05:27 +02:00
quirks.c USB: Add USB_QUIRK_NO_SET_INTF quirk for START BP-850k 2024-07-18 13:07:41 +02:00
sysfs.c USB: core: Fix deadlock in usb_deauthorize_interface() 2024-04-10 16:19:34 +02:00
urb.c USB: core: Fix hang in usb_kill_urb by adding memory barriers 2022-02-01 17:27:04 +01:00
usb-acpi.c usb: acpi: add helper to check port lpm capability using acpi _DSM 2023-01-24 07:22:44 +01:00
usb.c USB: core: Add routines for endpoint checks in old drivers 2023-05-30 13:55:31 +01:00
usb.h USB: core: Change usb_get_device_descriptor() API 2023-09-19 12:22:53 +02:00