[PATCH v2] usb: cdc-wdm: fix double submission of URB

From: Timo Joannin

Date: Thu Dec 03 2026 - 07:17:02 EST


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
and service_outstanding_interrupt() decremented desc->resp_count
before checking the 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@xxxxxxxxxxxxxxxxxxxxxxxxx
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@xxxxxxxxx>
---
Changes in v2:
- Add comment in service_outstanding_interrupt()
explaining that we're protected by the desc->iuspin
spinlock for the test_bit(), desc->resp_count decrement
and set_bit() sequence.

Compile tested only, there is no C reproducer
for this issue, and #syz test is still down.

drivers/usb/class/cdc-wdm.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 7556c0dac908..d49cb8d74128 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,13 @@ static int service_outstanding_interrupt(struct wdm_device *desc)
{
int rv = 0;

+ /* Don't submit or consume interrupt if URB already active
+ * Safe to separate test_bit() and set_bit() because
+ * we're protected by the desc->iuspin spinlock
+ */
+ 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