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 04/19] USB: Release interface claims refused during registration
Date: Tue, 10 Nov 2026 07:35:14 +0000 [thread overview]
Message-ID: <sashiko-outbox-206504@kernel.org> (raw)
In-Reply-To: <20261109-device-trust-core-v2-4-3b12d9a9f861@nvidia.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] usb: core: unreleased interface claim when device_add() fails
or skips probe
- [Medium] usb: core: skipped claim release when try_module_get() fails
in usb_set_configuration()
--
commit fe8ed7c8ae2a463fe7346f0944a52ef057b538c6
Author: Leon Romanovsky <leon@kernel.org>
USB: Release interface claims refused during registration
This commit tracks pre-registration interface claims across device_add() in
usb_set_configuration() and invokes usb_driver_release_refused_claim() to
unbind the interface if the driver core drops the claim during registration.
> diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
> index a738d03c23eac..d35a7710c8ef4 100644
> --- a/drivers/usb/core/message.c
> +++ b/drivers/usb/core/message.c
> @@ -2264,6 +2264,7 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
> */
> for (i = 0; i < nintf; ++i) {
> struct usb_interface *intf = cp->interface[i];
> + struct device_driver *claimant;
>
> if (intf->dev.of_node &&
> !of_device_is_available(intf->dev.of_node)) {
> @@ -2277,7 +2278,14 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
> dev_name(&intf->dev), configuration,
> intf->cur_altsetting->desc.bInterfaceNumber);
> device_enable_async_suspend(&intf->dev);
> + claimant = intf->dev.driver;
> + if (claimant && !try_module_get(claimant->owner))
> + claimant = NULL;
[Severity: Medium]
Does clearing claimant to NULL when try_module_get() fails skip releasing
the refused claim if the claimant module is concurrently unloading?
Binding a USB driver to an interface does not take a module reference on
claimant->owner. If delete_module() races with usb_set_configuration(),
try_stop_module() sets MODULE_STATE_GOING (causing try_module_get() to fail)
before mod->exit() -> usb_deregister() -> driver_detach() blocks on
device_lock(&dev->dev) while detaching the already-bound sibling interface.
If device_add() then fails to bind intf and clears intf->dev.driver to NULL,
usb_driver_release_refused_claim() is skipped because claimant is NULL, and
the sibling's later usb_driver_release_interface() call returns early because
intf->dev.driver is already NULL. That leaves intf registered with
intf->condition == USB_INTERFACE_BOUND and intf->dev.driver == NULL, which
causes a NULL pointer dereference in usb_suspend_interface().
> ret = device_add(&intf->dev);
> + if (!ret && claimant && !intf->dev.driver)
> + usb_driver_release_refused_claim(intf, claimant);
[Severity: Medium]
Can a pre-claimed interface also be left in USB_INTERFACE_BOUND state without
a bound driver when device_add() returns an error or skips probing?
If dpm_sysfs_add() fails in device_add(), its DPMError path calls
device_set_driver(dev, NULL) and returns a non-zero ret:
drivers/base/core.c:device_add() {
...
DPMError:
device_set_driver(dev, NULL);
bus_remove_device(dev);
...
}
Because usb_set_configuration() logs the device_add() error and continues,
skipping usb_driver_release_refused_claim() when ret != 0 leaves intf in
dev->actconfig->interface[i] with intf->condition == USB_INTERFACE_BOUND and
intf->dev.driver == NULL, which crashes in usb_suspend_interface() and
prevents usb_driver_release_interface() from cleaning it up. If device_add()
fails before DPMError, intf remains unregistered in USB_INTERFACE_BOUND
state, so usb_disable_device() also skips unbinding it on teardown.
Similarly, if bus autoprobe is disabled when device_initial_probe() runs,
device_add() returns 0 without calling device_bind_driver() or clearing
intf->dev.driver, leaving intf->dev.driver set while !device_is_bound(&intf->dev).
Checking !device_is_bound(&intf->dev) instead of !ret && !intf->dev.driver
would cover all of these cases.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261109-device-trust-core-v2-0-3b12d9a9f861@nvidia.com?part=4
next prev parent reply other threads:[~2026-11-10 7:35 UTC|newest]
Thread overview: 52+ 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-09 10:06 ` driver core: Authorize device trust before driver binding bluez.test.bot
2026-11-10 7:35 ` [PATCH v2 01/19] Input: gameport - attach manual drivers through the driver core 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
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 [this message]
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-206504@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 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.