Skip to contentSkip to conversation

driver core: Disable driver overriding by default

PATCH In review Uwe Kleine-König 3 participants 14 messages Dec 4

Subsystems (38)
lore
Share & tools
lore
#0 lore raw

v3 cover driver core: Disable driver overriding by default

Hello,

here comes v3 of this series, compared to v2[1] the following things changed:

- reshuffled the series to have patches which I consider adequately acked by maintainers to be picked up (that is patch #2 (spi) for sure, I'd say #3-#5 (remoteproc, s390/*) are fine, too).

- Added a patch by Peter Oberparleiter that was created in reply to v2's patch #4

- Dropped a =1 in patch #1's commit log that I failed to adapt for the changed parameter usage, thanks to Michael Kelley.

As before this series closes the possibility for root-triggered oopses which happen for many drivers when bound to devices they don't match to without the driver_override mechanism. With this series drivers must explicitly allow matching devices using driver_override. If a driver is missed, this can be easily addressed by setting the new driver flag (as done in patches #2 and later) and for end-users there is a kernel parameter that can be set without source changes to restore the current behaviour (with a taint however).

Danilo Krummrich wrote that he expects a stable branch won't be needed and just taking the whole patch set via driver-core should be fine. I'd give him the responsibility to judge if the patches without maintainer feedback should be picked, too. If you're such a maintainer, an ack would be helpful for sure. That would be:

- patch #6: PCI: Allow untainted driver_override for PCI stub drivers Bjorn Helgaas <[email protected]>

- patch #7: vfio: Allow untainted use of driver_override Alex Williamson <[email protected]> (I assume that one is fine, too, given he is the author of the patch)

- patch #8: uio: Allow untainted use of driver_override Greg Kroah-Hartman <[email protected]>

- patch #9: clk: imx: scu: Allow untainted use of driver_override Stephen Boyd <[email protected]>
Brian Masney <[email protected]>
Jerome Brunet <[email protected]>

- patch #10: slimbus: qcom-ngd-ctrl: Allow untainted use of driver_override Srinivas Kandagatla <[email protected]>

- patch #11: ASoC: samsung: i2s: Allow untainted use of driver_override Liam Girdwood <[email protected]>
Mark Brown <[email protected]>
Jaroslav Kysela <[email protected]> (?)
Takashi Iwai <[email protected]> (?)

Gary Guo mentioned an alternative for some busses in
https://lore.kernel.org/lkml/[email protected] . I didn't check/understood his proposal in detail, but I think for all the busses that don't have their own override management the approach from this patch set is the way to go. For the busses mentioned by Gary (CDX, PCI, s390/css, s390/ap, spi, and vdpa) the special handling can be discussed separately.
@Gary: Please speak up if I misjudged that and this series needs adaption.

Best regards
Uwe

[1] https:/lore.kernel.org/lkml/[email protected]

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

Peter Oberparleiter (1):
s390/cio: Allow untainted use of driver_override

Uwe Kleine-König (7):
driver core: Disable driver overriding by default
spi: spidev: Allow untainted use of driver_override
remoteproc: Allow untainted use of driver_override
uio: Allow untainted use of driver_override
clk: imx: scu: 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/device.c                     |  1 +
 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 ++++
 37 files changed, 145 insertions(+), 55 deletions(-)

base-commit: 0b5bb03d26a268f2606e3f574b277a1105136328

Signature · 1 line
2.47.3
#1 lore raw

PATCH v3 1/11 driver core: Disable driver overriding by default

Driver overriding is useful only in a very limited set of situations and then only with very few drivers that are designed to support that.

Disallow matching via driver_override unless the driver explicitly allows it or the safe guard is disabled using the "allow_driver_override" kernel parameter.

There are many drivers that don't expect to be force-bound and often doing it anyhow results in a NULL pointer exception. To make debugging such cases easier, add a new taint if such a forced match happens.

Implementation detail: device_match_driver_override() isn't a static inline any more. It grew a certain complexity (e.g. a pr_info()) and so was made a regular exported function.

---
 .../admin-guide/kernel-parameters.txt         |  6 +++
 Documentation/admin-guide/tainted-kernels.rst | 54 ++++++++++---------
 drivers/base/bus.c                            | 51 ++++++++++++++++++
 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 +-
 tools/debugging/kernel-chktaint               |  9 ++++
 9 files changed, 105 insertions(+), 45 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +6 -0
index e360b230a56d..ff9b57daca6a 100644
@@ -424,6 +424,12 @@ Kernel parameters
 			do not want to use tracing_snapshot_alloc() as it needs
 			to be done where GFP_KERNEL allocations are allowed.
 
+	allow_driver_override
+			Allow matching drivers without
+			.support_driver_override = true to devices using
+			driver_override. This is a dangerous operation in
+			general allowing root to oops the kernel.
+
 	allow_mismatched_32bit_el0 [ARM64,EARLY]
 			Allow execve() of 32-bit applications and setting of the
 			PER_LINUX32 personality on systems where only a strict
Documentation/admin-guide/tainted-kernels.rst +29 -25

67 lines not on this page · raw message

drivers/base/bus.c +51 -0

57 lines not on this page · raw message

include/linux/device.h +2 -17
index 6b082c638d45..05413c1a9454 100644
@@ -907,23 +907,8 @@ static inline bool device_has_driver_override(struct device *dev)
 	return !!dev->driver_override.name;
 }
 
