From: Ilia Snezhkov <iasnezhkov@gmail.com>
To: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org
Cc: hdegoede@redhat.com, sven@kernel.org, j@jannau.net,
Thinh.Nguyen@synopsys.com, asahi@lists.linux.dev,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 0/2] usb: roles: serialize unregister against callbacks and fix dwc3-apple lock order
Date: Thu, 26 Nov 2026 00:53:18 +0000 [thread overview]
Message-ID: <20261126005318.71705-1-iasnezhkov@gmail.com> (raw)
This two-patch v2 series fixes the race between
usb_role_switch_unregister() and concurrent usb_role_switch_{get,set}_role()
callbacks without introducing an ABBA lock-order inversion in callers:
1. Move usb_role_switch_unregister() outside appledwc->lock in
dwc3_apple_remove(), the only in-tree caller holding a mutex taken by
its role switch callbacks.
2. Serialize sw->registered checks and teardown under sw->lock in
drivers/usb/roles/class.c and document the locking contract on
usb_role_switch_unregister().
Changes in v2:
- Audited all 15 in-tree usb_role_switch_unregister() callers and
confirmed drivers/usb/dwc3/dwc3-apple.c is the sole caller holding a
lock also acquired by ->set()/->get().
- Added patch 1/2 fixing dwc3_apple_remove() before patch 2/2 takes
sw->lock in usb_role_switch_unregister().
- Documented the lock-ordering requirement in the kerneldoc of
usb_role_switch_unregister().
- Link to v1: https://lore.kernel.org/r/20261125234825.94733-1-iasnezhkov@gmail.com
Found and drafted with an AI coding assistant.
Ilia Snezhkov (2):
usb: dwc3: apple: unregister role switch outside appledwc->lock
usb: roles: serialize registered checks and unregister under sw->lock
drivers/usb/dwc3/dwc3-apple.c | 4 ++--
drivers/usb/roles/class.c | 19 ++++++++++++++-----
2 files changed, 16 insertions(+), 7 deletions(-)
--
2.54.0 (Apple Git-157)
WARNING: multiple messages have this Message-ID (diff)
From: Ilia Snezhkov via B4 Relay <devnull+iasnezhkov.gmail.com@kernel.org>
To: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org
Cc: hdegoede@redhat.com, sven@kernel.org, j@jannau.net,
Thinh.Nguyen@synopsys.com, asahi@lists.linux.dev,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 0/2] usb: roles: serialize unregister against callbacks and fix dwc3-apple lock order
Date: Thu, 26 Nov 2026 00:53:18 +0000 [thread overview]
Message-ID: <20261126005318.71705-1-iasnezhkov@gmail.com> (raw)
This two-patch v2 series fixes the race between
usb_role_switch_unregister() and concurrent usb_role_switch_{get,set}_role()
callbacks without introducing an ABBA lock-order inversion in callers:
1. Move usb_role_switch_unregister() outside appledwc->lock in
dwc3_apple_remove(), the only in-tree caller holding a mutex taken by
its role switch callbacks.
2. Serialize sw->registered checks and teardown under sw->lock in
drivers/usb/roles/class.c and document the locking contract on
usb_role_switch_unregister().
Changes in v2:
- Audited all 15 in-tree usb_role_switch_unregister() callers and
confirmed drivers/usb/dwc3/dwc3-apple.c is the sole caller holding a
lock also acquired by ->set()/->get().
- Added patch 1/2 fixing dwc3_apple_remove() before patch 2/2 takes
sw->lock in usb_role_switch_unregister().
- Documented the lock-ordering requirement in the kerneldoc of
usb_role_switch_unregister().
- Link to v1: https://lore.kernel.org/r/20261125234825.94733-1-iasnezhkov@gmail.com
Found and drafted with an AI coding assistant.
Ilia Snezhkov (2):
usb: dwc3: apple: unregister role switch outside appledwc->lock
usb: roles: serialize registered checks and unregister under sw->lock
drivers/usb/dwc3/dwc3-apple.c | 4 ++--
drivers/usb/roles/class.c | 19 ++++++++++++++-----
2 files changed, 16 insertions(+), 7 deletions(-)
--
2.54.0 (Apple Git-157)
next reply other threads:[~2026-11-26 0:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 0:53 Ilia Snezhkov [this message]
2026-11-26 0:53 ` [PATCH v2 0/2] usb: roles: serialize unregister against callbacks and fix dwc3-apple lock order Ilia Snezhkov via B4 Relay
2026-11-26 0:53 ` [PATCH v2 1/2] usb: dwc3: apple: unregister role switch outside appledwc->lock Ilia Snezhkov
2026-11-26 0:53 ` Ilia Snezhkov via B4 Relay
2026-11-26 0:53 ` [PATCH v2 2/2] usb: roles: serialize registered checks and unregister under sw->lock Ilia Snezhkov
2026-11-26 0:53 ` Ilia Snezhkov via B4 Relay
2026-11-30 13:21 ` Heikki Krogerus
2026-11-26 1:04 ` [PATCH v2 0/2] usb: roles: serialize unregister against callbacks and fix dwc3-apple lock order sashiko-bot
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=20261126005318.71705-1-iasnezhkov@gmail.com \
--to=iasnezhkov@gmail.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=asahi@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=j@jannau.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sven@kernel.org \
/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 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.