From: Leon Romanovsky <leon@kernel.org>
To: sashiko-reviews@lists.linux.dev
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 16:23:59 +0200 [thread overview]
Message-ID: <20261110142359.GI8635@unreal> (raw)
In-Reply-To: <sashiko-outbox-206504@kernel.org>
On Tue, Nov 10, 2026 at 07:35:14AM +0000, sashiko-bot@kernel.org wrote:
> 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().
I have no idea if this flow is possible, but the fix to satisfy AI
review is relatively simple, so let's do it.
>
> > 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?
Yes, like before this change.
Thanks
next prev parent reply other threads:[~2026-11-10 14:24 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
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 [this message]
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=20261110142359.GI8635@unreal \
--to=leon@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--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