linux/drivers/usb/core
Alan Stern 63533549ff USB: core: Fix access violation during port device removal
commit a4b46d450c upstream.

Testing with KASAN and syzkaller revealed a bug in port.c:disable_store():
usb_hub_to_struct_hub() can return NULL if the hub that the port belongs to
is concurrently removed, but the function does not check for this
possibility before dereferencing the returned value.

It turns out that the first dereference is unnecessary, since hub->intfdev
is the parent of the port device, so it can be changed easily.  Adding a
check for hub == NULL prevents further problems.

The same bug exists in the disable_show() routine, and it can be fixed the
same way.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-and-tested-by: Yue Sun <samsun1006219@gmail.com>
Reported-by: xingwei lee <xrivendell7@gmail.com>
Link: https://lore.kernel.org/linux-usb/CAEkJfYON+ry7xPx=AiLR9jzUNT+i_Va68ACajOC3HoacOfL1ig@mail.gmail.com/
Fixes: f061f43d74 ("usb: hub: port: add sysfs entry to switch port power")
CC: Michael Grzeschik <m.grzeschik@pengutronix.de>
CC: stable@vger.kernel.org
Link: https://lore.kernel.org/r/393aa580-15a5-44ca-ad3b-6462461cd313@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-05-17 12:02:28 +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
endpoint.c
file.c USB: make usb class a const structure 2023-07-25 17:49:30 +02:00
generic.c
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: 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: new quirk to reduce the SET_ADDRESS request timeout 2024-04-27 17:11:36 +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