-/**
- * 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.
- */
-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);
-	return -1;
-}
+int device_match_driver_override(struct device *dev,
+				 const struct device_driver *drv);
 
 /**
  * device_iommu_mapped - Returns true when the device DMA is translated
include/linux/device/driver.h +2 -0
index 29fbc01ef06f..0153cfcbe1b9 100644
@@ -56,6 +56,7 @@ enum probe_type {
  * @bus:	The bus which the device of this driver belongs to.
  * @owner:	The module owner.
  * @mod_name:	Used for built-in modules.
+ * @support_driver_override: driver_override only works if this is true.
  * @suppress_bind_attrs: Disables bind/unbind via sysfs.
  * @probe_type:	Type of the probe (synchronous or asynchronous) to use.
  * @of_match_table: The open firmware table.
@@ -104,6 +105,7 @@ struct device_driver {
 	struct module		*owner;
 	const char		*mod_name;	/* used for built-in modules */
 
+	bool support_driver_override;
 	bool suppress_bind_attrs;	/* disables bind/unbind via sysfs */
 	enum probe_type probe_type;
 
include/linux/panic.h +2 -1
index 17e61b61c45f..009232511cc7 100644
@@ -89,7 +89,8 @@ static inline void set_arch_panic_timeout(int timeout, int arch_default_timeout)
 #define TAINT_RANDSTRUCT		17
 #define TAINT_TEST			18
 #define TAINT_FWCTL			19
