Linux-HyperV List
 help / color / mirror / Atom feed
* [PATCH v2 00/10] driver core: Disable driver overriding by default
@ 2026-11-20 11:11 Uwe Kleine-König
  2026-11-20 11:11 ` [PATCH v2 05/10] uio: Allow untainted use of driver_override Uwe Kleine-König
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2026-11-20 11:11 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Danilo Krummrich, Johan Hovold, Bjorn Helgaas,
	Nipun Gupta, Nikhil Agarwal, Ioana Ciornei, Longfang Liu,
	Julian Ruess, Ankit Agrawal, Brett Creeley, Giovanni Cabiddu,
	Michał Winiarski, Eric Auger, Eric Farman, Matthew Rosato,
	Tony Krowiak, Jason Herne, Harald Freudenberger, Holger Dengler,
	Haiyang Zhang, Wei Liu, Dexuan Cui, Michael S. Tsirkin,
	Mark Brown, Abel Vesa, Stephen Boyd, Brian Masney, Jerome Brunet,
	Bjorn Andersson, Mathieu Poirier, Srinivas Kandagatla,
	Sylwester Nawrocki, Liam Girdwood, Jaroslav Kysela
  Cc: Jonathan Corbet, Rafael J. Wysocki, Steven Rostedt,
	Bradley Morgan, Armin Wolf, Masami Hiramatsu, linux-doc,
	driver-core, linux-kernel, linux-trace-kernel, linux-pci,
	Alex Williamson, Mostafa Saleh, kvm, qat-linux, virtualization,
	intel-xe, Vineeth Vijayan, Peter Oberparleiter, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev, linux-s390, linux-hyperv,
	linux-spi, Frank Li, Sascha Hauer, linux-clk, imx,
	linux-arm-kernel, linux-remoteproc, linux-arm-msm, linux-sound,
	Takashi Iwai

Hello,

here comes v2 which addresses the review feedback I got for (implicit)
v1. See https://lore.kernel.org/linux-kernel/20261116110853.3418077-2-u.kleine-koenig@baylibre.com
for the discussion about that previous submission.
 
The objective is to deny force binding a device to a driver that isn't
prepared for that. There are many drivers that run in a null pointer
exception when this happens and only very few drivers are supposed to be
used like that. So the first patch implements an explicit opt-in for
drivers and denies other matches; the remaining patches implement the
opt-in for drivers that rely on it. This makes it unnecessary to fix
individual drivers to explicitly refuse such bindings. See commit
1e50a0349012 ("iio: adc: mcp3564: reject devices without match data")
for an example of such a driver-specific fix.

Changes since (implicit) v1:
 
 - Rework parameter parsing to just use `allow_driver_override` on the
   kernel commandline
 - Add review tags
 - Add patches by Alex Williamson setting .support_driver_override in
   pci and vfio drivers
 - Add patches for uio, spidev and a few more drivers setting
   .support_driver_override
 - align wording in Documentation/admin-guide/tainted-kernels.rst with 
   tools/debugging/kernel-chktaint

It is sensible to merge the driver core change (patch #1) together with
the individual driver patches setting .support_driver_override because
with the driver core change the driver override doesn't work any more
for the unmodified drivers (unless the new kernel parameter is provided
and a taint is accepted). So I suggest (once there is agreement that the
patches are fine) to merge them all in one go and provide a stable
branch in case a driver was missed to be adapted. I can create such a
branch and ask Greg or Linus to pull it, or Greg can do that.

So if you're the maintainer of one of the drivers touched by patches #2
and later and assuming your ok with that patch, please provide your Ack
(plus the required coordination if applicable) for not merging via your
usual tree.

Best regards
Uwe

Alex Williamson (3):
  PCI: Allow untainted driver_override for PCI stub drivers
  vfio: Allow untainted use of driver_override
  s390/vfio: Allow untainted use of driver_override

Uwe Kleine-König (7):
  driver core: Disable driver overriding by default
  uio: Allow untainted use of driver_override
  spi: spidev: Allow untainted use of driver_override
  clk: imx: scu: Allow untainted use of driver_override
  remoteproc: Allow untainted use of driver_override
  slimbus: qcom-ngd-ctrl: Allow untainted use of driver_override
  ASoC: samsung: i2s: Allow untainted use of driver_override

 .../admin-guide/kernel-parameters.txt         |  6 +++
 Documentation/admin-guide/tainted-kernels.rst | 54 ++++++++++---------
 drivers/base/bus.c                            | 51 ++++++++++++++++++
 drivers/clk/imx/clk-scu.c                     |  1 +
 drivers/pci/pci-pf-stub.c                     |  1 +
 drivers/pci/pci-stub.c                        |  1 +
 drivers/rpmsg/rpmsg_ctrl.c                    |  1 +
 drivers/rpmsg/rpmsg_ns.c                      |  5 +-
 drivers/s390/cio/vfio_ccw_drv.c               |  1 +
 drivers/s390/crypto/vfio_ap_drv.c             |  1 +
 drivers/slimbus/qcom-ngd-ctrl.c               |  1 +
 drivers/spi/spidev.c                          |  1 +
 drivers/uio/uio_dmem_genirq.c                 |  1 +
 drivers/uio/uio_hv_generic.c                  |  1 +
 drivers/uio/uio_pci_generic.c                 |  1 +
 drivers/uio/uio_pdrv_genirq.c                 |  1 +
 drivers/vfio/cdx/main.c                       |  1 +
 drivers/vfio/fsl-mc/vfio_fsl_mc.c             |  1 +
 .../vfio/pci/hisilicon/hisi_acc_vfio_pci.c    |  3 +-
 drivers/vfio/pci/ism/main.c                   |  3 +-
 drivers/vfio/pci/mlx5/main.c                  |  3 +-
 drivers/vfio/pci/nvgrace-gpu/main.c           |  3 +-
 drivers/vfio/pci/pds/pci_drv.c                |  3 +-
 drivers/vfio/pci/qat/main.c                   |  3 +-
 drivers/vfio/pci/vfio_pci.c                   |  3 +-
 drivers/vfio/pci/virtio/main.c                |  3 +-
 drivers/vfio/pci/xe/main.c                    |  3 +-
 drivers/vfio/platform/vfio_amba.c             |  1 +
 drivers/vfio/platform/vfio_platform.c         |  1 +
 include/linux/device.h                        | 19 +------
 include/linux/device/driver.h                 |  2 +
 include/linux/panic.h                         |  3 +-
 include/trace/events/module.h                 |  3 +-
 kernel/panic.c                                |  3 +-
 sound/soc/samsung/i2s.c                       |  1 +
 tools/debugging/kernel-chktaint               |  9 ++++
 36 files changed, 144 insertions(+), 55 deletions(-)


base-commit: 7cfbf79c66c63e807ea452abf0546e6f6d6833a6
-- 
2.56.0.rc1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 05/10] uio: Allow untainted use of driver_override
  2026-11-20 11:11 [PATCH v2 00/10] driver core: Disable driver overriding by default Uwe Kleine-König
@ 2026-11-20 11:11 ` Uwe Kleine-König
  2026-11-20 20:08   ` Michael Kelley
  2026-11-21  1:16 ` [PATCH v2 00/10] driver core: Disable driver overriding by default Danilo Krummrich
  2026-11-26  1:57 ` Gary Guo
  2 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2026-11-20 11:11 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Haiyang Zhang, Wei Liu, Dexuan Cui,
	Michael S. Tsirkin
  Cc: linux-kernel, linux-hyperv, kvm

uio drivers support being matched to devices using the driver_override
mechanism. Add .support_driver_override = true to continue having
this mechanism work for them without tainting the kernel.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
 drivers/uio/uio_dmem_genirq.c | 1 +
 drivers/uio/uio_hv_generic.c  | 1 +
 drivers/uio/uio_pci_generic.c | 1 +
 drivers/uio/uio_pdrv_genirq.c | 1 +
 4 files changed, 4 insertions(+)

diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c
index 263c1ebc2d57..71992431770e 100644
--- a/drivers/uio/uio_dmem_genirq.c
+++ b/drivers/uio/uio_dmem_genirq.c
@@ -309,6 +309,7 @@ static struct platform_driver uio_dmem_genirq = {
 	.driver = {
 		.name = DRIVER_NAME,
 		.of_match_table = of_match_ptr(uio_of_genirq_match),
+		.support_driver_override = true,
 	},
 };
 
diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
index dff92dcbb10d..255c2b5730f6 100644
--- a/drivers/uio/uio_hv_generic.c
+++ b/drivers/uio/uio_hv_generic.c
@@ -407,6 +407,7 @@ static struct hv_driver hv_uio_drv = {
 	.id_table = hv_uio_id_table,
 	.probe = hv_uio_probe,
 	.remove = hv_uio_remove,
+	.driver.support_driver_override = true,
 };
 
 static int __init
diff --git a/drivers/uio/uio_pci_generic.c b/drivers/uio/uio_pci_generic.c
index c0cab3adb7b0..9785df9fc5de 100644
--- a/drivers/uio/uio_pci_generic.c
+++ b/drivers/uio/uio_pci_generic.c
@@ -140,6 +140,7 @@ static struct pci_driver uio_pci_driver = {
 	.name = "uio_pci_generic",
 	.id_table = NULL, /* only dynamic id's */
 	.probe = probe,
+	.driver.support_driver_override = true,
 };
 
 module_pci_driver(uio_pci_driver);
diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c
index 87e43821ab0c..022178248962 100644
--- a/drivers/uio/uio_pdrv_genirq.c
+++ b/drivers/uio/uio_pdrv_genirq.c
@@ -261,6 +261,7 @@ static struct platform_driver uio_pdrv_genirq = {
 	.driver = {
 		.name = DRIVER_NAME,
 		.of_match_table = of_match_ptr(uio_of_genirq_match),
+		.support_driver_override = true,
 	},
 };
 
-- 
2.56.0.rc1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [PATCH v2 05/10] uio: Allow untainted use of driver_override
  2026-11-20 11:11 ` [PATCH v2 05/10] uio: Allow untainted use of driver_override Uwe Kleine-König
