* [PATCH] usb: cdc-wdm: fix double submission of URB
@ 2026-12-02 21:04 Timo Joannin
2026-12-02 21:19 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Timo Joannin @ 2026-12-02 21:04 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Oliver Neukum, Bjørn Mork, Greg Suarez, Gui-Dong Han,
linux-usb, linux-kernel, Timo Joannin,
syzbot+eb8f169da355a394fe04
Syzbot found a bug where "URB submitted while active".
This is because service_outstanding_interrupt() doesn't check whether
WDM_RESPONDING is already set and allows it to resubmit an already
active URB triggering the warning.
An earlier attempt to check responding in service_outstanding_interrupt()
was reverted in commit 1607830dadee
("Revert "usb: cdc-wdm: close race between read and workqueue""),
because wdm_int_callback() left WDM_RESPONDING stuck at 1 while
the driver wasn't responding,
and service_outstanding_interrupt() decremented desc->resp_count
before checking the WDM_RESPONDING bit.
In wdm_int_callback check the desc->resp_count before setting
the WDM_RESPONDING bit so that when desc->resp_count >= 1,
we leave WDM_RESPONDING unchanged.
In service_outstanding_interrupt() bail if WDM_RESPONDING is set
before decrementing desc->resp_count.
Reported-by: syzbot+eb8f169da355a394fe04@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=eb8f169da355a394fe04
Fixes: 73e06865ead1 ("USB: cdc-wdm: support back-to-back USB_CDC_NOTIFY_RESPONSE_AVAILABLE notifications")
Signed-off-by: Timo Joannin <timo.joannin@gmail.com>
---
Compile tested only, there is no C reproducer
for this issue, and #syz test is still down.
drivers/usb/class/cdc-wdm.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 7556c0dac908..87de4e7e0196 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -252,7 +252,6 @@ static void wdm_int_callback(struct urb *urb)
{
unsigned long flags;
int rv = 0;
- int responding;
int status = urb->status;
struct wdm_device *desc;
struct usb_cdc_notification *dr;
@@ -311,10 +310,10 @@ static void wdm_int_callback(struct urb *urb)
}
spin_lock_irqsave(&desc->iuspin, flags);
- responding = test_and_set_bit(WDM_RESPONDING, &desc->flags);
- if (!desc->resp_count++ && !responding
+ if (!desc->resp_count++
&& !test_bit(WDM_DISCONNECTING, &desc->flags)
- && !test_bit(WDM_SUSPENDING, &desc->flags)) {
+ && !test_bit(WDM_SUSPENDING, &desc->flags)
+ && !test_and_set_bit(WDM_RESPONDING, &desc->flags)) {
rv = usb_submit_urb(desc->response, GFP_ATOMIC);
dev_dbg(&desc->intf->dev, "submit response URB %d\n", rv);
}
@@ -491,6 +490,10 @@ static int service_outstanding_interrupt(struct wdm_device *desc)
{
int rv = 0;
+ /* don't submit or consume interrupt if URB already active */
+ if (test_bit(WDM_RESPONDING, &desc->flags))
+ goto out;
+
/* submit read urb only if the device is waiting for it */
if (!desc->resp_count || !--desc->resp_count)
goto out;
--
2.56.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: cdc-wdm: fix double submission of URB
2026-12-02 21:04 [PATCH] usb: cdc-wdm: fix double submission of URB Timo Joannin
@ 2026-12-02 21:19 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-02 21:19 UTC (permalink / raw)
To: Timo Joannin; +Cc: linux-usb
> Syzbot found a bug where "URB submitted while active".
> This is because service_outstanding_interrupt() doesn't check whether
> WDM_RESPONDING is already set and allows it to resubmit an already
> active URB triggering the warning.
>
> An earlier attempt to check responding in service_outstanding_interrupt()
> was reverted in commit 1607830dadee
> ("Revert "usb: cdc-wdm: close race between read and workqueue""),
> because wdm_int_callback() left WDM_RESPONDING stuck at 1 while
> the driver wasn't responding,
> and service_outstanding_interrupt() decremented desc->resp_count
> before checking the WDM_RESPONDING bit.
>
> In wdm_int_callback check the desc->resp_count before setting
> the WDM_RESPONDING bit so that when desc->resp_count >= 1,
> we leave WDM_RESPONDING unchanged.
> In service_outstanding_interrupt() bail if WDM_RESPONDING is set
> before decrementing desc->resp_count.
>
> Reported-by: syzbot+eb8f169da355a394fe04@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=eb8f169da355a394fe04
> Fixes: 73e06865ead1 ("USB: cdc-wdm: support back-to-back USB_CDC_NOTIFY_RESPONSE_AVAILABLE notifications")
> Signed-off-by: Timo Joannin <timo.joannin@gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202210431.242596-1-timo.joannin@gmail.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-02 21:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 21:04 [PATCH] usb: cdc-wdm: fix double submission of URB Timo Joannin
2026-12-02 21:19 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.