linux/drivers/usb/core
Alan Stern 80ba43e9f7 USB: core: Fix deadlock in usb_deauthorize_interface()
Among the attribute file callback routines in
drivers/usb/core/sysfs.c, the interface_authorized_store() function is
the only one which acquires a device lock on an ancestor device: It
calls usb_deauthorize_interface(), which locks the interface's parent
USB device.

The will lead to deadlock if another process already owns that lock
and tries to remove the interface, whether through a configuration
change or because the device has been disconnected.  As part of the
removal procedure, device_del() waits for all ongoing sysfs attribute
callbacks to complete.  But usb_deauthorize_interface() can't complete
until the device lock has been released, and the lock won't be
released until the removal has finished.

The mechanism provided by sysfs to prevent this kind of deadlock is
to use the sysfs_break_active_protection() function, which tells sysfs
not to wait for the attribute callback.

Reported-and-tested by: Yue Sun <samsun1006219@gmail.com>
Reported by: xingwei lee <xrivendell7@gmail.com>

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/linux-usb/CAEkJfYO6jRVC8Tfrd_R=cjO0hguhrV31fDPrLrNOOHocDkPoAA@mail.gmail.com/#r
Fixes: 310d2b4124 ("usb: interface authorization: SysFS part of USB interface authorization")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/1c37eea1-9f56-4534-b9d8-b443438dc869@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-03-26 11:02:47 +01:00
..
buffer.c - Yosry Ahmed brought back some cgroup v1 stats in OOM logs. 2023-06-28 10:28:11 -07:00
config.c usb: config: fix iteration issue in 'usb_get_bos_descriptor()' 2023-11-21 15:30:56 +01:00
devices.c USB: Remove remnants of Wireless USB and UWB 2023-08-09 14:17:06 +02:00
devio.c usb: convert to new timestamp accessors 2023-10-18 13:26:17 +02:00
driver.c usb: usb_autopm_get_interface use modern helper 2024-01-27 16:43:48 -08:00
endpoint.c usb: core: constify the struct device_type usage 2024-02-19 09:35:46 +01:00
file.c USB: make usb class a const structure 2023-07-25 17:49:30 +02:00
generic.c usb: core: Fix crash w/ usb_choose_configuration() if no driver 2023-12-15 13:54:09 +01:00
hcd-pci.c usb: pci-quirks: handle HAS_IOPORT dependency for AMD quirk 2023-10-02 16:19:12 +02:00
hcd.c USB/Thunderbolt changes for 6.9-rc1 2024-03-21 12:35:20 -07:00
hub.c Merge 6.8-rc3 into usb-next 2024-02-04 06:19:37 -08:00
hub.h usb: Inform the USB Type-C class about enumerated devices 2023-10-16 20:02:36 +02:00
Kconfig usb: core: Kconfig: Improve USB authorization mode help 2024-02-17 16:38:35 +01:00
ledtrig-usbport.c usb: core: Use module_led_trigger macro to simplify the code 2023-08-22 14:44:23 +02:00
Makefile usb: misc: Add onboard_usb_hub driver 2022-07-08 14:53:50 +02:00
message.c USB: document some API requirements on disconnection 2024-03-02 20:37:14 +01:00
notify.c USB: core: Remove usbfs_mutex 2019-06-26 10:28:09 +08:00
of.c usb: core: Set connect_type of ports based on DT node 2024-03-05 13:28:46 +00:00
otg_productlist.h USB: OTG: rename product list of devices 2020-06-19 08:58:55 +02:00
phy.c usb: core: add phy notify connect and disconnect 2024-01-27 17:36:14 -08:00
phy.h usb: core: add phy notify connect and disconnect 2024-01-27 17:36:14 -08:00
port.c USB/Thunderbolt changes for 6.9-rc1 2024-03-21 12:35:20 -07:00
quirks.c usb: new quirk to reduce the SET_ADDRESS request timeout 2023-11-23 12:32:44 +00:00
sysfs.c USB: core: Fix deadlock in usb_deauthorize_interface() 2024-03-26 11:02:47 +01:00
urb.c USB: Remove remnants of Wireless USB and UWB 2023-08-09 14:17:06 +02:00
usb-acpi.c usb: usb-acpi: Fix oops due to freeing uninitialized pld pointer 2024-03-19 13:07:35 +01:00
usb.c usb: core: constify the struct device_type usage 2024-02-19 09:35:46 +01:00
usb.h usb: core: constify the struct device_type usage 2024-02-19 09:35:46 +01:00