@ 2026-11-20 20:08   ` Michael Kelley
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Kelley @ 2026-11-20 20:08 UTC (permalink / raw)
  To: Uwe Kleine-König, Greg Kroah-Hartman, Haiyang Zhang, Wei Liu,
	Dexuan Cui, Michael S. Tsirkin
  Cc: linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org,
	kvm@vger.kernel.org

From: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Sent: Friday, November 20, 2026 3:11 AM
> 
> uio drivers support being matched to devices using the driver_override
> mechanism. Add .support_driver_override = true to continue having
> this mechanism work for them without tainting the kernel.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>

Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Tested-by: Michael Kelley <mhklinux@outlook.com>   # uio_hv_generic.c change only

> ---
>  drivers/uio/uio_dmem_genirq.c | 1 +
>  drivers/uio/uio_hv_generic.c  | 1 +
>  drivers/uio/uio_pci_generic.c | 1 +
>  drivers/uio/uio_pdrv_genirq.c | 1 +
>  4 files changed, 4 insertions(+)
> 
> diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c
> index 263c1ebc2d57..71992431770e 100644
> --- a/drivers/uio/uio_dmem_genirq.c
> +++ b/drivers/uio/uio_dmem_genirq.c
> @@ -309,6 +309,7 @@ static struct platform_driver uio_dmem_genirq = {
>  	.driver = {
>  		.name = DRIVER_NAME,
>  		.of_match_table = of_match_ptr(uio_of_genirq_match),
> +		.support_driver_override = true,
>  	},
>  };
> 
> diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
> index dff92dcbb10d..255c2b5730f6 100644
> --- a/drivers/uio/uio_hv_generic.c
> +++ b/drivers/uio/uio_hv_generic.c
> @@ -407,6 +407,7 @@ static struct hv_driver hv_uio_drv = {
>  	.id_table = hv_uio_id_table,
>  	.probe = hv_uio_probe,
>  	.remove = hv_uio_remove,
> +	.driver.support_driver_override = true,
>  };
> 
>  static int __init
> diff --git a/drivers/uio/uio_pci_generic.c b/drivers/uio/uio_pci_generic.c
> index c0cab3adb7b0..9785df9fc5de 100644
> --- a/drivers/uio/uio_pci_generic.c
> +++ b/drivers/uio/uio_pci_generic.c
> @@ -140,6 +140,7 @@ static struct pci_driver uio_pci_driver = {
>  	.name = "uio_pci_generic",
>  	.id_table = NULL, /* only dynamic id's */
>  	.probe = probe,
> +	.driver.support_driver_override = true,
>  };
> 
>  module_pci_driver(uio_pci_driver);
> diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c
> index 87e43821ab0c..022178248962 100644
> --- a/drivers/uio/uio_pdrv_genirq.c
> +++ b/drivers/uio/uio_pdrv_genirq.c
> @@ -261,6 +261,7 @@ static struct platform_driver uio_pdrv_genirq = {
>  	.driver = {
>  		.name = DRIVER_NAME,
>  		.of_match_table = of_match_ptr(uio_of_genirq_match),
> +		.support_driver_override = true,
>  	},
>  };
> 
> --
> 2.56.0.rc1
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 00/10] driver core: Disable driver overriding by default
  2026-11-20 11:11 [PATCH v2 00/10] driver core: Disable driver overriding by default Uwe Kleine-König
  2026-11-20 11:11 ` [PATCH v2 05/10] uio: Allow untainted use of driver_override Uwe Kleine-König
