1
linux/drivers/usb/gadget/udc
Alan Stern 5189df7b80 USB: gadget: dummy-hcd: Fix "task hung" problem
The syzbot fuzzer has been encountering "task hung" problems ever
since the dummy-hcd driver was changed to use hrtimers instead of
regular timers.  It turns out that the problems are caused by a subtle
difference between the timer_pending() and hrtimer_active() APIs.

The changeover blindly replaced the first by the second.  However,
timer_pending() returns True when the timer is queued but not when its
callback is running, whereas hrtimer_active() returns True when the
hrtimer is queued _or_ its callback is running.  This difference
occasionally caused dummy_urb_enqueue() to think that the callback
routine had not yet started when in fact it was almost finished.  As a
result the hrtimer was not restarted, which made it impossible for the
driver to dequeue later the URB that was just enqueued.  This caused
usb_kill_urb() to hang, and things got worse from there.

Since hrtimers have no API for telling when they are queued and the
callback isn't running, the driver must keep track of this for itself.
That's what this patch does, adding a new "timer_pending" flag and
setting or clearing it at the appropriate times.

Reported-by: syzbot+f342ea16c9d06d80b585@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-usb/6709234e.050a0220.3e960.0011.GAE@google.com/
Tested-by: syzbot+f342ea16c9d06d80b585@syzkaller.appspotmail.com
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Fixes: a7f3813e58 ("usb: gadget: dummy_hcd: Switch to hrtimer transfer scheduler")
Cc: Marcello Sylvester Bauer <sylv@sylv.io>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/2dab644e-ef87-4de8-ac9a-26f100b2c609@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-10-17 08:45:10 +02:00
..
aspeed-vhub
bdc move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
cdns2 move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
amd5536udc_pci.c
amd5536udc.h
aspeed_udc.c Merge 6.10-rc6 into usb-next 2024-07-01 13:59:29 +02:00
at91_udc.c
at91_udc.h
atmel_usba_udc.c [tree-wide] finally take no_llseek out 2024-09-27 08:18:43 -07:00
atmel_usba_udc.h
bcm63xx_udc.c
core.c usb: gadget: core: force synchronous registration 2024-10-04 15:28:43 +02:00
dummy_hcd.c USB: gadget: dummy-hcd: Fix "task hung" problem 2024-10-17 08:45:10 +02:00
fsl_qe_udc.c
fsl_qe_udc.h
fsl_udc_core.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
fsl_usb2_udc.h
fusb300_udc.c
fusb300_udc.h
goku_udc.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
goku_udc.h
gr_udc.c
gr_udc.h
Kconfig
lpc32xx_udc.c usb: gadget: lpc32xx_udc: Remove NULL check of list_entry() 2024-08-22 17:17:56 +08:00
m66592-udc.c
m66592-udc.h
Makefile
max3420_udc.c
mv_u3d_core.c usb: gadget: mv_u3d: replace deprecated strncpy with strscpy 2024-03-26 10:44:32 +01:00
mv_u3d.h
mv_udc_core.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
mv_udc.h
net2272.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
net2272.h
net2280.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
net2280.h
omap_udc.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
omap_udc.h
pch_udc.c
pxa25x_udc.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
pxa25x_udc.h
pxa27x_udc.c USB: gadget: pxa27x_udc: Remove unused of_gpio.h 2024-03-07 20:58:30 +00:00
pxa27x_udc.h
r8a66597-udc.c
r8a66597-udc.h
renesas_usb3.c
renesas_usbf.c
rzv2m_usb3drd.c
snps_udc_core.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
snps_udc_plat.c usb: gadget/snps_udc_plat: Remove unused of_gpio.h 2024-03-07 20:58:27 +00:00
tegra-xudc.c usb: gadget: tegra-xudc: Fix USB3 PHY retrieval logic 2024-03-07 20:58:33 +00:00
trace.c
trace.h tracing/treewide: Remove second parameter of __assign_str() 2024-05-22 20:14:47 -04:00
udc-xilinx.c usb: gadget: udc-xilinx: Remove trailing space after \n newline 2024-09-03 09:53:21 +02:00