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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADvopvZZKCdwT=XfaJzgFRgH=eXcTmjsdA8-86hJaki5PDjx=A@mail.gmail.com>
Date: Tue, 15 Jul 2025 08:59:42 -0700
From: Matthew Wood <thepacketgeek@...il.com>
To: Jonathan Cameron <Jonathan.Cameron@...wei.com>
Cc: Bjorn Helgaas <bhelgaas@...gle.com>, linux-pci@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH pci-next v1 0/1] PCI/sysfs: Expose PCIe device serial number

On Tue, Jul 15, 2025 at 4:19 AM Jonathan Cameron
<Jonathan.Cameron@...wei.com> wrote:
>
> On Sat, 12 Jul 2025 18:17:12 -0700
> Matthew Wood <thepacketgeek@...il.com> wrote:
>
> > Add a single sysfs read-only interface for reading PCIe device serial
> > numbers from userspace in a programmatic way. This device attribute
> > uses the same 2-byte dashed formatting as lspci serial number capability
> > output:
> >
> >     more /sys/devices/pci0000:c0/0000:c0:01.1/0000:c1:00.0/0000:c2:1f.0/0000:cc:00.0/device_serial_number
> >     00-80-ee-00-00-00-41-80
> >
>
> What is the use case for this? I can think of some possibilities but good to
> see why you care here.

Two primary use cases we have are for inventory tooling and health
check tooling; being able to
reliably collect device serial numbers for tracking unique devices
whose BDFs could change is
critical. Sometimes in the process of hardware troubleshooting, cards
are swapped and BDF idents
change but we want to track devices by serial number without possibly
fragile regexps.

>
>
> > Accompanying lspci output:
> >
> >     sudo lspci -vvv -s cc:00.0
> >         cc:00.0 Serial Attached SCSI controller: Broadcom / LSI PCIe Switch management endpoint (rev b0)
> >             Subsystem: Broadcom / LSI Device 0144
> >             ...
> >             Capabilities: [100 v1] Device Serial Number 00-80-ee-00-00-00-41-80
> >             ...
> >
> > If a device doesn't support the serial number capability, userspace will receive
> > an empty read:
>
> Better if possible to not expose the sysfs attribute if no such capability.
> We already have pcie_dev_attrs_are_visible() so easy to extend that.

That's a great point, it looks like I could match on the attribute
name to specifically hide device_serial_number
if the device does not support the cap, but I can't find any precedent
for matching on a->name in pci-sysfs.c.
Would something like this be alright after the check for pci_is_pcie(dev):

    if (a->name == "device_serial_number") {
        // check if device has serial, if not return 0
    }

>
>
> >
> >     more /sys/devices/pci0000:00/0000:00:07.1/device_serial_number
> >     echo $?
> >     0
> >
> >
> > Matthew Wood (1):
> >   PCI/sysfs: Expose PCIe device serial number
> >
> >  drivers/pci/pci-sysfs.c | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> >
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