@ 2026-11-21  1:16 ` Danilo Krummrich
  2026-11-26  1:57 ` Gary Guo
  2 siblings, 0 replies; 6+ messages in thread
From: Danilo Krummrich @ 2026-11-21  1:16 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Greg Kroah-Hartman, Johan Hovold, Bjorn Helgaas, Nipun Gupta,
	Nikhil Agarwal, Ioana Ciornei, Longfang Liu, Julian Ruess,
	Ankit Agrawal, Brett Creeley, Giovanni Cabiddu,
	Michał Winiarski, Eric Auger, Eric Farman, Matthew Rosato,
	Tony Krowiak, Jason Herne, Harald Freudenberger, Holger Dengler,
	Haiyang Zhang, Wei Liu, Dexuan Cui, Michael S. Tsirkin,
	Mark Brown, Abel Vesa, Stephen Boyd, Brian Masney, Jerome Brunet,
	Bjorn Andersson, Mathieu Poirier, Srinivas Kandagatla,
	Sylwester Nawrocki, Liam Girdwood, Jaroslav Kysela,
	Jonathan Corbet, Rafael J. Wysocki, Steven Rostedt,
	Bradley Morgan, Armin Wolf, Masami Hiramatsu, linux-doc,
	driver-core, linux-kernel, linux-trace-kernel, linux-pci,
	Alex Williamson, Mostafa Saleh, kvm, qat-linux, virtualization,
	intel-xe, Vineeth Vijayan, Peter Oberparleiter, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev, linux-s390, linux-hyperv,
	linux-spi, Frank Li, Sascha Hauer, linux-clk, imx,
	linux-arm-kernel, linux-remoteproc, linux-arm-msm, linux-sound,
	Takashi Iwai

