mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
bus: fsl-mc: use generic driver_override infrastructure
When a driver is probed through __driver_attach(), the bus' match()
callback is called without the device lock held, thus accessing the
driver_override field without a lock, which can cause a UAF.
Fix this by using the driver-core driver_override infrastructure taking
care of proper locking internally.
Note that calling match() from __driver_attach() without the device lock
held is intentional. [1]
Tested-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Acked-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Acked-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Link: https://lore.kernel.org/driver-core/DGRGTIRHA62X.3RY09D9SOK77P@kernel.org/ [1]
Reported-by: Gui-Dong Han <hanguidong02@gmail.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220789
Fixes: 1f86a00c11 ("bus/fsl-mc: add support for 'driver_override' in the mc-bus")
Link: https://patch.msgid.link/20260324005919.2408620-3-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
@@ -424,9 +424,7 @@ static int vfio_fsl_mc_bus_notifier(struct notifier_block *nb,
|
||||
|
||||
if (action == BUS_NOTIFY_ADD_DEVICE &&
|
||||
vdev->mc_dev == mc_cont) {
|
||||
mc_dev->driver_override = kasprintf(GFP_KERNEL, "%s",
|
||||
vfio_fsl_mc_ops.name);
|
||||
if (!mc_dev->driver_override)
|
||||
if (device_set_driver_override(dev, vfio_fsl_mc_ops.name))
|
||||
dev_warn(dev, "VFIO_FSL_MC: Setting driver override for device in dprc %s failed\n",
|
||||
dev_name(&mc_cont->dev));
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user