-#define TAINT_FLAGS_COUNT		20
+#define TAINT_DRIVER_OVERRIDE		20
+#define TAINT_FLAGS_COUNT		21
 #define TAINT_FLAGS_MAX			((1UL << TAINT_FLAGS_COUNT) - 1)
 
 struct taint_flag {
include/trace/events/module.h +2 -1
index e5a006be9dc6..d54ce3c7572b 100644
@@ -26,7 +26,8 @@ struct module;
 	{ (1UL << TAINT_OOT_MODULE),		"O" },		\
 	{ (1UL << TAINT_FORCED_MODULE),		"F" },		\
 	{ (1UL << TAINT_CRAP),			"C" },		\
-	{ (1UL << TAINT_UNSIGNED_MODULE),	"E" })
+	{ (1UL << TAINT_UNSIGNED_MODULE),	"E" },		\
+	{ (1UL << TAINT_DRIVER_OVERRIDE),	"Z" })
 
 TRACE_EVENT(module_load,
 
kernel/panic.c +2 -1
index 39376f270a9a..055a0f021564 100644
@@ -826,6 +826,7 @@ const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = {
 	TAINT_FLAG(RANDSTRUCT,			'T', ' '),
 	TAINT_FLAG(TEST,			'N', ' '),
 	TAINT_FLAG(FWCTL,			'J', ' '),
+	TAINT_FLAG(DRIVER_OVERRIDE,		'Z', ' '),
 };
 
 #undef TAINT_FLAG
@@ -862,7 +863,7 @@ static void print_tainted_seq(struct seq_buf *s, bool verbose)
  * exact size is allocated dynamically; the initial buffer remains
  * as a fallback if allocation fails.
  *
- * The verbose taint string currently requires up to 327 characters.
+ * The verbose taint string currently requires up to 348 characters.
  */
 #define INIT_TAINT_BUF_MAX 350
 
tools/debugging/kernel-chktaint +9 -0
index e1571c04afb5..56215e0f5112 100755
@@ -211,6 +211,15 @@ else
 	addout "J"
 	echo " * fwctl's mutating debug interface was used (#19)"
 fi
+
+T=`expr $T / 2`
+if [ `expr $T % 2` -eq 0 ]; then
+	addout " "
+else
+	addout "Z"
+	echo " * A device was matched using driver_override to a driver not supporting that (#20)"
+fi
+
 echo "Raw taint value as int/string: $taint/'$out'"
 
 # report on any tainted loadable modules
Signature · 1 line
2.47.3
#2 lore raw

PATCH v3 2/11 spi: spidev: Allow untainted use of driver_override

In reply to Uwe Kleine-König

The spidev driver is designed to be bound to devices using the driver_override mechanism. Set .support_driver_override = true to continue having this mechanism work for it without tainting the kernel.

---
 drivers/spi/spidev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/spi/spidev.c +1 -0
index 15d2aaeb08e9..0b50474ab20b 100644
@@ -843,6 +843,7 @@ static struct spi_driver spidev_spi_driver = {
 		.name =		"spidev",
 		.of_match_table = spidev_dt_ids,
 		.acpi_match_table = spidev_acpi_ids,
+		.support_driver_override = true,
 	},
 	.probe =	spidev_probe,
 	.remove =	spidev_remove,
Signature · 1 line
2.47.3
#3 lore raw

PATCH v3 3/11 remoteproc: Allow untainted use of driver_override

In reply to Uwe Kleine-König

The two drivers are expected to be bound to devices using a driver override. (See the respective use of device_set_driver_override()) and so should be allowed to match via that mechanism.

---
 drivers/rpmsg/rpmsg_ctrl.c | 1 +
 drivers/rpmsg/rpmsg_ns.c   | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/rpmsg/rpmsg_ctrl.c +1 -0
index 5c19188d0294..79ae495c9c07 100644
@@ -210,6 +210,7 @@ static struct rpmsg_driver rpmsg_ctrldev_driver = {
 	.remove = rpmsg_ctrldev_remove,
 	.drv = {
 		.name = "rpmsg_ctrl",
+		.support_driver_override = true,
 	},
 };
 
drivers/rpmsg/rpmsg_ns.c +4 -1
index bde8c8d433e0..820dabbc9500 100644
@@ -96,7 +96,10 @@ static int rpmsg_ns_probe(struct rpmsg_device *rpdev)
 }
 
 static struct rpmsg_driver rpmsg_ns_driver = {
-	.drv.name = KBUILD_MODNAME,
+	.drv = {
+		.name = KBUILD_MODNAME,
+		.support_driver_override = true,
+	},
 	.probe = rpmsg_ns_probe,
 };
 
Signature · 1 line
2.47.3
#4 lore raw

PATCH v3 4/11 s390/vfio: Allow untainted use of driver_override

In reply to Uwe Kleine-König

From: Alex Williamson <[email protected]>

