lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9323BB3E-EE65-4863-8060-FC124066C456@nutanix.com>
Date: Thu, 2 Oct 2025 12:04:32 +0000
From: Vincent Liu <vincent.liu@...anix.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
CC: "Rafael J. Wysocki" <rafael@...nel.org>,
        Danilo Krummrich
	<dakr@...nel.org>,
        "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>,
        "bhelgaas@...gle.com" <bhelgaas@...gle.com>,
        "linux-pci@...r.kernel.org" <linux-pci@...r.kernel.org>
Subject: Re: [PATCH] driver core: PCI: Check drivers_autoprobe for all added
 devices

On 2 Oct 2025, at 06:55, Greg Kroah-Hartman <gregkh@...uxfoundation.org> wrote:
> 
> If this is a PCI-specific issue, why not cc: the pci developers and
> maintainer as well?
> 
> Also, a PCI patch shouldn't be for the driver-core only, I think the
> subject line needs to have "driver core" in it.

You are right, this won’t be PCI-specific. And will affect all (future) callers of
device_initial_probe. Currently there are only two callers, bus_probe_device
and pci_bus_add_device, hence this change only affects PCI devices for
now. But in the future if there are more callers, then those devices will get
this behaviour as well. I’ll make this clear in the commit message, and the
subject.

Also ccing the pci developers.

> I don't see why this is specific to PCI VF devices.  

I included PCI VF devices and hot-plugged PCIe devices here because
those are the only two examples that I can think of that supports
“hot-plugging” (at least on the PCI bus), as cold-plugged PCI devices
will still use the default value of drivers_autoprobe, so will not be
affected by this patch. Devices on other buses should maintain their
current behaviour, as explained above.


> Did you see the
> recent PCI patch for not probing VF devices that was sent out yesterday?
> I think that might fix this instead:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20251002020010.315944-2D1-2Djhubbard-40nvidia.com&d=DwIBAg&c=s883GpUCOChKOHiocYtGcg&r=C7C0cxreo6ySFXxtT1zeCPCXI1KQm0FvA2Qq3148J_o&m=2oab-T75r4KLDtgw7uMI8jSQdHz-AKdHuTf2hLRfs7NKcDaAE-FbL5ejYixSNw6E&s=7dPLQqzutOX8VN5aZmpoliZk10DYGPzrmWGQhTKC6ec&e=
> 

As far as I can tell, patch above is about an optimisation on avoiding 
checking a driver for VF device if it doesn’t support VFs at all? This patch 
is about respecting the drivers_autoprobe sysfs knob.

Here is a rephrased commit message (no code change), happy to send a
v2 if needed.

Thanks,
Vincent

-- >8 --

Subject: [PATCH] driver core: PCI: Check drivers_autoprobe for all added
devices

When a device is hot-plugged, the drivers_autoprobe sysfs attribute is
not checked. This means that drivers_autoprobe is not working as
intended, e.g. hot-plugged PCIe devices will still be autoprobed and
bound to drivers even with drivers_autoprobe disabled.

Make sure all devices check drivers_autoprobe by pushing the
drivers_autoprobe check into device_initial_probe. This will only
affect devices on the PCI bus for now as device_initial_probe is only
called by pci_bus_add_device and bus_probe_device (but bus_probe_device
already checks for autoprobe). In particular for the PCI devices, only
hot-plugged PCIe devices/VFs should be affected as the default value of
pci/drivers_autoprobe remains 1 and can only be cleared from userland.

Any future callers of device_initial_probe will respsect the
drivers_autoprobe sysfs attribute, but this should be the intended
purpose of drivers_autoprobe.

Signed-off-by: Vincent Liu <vincent.liu@...anix.com>

Link: https://lore.kernel.org/20251001151508.1684592-1-vincent.liu@nutanix.com
---
drivers/base/bus.c |  3 +--
drivers/base/dd.c  | 10 +++++++++-
2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 5e75e1bce551..320e155c6be7 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -533,8 +533,7 @@ void bus_probe_device(struct device *dev)
       if (!sp)
               return;

-       if (sp->drivers_autoprobe)
-               device_initial_probe(dev);
+       device_initial_probe(dev);

       mutex_lock(&sp->mutex);
       list_for_each_entry(sif, &sp->interfaces, node)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 13ab98e033ea..37fc57e44e54 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -1077,7 +1077,15 @@ EXPORT_SYMBOL_GPL(device_attach);

void device_initial_probe(struct device *dev)
{
-       __device_attach(dev, true);
+       struct subsys_private *sp = bus_to_subsys(dev->bus);
+
+       if (!sp)
+               return;
+
+       if (sp->drivers_autoprobe)
+               __device_attach(dev, true);
+
+       subsys_put(sp);
}

/*
--
2.43.7

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