linux/drivers/usb/gadget/udc
Jinchao Wang d5e5cd3654 usb: gadget: dummy_hcd: prevent fifo_req reuse during giveback
dummy_hcd embeds a single shared usb_request (dum->fifo_req) that the
"emulated single-request FIFO" fast-path in dummy_queue() reuses for
small IN transfers: it copies the caller's request into it
(req->req = *_req) and queues it, treating list_empty(&fifo_req.queue)
as "the slot is free".

The completion side (dummy_timer/transfer/nuke/dummy_dequeue) follows
the standard pattern: list_del_init(&req->queue) unlinks the request,
then the lock is dropped and usb_gadget_giveback_request() invokes
req->complete().  But list_del_init() makes fifo_req.queue look empty
*before* the completion callback returns, so a concurrent dummy_queue()
on another CPU sees the slot as free, reuses fifo_req and runs
req->req = *_req -- overwriting req->complete while dummy_timer is
mid-calling it.  The indirect call then jumps to a clobbered pointer,
causing a general protection fault / page fault in dummy_timer
(syzkaller extid faf3a6cf579fc65591ca).  The clobbering write is an
in-bounds memcpy on a live shared object, so KASAN cannot flag it.

Add a fifo_req_busy bit covering the shared request's whole lifetime:
set it in dummy_queue() when the FIFO fast-path takes fifo_req (making
it the fast-path guard, replacing the list_empty(&fifo_req.queue)
test), and clear it after the completion callback has returned, via a
dummy_giveback() helper used at all four gadget-request giveback
sites.  The shared slot can no longer be reused until its completion
callback has finished.

Reported-by: syzbot+faf3a6cf579fc65591ca@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=faf3a6cf579fc65591ca
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Cc: stable <stable@kernel.org>
Signed-off-by: Jinchao Wang <wangjinchao600@gmail.com>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://patch.msgid.link/5db8bba5b3499a86cd2e776f9918126b68b2508b.1784198306.git.wangjinchao600@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-07-16 17:12:36 +02:00
..
aspeed-vhub driver core: Replace dev->of_node_reused with dev_of_node_reused() 2026-04-26 23:50:20 +02:00
bdc usb: gadget: udc: bdc: free IRQ and drain func_wake_notify before teardown 2026-07-13 07:10:11 +02:00
cdns2 treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
amd5536udc_pci.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
amd5536udc.h USB: gadget: udc: Remove some dead code 2021-10-10 15:12:34 +02:00
aspeed_udc.c usb: gadget: aspeed_udc: avoid past-the-end iterator in dequeue 2026-05-22 11:36:01 +02:00
at91_udc.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
at91_udc.h usb: gadget: at91_udc: Convert to GPIO descriptors 2021-11-17 14:41:15 +01:00
atmel_usba_udc.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
atmel_usba_udc.h usb: gadget: udc: atmel: update endpoint allocation for sam9x60 2020-09-24 11:56:17 +03:00
bcm63xx_udc.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
core.c usb: gadget: udc: Fix use-after-free in gadget_match_driver 2026-07-08 13:35:42 +02:00
dummy_hcd.c usb: gadget: dummy_hcd: prevent fifo_req reuse during giveback 2026-07-16 17:12:36 +02:00
fsl_qe_udc.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
fsl_qe_udc.h usb: Spelling s/enpoint/endpoint/ 2019-11-04 15:53:00 +01:00
fsl_udc_core.c USB: gadget: fsl-udc: drop misleading unbind sanity check 2026-07-13 07:10:11 +02:00
fsl_usb2_udc.h USB: gadget: fsl-udc: fix dev_printk() device 2026-07-13 07:10:11 +02:00
goku_udc.c usb: gadget: goku_udc: avoid NULL deref of dev->driver in INT_USBRESET log 2026-05-22 11:34:41 +02:00
goku_udc.h usb: gadget: udc: change comparison to bitshift when dealing with a mask 2018-03-08 15:12:00 +02:00
gr_udc.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
gr_udc.h USB: gr_udc: remove dentry storage for debugfs file 2021-06-02 16:41:00 +02:00
Kconfig usb: Remove orphaned UDC drivers 2025-04-11 16:11:25 +02:00
lpc32xx_udc.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
m66592-udc.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
m66592-udc.h USB: gadget: udc: Remove redundant license text 2017-11-07 15:45:02 +01:00
Makefile usb: Remove orphaned UDC drivers 2025-04-11 16:11:25 +02:00
max3420_udc.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
net2280.c usb: gadget: net2280: Fix double free in probe error path 2026-05-22 10:35:22 +02:00
net2280.h USB: UDC: Implement udc_async_callbacks in net2280 2021-06-04 13:52:06 +02:00
omap_udc.c USB: omap_udc: DMA: Don't enable burst 4 mode 2026-04-27 09:49:28 -06:00
omap_udc.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pch_udc.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
pxa25x_udc.c usb: udc: pxa: remove unused platform_data 2026-04-27 10:18:19 -06:00
pxa25x_udc.h usb: udc: pxa: remove unused platform_data 2026-04-27 10:18:19 -06:00
pxa27x_udc.c usb: udc: pxa: fix error handling 2026-07-13 07:10:10 +02:00
pxa27x_udc.h usb: udc: pxa: remove unused platform_data 2026-04-27 10:18:19 -06:00
r8a66597-udc.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
r8a66597-udc.h USB: gadget: udc: Remove redundant license text 2017-11-07 15:45:02 +01:00
renesas_usb3.c usb: gadget: renesas_usb3: validate endpoint index in standard request handlers 2026-04-07 13:48:30 +02:00
renesas_usbf.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
rzv2m_usb3drd.c usb: Switch back to struct platform_driver::remove() 2024-10-04 15:13:03 +02:00
snps_udc_core.c USB: gadget: snps-udc: fix device name leak on probe failure 2026-07-13 07:10:11 +02:00
snps_udc_plat.c usb: Switch back to struct platform_driver::remove() 2024-10-04 15:13:03 +02:00
tegra-xudc.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
trace.c USB: gadget: udc: fix kernel-doc syntax in file headers 2021-05-24 15:27:03 +02:00
trace.h usb: udc: Add trace event for usb_gadget_set_state 2025-09-12 14:03:14 +02:00
udc-xilinx.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00