linux/drivers/usb/core
Douglas Anderson 44995e6f07 usb: core: Fix crash w/ usb_choose_configuration() if no driver
It's possible that usb_choose_configuration() can get called when a
USB device has no driver. In this case the recent commit a87b8e3be9
("usb: core: Allow subclassed USB drivers to override
usb_choose_configuration()") can cause a crash since it dereferenced
the driver structure without checking for NULL. Let's add a check.

A USB device with no driver is an anomaly, so make
usb_choose_configuration() return immediately if there is no driver.

This was seen in the real world when usbguard got ahold of a r8152
device at the wrong time. It can also be simulated via this on a
computer with one r8152-based USB Ethernet adapter:
  cd /sys/bus/usb/drivers/r8152-cfgselector
  to_unbind="$(ls -d *-*)"
  real_dir="$(readlink -f "${to_unbind}")"
  echo "${to_unbind}" > unbind
  cd "${real_dir}"
  echo 0 > authorized
  echo 1 > authorized

Fixes: a87b8e3be9 ("usb: core: Allow subclassed USB drivers to override usb_choose_configuration()")
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20231211073237.v3.1.If27eb3bf7812f91ab83810f232292f032f4203e0@changeid
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-12-15 13:54:09 +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: core: Don't force USB generic_subclass drivers to define probe() 2023-12-04 22:28:19 +09: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 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: Remove remnants of Wireless USB and UWB 2023-08-09 14:17:06 +02:00
hub.c usb: hub: Add quirk to decrease IN-ep poll interval for Microchip USB491x hub 2023-12-06 12:37:07 +09:00
hub.h usb: Inform the USB Type-C class about enumerated devices 2023-10-16 20:02:36 +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 usb: misc: Add onboard_usb_hub driver 2022-07-08 14:53:50 +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: Remove duplicated check in usb_hub_create_port_device 2023-10-21 12:53:55 +02:00
quirks.c usb: new quirk to reduce the SET_ADDRESS request timeout 2023-11-23 12:32:44 +00:00
sysfs.c USB: Remove remnants of Wireless USB and UWB 2023-08-09 14:17:06 +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