The vfio_ap and vfio_ccw drivers bind devices through driver_override. With the introduction of the support_driver_override flag in the core driver struct, it's now required for drivers to declare themselves as driver_override compatible, otherwise driver_override bindings will be denied or generate a kernel taint.

Set the support_driver_override flag on the vfio_ap and vfio_ccw driver structs.

---
 drivers/s390/cio/vfio_ccw_drv.c   | 1 +
 drivers/s390/crypto/vfio_ap_drv.c | 1 +
 2 files changed, 2 insertions(+)
drivers/s390/cio/vfio_ccw_drv.c +1 -0
index 7546bd137e4e..77765cde87f7 100644
@@ -375,6 +375,7 @@ static struct css_driver vfio_ccw_sch_driver = {
 	.drv = {
 		.name = "vfio_ccw",
 		.owner = THIS_MODULE,
+		.support_driver_override = true,
 	},
 	.subchannel_type = vfio_ccw_sch_ids,
 	.irq = vfio_ccw_sch_irq,
drivers/s390/crypto/vfio_ap_drv.c +1 -0
index 8e69ed286bb9..2d47dc643269 100644
@@ -62,6 +62,7 @@ static struct ap_driver vfio_ap_drv = {
 	.on_config_changed = vfio_ap_on_cfg_changed,
 	.on_scan_complete = vfio_ap_on_scan_complete,
 	.ids = ap_queue_ids,
+	.driver.support_driver_override = true,
 };
 
 static void vfio_ap_matrix_dev_release(struct device *dev)
Signature · 1 line
2.47.3
maintainer Acked-by on v3 4/11
#5 lore raw

Re: [PATCH v3 04/11] s390/vfio: Allow untainted use of driver_override

Quoted 38 lines · Uwe Kleine-König

From: Alex Williamson <[email protected]>

The vfio_ap and vfio_ccw drivers bind devices through driver_override. With the introduction of the support_driver_override flag in the core driver struct, it's now required for drivers to declare themselves as driver_override compatible, otherwise driver_override bindings will be denied or generate a kernel taint.

Set the support_driver_override flag on the vfio_ap and vfio_ccw driver structs.

---
  drivers/s390/cio/vfio_ccw_drv.c   | 1 +
  drivers/s390/crypto/vfio_ap_drv.c | 1 +
  2 files changed, 2 insertions(+)
drivers/s390/cio/vfio_ccw_drv.c +1 -0
index 7546bd137e4e..77765cde87f7 100644
@@ -375,6 +375,7 @@ static struct css_driver vfio_ccw_sch_driver = {
  	.drv = {
  		.name = "vfio_ccw",
  		.owner = THIS_MODULE,
+		.support_driver_override = true,
  	},
  	.subchannel_type = vfio_ccw_sch_ids,
  	.irq = vfio_ccw_sch_irq,
drivers/s390/crypto/vfio_ap_drv.c +0 -0
index 8e69ed286bb9..2d47dc643269 100644

drivers/s390/crypto/vfio_ap_drv.c static struct ap_driver vfio_ap_drv = { · line 65

Quoted 4 lines
drivers/s390/crypto/vfio_ap_drv.c +1 -0
@@ -62,6 +62,7 @@ static struct ap_driver vfio_ap_drv = {
  	.on_config_changed = vfio_ap_on_cfg_changed,
  	.on_scan_complete = vfio_ap_on_scan_complete,
  	.ids = ap_queue_ids,
+	.driver.support_driver_override = true,
Quoted 3 lines
drivers/s390/crypto/vfio_ap_drv.c +0 -0
  };
 
  static void vfio_ap_matrix_dev_release(struct device *dev)
#6 lore raw

PATCH v3 5/11 s390/cio: Allow untainted use of driver_override

In reply to Uwe Kleine-König

From: Peter Oberparleiter <[email protected]>

I/O subchannel devices on the CSS bus can be bound to either of two drivers:

1. io_subchannel: the default driver
2. vfio_ccw: used for KVM guest pass-through

Although the CSS bus also hosts devices that are not I/O subchannels, css_bus_match() ensures that only compatible drivers can be bound, even when driver_override is used.

A previous change marked vfio_ccw as compatible with driver_override as part of the logic that disables driver_override by default. This created an asymmetry between vfio_ccw and io_subchannel: users can switch a subchannel device from io_subchannel to vfio_ccw, but not back to io_subchannel.

Restore symmetry by marking io_subchannel as compatible with driver_override as well.

---
 drivers/s390/cio/device.c | 1 +
 1 file changed, 1 insertion(+)
drivers/s390/cio/device.c +1 -0
index 68dd4a62975d..bfb0a18c395a 100644
@@ -164,6 +164,7 @@ static struct css_driver io_subchannel_driver = {
 	.drv = {
 		.owner = THIS_MODULE,
 		.name = "io_subchannel",
+		.support_driver_override = true,
 	},
 	.subchannel_type = io_subchannel_ids,
 	.irq = io_subchannel_irq,
Signature · 1 line
2.47.3
#7 lore raw

PATCH v3 6/11 PCI: Allow untainted driver_override for PCI stub drivers

In reply to Uwe Kleine-König

From: Alex Williamson <[email protected]>

As the name suggests, the pci-stub driver is only a stub, it performs no hardware access and is typically used only to prevent other drivers from binding to the device.

Similarly, pci-pf-stub only interacts with devices through the SR-IOV capability, and may be used to create VFs on any PF that otherwise does not require a PF driver.

Both of these are often used with driver_override, as this is our standard, non-racy mechanism for associating a driver to a device. With the introduction of support_driver_override in driver core, this use case needs to be explicitly flagged as safe or else the bind will be denied or taint the kernel. Declare these drivers as safe for use with driver_override.

---
 drivers/pci/pci-pf-stub.c | 1 +
 drivers/pci/pci-stub.c    | 1 +
 2 files changed, 2 insertions(+)
drivers/pci/pci-pf-stub.c +1 -0
index da4db4928907..328fb4a57092 100644
@@ -36,6 +36,7 @@ static struct pci_driver pf_stub_driver = {
 	.id_table		= pci_pf_stub_whitelist,
 	.probe			= pci_pf_stub_probe,
 	.sriov_configure	= pci_sriov_configure_simple,
+	.driver.support_driver_override = true,
 };
 module_pci_driver(pf_stub_driver);
 
drivers/pci/pci-stub.c +1 -0
index 9bc478df4e8f..acbd43c17adc 100644
@@ -37,6 +37,7 @@ static struct pci_driver stub_driver = {
 	.id_table	= NULL,	/* only dynamic id's */
 	.probe		= pci_stub_probe,
 	.driver_managed_dma = true,
+	.driver.support_driver_override = true,
 };
 
 static int __init pci_stub_init(void)
Signature · 1 line
2.47.3
#8 lore raw

PATCH v3 7/11 vfio: Allow untainted use of driver_override

In reply to Uwe Kleine-König

From: Alex Williamson <[email protected]>

Driver overrides are the standard mechanism for binding vfio drivers to devices. With the introduction of the support_driver_override flag in the core driver struct, it's now required for drivers to declare themselves as driver_override compatible, otherwise driver_override bindings will be denied or generate a kernel taint.

Set the support_driver_override flag on the driver struct across all vfio drivers.

---
 drivers/vfio/cdx/main.c                        | 1 +
 drivers/vfio/fsl-mc/vfio_fsl_mc.c              | 1 +
 drivers/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 +
 13 files changed, 22 insertions(+), 9 deletions(-)
drivers/vfio/cdx/main.c +1 -0
index 28dc8c825600..fb7679bf92fd 100644
@@ -358,6 +358,7 @@ static struct cdx_driver vfio_cdx_driver = {
 	.match_id_table	= vfio_cdx_table,
 	.driver	= {
 		.name	= "vfio-cdx",
+		.support_driver_override = true,
 	},
 	.driver_managed_dma = true,
 };
drivers/vfio/fsl-mc/vfio_fsl_mc.c +1 -0
index 15b05b8c0c90..1603f81e0257 100644
@@ -597,6 +597,7 @@ static struct fsl_mc_driver vfio_fsl_mc_driver = {
 	.remove		= vfio_fsl_mc_remove,
 	.driver	= {
 		.name	= "vfio-fsl-mc",
+		.support_driver_override = true,
 	},
 	.driver_managed_dma = true,
 };
drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +2 -1
index c82c59246a3f..5c56aff8db01 100644
@@ -1737,7 +1737,8 @@ static struct pci_driver hisi_acc_vfio_pci_driver = {
 	.id_table = hisi_acc_vfio_pci_table,
 	.probe = hisi_acc_vfio_pci_probe,
 	.remove = hisi_acc_vfio_pci_remove,
-	.driver = { .pm = pm_ptr(&hisi_acc_vf_pm_ops) },
+	.driver = { .pm = pm_ptr(&hisi_acc_vf_pm_ops),
+		    .support_driver_override = true },
 	.err_handler = &hisi_acc_vf_err_handlers,
 	.driver_managed_dma = true,
 };
drivers/vfio/pci/ism/main.c +2 -1
index cce3bdf1f070..263b377e87c4 100644
@@ -399,7 +399,8 @@ static struct pci_driver ism_vfio_pci_driver = {
 	.id_table = ism_device_table,
 	.probe = ism_vfio_pci_probe,
 	.remove = ism_vfio_pci_remove,
-	.driver	= { .pm = pm_ptr(&ism_vfio_pm_ops) },
+	.driver	= { .pm = pm_ptr(&ism_vfio_pm_ops),
+		    .support_driver_override = true },
 	.err_handler = &ism_vfio_err_handlers,
 	.driver_managed_dma = true,
 };
drivers/vfio/pci/mlx5/main.c +2 -1
index ebcc22bcb754..41695d975ad3 100644
@@ -1456,7 +1456,8 @@ static struct pci_driver mlx5vf_pci_driver = {
 	.id_table = mlx5vf_pci_table,
 	.probe = mlx5vf_pci_probe,
 	.remove = mlx5vf_pci_remove,
-	.driver	= { .pm = pm_ptr(&mlx5vf_pm_ops) },
+	.driver	= { .pm = pm_ptr(&mlx5vf_pm_ops),
+		    .support_driver_override = true },
 	.err_handler = &mlx5vf_err_handlers,
 	.driver_managed_dma = true,
 };
drivers/vfio/pci/nvgrace-gpu/main.c +2 -1
index 5ddec340b73b..946da32c61ff 100644
@@ -1438,7 +1438,8 @@ static struct pci_driver nvgrace_gpu_vfio_pci_driver = {
 	.id_table = nvgrace_gpu_vfio_pci_table,
 	.probe = nvgrace_gpu_probe,
 	.remove = nvgrace_gpu_remove,
-	.driver = { .pm = pm_ptr(&nvgrace_gpu_pm_ops) },
+	.driver = { .pm = pm_ptr(&nvgrace_gpu_pm_ops),
+		    .support_driver_override = true },
 	.err_handler = &nvgrace_gpu_vfio_pci_err_handlers,
 	.driver_managed_dma = true,
 };
drivers/vfio/pci/pds/pci_drv.c +2 -1
index cf7e33d4d17b..1fcef987f1b0 100644
@@ -184,7 +184,8 @@ static struct pci_driver pds_vfio_pci_driver = {
 	.id_table = pds_vfio_pci_table,
 	.probe = pds_vfio_pci_probe,
 	.remove = pds_vfio_pci_remove,
-	.driver = { .pm = pm_ptr(&pds_vfio_pm_ops) },
+	.driver = { .pm = pm_ptr(&pds_vfio_pm_ops),
+		    .support_driver_override = true },
 	.err_handler = &pds_vfio_pci_err_handlers,
 	.driver_managed_dma = true,
 };
drivers/vfio/pci/qat/main.c +2 -1
index 69448fa57df4..8a616f9b6494 100644
@@ -695,7 +695,8 @@ static struct pci_driver qat_vf_vfio_pci_driver = {
 	.id_table = qat_vf_vfio_pci_table,
 	.probe = qat_vf_vfio_pci_probe,
 	.remove = qat_vf_vfio_pci_remove,
-	.driver	= { .pm = pm_ptr(&qat_vf_pm_ops) },
+	.driver	= { .pm = pm_ptr(&qat_vf_pm_ops),
+		    .support_driver_override = true },
 	.err_handler = &qat_vf_err_handlers,
 	.driver_managed_dma = true,
 };
drivers/vfio/pci/vfio_pci.c +2 -1
index e7c012febe91..fde2c3fc88eb 100644
@@ -260,7 +260,8 @@ static struct pci_driver vfio_pci_driver = {
 	.remove			= vfio_pci_remove,
 	.sriov_configure	= vfio_pci_sriov_configure,
 	.err_handler		= &vfio_pci_err_handlers,
-	.driver		= { .pm = pm_ptr(&vfio_pci_pm_ops) },
+	.driver		= { .pm = pm_ptr(&vfio_pci_pm_ops),
+			    .support_driver_override = true },
 	.driver_managed_dma	= true,
 };
 
drivers/vfio/pci/virtio/main.c +2 -1
index 123ff5193812..1e02a8fd4a61 100644
@@ -222,7 +222,8 @@ static struct pci_driver virtiovf_pci_driver = {
 	.id_table = virtiovf_pci_table,
 	.probe = virtiovf_pci_probe,
 	.remove = virtiovf_pci_remove,
-	.driver = { .pm = pm_ptr(&virtiovf_pm_ops) },
+	.driver = { .pm = pm_ptr(&virtiovf_pm_ops),
+		    .support_driver_override = true },
 	.err_handler = &virtiovf_err_handlers,
 	.driver_managed_dma = true,
 };
drivers/vfio/pci/xe/main.c +2 -1
index 7dab3e024aa8..e0ab61f604de 100644
@@ -592,7 +592,8 @@ static struct pci_driver xe_vfio_pci_driver = {
 	.id_table = xe_vfio_pci_table,
 	.probe = xe_vfio_pci_probe,
 	.remove = xe_vfio_pci_remove,
-	.driver = { .pm = pm_ptr(&xe_vfio_pm_ops) },
+	.driver = { .pm = pm_ptr(&xe_vfio_pm_ops),
+		    .support_driver_override = true },
 	.err_handler = &xe_vfio_pci_err_handlers,
 	.driver_managed_dma = true,
 };
drivers/vfio/platform/vfio_amba.c +1 -0
index fa754f203b2d..2c87caf1b7f7 100644
@@ -137,6 +137,7 @@ static struct amba_driver vfio_amba_driver = {
 	.id_table = vfio_amba_ids,
 	.drv = {
 		.name = "vfio-amba",
+		.support_driver_override = true,
 	},
 	.driver_managed_dma = true,
 };
drivers/vfio/platform/vfio_platform.c +1 -0
index a4d3ace3e02d..93d06032cdde 100644
@@ -116,6 +116,7 @@ static struct platform_driver vfio_platform_driver = {
 	.remove		= vfio_platform_remove,
 	.driver	= {
 		.name	= "vfio-platform",
+		.support_driver_override = true,
 	},
 	.driver_managed_dma = true,
 };
Signature · 1 line
2.47.3
#9 lore raw

PATCH v3 8/11 uio: Allow untainted use of driver_override

In reply to Uwe Kleine-König

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.

---
 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(+)
drivers/uio/uio_dmem_genirq.c +1 -0
index 263c1ebc2d57..71992431770e 100644
@@ -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,
 	},
 };
 
drivers/uio/uio_hv_generic.c +1 -0
index dff92dcbb10d..255c2b5730f6 100644
@@ -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
drivers/uio/uio_pci_generic.c +1 -0
index c0cab3adb7b0..9785df9fc5de 100644
@@ -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);
drivers/uio/uio_pdrv_genirq.c +1 -0
index 87e43821ab0c..022178248962 100644
@@ -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,
 	},
 };
 
