RE: [PATCH] driver core: Disable driver overriding by default
From: Michael Kelley
Date: Wed Nov 18 2026 - 10:47:30 EST
From: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxx> Sent: Tuesday, November 17, 2026 11:44 PM
>
> On Wed, Nov 18, 2026 at 05:51:29AM +0000, Michael Kelley wrote:
> > From: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxx> Sent: Monday, November 16, 2026 3:09 AM
[snip]
> > > +/**
> > > + * device_match_driver_override() - Match a driver against the device's driver_override.
> > > + * @dev: device to check
> > > + * @drv: driver to match against
> > > + *
> > > + * Returns > 0 if a driver override is set and matches the given driver, 0 if a
> > > + * driver override is set but does not match, or < 0 if a driver override is not
> > > + * set at all.
> >
> > Additionally, returns < 0 if a matching override exists but is disallowed.
>
> Yeah, that comment is just taken unmodified from the old location of
> device_match_driver_override(). Indeed needs adaption.
>
> > > + */
> > > +int device_match_driver_override(struct device *dev,
> > > + const struct device_driver *drv)
> > > +{
> > > + guard(spinlock)(&dev->driver_override.lock);
> > > + if (dev->driver_override.name) {
> > > + int ret = !strcmp(dev->driver_override.name, drv->name);
> > > +
> > > + if (ret > 0 && !drv->support_driver_override) {
> >
> > Using "ret > 0" seems a bit odd since the value is essentially Boolean.
> > Suggest using just "ret".
>
> ok
>
> > > + if (allow_driver_override) {
> > > + add_taint_module(drv->owner,
> > > + TAINT_DRIVER_OVERRIDE, LOCKDEP_STILL_OK);
> > > + } else {
> > > + /*
> > > + * If you hit this warning and you need to
> > > + * quickly workaround this check, boot with
> > > + * allow_driver_override=1 on the kernel
> > > + * commandline. The right fix is to set the
> > > + * driver's .support_driver_override property.
> > > + */
> > > + dev_warn(dev, "Suppressed driver override binding to %s.\n", drv->name);
> >
> > Maybe "Disallowed" instead of "Suppressed" in the message? Even better,
> > could the name of the device be provided? For example,
> >
> > "Disallowed bind of driver %s to device %s using driver override"
>
> dev_warn() emits the device name.
Oh, right. Ignore my comment about the device name. I just tried it
with a Hyper-V VMBus synthetic device, and here's the output, which
is fine:
[ 80.105203] vmbus 0f749bd1-5637-4279-91f1-bde768dd030f: Suppressed driver override binding to uio_hv_generic.
VMBus device names are full GUIDs, which isn't super handy, but it
is what it is. :-(
Michael