Linux USB
 help / color / mirror / Atom feed
* [PATCH v4 0/3] usb: core: Fix three use-after-free windows in the USB anchor protocol
@ 2026-12-03  0:48 Hongyu Xie
  2026-12-03  0:48 ` [PATCH v4 1/3] usb: core: Fix use-after-free in anchor wakeup protocol Hongyu Xie
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Hongyu Xie @ 2026-12-03  0:48 UTC (permalink / raw)
  To: Greg KH, Alan Stern
  Cc: Oliver Neukum, oliver, Hans de Goede, linux-usb, linux-kernel

This series closes three use-after-free windows in the USB anchor
teardown and URB giveback protocol:

1. Serialize usb_anchor_check_wakeup() and usb_anchor_resume_wakeups()
   under anchor->lock so a waiter cannot observe the anchor unused and
   free it while a giveback still touches anchor->wait.
2. Atomically re-check urb->anchor, increment anchor->suspend_wakeups,
   and unanchor the URB under anchor->lock during URB giveback via
   usb_unanchor_urb_and_suspend_wakeups().
3. Protect lockless urb->anchor readers with contention-gated RCU and
   replace busy-waiting in kill/poison/scuttle drains with wait_event().

Changes since v3:
- Use guard(spinlock_irqsave), scoped_guard(), and guard(rcu)() in
  drivers/usb/core/urb.c.
- Annotate __usb_anchor_check_wakeup(), __usb_anchor_prepare_rcu_gp(),
  and __usb_unanchor_urb() with __must_hold(&anchor->lock) and
  lockdep_assert_held(&anchor->lock).
- Shorten comments and rewrite all commit messages concisely per review.

v3: https://lore.kernel.org/r/179578612505.44635.14553263875690325600@kylinos.cn
v3 review: https://lore.kernel.org/all/2026112752-comic-stream-65a3@gregkh/

Hongyu Xie (3):
  usb: core: Fix use-after-free in anchor wakeup protocol
  usb: core: Close anchor capture-to-increment race in URB giveback
  usb: core: Close residual anchor read-to-lock window with RCU

 Documentation/driver-api/usb/anchors.rst |  14 +-
 drivers/usb/core/hcd.c                   |   5 +-
 drivers/usb/core/urb.c                   | 305 +++++++++++++++++++----
 drivers/usb/core/usb.h                   |   1 +
 include/linux/usb.h                      |   8 +-
 5 files changed, 276 insertions(+), 57 deletions(-)


base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
-- 
2.32.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-03  1:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  0:48 [PATCH v4 0/3] usb: core: Fix three use-after-free windows in the USB anchor protocol Hongyu Xie
2026-12-03  0:48 ` [PATCH v4 1/3] usb: core: Fix use-after-free in anchor wakeup protocol Hongyu Xie
2026-12-03  0:48 ` [PATCH v4 2/3] usb: core: Close anchor capture-to-increment race in URB giveback Hongyu Xie
2026-12-03  0:48 ` [PATCH v4 3/3] usb: core: Close residual anchor read-to-lock window with RCU Hongyu Xie
2026-12-03  1:04 ` [PATCH v4 0/3] usb: core: Fix three use-after-free windows in the USB anchor protocol sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox