linux/drivers/usb
Alan Stern 22f0081286 USB: class: cdc-wdm: Fix CPU lockup caused by excessive log messages
The syzbot fuzzer found that the interrupt-URB completion callback in
the cdc-wdm driver was taking too long, and the driver's immediate
resubmission of interrupt URBs with -EPROTO status combined with the
dummy-hcd emulation to cause a CPU lockup:

cdc_wdm 1-1:1.0: nonzero urb status received: -71
cdc_wdm 1-1:1.0: wdm_int_callback - 0 bytes
watchdog: BUG: soft lockup - CPU#0 stuck for 26s! [syz-executor782:6625]
CPU#0 Utilization every 4s during lockup:
	#1:  98% system,	  0% softirq,	  3% hardirq,	  0% idle
	#2:  98% system,	  0% softirq,	  3% hardirq,	  0% idle
	#3:  98% system,	  0% softirq,	  3% hardirq,	  0% idle
	#4:  98% system,	  0% softirq,	  3% hardirq,	  0% idle
	#5:  98% system,	  1% softirq,	  3% hardirq,	  0% idle
Modules linked in:
irq event stamp: 73096
hardirqs last  enabled at (73095): [<ffff80008037bc00>] console_emit_next_record kernel/printk/printk.c:2935 [inline]
hardirqs last  enabled at (73095): [<ffff80008037bc00>] console_flush_all+0x650/0xb74 kernel/printk/printk.c:2994
hardirqs last disabled at (73096): [<ffff80008af10b00>] __el1_irq arch/arm64/kernel/entry-common.c:533 [inline]
hardirqs last disabled at (73096): [<ffff80008af10b00>] el1_interrupt+0x24/0x68 arch/arm64/kernel/entry-common.c:551
softirqs last  enabled at (73048): [<ffff8000801ea530>] softirq_handle_end kernel/softirq.c:400 [inline]
softirqs last  enabled at (73048): [<ffff8000801ea530>] handle_softirqs+0xa60/0xc34 kernel/softirq.c:582
softirqs last disabled at (73043): [<ffff800080020de8>] __do_softirq+0x14/0x20 kernel/softirq.c:588
CPU: 0 PID: 6625 Comm: syz-executor782 Tainted: G        W          6.10.0-rc2-syzkaller-g8867bbd4a056 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/02/2024

Testing showed that the problem did not occur if the two error
messages -- the first two lines above -- were removed; apparently adding
material to the kernel log takes a surprisingly large amount of time.

In any case, the best approach for preventing these lockups and to
avoid spamming the log with thousands of error messages per second is
to ratelimit the two dev_err() calls.  Therefore we replace them with
dev_err_ratelimited().

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Suggested-by: Greg KH <gregkh@linuxfoundation.org>
Reported-and-tested-by: syzbot+5f996b83575ef4058638@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-usb/00000000000073d54b061a6a1c65@google.com/
Reported-and-tested-by: syzbot+1b2abad17596ad03dcff@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-usb/000000000000f45085061aa9b37e@google.com/
Fixes: 9908a32e94 ("USB: remove err() macro from usb class drivers")
Link: https://lore.kernel.org/linux-usb/40dfa45b-5f21-4eef-a8c1-51a2f320e267@rowland.harvard.edu/
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/29855215-52f5-4385-b058-91f42c2bee18@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-06-14 08:47:59 +02:00
..
atm usb: ueagle-atm: Use wait_event_freezable_timeout() in uea_wait() 2024-01-04 15:57:29 +01:00
c67x00 USB: c67x00: Remove unused declaration c67x00_hcd_msg_received() 2023-10-02 16:42:33 +02:00
cdns3 tracing/treewide: Remove second parameter of __assign_str() 2024-05-22 20:14:47 -04:00
chipidea Revert "usb: chipidea: move ci_ulpi_init after the phy initialization" 2024-06-04 14:51:09 +02:00
class USB: class: cdc-wdm: Fix CPU lockup caused by excessive log messages 2024-06-14 08:47:59 +02:00
common usb: ulpi: Fix debugfs directory leak 2024-01-27 17:41:42 -08:00
core kcov, usb: disable interrupts in kcov_remote_start_usb_softirq 2024-06-04 15:34:44 +02:00
dwc2 Merge 6.9-rc5 into usb-next 2024-04-23 13:33:26 +02:00
dwc3 tracing/treewide: Remove second parameter of __assign_str() 2024-05-22 20:14:47 -04:00
early usb: early: xhci-dbc: Use memcpy_and_pad() 2023-01-31 10:40:54 +01:00
fotg210 usb: fotg210: Add missing kernel doc description 2024-05-11 08:42:03 +01:00
gadget tracing/treewide: Remove second parameter of __assign_str() 2024-05-22 20:14:47 -04:00
host xhci: Handle TD clearing for multiple streams case 2024-06-12 09:43:36 +02:00
image scsi: core: Add a dma_alignment field to the host and host template 2024-04-11 21:37:48 -04:00
isp1760 mm, slab: remove last vestiges of SLAB_MEM_SPREAD 2024-03-12 20:32:19 -07:00
misc USB: fix up for "usb: misc: onboard_hub: rename to onboard_dev" 2024-04-30 18:11:13 +02:00
mon usb: mon: Fix atomicity violation in mon_bin_vma_fault 2024-01-05 10:36:08 +01:00
mtu3 tracing/treewide: Remove second parameter of __assign_str() 2024-05-22 20:14:47 -04:00
musb tracing/treewide: Remove second parameter of __assign_str() 2024-05-22 20:14:47 -04:00
phy usb: phy-generic: add short delay after pulling the reset pin 2024-04-09 17:37:35 +02:00
renesas_usbhs usb: renesas_usbhs: Remove renesas_usbhs_get_info() wrapper 2024-04-18 16:47:49 +02:00
roles Merge v6.8-rc6 into usb-next 2024-02-26 06:53:50 +01:00
serial USB: serial: option: add Telit FN920C04 rmnet compositions 2024-04-18 17:14:49 +02:00
storage usb-storage: alauda: Check whether the media is initialized 2024-06-04 15:36:28 +02:00
typec usb: typec: ucsi: Ack also failed Get Error commands 2024-06-04 15:36:12 +02:00
usbip USB: core: Use device_driver directly in struct usb_driver and usb_device_driver 2024-01-04 16:06:32 +01:00
Kconfig usb: pci-quirks: handle HAS_IOPORT dependency for AMD quirk 2023-10-02 16:19:12 +02:00
Makefile USB: xen-hcd: Traverse host/ when CONFIG_USB_XEN_HCD is selected 2024-06-04 15:33:38 +02:00
usb-skeleton.c