Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hongyu Xie" <xiehongyu1@kylinos.cn>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH 2/3] usb: core: Close anchor capture-to-increment race in URB giveback
Date: Thu, 22 Oct 2026 03:58:48 +0000	[thread overview]
Message-ID: <sashiko-outbox-180987@kernel.org> (raw)
In-Reply-To: <179264121348.17277.2207660107714201051@kylinos.cn>

> __usb_hcd_giveback_urb() captures urb->anchor into a local variable at
> the top of the function, but increments the anchor's suspend_wakeups
> counter only after unmapping the URB for DMA and running the usbmon
> hooks.  Nothing pins the anchor during that window.  If the URB is
> concurrently unanchored by another thread -- a driver calling
> usb_unanchor_urb() on its own in-flight URB, or usb_get_from_anchor()
> or usb_scuttle_anchored_urbs() taking it -- the anchor list can become
> empty while suspend_wakeups is still zero.  A
> usb_wait_anchor_empty_timeout() waiter then observes the wait condition
> true, returns, and the driver may free the anchor (anchors are
> typically embedded in driver-private structures); the giveback's
> atomic_inc() on the captured pointer, and the later decrement and
> wake_up() in usb_anchor_resume_wakeups(), operate on freed memory.
> 
> The previous fix ("usb: core: Fix use-after-free in anchor wakeup
> [ ... ]
> Cc: stable@vger.kernel.org
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Oliver Neukum <oliver@neukum.org>
> Cc: Hans de Goede <hansg@kernel.org>
> Signed-off-by: Hongyu Xie <xiehongyu1@kylinos.cn>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/179264120148.17277.68253767316647311@kylinos.cn?part=2


  reply	other threads:[~2026-10-22  3:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22  3:53 [PATCH 0/3] usb: core: fix three use-after-free windows in the USB anchor protocol Hongyu Xie
2026-10-22  3:53 ` [PATCH 1/3] usb: core: Fix use-after-free in anchor wakeup protocol Hongyu Xie
2026-10-22  4:00   ` sashiko-bot
2026-10-22  3:53 ` [PATCH 2/3] usb: core: Close anchor capture-to-increment race in URB giveback Hongyu Xie
2026-10-22  3:58   ` sashiko-bot [this message]
2026-10-22  3:53 ` [PATCH 3/3] usb: core: Close residual anchor read-to-lock window with RCU Hongyu Xie
2026-10-22  4:21   ` sashiko-bot
2026-10-22 17:29     ` What happened with Sashiko? Alan Stern
2026-10-22 23:07       ` Roman Gushchin

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-180987@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=xiehongyu1@kylinos.cn \
    /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