On Fri Nov 20, 2026 at 12:11 PM CET, Uwe Kleine-König wrote:
> It is sensible to merge the driver core change (patch #1) together with
> the individual driver patches setting .support_driver_override because
> with the driver core change the driver override doesn't work any more
> for the unmodified drivers (unless the new kernel parameter is provided
> and a taint is accepted). So I suggest (once there is agreement that the
> patches are fine) to merge them all in one go and provide a stable
> branch in case a driver was missed to be adapted. I can create such a
> branch and ask Greg or Linus to pull it, or Greg can do that.

I think it should be good enough to just take them all through driver-core. If
it turns out in linux-next that we missed a driver we can always add another
patch to the driver-core tree.

Those patches only set support_driver_override = true, so there shouldn't be
interactions with other trees.

So, let's keep it simple. I can pick this up once we have all the ACKs.

Thanks,
Danilo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 00/10] driver core: Disable driver overriding by default
  2026-11-20 11:11 [PATCH v2 00/10] driver core: Disable driver overriding by default Uwe Kleine-König
  2026-11-20 11:11 ` [PATCH v2 05/10] uio: Allow untainted use of driver_override Uwe Kleine-König
  2026-11-21  1:16 ` [PATCH v2 00/10] driver core: Disable driver overriding by default Danilo Krummrich
@ 2026-11-26  1:57 ` Gary Guo
  2026-11-26  2:13   ` Gary Guo
  2 siblings, 1 reply; 6+ messages in thread