Signature · 1 line
2.47.3
maintainer Acked-by on v3 8/11
#10 lore raw

Re: [PATCH v3 08/11] uio: Allow untainted use of driver_override

Quoted 7 lines · Uwe Kleine-König

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.

This patch is just a technicality, if the rest is merged, this part is ok. Without taking any position on the rest, this one:

Quoted 58 lines
---
 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(+)
drivers/uio/uio_dmem_genirq.c +1 -0
index 263c1ebc2d57..71992431770e 100644
@@ -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,
 	},
 };
 
drivers/uio/uio_hv_generic.c +1 -0
index dff92dcbb10d..255c2b5730f6 100644
@@ -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
drivers/uio/uio_pci_generic.c +1 -0
index c0cab3adb7b0..9785df9fc5de 100644
@@ -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);
drivers/uio/uio_pdrv_genirq.c +1 -0
index 87e43821ab0c..022178248962 100644
@@ -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,
 	},
 };
 
Signature · 1 line
2.47.3
#11 lore raw

PATCH v3 9/11 clk: imx: scu: Allow untainted use of driver_override

In reply to Uwe Kleine-König

The driver makes use of device_set_driver_override and so should be allowed to match via that driver_override. Note that the .probe() function assumes that platform_data is set for the device to bind, so it can very likely allow root to oops the kernel. This is not a regression however.

