linux-stable/drivers/usb/core
Alan Stern ab062fa3dc USB: core: Fix deadlock in usb_deauthorize_interface()
commit 80ba43e9f7 upstream.

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-04-03 15:19:55 +02:00
..
buffer.c
config.c usb: config: fix iteration issue in 'usb_get_bos_descriptor()' 2023-12-08 08:51:17 +01:00
devices.c
devio.c
driver.c
endpoint.c
file.c
generic.c
hcd-pci.c
hcd.c
hub.c USB: core: Add hub_get() and hub_put() routines 2024-04-03 15:19:51 +02:00
hub.h USB: core: Add hub_get() and hub_put() routines 2024-04-03 15:19:51 +02:00
Kconfig
ledtrig-usbport.c
Makefile
message.c
notify.c
of.c
otg_productlist.h
phy.c
phy.h
port.c USB: core: Fix deadlock in port "disable" sysfs attribute 2024-04-03 15:19:51 +02:00
quirks.c
sysfs.c USB: core: Fix deadlock in usb_deauthorize_interface() 2024-04-03 15:19:55 +02:00
urb.c
usb-acpi.c
usb.c
usb.h