From: Gary Guo @ 2026-11-26  1:57 UTC (permalink / raw)
  To: Uwe Kleine-König, Greg Kroah-Hartman, Danilo Krummrich,
	Johan Hovold, Bjorn Helgaas, Nipun Gupta, Nikhil Agarwal,
	Ioana Ciornei, Longfang Liu, Julian Ruess, Ankit Agrawal,
	Brett Creeley, Giovanni Cabiddu, Michał Winiarski,
	Eric Auger, Eric Farman, Matthew Rosato, Tony Krowiak,
	Jason Herne, Harald Freudenberger, Holger Dengler, Haiyang Zhang,
	Wei Liu, Dexuan Cui, Michael S. Tsirkin, Mark Brown, Abel Vesa,
	Stephen Boyd, Brian Masney, Jerome Brunet, Bjorn Andersson,
	Mathieu Poirier, Srinivas Kandagatla, Sylwester Nawrocki,
	Liam Girdwood, Jaroslav Kysela
  Cc: Jonathan Corbet, Rafael J. Wysocki, Steven Rostedt,
	Bradley Morgan, Armin Wolf, Masami Hiramatsu, linux-doc,
	driver-core, linux-kernel, linux-trace-kernel, linux-pci,
	Alex Williamson, Mostafa Saleh, kvm, qat-linux, virtualization,
	intel-xe, Vineeth Vijayan, Peter Oberparleiter, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev, linux-s390, linux-hyperv,
	linux-spi, Frank Li, Sascha Hauer, linux-clk, imx,
	linux-arm-kernel, linux-remoteproc, linux-arm-msm, linux-sound,
	Takashi Iwai

On Fri Nov 20, 2026 at 11:11 AM GMT, Uwe Kleine-König wrote:
> Hello,
>
> here comes v2 which addresses the review feedback I got for (implicit)
> v1. See https://lore.kernel.org/linux-kernel/20261116110853.3418077-2-u.kleine-koenig@baylibre.com
> for the discussion about that previous submission.
>  
> The objective is to deny force binding a device to a driver that isn't
> prepared for that. There are many drivers that run in a null pointer
> exception when this happens and only very few drivers are supposed to be
> used like that. So the first patch implements an explicit opt-in for
> drivers and denies other matches; the remaining patches implement the
> opt-in for drivers that rely on it. This makes it unnecessary to fix
> individual drivers to explicitly refuse such bindings. See commit
> 1e50a0349012 ("iio: adc: mcp3564: reject devices without match data")
> for an example of such a driver-specific fix.

For PCI, there is actually already a mechanism for it -- override_only. VFIO
devices already have that annotation. I think it's a better mechanism. In
addition to providing a useful id_info, you can also say what IDs you want the
override match to become possible.

We can do something like this?

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 2398f03a77c1..2cf4659b36a4 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -218,8 +218,8 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv,
 	if (found_id)
 		return found_id;
 
-	/* driver_override will always match, send a dummy id */
-	if (ret > 0)
+	/* For a forced driver override, send a dummy id */
+	if (ret > 0 && device_forced_driver_override(dev))
 		return &pci_device_id_any;
 	return NULL;
 }

Where device_forced_driver_override your added logic about parameter and
tainting/warning logic.

I suppose the issue is that only CDX and PCI have this mechanism via ID table.
That said, other buses can gain a bus-specific allow_override field and you just
do

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 720a72ecd174..7539b43961e6 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -563,7 +563,8 @@ static int spi_match_device(struct device *dev, const struct device_driver *drv)
 
 	/* Check override first, and if set, only use the named driver */
 	ret = device_match_driver_override(dev, drv);
-	if (ret >= 0)
+	if (ret >= 0 && (sdrv->support_driver_override ||
+			 device_force_driver_override(dev, drv)))
 		return ret;
 
Thoughts?

Best,
Gary

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 00/10] driver core: Disable driver overriding by default
  2026-11-26  1:57 ` Gary Guo
@ 2026-11-26  2:13   ` Gary Guo
  0 siblings, 0 replies; 6+ messages in thread
