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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230817235810.596458-3-alistair.francis@wdc.com>
Date:   Thu, 17 Aug 2023 19:58:10 -0400
From:   Alistair Francis <alistair23@...il.com>
To:     bhelgaas@...gle.com, linux-pci@...r.kernel.org,
        Jonathan.Cameron@...wei.com, lukas@...ner.de
Cc:     alex.williamson@...hat.com, christian.koenig@....com,
        kch@...dia.com, gregkh@...uxfoundation.org, logang@...tatee.com,
        linux-kernel@...r.kernel.org, alistair23@...il.com,
        chaitanyak@...dia.com, rdunlap@...radead.org,
        Alistair Francis <alistair.francis@....com>
Subject: [PATCH v6 3/3] PCI/DOE: Only expose the sysfs attribute group if DOE is supported

Now that the new attr_is_visible() function is avaliable as part of
`struct attribute_group` we can use that to hide the attribute group
on devices that don't support DOE.

Signed-off-by: Alistair Francis <alistair.francis@....com>
---
v6:
 - Add patch

 drivers/pci/doe.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/doe.c b/drivers/pci/doe.c
index 316aac60ccd5..1a021e8b3e0c 100644
--- a/drivers/pci/doe.c
+++ b/drivers/pci/doe.c
@@ -95,8 +95,7 @@ struct pci_doe_task {
 };
 
 #ifdef CONFIG_SYSFS
-static umode_t pci_doe_sysfs_attr_is_visible(struct kobject *kobj,
-					     struct attribute *a, int n)
+static umode_t pci_doe_sysfs_group_is_visible(struct kobject *kobj)
 {
 	struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
 	unsigned long total_features = 0;
@@ -112,7 +111,17 @@ static umode_t pci_doe_sysfs_attr_is_visible(struct kobject *kobj,
 	if (total_features == 0)
 		return 0;
 
-	return a->mode;
+	return S_IRWXU | S_IRUGO | S_IXUGO;
+}
+
+static umode_t pci_doe_sysfs_attr_is_visible(struct kobject *kobj,
+					     struct attribute *a, int n)
+{
+	if (pci_doe_sysfs_group_is_visible(kobj)) {
+		return a->mode;
+	}
+
+	return 0;
 }
 
 static struct attribute *pci_dev_doe_feature_attrs[] = {
@@ -122,6 +131,7 @@ static struct attribute *pci_dev_doe_feature_attrs[] = {
 const struct attribute_group pci_dev_doe_feature_group = {
 	.name	= "doe_features",
 	.attrs	= pci_dev_doe_feature_attrs,
+	.attr_is_visible = pci_doe_sysfs_group_is_visible,
 	.is_visible = pci_doe_sysfs_attr_is_visible,
 };
 
-- 
2.41.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