OpenCloudOS-Kernel/drivers/usb/core
Alan Stern f518498337 USB: core: Fix deadlock in port "disable" sysfs attribute
commit f4d1960764d8a70318b02f15203a1be2b2554ca1 upstream.

The show and store callback routines for the "disable" sysfs attribute
file in port.c acquire the device lock for the port's parent hub
device.  This can cause problems if another process has locked the hub
to remove it or change its configuration:

	Removing the hub or changing its configuration requires the
	hub interface to be removed, which requires the port device
	to be removed, and device_del() waits until all outstanding
	sysfs attribute callbacks for the ports have returned.  The
	lock can't be released until then.

	But the disable_show() or disable_store() routine can't return
	until after it has acquired the lock.

The resulting deadlock can be avoided by calling
sysfs_break_active_protection().  This will cause the sysfs core not
to wait for the attribute's callback routine to return, allowing the
removal to proceed.  The disadvantage is that after making this call,
there is no guarantee that the hub structure won't be deallocated at
any moment.  To prevent this, we have to acquire a reference to it
first by calling hub_get().

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@kernel.org>
Link: https://lore.kernel.org/r/f7a8c135-a495-4ce6-bd49-405a45e7ea9a@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-04-03 15:29:00 +02:00
..
Kconfig
Makefile usb: misc: Add onboard_usb_hub driver 2022-07-08 14:53:50 +02: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-12-03 07:33:09 +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 ctime accessor functions 2023-07-13 10:28:03 +02:00
driver.c USB: mark all struct bus_type as const 2023-03-23 13:22:00 +01:00
endpoint.c
file.c USB: make usb class a const structure 2023-07-25 17:49:30 +02:00
generic.c usb: core: Fix file path that does not exist 2021-12-05 14:24:19 +01:00
hcd-pci.c USB: Extend pci resume function to handle PM events 2023-05-13 17:33:18 +09:00
hcd.c USB: Remove remnants of Wireless USB and UWB 2023-08-09 14:17:06 +02:00
hub.c USB: core: Add hub_get() and hub_put() routines 2024-04-03 15:29:00 +02:00
hub.h USB: core: Add hub_get() and hub_put() routines 2024-04-03 15:29:00 +02:00
ledtrig-usbport.c usb: core: Use module_led_trigger macro to simplify the code 2023-08-22 14:44:23 +02:00
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 deadlock in port "disable" sysfs attribute 2024-04-03 15:29:00 +02:00
quirks.c USB: quirks: add quirk for Focusrite Scarlett 2023-07-25 17:41:22 +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: acpi: Switch to use acpi_evaluate_dsm_typed() 2023-03-16 12:15:10 +01:00
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