From: Gary Guo @ 2026-11-26  2:13 UTC (permalink / raw)
  To: Gary Guo, Uwe Kleine-König, Greg Kroah-Hartman,
	Danilo Krummrich, Johan Hovold, Bjorn Helgaas, Nipun Gupta,
	Nikhil Agarwal, Ioana Ciornei, Longfang Liu, Julian Ruess,
	Ankit Agrawal, Brett Creeley, Giovanni Cabiddu,
	Michał Winiarski, Eric Auger, Eric Farman, Matthew Rosato,
	Tony Krowiak, Jason Herne, Harald Freudenberger, Holger Dengler,
	Haiyang Zhang, Wei Liu, Dexuan Cui, Michael S. Tsirkin,
	Mark Brown, Abel Vesa, Stephen Boyd, Brian Masney, Jerome Brunet,
	Bjorn Andersson, Mathieu Poirier, Srinivas Kandagatla,
	Sylwester Nawrocki, Liam Girdwood, Jaroslav Kysela
  Cc: Jonathan Corbet, Rafael J. Wysocki, Steven Rostedt,
	Bradley Morgan, Armin Wolf, Masami Hiramatsu, linux-doc,
	driver-core, linux-kernel, linux-trace-kernel, linux-pci,
	Alex Williamson, Mostafa Saleh, kvm, qat-linux, virtualization,
	intel-xe, Vineeth Vijayan, Peter Oberparleiter, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev, linux-s390, linux-hyperv,
	linux-spi, Frank Li, Sascha Hauer, linux-clk, imx,
	linux-arm-kernel, linux-remoteproc, linux-arm-msm, linux-sound,
	Takashi Iwai

On Thu Nov 26, 2026 at 1:57 AM GMT, Gary Guo wrote:
> On Fri Nov 20, 2026 at 11:11 AM GMT, Uwe Kleine-König wrote:
>> Hello,
>>
>> here comes v2 which addresses the review feedback I got for (implicit)
>> v1. See https://lore.kernel.org/linux-kernel/20261116110853.3418077-2-u.kleine-koenig@baylibre.com
>> for the discussion about that previous submission.
>>  
>> The objective is to deny force binding a device to a driver that isn't
>> prepared for that. There are many drivers that run in a null pointer
>> exception when this happens and only very few drivers are supposed to be
>> used like that. So the first patch implements an explicit opt-in for
>> drivers and denies other matches; the remaining patches implement the
>> opt-in for drivers that rely on it. This makes it unnecessary to fix
>> individual drivers to explicitly refuse such bindings. See commit
>> 1e50a0349012 ("iio: adc: mcp3564: reject devices without match data")
>> for an example of such a driver-specific fix.
>
> For PCI, there is actually already a mechanism for it -- override_only. VFIO
> devices already have that annotation. I think it's a better mechanism. In
> addition to providing a useful id_info, you can also say what IDs you want the
> override match to become possible.
>
> We can do something like this?
>
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index 2398f03a77c1..2cf4659b36a4 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -218,8 +218,8 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv,
>  	if (found_id)
>  		return found_id;
>  
> -	/* driver_override will always match, send a dummy id */
> -	if (ret > 0)
> +	/* For a forced driver override, send a dummy id */
> +	if (ret > 0 && device_forced_driver_override(dev))
>  		return &pci_device_id_any;
>  	return NULL;
>  }
>
> Where device_forced_driver_override your added logic about parameter and
> tainting/warning logic.
>
> I suppose the issue is that only CDX and PCI have this mechanism via ID table.
> That said, other buses can gain a bus-specific allow_override field and you just
> do
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 720a72ecd174..7539b43961e6 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -563,7 +563,8 @@ static int spi_match_device(struct device *dev, const struct device_driver *drv)
>  
>  	/* Check override first, and if set, only use the named driver */
>  	ret = device_match_driver_override(dev, drv);
> -	if (ret >= 0)
> +	if (ret >= 0 && (sdrv->support_driver_override ||
> +			 device_force_driver_override(dev, drv)))
>  		return ret;

To add on this, from
https://lore.kernel.org/all/7008c5ea-58fd-4452-a70a-2162cc3d562b@linux.ibm.com/
tt looks like that for some buses, the "driver_override" is a mere preference
mechanism and not forced override, as ID/filter must still match.

I took another look at this direction, and it seems that s390/css, s390/ap, cdx
and vdpa all have this property where forced override wouldn't occur, which is
probably a hint that this direction is worth exploring.

Best,
Gary

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-26  2:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 11:11 [PATCH v2 00/10] driver core: Disable driver overriding by default Uwe Kleine-König
2026-11-20 11:11 ` [PATCH v2 05/10] uio: Allow untainted use of driver_override Uwe Kleine-König
2026-11-20 20:08   ` Michael Kelley
2026-11-21  1:16 ` [PATCH v2 00/10] driver core: Disable driver overriding by default Danilo Krummrich
2026-11-26  1:57 ` Gary Guo
2026-11-26  2:13   ` Gary Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox