From: sashiko-bot@kernel.org
To: "Leon Romanovsky" <leon@kernel.org>
Cc: linux-input@vger.kernel.org, linux-usb@vger.kernel.org,
linux-pci@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v2 03/19] USB: Lock registered interfaces during manual driver binding
Date: Tue, 10 Nov 2026 07:35:13 +0000 [thread overview]
Message-ID: <sashiko-outbox-206503@kernel.org> (raw)
In-Reply-To: <20261109-device-trust-core-v2-3-3b12d9a9f861@nvidia.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] usb: core: unlocked dev->driver updates in
usb_driver_claim_interface()
--
commit aa47d25b59fe6dc15ab05e899c754ff4b6a72894
Author: Leon Romanovsky <leon@kernel.org>
USB: Lock registered interfaces during manual driver binding
This commit locks registered USB interfaces around device_bind_driver() in
usb_driver_claim_interface() and updates btusb_mtk_claim_iso_intf() to acquire
the USB device lock instead of the target interface lock.
> diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
> index d3a61ebc6afb0..ad5d9d5fc7598 100644
> --- a/drivers/usb/core/driver.c
> +++ b/drivers/usb/core/driver.c
> @@ -584,8 +584,11 @@ int usb_driver_claim_interface(struct usb_driver *driver,
> /* if interface was already added, bind now; else let
> * the future device_add() bind it, bypassing probe()
> */
> - if (device_is_registered(dev))
> + if (device_is_registered(dev)) {
> + device_lock(dev);
> retval = device_bind_driver(dev);
> + device_unlock(dev);
> + }
>
> if (retval) {
> dev->driver = NULL;
[Severity: High]
Does taking device_lock(dev) only around device_bind_driver() leave
dev->driver and the interface binding state unprotected on a registered
interface?
Callers of usb_driver_claim_interface() hold the parent USB device lock, not
the target interface lock. When device_is_registered(dev) is true,
usb_driver_claim_interface() checks dev->driver and iface->authorized and
writes dev->driver, intfdata, iface->needs_binding, and iface->condition
before acquiring device_lock(dev), and rolls them back after releasing
device_unlock(dev) if device_bind_driver() fails.
Readers that synchronize using only the interface lock, such as
supports_autosuspend_show(), can race with the unlocked rollback and
dereference a NULL dev->driver:
drivers/usb/core/sysfs.c:supports_autosuspend_show() {
s = device_lock_interruptible(dev);
if (s < 0)
return -EINTR;
/* Devices will be autosuspended even when an interface isn't claimed */
s = (!dev->driver || to_usb_driver(dev->driver)->supports_autosuspend);
device_unlock(dev);
}
CPU0 CPU1
usb_driver_claim_interface()
dev->driver = &driver->driver
device_lock(dev)
device_bind_driver(dev) -> fails
device_unlock(dev)
supports_autosuspend_show()
device_lock_interruptible(dev)
!dev->driver (false)
dev->driver = NULL
to_usb_driver(dev->driver)
->supports_autosuspend
<-- NULL pointer dereference
Setting dev->driver outside device_lock(dev) also allows
device_trust_set_policy() and usb_authorize_interface() to observe a
transient non-NULL dev->driver before admission completes or after it fails,
races with __driver_attach() checking !dev->driver under device_lock(dev),
and modifies struct usb_interface bitfields (needs_binding,
needs_remote_wakeup) without serializing against iface->authorized updates.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261109-device-trust-core-v2-0-3b12d9a9f861@nvidia.com?part=3
next prev parent reply other threads:[~2026-11-10 7:35 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 7:33 [PATCH v2 00/19] driver core: Authorize device trust before driver binding Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 01/19] Input: gameport - attach manual drivers through the driver core Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 02/19] wifi: mac80211_hwsim: lock device for manual driver binding Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 03/19] USB: Lock registered interfaces during " Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot [this message]
2026-11-10 14:19 ` Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 04/19] USB: Release interface claims refused during registration Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-10 14:23 ` Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 05/19] PNP: Attach card devices through the driver core Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 06/19] cdx: Propagate DMA configuration errors Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 07/19] driver core: Report deferred probes through sysfs drivers_probe Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 08/19] driver core: Add a compatibility API for manual driver attachment Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 09/19] Input: serio - use the compatibility driver attachment API Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-10 14:29 ` Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 10/19] net: phy: Use " Leon Romanovsky
2026-11-09 13:45 ` Andrew Lunn
2026-11-10 7:39 ` Leon Romanovsky
2026-11-10 14:31 ` Andrew Lunn
2026-11-10 14:58 ` Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 11/19] driver core: Introduce a generic device trust level Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-10 15:12 ` Leon Romanovsky
2026-11-09 7:33 ` [PATCH v2 12/19] driver core: Expose device trust authorization interfaces Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 13/19] driver core: Accept device trust policy on the kernel command line Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 14/19] driver core: Accept device trust policy by driver name Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 15/19] driver core: Expose committed device trust level Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 16/19] driver core: Cover trust authorization and binding with KUnit Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 17/19] driver core: Document trust admission and initrd authorization Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 18/19] PCI: Replace untrusted state with device trust Leon Romanovsky
2026-11-09 13:53 ` Robin Murphy
2026-11-10 12:22 ` Leon Romanovsky
2026-11-10 14:25 ` Jason Gunthorpe
2026-11-10 14:34 ` Leon Romanovsky
2026-11-10 7:35 ` sashiko-bot
2026-11-09 7:33 ` [PATCH v2 19/19] USB: Authorize devices and interfaces through " Leon Romanovsky
2026-11-10 7:35 ` 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=sashiko-outbox-206503@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=leon@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--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