Linux Trace Kernel
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/3] Add TAINT_DRIVER_OVERRIDE for usage of driver_override
Date: Mon, 28 Sep 2026 21:43:34 +0200	[thread overview]
Message-ID: <arrCUYnwhK68Q46T@monoceros> (raw)
In-Reply-To: <20260928165818.69F321F000FF@smtp.kernel.org>

[-- Attachment #1: Type: text/plain, Size: 2827 bytes --]

On Mon, Sep 28, 2026 at 04:58:18PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] device: false kernel taint from internal driver_override usage
> --
> 
> commit 224a6c2cd832599abb4180f63153f96e5c11d2a8
> Author: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> 
> Add TAINT_DRIVER_OVERRIDE for usage of driver_override
> 
> This commit introduces a new kernel taint, TAINT_DRIVER_OVERRIDE, which is
> applied when a driver is matched to a device via the driver_override
> mechanism. It aims to distinguish overrides from manual sysfs bindings, as
> overrides can lead to driver crashes if the driver expects specific match data.
> 
> Link: https://lore.kernel.org/driver-core/DLIL9H50MALI.3JROXYEEUM3KU@kernel.org/
> 
> > diff --git a/include/linux/device.h b/include/linux/device.h
> > index 879eb758b5eec..4dac5e09b74c1 100644
> > --- a/include/linux/device.h
> > +++ b/include/linux/device.h
> > @@ -905,8 +905,15 @@ static inline int device_match_driver_override(struct device *dev,
> >  					       const struct device_driver *drv)
> >  {
> >  	guard(spinlock)(&dev->driver_override.lock);
> > -	if (dev->driver_override.name)
> > -		return !strcmp(dev->driver_override.name, drv->name);
> > +	if (dev->driver_override.name) {
> > +		int ret = !strcmp(dev->driver_override.name, drv->name);
> > +
> > +		if (ret > 0)
> > +			add_taint_module(drv->owner,
> > +					 TAINT_DRIVER_OVERRIDE, LOCKDEP_STILL_OK);
> 
> [Severity: Medium]
> Will this unconditionally taint the kernel even for valid internal usages of
> driver_override?

Well, if you assume there are valid internal usages of driver_override,
yes. I think it is possible to not need these all.
 
> Many kernel subsystems and drivers use device_set_driver_override()
> programmatically to force driver matching for dynamically instantiated devices
> during normal operation or probing.
> 
> For example, in drivers/clk/imx/clk-scu.c:imx_clk_scu_alloc_dev() sets the
> override internally:
> 
> 	ret = device_set_driver_override(&pdev->dev, "imx-scu-clk");

Here I think you need to change `platform_device_alloc(name,
PLATFORM_DEVID_NONE)` to `platform_device_alloc("imx-scu-clk",
PLATFORM_DEVID_NONE)` plus maybe create uniq device ids (using a static
int that is increased for each call).

> Since device_match_driver_override() cannot distinguish between a userspace
> sysfs override and a legitimate internal programmatic override, won't this
> cause production systems using these platforms to falsely report as tainted on
> boot?
> 
> Falsely tainting the kernel breaks the reliability of the taint mechanism and
> could lead to valid bug reports being ignored by maintainers.

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2026-09-28 19:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 16:46 [PATCH v3 0/3] Add TAINT_DRIVER_OVERRIDE for usage of driver_override Uwe Kleine-König
2026-09-28 16:46 ` [PATCH v3 1/3] docs: admin-guide: Handle TAINT_FORCED_BIND when parsing /proc/sys/kernel/tainted Uwe Kleine-König
2026-09-28 17:25   ` Bradley Morgan
2026-09-28 16:46 ` [PATCH v3 2/3] Add TAINT_DRIVER_OVERRIDE for usage of driver_override Uwe Kleine-König
2026-09-28 16:58   ` sashiko-bot
2026-09-28 19:43     ` Uwe Kleine-König [this message]
2026-09-28 17:25   ` Bradley Morgan
2026-09-28 16:46 ` [PATCH v3 3/3] driver core: Disable driver overriding by default Uwe Kleine-König
2026-09-28 16:57   ` sashiko-bot
2026-09-28 19:47     ` Uwe Kleine-König
2026-09-28 17:26   ` Bradley Morgan
2026-09-28 17:15 ` [PATCH v3 0/3] Add TAINT_DRIVER_OVERRIDE for usage of driver_override Danilo Krummrich
2026-09-29  5:53   ` Uwe Kleine-König
2026-09-29 10:28     ` Danilo Krummrich
2026-09-28 21:51 ` (subset) " Danilo Krummrich
2026-09-28 21:53   ` Danilo Krummrich
2026-09-29  5:47     ` Uwe Kleine-König

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=arrCUYnwhK68Q46T@monoceros \
    --to=u.kleine-koenig@baylibre.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox