Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Igor Putko" <igorpetindev@gmail.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v4] usb: core: hcd: flush giveback work on stop
Date: Thu, 29 Oct 2026 11:53:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-189223@kernel.org> (raw)
In-Reply-To: <20261029114733.2688-1-igorpetindev@gmail.com>

> When an HCD is stopped/removed (either during module unload, driver
> unbind, or an error path in probe), pending URBs are unlinked and
> completed. However, for root hubs or HCDs with giveback done in BH
> context, the work function usb_giveback_urb_bh() may still be executing
> on another CPU after __usb_hcd_giveback_urb() drops the URB use_count
> and wakes up waiters in usb_kill_urb().
> 
> Since the caller may immediately free the struct usb_hcd via usb_put_hcd()
> after usb_stop_hcd() or usb_remove_hcd(), the running worker accesses
> the embedded giveback_urb_bh structure in its epilogue (e.g. clearing
> completing_ep or clearing the running flag) after the memory has been
> freed, triggering a slab-use-after-free write detected by KASAN.
> 
> Ensure all giveback work has fully completed in usb_stop_hcd() by calling
> flush_work() on both high and low priority BHs before deallocating.
> Also remove the misleading comment in usb_remove_hcd() claiming
> flush_work() is unneeded, and document the queue emptiness in the
> usb_stop_hcd() kerneldoc.
> 
> Fixes: 8fea0c8fda30 ("usb: core: hcd: Convert from tasklet to BH workqueue")
> Reported-by: syzbot+a5b220cacb0618384d5a@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=a5b220cacb0618384d5a
> Suggested-by: Alan Stern <stern@rowland.harvard.edu>
> Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
> Signed-off-by: Igor Putko <igorpetindev@gmail.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261029114733.2688-1-igorpetindev@gmail.com?part=1


      reply	other threads:[~2026-10-29 11:53 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 17:40 [PATCH] usb: core: hcd: cancel giveback work synchronously on stop Igor Putko
2026-10-23 18:06 ` sashiko-bot
2026-10-23 19:15 ` Alan Stern
2026-10-23 19:31   ` IgorpetinDev
2026-10-24  1:53     ` Alan Stern
2026-10-24  8:36 ` [PATCH v2] usb: core: hcd: flush giveback work " Igor Putko
2026-10-24  9:11   ` sashiko-bot
2026-10-24 15:10     ` Alan Stern
2026-10-24 15:56 ` [PATCH v3] " Igor Putko
2026-10-24 16:11   ` sashiko-bot
2026-10-24 18:28   ` Alan Stern
2026-10-24 22:06   ` Michal Pecio
2026-10-25  7:54     ` IgorpetinDev
2026-10-25 15:16       ` Alan Stern
2026-10-25 16:10         ` Michal Pecio
2026-10-26  1:09           ` Alan Stern
2026-10-29  9:42       ` Greg Kroah-Hartman
2026-10-29 10:44         ` Michal Pecio
2026-10-29 11:47   ` [PATCH v4] " Igor Putko
2026-10-29 11:53     ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-189223@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=igorpetindev@gmail.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox