From: Armin Wolf <W_Armin@gmx.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Daniel Gomez <da.gomez@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
Aaron Tomlin <atomlin@atomlin.com>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Bradley Morgan <brads@mainlining.org>,
Aleksandr Nogikh <nogikh@google.com>,
linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, linux-usb@vger.kernel.org,
driver-core@lists.linux.dev, linux-trace-kernel@vger.kernel.org,
Johan Hovold <johan@kernel.org>
Subject: Re: [PATCH v3 0/2] driver core: add TAINT_FORCED_BIND for when userspace manually messes with devices and drivers
Date: Sat, 5 Sep 2026 14:51:36 +0200 [thread overview]
Message-ID: <aa9f7f23-f9b2-4b54-b287-5089caa5b0c9@gmx.de> (raw)
In-Reply-To: <2026090546-skimming-bundle-0655@gregkh>
Am 05.09.26 um 13:27 schrieb Greg Kroah-Hartman:
> On Fri, Sep 04, 2026 at 09:46:59PM +0200, Armin Wolf wrote:
>> Am 04.09.26 um 07:10 schrieb Greg Kroah-Hartman:
>>> The ability to add and remove devices from a driver through the sysfs
>>> "bind" and "unbind" files was created all those decades ago as a way
>>> that kernel developers can iterate faster, and provide a debugging way
>>> for users to attempt to add a new device to a driver without having to
>>> rebuild their kernel.
>>>
>>> This api over the years has been abused and recently come under a major
>>> fuzzing "attack" through tools like syzbot which decided that it would
>>> attempt to just randomly bind any driver to any type of device, causing
>>> loads of unneeded errors and pointless kernel patches to be generated by
>>> unsuspecting new developers.
>>>
>>> Handle all of this by adding a new taint flag, TAINT_FORCED_BIND, which
>>> will be set on the driver if the bind/unbind sysfs files are ever
>>> written to. This lets kernel developers "know" that a user is
>>> attempting to do something that is not normal, and as such, if the
>>> kernel breaks they get to keep the shiny pieces laying around on the
>>> floor.
>>>
>>> The flag is 'Y' which was unused, and can remembered as the user is
>>> "yeeting" the device being operated on here (thrown with force without
>>> regard for the thing being thrown).
>>>
>>> Note, the taint flag gets set _BEFORE_ the bind/unbind callback happens,
>>> as many times crashes/oops/warnings/failures happen within the callback,
>>> and the taint flag needs to be there to show what was being attempted.
>>> If it were to be set after the callback happens, the oops report would
>>> not properly reflect what foolishness was being attempted.
>>>
>>> Fuzzing tools like syzbot, that doesn't have hand-crafted rules to keep
>>> the tool from hitting bind/unbind, should be run with panic_on_taint
>>> enabled so that they fall over and don't continue on, thinking that they
>>> actually found a real issue.
>>>
>>> Userspace operations that rely on the bind/unbind files to work around
>>> the lack of will to upgrade a kernel image to a newer version with
>>> proper support for new devices, or the lack of will to submit valid
>>> device ids to driver authors, will still work properly, but now the
>>> kernel will be flagged in a way that will show that perhaps those users
>>> should reconsider their behavior and work to have the drivers properly
>>> support these devices in a "native" manner.
>> What about users that use driver_override together with vfio-pci? AFAIK
>> they still need to write to bind/unbind.
> As I state above, that is an abuse of this api.
>
>> Also i always liked the fact that the bind/unbind attributes make it very
>> easy in creating generic drivers. In fact, i am intending to use this feature
>> in order to add netlink support to the ACPI-WMI subsystem in the future.
>> I am planning to realize this thru a generic WMI driver that has to be manually
>> bound to a given WMI device to make it available over netlink, so having
>> users be able to write bind/unbind without potentially triggering a kernel panic
>> would be very nice.
> It's a taint flag being set, not a panic, showing developers that "hey,
> the user just did something odd here, ask them about it when handling
> this bug report."
>> Additionally, writing into the bind attribute still checks if the driver and the
>> device match:
>>
>> /*
>> * Manually attach a device to a driver.
>> * Note: the driver must want to bind to the device,
>> * it is not possible to override the driver's id table.
>> */
>> static ssize_t bind_store(struct device_driver *drv, const char *buf, size_t count)
>>
>> Because of this i would suggest that the taint (if at all) be added to the
>> driver_override attribute instead, because only with this attribute users can bind
>> random drivers to truly random devices.
> I had thought of that, but the force removal of drivers from devices
> wouldn't show up this way, which is one of the things that we do want to
> warn developers about.
IMHO drivers that do not support this should rather just set suppress_bind_attrs.
And drivers for busses that do support hotplugging must support surprise removal
anyway.
Would it be possible to only taint the kernel if the underlying bus does not
claim to be hotplugable?
> And, if we just did the driver_override taint, it would allow those
> drivers who claim to be "generic" like you are referring to, to keep
> "getting away with that" when it's obviously not true that they can
> handle any device for that bus, otherwise it would have automatically
> bound to it already (and no manual intervention would be needed.)
>
> By keeping the manual configuration of bind, you are forcing userspace
> to manually do work, while still a possible thing to do, now at least a
> developer who gets a bug report will _know_ it happened, which is why
> the taint flag is there.
>
> Does that make a bit more sense?
How are users supposed to select between multiple drivers for the same device
if all those drivers claim to support said device? Assuming i have a generic driver
and a more specialized driver that both claim support for the same device. How
can i control which one is ultimately bound to the device without using bind/unbind?
How to utilize driver_override when another driver is already bound to the device
without using the unbind attribute?
Also drivers that claim to be generic while obviously not being able to handle all
devices are themselves broken, not the surrounding mechanism that relies on the data
being supplied by the broken drivers.
Maybe we should instead fix those drivers to stop claiming to be generic? Do you know
the names of some drivers that are affected by this?
Thanks,
Armin Wolf
> thanks,
>
> greg k-h
prev parent reply other threads:[~2026-09-05 12:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 5:10 [PATCH v3 0/2] driver core: add TAINT_FORCED_BIND for when userspace manually messes with devices and drivers Greg Kroah-Hartman
2026-09-04 5:10 ` [PATCH v3 1/2] module: pull out add_taint_module() to be public Greg Kroah-Hartman
2026-09-04 9:25 ` Petr Pavlu
2026-09-04 12:19 ` Greg Kroah-Hartman
2026-09-04 15:36 ` Petr Pavlu
2026-09-04 5:10 ` [PATCH v3 2/2] driver core: add TAINT_FORCED_BIND for when userspace manually messes with devices and drivers Greg Kroah-Hartman
2026-09-04 19:46 ` [PATCH v3 0/2] " Armin Wolf
2026-09-05 11:27 ` Greg Kroah-Hartman
2026-09-05 12:51 ` Armin Wolf [this message]
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=aa9f7f23-f9b2-4b54-b287-5089caa5b0c9@gmx.de \
--to=w_armin@gmx.de \
--cc=atomlin@atomlin.com \
--cc=brads@mainlining.org \
--cc=corbet@lwn.net \
--cc=da.gomez@kernel.org \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mcgrof@kernel.org \
--cc=mhiramat@kernel.org \
--cc=nogikh@google.com \
--cc=petr.pavlu@suse.com \
--cc=rafael@kernel.org \
--cc=rdunlap@infradead.org \
--cc=rostedt@goodmis.org \
--cc=samitolvanen@google.com \
--cc=skhan@linuxfoundation.org \
/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