From: sashiko-bot@kernel.org
To: "Nguyen Ngoc Thang" <ngocthang2710.1999@gmail.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] USB: core: don't release an unbound claimed interface via the driver core
Date: Thu, 08 Oct 2026 00:49:35 +0000 [thread overview]
Message-ID: <sashiko-outbox-163480@kernel.org> (raw)
In-Reply-To: <20261008003431.145352-1-ngocthang2710.1999@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] usb: core: incomplete fix allows KASAN null-ptr-deref via sysfs unbind
--
commit fd7979038e7e5e8a14bb9739dc4ce0f3b1576847
Author: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
USB: core: don't release an unbound claimed interface via the driver core
usb_driver_claim_interface() sets dev->driver on an interface and only
calls device_bind_driver() if the interface is already registered.
Otherwise the later device_add() is expected to bind it, but with
bus drivers_autoprobe disabled bus_probe_device() skips the attach, so
the interface ends up with dev->driver set while it was never added to
the driver's klist.
Closes: https://syzkaller.appspot.com/bug?extid=863936f50214e843ae0c
> diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
> index 3c3bbaf89609a..20e8e61bf6713 100644
> --- a/drivers/usb/core/driver.c
> +++ b/drivers/usb/core/driver.c
> @@ -636,10 +636,11 @@ void usb_driver_release_interface(struct usb_driver *driver,
> return;
> iface->condition = USB_INTERFACE_UNBINDING;
>
> - /* Release via the driver core only if the interface
> - * has already been registered
> + /* Release via the driver core only if the interface has been
> + * bound by it. A claimed interface is not bound if it was
> + * registered with drivers_autoprobe disabled.
> */
> - if (device_is_registered(dev)) {
> + if (device_is_bound(dev)) {
[Severity: High]
Does this change fully resolve the issue, or does the crash still trigger
via the sysfs unbind path?
If drivers_autoprobe=0 and the CDC NCM control interface is manually bound,
usb_driver_claim_interface() sets dev->driver for the data interface without
actually binding it, leaving its klist node unattached.
This patch prevents the crash in usb_driver_release_interface() by checking
device_is_bound(), but what happens if an administrator writes the data
interface's device name to /sys/bus/usb/drivers/cdc_ncm/unbind?
The unbind_store() function in drivers/base/bus.c will call
device_driver_detach(), reaching __device_release_driver():
drivers/base/dd.c:__device_release_driver() {
...
if (dev->driver) {
...
klist_remove(&dev->p->knode_driver);
...
}
Since dev->driver is set, will this still attempt to remove the unattached
klist node and result in the same NULL pointer dereference in klist_put()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261008003431.145352-1-ngocthang2710.1999@gmail.com?part=1
next prev parent reply other threads:[~2026-10-08 0:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 0:34 [PATCH] USB: core: don't release an unbound claimed interface via the driver core Nguyen Ngoc Thang
2026-10-08 0:49 ` sashiko-bot [this message]
2026-10-08 14:48 ` [PATCH v2] driver core: bind a device with a preset driver even without autoprobe Nguyen Ngoc Thang
2026-10-08 15:02 ` sashiko-bot
2026-10-08 16:12 ` [PATCH v3] " Nguyen Ngoc Thang
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-163480@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=ngocthang2710.1999@gmail.com \
--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