linux/drivers/usb/host
Mathias Nyman af8e119f52 xhci: Fix Panther point NULL pointer deref at full-speed re-enumeration
re-enumerating full-speed devices after a failed address device command
can trigger a NULL pointer dereference.

Full-speed devices may need to reconfigure the endpoint 0 Max Packet Size
value during enumeration. Usb core calls usb_ep0_reinit() in this case,
which ends up calling xhci_configure_endpoint().

On Panther point xHC the xhci_configure_endpoint() function will
additionally check and reserve bandwidth in software. Other hosts do
this in hardware

If xHC address device command fails then a new xhci_virt_device structure
is allocated as part of re-enabling the slot, but the bandwidth table
pointers are not set up properly here.
This triggers the NULL pointer dereference the next time usb_ep0_reinit()
is called and xhci_configure_endpoint() tries to check and reserve
bandwidth

[46710.713538] usb 3-1: new full-speed USB device number 5 using xhci_hcd
[46710.713699] usb 3-1: Device not responding to setup address.
[46710.917684] usb 3-1: Device not responding to setup address.
[46711.125536] usb 3-1: device not accepting address 5, error -71
[46711.125594] BUG: kernel NULL pointer dereference, address: 0000000000000008
[46711.125600] #PF: supervisor read access in kernel mode
[46711.125603] #PF: error_code(0x0000) - not-present page
[46711.125606] PGD 0 P4D 0
[46711.125610] Oops: Oops: 0000 [#1] PREEMPT SMP PTI
[46711.125615] CPU: 1 PID: 25760 Comm: kworker/1:2 Not tainted 6.10.3_2 #1
[46711.125620] Hardware name: Gigabyte Technology Co., Ltd.
[46711.125623] Workqueue: usb_hub_wq hub_event [usbcore]
[46711.125668] RIP: 0010:xhci_reserve_bandwidth (drivers/usb/host/xhci.c

Fix this by making sure bandwidth table pointers are set up correctly
after a failed address device command, and additionally by avoiding
checking for bandwidth in cases like this where no actual endpoints are
added or removed, i.e. only context for default control endpoint 0 is
evaluated.

Reported-by: Karel Balej <balejk@matfyz.cz>
Closes: https://lore.kernel.org/linux-usb/D3CKQQAETH47.1MUO22RTCH2O3@matfyz.cz/
Cc: stable@vger.kernel.org
Fixes: 651aaf36a7 ("usb: xhci: Handle USB transaction error on address command")
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20240815141117.2702314-2-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-08-15 16:29:46 +02:00
..
bcma-hcd.c USB: bcma: Make GPIO explicitly optional 2022-11-08 16:39:56 +01:00
ehci-atmel.c usb: host: Do not check for 0 return after calling platform_get_irq() 2023-08-04 14:46:53 +02:00
ehci-brcm.c usb: host: Do not check for 0 return after calling platform_get_irq() 2023-08-04 14:46:53 +02:00
ehci-dbg.c USB: Use EHCI control transfer pid macros instead of constant values. 2024-03-26 10:43:35 +01:00
ehci-exynos.c usb: ehci-exynos: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions 2024-04-18 16:48:23 +02:00
ehci-fsl.c usb: ehci-fsl: Use devm_platform_get_and_ioremap_resource() 2023-07-27 10:24:10 +02:00
ehci-fsl.h
ehci-grlib.c usb: ehci-grlib: Convert to platform remove callback returning void 2023-05-28 12:36:28 +01:00
ehci-hcd.c usb: ehci: add workaround for chipidea PORTSC.PEC bug 2023-08-09 14:16:06 +02:00
ehci-hub.c usb: ehci: add workaround for chipidea PORTSC.PEC bug 2023-08-09 14:16:06 +02:00
ehci-mem.c
ehci-mv.c usb: ehci-mv: Use devm_platform_get_and_ioremap_resource() 2023-07-27 10:24:11 +02:00
ehci-npcm7xx.c usb: ehci-npcm7xx: Use devm_platform_get_and_ioremap_resource() 2023-07-27 10:24:10 +02:00
ehci-omap.c usb: ehci-omap: Use devm_platform_get_and_ioremap_resource() 2023-07-27 10:24:10 +02:00
ehci-orion.c usb: host: Add ac5 to EHCI Orion 2024-01-27 16:53:51 -08:00
ehci-pci.c USB: Extend pci resume function to handle PM events 2023-05-13 17:33:18 +09:00
ehci-platform.c usb: ehci-platform: Use devm_platform_get_and_ioremap_resource() 2023-07-27 10:24:09 +02:00
ehci-ppc-of.c usb: ehci-ppc-of: Convert to platform remove callback returning void 2023-05-28 12:36:29 +01:00
ehci-ps3.c
ehci-q.c USB: Use EHCI control transfer pid macros instead of constant values. 2024-03-26 10:43:35 +01:00
ehci-sched.c usb: host: ehci-sched: try to turn on io watchdog as long as periodic_count > 0 2023-08-12 10:03:22 +02:00
ehci-sh.c usb: host: Do not check for 0 return after calling platform_get_irq() 2023-08-04 14:46:53 +02:00
ehci-spear.c usb: ehci-spear: Use devm_platform_get_and_ioremap_resource() 2023-07-27 10:24:09 +02:00
ehci-st.c usb: ehci-st: Use devm_platform_get_and_ioremap_resource() 2023-07-27 10:24:11 +02:00
ehci-sysfs.c
ehci-timer.c
ehci-xilinx-of.c usb: ehci-xilinx-of: Convert to platform remove callback returning void 2023-05-28 12:36:29 +01:00
ehci.h USB: Use EHCI control transfer pid macros instead of constant values. 2024-03-26 10:43:35 +01:00
fhci-dbg.c
fhci-hcd.c usb: Explicitly include correct DT includes 2023-07-25 18:20:02 +02:00
fhci-hub.c USB: FHCI: Switch to GPIO descriptors 2022-09-01 16:08:29 +02:00
fhci-mem.c
fhci-q.c
fhci-sched.c
fhci-tds.c
fhci.h USB: FHCI: Switch to GPIO descriptors 2022-09-01 16:08:29 +02:00
fsl-mph-dr-of.c usb: fsl-mph-dr-of: mark fsl_usb2_mpc5121_init() static 2023-12-10 17:21:43 -08:00
isp116x-hcd.c usb: isp116x-hcd: Convert to platform remove callback returning void 2023-05-28 12:36:29 +01:00
isp116x.h
isp1362-hcd.c usb: isp1362-hcd: Use devm_platform_get_and_ioremap_resource() 2023-07-27 10:24:09 +02:00
isp1362.h
Kconfig usb: add HAS_IOPORT dependencies 2023-05-29 15:28:34 +01:00
Makefile usb: host: u132-hcd: Delete driver 2023-03-21 14:06:11 +01:00
max3421-hcd.c usb: host: max3421-hcd: Replace snprintf() with the safer scnprintf() variant 2023-12-15 13:55:30 +01:00
octeon-hcd.c usb: octeon-hcd: Convert to platform remove callback returning void 2023-05-28 12:36:30 +01:00
octeon-hcd.h staging: octeon-usb: move driver out of staging 2022-06-21 16:43:37 +02:00
ohci-at91.c usb: ohci-at91: Fix the unhandle interrupt when resume 2023-07-30 13:26:09 +02:00
ohci-da8xx.c usb: ohci-da8xx: Use devm_platform_get_and_ioremap_resource() 2023-07-27 10:24:09 +02:00
ohci-dbg.c
ohci-exynos.c usb: host: add missing MODULE_DESCRIPTION() macros 2024-06-20 19:18:29 +02:00
ohci-hcd.c usb: ohci: Prevent missed ohci interrupts 2024-04-30 18:04:40 +02:00
ohci-hub.c
ohci-mem.c
ohci-nxp.c usb: ohci-nxp: Use devm_platform_get_and_ioremap_resource() 2023-07-27 10:24:10 +02:00
ohci-omap.c usb: ohci-omap: Convert to platform remove callback returning void 2023-05-28 12:36:30 +01:00
ohci-pci.c USB: Extend pci resume function to handle PM events 2023-05-13 17:33:18 +09:00
ohci-platform.c usb: host: ohci-platform: Use devm_platform_get_and_ioremap_resource() 2023-07-27 10:24:09 +02:00
ohci-ppc-of.c usb: Explicitly include correct DT includes 2023-07-25 18:20:02 +02:00
ohci-ps3.c
ohci-pxa27x.c usb: ohci-pxa27x: Remove unused of_gpio.h 2024-03-07 20:58:25 +00:00
ohci-q.c
ohci-s3c2410.c usb: ohci-s3c2410: Convert to platform remove callback returning void 2023-05-28 12:36:31 +01:00
ohci-sa1111.c ARM: sa1100: remove unused board files 2023-01-12 10:53:12 +01:00
ohci-sm501.c USB: ohci-sm501: remove unnecessary check of mem 2023-08-12 10:03:16 +02:00
ohci-spear.c usb: ohci-spear: Use devm_platform_get_and_ioremap_resource() 2023-07-27 10:24:10 +02:00
ohci-st.c usb: ohci-st: Use devm_platform_get_and_ioremap_resource() 2023-07-27 10:24:11 +02:00
ohci.h usb: Annotate struct urb_priv with __counted_by 2023-10-02 09:48:52 -07:00
oxu210hp-hcd.c usb: host: oxu210hp: remove unused struct 'ehci_dbg_port' 2024-06-04 15:42:33 +02:00
pci-quirks.c usb: pci-quirks: handle HAS_IOPORT dependency for UHCI handoff 2023-10-02 16:19:13 +02:00
pci-quirks.h usb: pci-quirks: handle HAS_IOPORT dependency for AMD quirk 2023-10-02 16:19:12 +02:00
r8a66597-hcd.c usb: r8a66597-hcd: Convert to platform remove callback returning void 2023-05-28 12:36:31 +01:00
r8a66597.h
sl811_cs.c
sl811-hcd.c usb: sl811-hcd: only defined function checkdone if QUIRK2 is defined 2024-03-07 20:58:18 +00:00
sl811.h
ssb-hcd.c
uhci-debug.c
uhci-grlib.c usb: uhci-grlib: Explicitly include linux/platform_device.h 2024-02-19 09:23:00 +01:00
uhci-hcd.c usb: uhci: handle HAS_IOPORT dependencies 2023-05-29 15:29:03 +01:00
uhci-hcd.h usb: uhci: handle HAS_IOPORT dependencies 2023-05-29 15:29:03 +01:00
uhci-hub.c
uhci-pci.c Merge 6.4-rc4 into usb-next 2023-05-28 15:25:53 +01:00
uhci-platform.c usb: uhci-platform: Use devm_platform_get_and_ioremap_resource() 2023-07-27 10:24:11 +02:00
uhci-q.c
xen-hcd.c xen: make remove callback of xen driver void returned 2022-12-15 16:06:10 +01:00
xhci-caps.h XHCI: Separate PORT and CAPs macros into dedicated file 2024-01-27 17:39:09 -08:00
xhci-dbg.c
xhci-dbgcap.c xhci: dbc: Allow users to modify DbC poll interval via sysfs 2024-06-27 16:08:05 +02:00
xhci-dbgcap.h xhci: dbc: Allow users to modify DbC poll interval via sysfs 2024-06-27 16:08:05 +02:00
xhci-dbgtty.c tty: make tty_operations::write()'s count size_t 2023-08-11 21:12:46 +02:00
xhci-debugfs.c xhci: add support to allocate several interrupters 2024-01-04 16:08:13 +01:00
xhci-debugfs.h
xhci-ext-caps.c
xhci-ext-caps.h usb: xhci: Move extcaps related macros to respective header file 2023-10-02 13:55:44 +02:00
xhci-histb.c xhci: get rid of XHCI_PLAT quirk that used to prevent MSI setup 2023-06-13 11:34:50 +02:00
xhci-hub.c xhci: save slot ID in struct 'xhci_port' 2024-03-02 20:25:27 +01:00
xhci-mem.c usb: xhci: Check for xhci->interrupters being allocated in xhci_mem_clearup() 2024-08-13 10:26:27 +02:00
xhci-mtk-sch.c xhci: replace real & fake port with pointer to root hub port 2024-03-02 20:25:27 +01:00
xhci-mtk.c usb: xhci-mtk: fix a short packet issue of gen1 isoc-in transfer 2024-01-04 16:05:50 +01:00
xhci-mtk.h usb: xhci-mtk: fix a short packet issue of gen1 isoc-in transfer 2024-01-04 16:05:50 +01:00
xhci-mvebu.c usb: host: xhci: mvebu: Iterate over array indexes instead of using pointer math 2023-02-06 13:46:42 +01:00
xhci-mvebu.h
xhci-pci-renesas.c usb: host: add missing MODULE_DESCRIPTION() macros 2024-06-20 19:18:29 +02:00
xhci-pci.c xhci: Apply XHCI_RESET_TO_DEFAULT quirk to TGL 2024-06-27 16:08:06 +02:00
xhci-pci.h
xhci-plat.c usb: host: xhci-plat: Add support for XHCI_WRITE_64_HI_LO 2024-06-20 19:30:30 +02:00
xhci-plat.h usb: xhci-plat: Don't include xhci.h 2024-04-23 16:25:29 -07:00
xhci-port.h XHCI: Separate PORT and CAPs macros into dedicated file 2024-01-27 17:39:09 -08:00
xhci-rcar.c xhci: remove XHCI_TRUST_TX_LENGTH quirk 2024-05-01 08:47:14 +02:00
xhci-ring.c usb: xhci: fix duplicate stall handling in handle_tx_event() 2024-08-13 10:26:28 +02:00
xhci-rzv2m.c usb: xhci-plat: Don't include xhci.h 2024-04-23 16:25:29 -07:00
xhci-rzv2m.h xhci: host: Add Renesas RZ/V2M SoC support 2023-01-25 15:48:17 +01:00
xhci-tegra.c Merge 6.5-rc4 into usb-next 2023-07-31 09:36:55 +02:00
xhci-trace.c xhci: Move functions to setup msi to xhci-pci 2023-03-23 17:25:22 +01:00
xhci-trace.h xhci: show usb device name in xhci urb tracing 2024-06-27 16:08:05 +02:00
xhci.c xhci: Fix Panther point NULL pointer deref at full-speed re-enumeration 2024-08-15 16:29:46 +02:00
xhci.h xhci: sort out TRB Endpoint ID bitfield macros 2024-06-27 16:08:06 +02:00