---
 drivers/clk/imx/clk-scu.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/imx/clk-scu.c +1 -0
index 0d034e206c6b..7622890d1124 100644
@@ -626,6 +626,7 @@ static struct platform_driver imx_clk_scu_driver = {
 		.name = "imx-scu-clk",
 		.suppress_bind_attrs = true,
 		.pm = &imx_clk_scu_pm_ops,
+		.support_driver_override = true,
 	},
 	.probe = imx_clk_scu_probe,
 };
Signature · 1 line
2.47.3
#12 lore raw

PATCH v3 10/11 slimbus: qcom-ngd-ctrl: Allow untainted use of driver_override

In reply to Uwe Kleine-König

The driver is expected to be bound to devices using a driver override---see the respective use of device_set_driver_override()---and so should be allowed to match via that mechanism.

---
 drivers/slimbus/qcom-ngd-ctrl.c | 1 +
 1 file changed, 1 insertion(+)
drivers/slimbus/qcom-ngd-ctrl.c +1 -0
index a29e57303046..5ac4dee87f6f 100644
@@ -1849,6 +1849,7 @@ static struct platform_driver qcom_slim_ngd_driver = {
 	.driver	= {
 		.name = QCOM_SLIM_NGD_DRV_NAME,
 		.pm = &qcom_slim_ngd_dev_pm_ops,
+		.support_driver_override = true,
 	},
 };
 
Signature · 1 line
2.47.3
#13 lore raw

PATCH v3 11/11 ASoC: samsung: i2s: Allow untainted use of driver_override

In reply to Uwe Kleine-König

The driver is expected to be bound to devices using a driver override---see the respective use of device_set_driver_override()---and so should be allowed to match via that mechanism.

---
 sound/soc/samsung/i2s.c | 1 +
 1 file changed, 1 insertion(+)
sound/soc/samsung/i2s.c +1 -0
index 8a938d0d79f9..fdddd3d4eb65 100644
@@ -1740,6 +1740,7 @@ static struct platform_driver samsung_i2s_driver = {
 		.name = "samsung-i2s",
 		.of_match_table = of_match_ptr(exynos_i2s_match),
 		.pm = pm_ptr(&samsung_i2s_pm),
+		.support_driver_override = true,
 	},
 };
 
Signature · 1 line
2.47.3