From: sashiko-bot@kernel.org
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
Cc: linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] driver core: add TAINT_FORCED_BIND for when userspace manually messes with devices and drivers
Date: Wed, 26 Aug 2026 10:34:50 +0000 [thread overview]
Message-ID: <20260826103451.385891F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260826-bind_taint-v1-2-52b05f4a965c@linuxfoundation.org>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [High] Calling `add_taint_module()` unconditionally dereferences `drv->owner`, causing a kernel panic for built-in drivers where `drv->owner` is `NULL`.
- [Low] The patch breaks the build when `CONFIG_MODULES` is disabled due to a syntactically invalid inline stub for `add_taint_module` introduced in the previous patch.
- [Low] Malformed reStructuredText simple table and outdated `seq 20` script in the tainted-kernels documentation.
Pre-existing issues:
- [High] A race condition in `unbind_store` allows detaching an unintended driver if `dev->driver` changes concurrently.
--
commit 4cfb386dac8b53407ce0309b005475cf263546f7
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
driver core: add TAINT_FORCED_BIND for when userspace manually messes with devices and drivers
Add a new TAINT_FORCED_BIND taint flag to track when userspace successfully
adds or removes devices from a driver via the sysfs bind and unbind files.
This helps identify when userspace fuzzing or manual interference causes
subsequent kernel crashes.
> diff --git a/Documentation/admin-guide/tainted-kernels.rst b/Documentation/admin-guide/tainted-kernels.rst
> index 9ead927a37c0f..d4ca8b9e3819e 100644
> --- a/Documentation/admin-guide/tainted-kernels.rst
> +++ b/Documentation/admin-guide/tainted-kernels.rst
> @@ -79,30 +79,31 @@ which bits are set::
> Table for decoding tainted state
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> -=== === ====== ========================================================
> -Bit Log Number Reason that got the kernel tainted
> -=== === ====== ========================================================
> +=== === ====== ========================================================
> +Bit Log Number Reason that got the kernel tainted
> +=== === ====== ========================================================
[ ... ]
> + 19 _/J 524288 userspace used a mutating debug operation in fwctl
> + 20 _/Y 1048576 device was manually bound or unbound from a driver
> +=== === ======= ========================================================
[Severity: Low]
The header separator for the Number column is 6 characters wide, but the
footer separator is 7 characters wide. Can this mismatch break Sphinx
reStructuredText table parsing?
Also, does the quick-check script just above this table need to be updated?
It uses seq 20, which fails to cover this newly added 20th taint bit
(requires seq 21).
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> index d17bd91490ee4..c51ad96d4de4b 100644
> --- a/drivers/base/bus.c
> +++ b/drivers/base/bus.c
[ ... ]
> @@ -241,6 +242,7 @@ static ssize_t unbind_store(struct device_driver *drv, const char *buf,
>
> dev = bus_find_device_by_name(bus, NULL, buf);
> if (dev && dev->driver == drv) {
[Severity: High]
This is a pre-existing issue, but is there a race condition here?
The check of dev->driver is performed without holding the device lock. If the
driver is detached and a new driver attaches immediately after, could the
subsequent call to device_driver_detach(dev) blindly detach the unintended
new driver?
> + add_taint_module(drv->owner, TAINT_FORCED_BIND, LOCKDEP_STILL_OK);
[Severity: High]
For built-in drivers, drv->owner is NULL. Does calling add_taint_module
unconditionally dereference drv->owner, causing a kernel panic when a user
writes to the unbind sysfs file for a statically compiled driver?
[Severity: Low]
Will this unconditional call cause a compilation error when CONFIG_MODULES=n?
The inline stub for add_taint_module in include/linux/module.h omits the
parameter name for enum lockdep_ok, making it syntactically invalid, which
is activated by this new call.
> device_driver_detach(dev);
> err = count;
> }
> @@ -264,6 +266,7 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf,
>
> dev = bus_find_device_by_name(bus, NULL, buf);
> if (dev && driver_match_device(drv, dev)) {
> + add_taint_module(drv->owner, TAINT_FORCED_BIND, LOCKDEP_STILL_OK);
[Severity: High]
Similarly, for built-in drivers where drv->owner is NULL, does this
unconditionally dereference it and cause a kernel panic here as well?
> err = device_driver_attach(drv, dev);
> if (!err) {
> /* success */
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260826-bind_taint-v1-0-52b05f4a965c@linuxfoundation.org?part=2
next prev parent reply other threads:[~2026-08-26 10:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 9:19 [PATCH 0/2] driver core: add TAINT_FORCED_BIND for when userspace manually messes with devices and drivers Greg Kroah-Hartman
2026-08-26 9:19 ` [PATCH 1/2] module: pull out add_taint_module() to be public Greg Kroah-Hartman
2026-08-26 10:29 ` sashiko-bot
2026-08-26 10:39 ` Greg Kroah-Hartman
2026-08-26 11:13 ` Aaron Tomlin
2026-08-26 11:54 ` Greg Kroah-Hartman
2026-08-27 13:36 ` Johan Hovold
2026-08-27 14:30 ` Greg Kroah-Hartman
2026-08-26 9:19 ` [PATCH 2/2] driver core: add TAINT_FORCED_BIND for when userspace manually messes with devices and drivers Greg Kroah-Hartman
2026-08-26 10:34 ` sashiko-bot [this message]
2026-08-26 11:58 ` Bradley Morgan
2026-08-26 13:10 ` Greg KH
2026-08-26 14:26 ` Steven Rostedt
2026-08-26 14:34 ` Bradley Morgan
2026-08-27 13:33 ` Johan Hovold
2026-08-26 13:33 ` [PATCH 0/2] " Michal Pecio
2026-08-26 14:25 ` Greg Kroah-Hartman
2026-08-26 15:35 ` Michal Pecio
2026-08-26 15:44 ` Greg Kroah-Hartman
2026-08-26 17:09 ` Michal Pecio
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=20260826103451.385891F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-modules@vger.kernel.org \
--cc=linux-trace-kernel@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.