Skip to contentSkip to conversation

Platform integrity information in sysfs (version 9)

PATCH In review Daniel Gutson 4 participants 9 messages Sep 30, 2020 – Nov 10, 2020

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

cover Platform integrity information in sysfs (version 9)

This patch serie adds a misc kernel module and extends the intel-spi drivers to publish platform integrity data in the sys-fs.
Please check the comments in the following patches of this serie for further details.

Daniel Gutson (2):
Platform integrity information in sysfs (version 9)
This patch exports the BIOS Write Enable (bioswe), BIOS Lock Enable
(biosle), and the SMM BIOS Write Protect (SMM_BIOSWP) fields of the BIOS Control register using the platform-integrity misc kernel module. The idea is to keep adding more flags, not only from the BC but also from other registers in following versions.

 .../ABI/stable/sysfs-class-platform-integrity | 23 +++++
 MAINTAINERS                                   |  7 ++
 drivers/misc/Kconfig                          | 11 +++
 drivers/misc/Makefile                         |  1 +
 drivers/misc/platform-integrity.c             | 57 ++++++++++++
 drivers/mtd/spi-nor/controllers/Kconfig       |  1 +
 .../mtd/spi-nor/controllers/intel-spi-pci.c   | 75 +++++++++++++++-
 .../spi-nor/controllers/intel-spi-platform.c  |  2 +-
 drivers/mtd/spi-nor/controllers/intel-spi.c   | 90 ++++++++++++++++++-
 drivers/mtd/spi-nor/controllers/intel-spi.h   |  9 +-
 include/linux/platform-integrity.h            | 19 ++++
 11 files changed, 288 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/ABI/stable/sysfs-class-platform-integrity
 create mode 100644 drivers/misc/platform-integrity.c
 create mode 100644 include/linux/platform-integrity.h

--
2.25.1

#1 lore raw

PATCH 1/2 Platform integrity information in sysfs (version 9)

This patch provides a driver and an API for exporting information about the platform integrity firmware configuration in the sysfs filesystem.

The goal is that the attributes are avilable to fwupd.

---
 .../ABI/stable/sysfs-class-platform-integrity | 23 ++++++++
 MAINTAINERS                                   |  7 +++
 drivers/misc/Kconfig                          | 11 ++++
 drivers/misc/Makefile                         |  1 +
 drivers/misc/platform-integrity.c             | 56 +++++++++++++++++++
 include/linux/platform-integrity.h            | 19 +++++++
 6 files changed, 117 insertions(+)
 create mode 100644 Documentation/ABI/stable/sysfs-class-platform-integrity
 create mode 100644 drivers/misc/platform-integrity.c
 create mode 100644 include/linux/platform-integrity.h
Documentation/ABI/stable/sysfs-class-platform-integrity new file +23 -0
new file mode 100644
index 000000000000..0978079bde50
@@ -0,0 +1,23 @@
+What:		/sys/class/platform-integrity/intel-spi/bioswe
+Date:		September 2020
+KernelVersion:	5.10
+Contact:	Daniel Gutson <[email protected]>
+Description:	If the system firmware set BIOS Write Enable.
+		0: writes disabled, 1: writes enabled.
+Users:		https://github.com/fwupd/fwupd
+
+What:		/sys/class/platform-integrity/intel-spi/biosle
+Date:		September 2020
+KernelVersion:	5.10
+Contact:	Daniel Gutson <[email protected]>
+Description:	If the system firmware set BIOS Lock Enable.
+		0: SMM lock disabled, 1: SMM lock enabled.
+Users:		https://github.com/fwupd/fwupd
+
+What:		/sys/class/platform-integrity/intel-spi/smm_bioswp
+Date:		September 2020
+KernelVersion:	5.10
+Contact:	Daniel Gutson <[email protected]>
+Description:	If the system firmware set SMM BIOS Write Protect.
+		0: writes disabled unless in SMM, 1: writes enabled.
+Users:		https://github.com/fwupd/fwupd
MAINTAINERS +7 -0
index d746519253c3..98bd26cd1adc 100644
@@ -13774,6 +13774,13 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.yaml
 F:	drivers/iio/chemical/pms7003.c
 
+PLATFORM INTEGRITY DATA MODULE
+M:	Daniel Gutson <[email protected]>
+S:	Supported
+F:	Documentation/ABI/sysfs-class-platform-integrity
+F:	drivers/misc/platform-integrity.c
+F:	include/linux/platform-integrity.h
+
 PLDMFW LIBRARY
 M:	Jacob Keller <[email protected]>
 S:	Maintained
drivers/misc/Kconfig +11 -0
index ce136d685d14..8602049bd0ad 100644
@@ -456,6 +456,17 @@ config PVPANIC
 	  a paravirtualized device provided by QEMU; it lets a virtual machine
 	  (guest) communicate panic events to the host.
 
+config PLATFORM_INTEGRITY_DATA
+	bool "Platform integrity information in the sysfs"
+	depends on SYSFS
+	help
+	  This kernel module is a helper driver to provide information about
+	  platform integrity settings and configuration.
+	  This module is used by other device drivers -such as the intel-spi-
+	  to publish the information in /sys/class/platform-integrity which is
+	  consumed by software such as fwupd which can verify the platform
+	  has been configured in a secure way.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
index c7bd01ac6291..97ebb997fc47 100644
@@ -57,3 +57,4 @@ obj-$(CONFIG_PVPANIC)   	+= pvpanic.o
 obj-$(CONFIG_HABANA_AI)		+= habanalabs/
 obj-$(CONFIG_UACCE)		+= uacce/
 obj-$(CONFIG_XILINX_SDFEC)	+= xilinx_sdfec.o
+obj-$(CONFIG_PLATFORM_INTEGRITY_DATA)	+= platform-integrity.o
drivers/misc/platform-integrity.c new file +56 -0

56 lines not on this page · raw message

include/linux/platform-integrity.h new file +19 -0
new file mode 100644
index 000000000000..56eb1a1190e8
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Platform integrity data kernel module
+ *
+ * Copyright (C) 2020 Daniel Gutson <[email protected]>
+ * Copyright (C) 2020 Eclypsium Inc.
+ */
+#ifndef PLATFORM_INTEGRITY_H
+#define PLATFORM_INTEGRITY_H
+
+#include <linux/device.h>
+
+struct device *
+create_platform_integrity_device(struct device *parent, const char *name,
+				 const struct attribute_group **groups);
+
+extern void destroy_platform_integrity_device(struct device *pi_device);
+
+#endif /* PLATFORM_INTEGRITY_H */
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/2 Platform integrity information in sysfs (version 9)

In reply to Daniel Gutson

This patch exports the BIOS Write Enable (bioswe), BIOS
Lock Enable (biosle), and the SMM BIOS Write Protect (SMM_BIOSWP) fields of the BIOS Control register using the platform-integrity misc kernel module. The idea is to keep adding more flags, not only from the BC but also from other registers in following versions.

The goal is that the attributes are avilable to fwupd when SecureBoot is turned on.

---
 drivers/mtd/spi-nor/controllers/Kconfig       |  1 +
 .../mtd/spi-nor/controllers/intel-spi-pci.c   | 75 ++++++++++++++-
 .../spi-nor/controllers/intel-spi-platform.c  |  2 +-
 drivers/mtd/spi-nor/controllers/intel-spi.c   | 91 ++++++++++++++++++-
 drivers/mtd/spi-nor/controllers/intel-spi.h   |  9 +-
 5 files changed, 171 insertions(+), 7 deletions(-)
drivers/mtd/spi-nor/controllers/Kconfig +1 -0
index 5c0e0ec2e6d1..e7eaef506fc2 100644
@@ -29,6 +29,7 @@ config SPI_NXP_SPIFI
 
 config SPI_INTEL_SPI
 	tristate
+	depends on PLATFORM_INTEGRITY_DATA
 
 config SPI_INTEL_SPI_PCI
 	tristate "Intel PCH/PCU SPI flash PCI driver (DANGEROUS)"
drivers/mtd/spi-nor/controllers/intel-spi-pci.c +74 -1

98 lines not on this page · raw message

drivers/mtd/spi-nor/controllers/intel-spi-platform.c +1 -1
index f80f1086f928..5b1a9989426a 100644
@@ -23,7 +23,7 @@ static int intel_spi_platform_probe(struct platform_device *pdev)
 		return -EINVAL;
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	ispi = intel_spi_probe(&pdev->dev, mem, info);
+	ispi = intel_spi_probe(&pdev->dev, mem, info, NULL);
 	if (IS_ERR(ispi))
 		return PTR_ERR(ispi);
 
drivers/mtd/spi-nor/controllers/intel-spi.c +88 -3

139 lines not on this page · raw message

drivers/mtd/spi-nor/controllers/intel-spi.h +7 -2
index e2f41b8827bf..5b00df0d4f19 100644
@@ -14,8 +14,13 @@
 struct intel_spi;
 struct resource;
 
-struct intel_spi *intel_spi_probe(struct device *dev,
-	struct resource *mem, const struct intel_spi_boardinfo *info);
+typedef struct device *(*register_platform_integrity_t)(struct device *parent,
+			enum intel_spi_type type);
+
+struct intel_spi *intel_spi_probe(struct device *dev, struct resource *mem,
+				  const struct intel_spi_boardinfo *info,
+				  register_platform_integrity_t register_pi_cb);
+
 int intel_spi_remove(struct intel_spi *ispi);
 
 #endif /* INTEL_SPI_H */
Signature · 1 line
2.25.1
#3 lore raw
Quoted 10 lines · Daniel Gutson

This patch exports the BIOS Write Enable (bioswe), BIOS
Lock Enable (biosle), and the SMM BIOS Write Protect (SMM_BIOSWP) fields of the BIOS Control register using the platform-integrity misc kernel module. The idea is to keep adding more flags, not only from the BC but also from other registers in following versions.

The goal is that the attributes are avilable to fwupd when SecureBoot is turned on.

The subject line doesn't match what this patch does, please fix that up.

But there are more core issues in this patch:

Quoted 84 lines
---
 drivers/mtd/spi-nor/controllers/Kconfig       |  1 +
 .../mtd/spi-nor/controllers/intel-spi-pci.c   | 75 ++++++++++++++-
 .../spi-nor/controllers/intel-spi-platform.c  |  2 +-
 drivers/mtd/spi-nor/controllers/intel-spi.c   | 91 ++++++++++++++++++-
 drivers/mtd/spi-nor/controllers/intel-spi.h   |  9 +-
 5 files changed, 171 insertions(+), 7 deletions(-)
drivers/mtd/spi-nor/controllers/Kconfig +1 -0
index 5c0e0ec2e6d1..e7eaef506fc2 100644
@@ -29,6 +29,7 @@ config SPI_NXP_SPIFI
 
 config SPI_INTEL_SPI
 	tristate
+	depends on PLATFORM_INTEGRITY_DATA
 
 config SPI_INTEL_SPI_PCI
 	tristate "Intel PCH/PCU SPI flash PCI driver (DANGEROUS)"
drivers/mtd/spi-nor/controllers/intel-spi-pci.c +43 -0
index c72aa1ab71ad..644b1a6091dc 100644
@@ -10,11 +10,19 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/platform-integrity.h>
 
 #include "intel-spi.h"
 
 #define BCR		0xdc
 #define BCR_WPD		BIT(0)
+#define BCR_BLE		BIT(1)
+#define BCR_SMM_BWP	BIT(5)
+
+struct cnl_spi_attr {
+	struct device_attribute dev_attr;
+	u32 mask;
+};
 
 static const struct intel_spi_boardinfo bxt_info = {
 	.type = INTEL_SPI_BXT,
@@ -24,6 +32,70 @@ static const struct intel_spi_boardinfo cnl_info = {
 	.type = INTEL_SPI_CNL,
 };
 
+#ifdef CONFIG_PLATFORM_INTEGRITY_DATA
+static ssize_t intel_spi_cnl_spi_attr_show(struct device *dev,
+					   struct device_attribute *attr,
+					   char *buf, u32 mask)
+{
+	u32 bcr;
+
+	if (dev->parent == NULL)
+		return -EIO;
+
+	if (pci_read_config_dword(container_of(dev->parent, struct pci_dev, dev),
+				  BCR, &bcr) != PCIBIOS_SUCCESSFUL)
+		return -EIO;
+
+	return sprintf(buf, "%d\n", (int)!!(bcr & mask));
+}
+
+static ssize_t bioswe_show(struct device *dev, struct device_attribute *attr,
+			   char *buf)
+{
+	return intel_spi_cnl_spi_attr_show(dev, attr, buf, BCR_WPD);
+}
+static DEVICE_ATTR_RO(bioswe);
+
+static ssize_t biosle_show(struct device *dev, struct device_attribute *attr,
+			   char *buf)
+{
+	return intel_spi_cnl_spi_attr_show(dev, attr, buf, BCR_BLE);
+}
+static DEVICE_ATTR_RO(biosle);
+
+static ssize_t smm_bioswp_show(struct device *dev, struct device_attribute *attr,
+			       char *buf)
+{
+	return intel_spi_cnl_spi_attr_show(dev, attr, buf, BCR_SMM_BWP);

drivers/mtd/spi-nor/controllers/intel-spi-pci.c static const struct intel_spi_boardinfo cnl_info = { · line 79

Quoted 10 lines
drivers/mtd/spi-nor/controllers/intel-spi-pci.c +10 -0
+}
+static DEVICE_ATTR_RO(smm_bioswp);
+
+static struct attribute *cnl_attrs[] = {
+	&dev_attr_bioswe.attr,
+	&dev_attr_biosle.attr,
+	&dev_attr_smm_bioswp.attr,
+	NULL
+};
+ATTRIBUTE_GROUPS(cnl);

If you are forcing the driver to create the groups, then you are forcing us to audit each driver and verify that the files are the same name and such. Put the files in the "common" code please, and if you really need a way to get the data out, make that a callback or something.

Also, this name "platform integrity" is really really generic, while in reality you are describing something very specific. Are you sure you want that?

thanks,

greg k-h

#4 lore raw
Quoted 108 lines · Greg Kroah-Hartman
Quoted 10 lines · Daniel Gutson

This patch exports the BIOS Write Enable (bioswe), BIOS
Lock Enable (biosle), and the SMM BIOS Write Protect (SMM_BIOSWP) fields of the BIOS Control register using the platform-integrity misc kernel module. The idea is to keep adding more flags, not only from the BC but also from other registers in following versions.

The goal is that the attributes are avilable to fwupd when SecureBoot is turned on.

The subject line doesn't match what this patch does, please fix that up.

But there are more core issues in this patch:

Quoted 91 lines
---
 drivers/mtd/spi-nor/controllers/Kconfig       |  1 +
 .../mtd/spi-nor/controllers/intel-spi-pci.c   | 75 ++++++++++++++-
 .../spi-nor/controllers/intel-spi-platform.c  |  2 +-
 drivers/mtd/spi-nor/controllers/intel-spi.c   | 91 ++++++++++++++++++-
 drivers/mtd/spi-nor/controllers/intel-spi.h   |  9 +-
 5 files changed, 171 insertions(+), 7 deletions(-)
drivers/mtd/spi-nor/controllers/Kconfig +1 -0
index 5c0e0ec2e6d1..e7eaef506fc2 100644
@@ -29,6 +29,7 @@ config SPI_NXP_SPIFI
 
 config SPI_INTEL_SPI
      tristate
+     depends on PLATFORM_INTEGRITY_DATA
 
 config SPI_INTEL_SPI_PCI
      tristate "Intel PCH/PCU SPI flash PCI driver (DANGEROUS)"
drivers/mtd/spi-nor/controllers/intel-spi-pci.c +50 -0
index c72aa1ab71ad..644b1a6091dc 100644
@@ -10,11 +10,19 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/platform-integrity.h>
 
 #include "intel-spi.h"
 
 #define BCR          0xdc
 #define BCR_WPD              BIT(0)
+#define BCR_BLE              BIT(1)
+#define BCR_SMM_BWP  BIT(5)
+
+struct cnl_spi_attr {
+     struct device_attribute dev_attr;
+     u32 mask;
+};
 
 static const struct intel_spi_boardinfo bxt_info = {
      .type = INTEL_SPI_BXT,
@@ -24,6 +32,70 @@ static const struct intel_spi_boardinfo cnl_info = {
      .type = INTEL_SPI_CNL,
 };
 
+#ifdef CONFIG_PLATFORM_INTEGRITY_DATA
+static ssize_t intel_spi_cnl_spi_attr_show(struct device *dev,
+                                        struct device_attribute *attr,
+                                        char *buf, u32 mask)
+{
+     u32 bcr;
+
+     if (dev->parent == NULL)
+             return -EIO;
+
+     if (pci_read_config_dword(container_of(dev->parent, struct pci_dev, dev),
+                               BCR, &bcr) != PCIBIOS_SUCCESSFUL)
+             return -EIO;
+
+     return sprintf(buf, "%d\n", (int)!!(bcr & mask));
+}
+
+static ssize_t bioswe_show(struct device *dev, struct device_attribute *attr,
+                        char *buf)
+{
+     return intel_spi_cnl_spi_attr_show(dev, attr, buf, BCR_WPD);
+}
+static DEVICE_ATTR_RO(bioswe);
+
+static ssize_t biosle_show(struct device *dev, struct device_attribute *attr,
+                        char *buf)
+{
+     return intel_spi_cnl_spi_attr_show(dev, attr, buf, BCR_BLE);
+}
+static DEVICE_ATTR_RO(biosle);
+
+static ssize_t smm_bioswp_show(struct device *dev, struct device_attribute *attr,
+                            char *buf)
+{
+     return intel_spi_cnl_spi_attr_show(dev, attr, buf, BCR_SMM_BWP);
+}
+static DEVICE_ATTR_RO(smm_bioswp);
+
+static struct attribute *cnl_attrs[] = {
+     &dev_attr_bioswe.attr,
+     &dev_attr_biosle.attr,
+     &dev_attr_smm_bioswp.attr,
Quoted 8 lines

drivers/mtd/spi-nor/controllers/intel-spi-pci.c static const struct intel_spi_boardinfo cnl_info = { · line 79

Quoted 3 lines
drivers/mtd/spi-nor/controllers/intel-spi-pci.c +3 -0
+     NULL
+};
+ATTRIBUTE_GROUPS(cnl);

If you are forcing the driver to create the groups, then you are forcing us to audit each driver and verify that the files are the same name and such. Put the files in the "common" code please, and if you really need a way to get the data out, make that a callback or something.

If I understand you correctly, you are asking the opposite that Arnd asked me in a
previous patch version: he told me no new callbacks, just use the device attribute API.
However I'm not sure I understand your proposal, do you mean to let the device attr
stay in the driver file, and do the group inside the common part? Therefore, to pass a dev attributes array to the common part?
If not, could you please explain your proposal again?

Quoted 8 lines

Also, this name "platform integrity" is really really generic, while in reality you are describing something very specific. Are you sure you want that?

thanks,

greg k-h

Signature · 8 lines
Daniel Gutson
Engineering Director
Eclypsium, Inc.


Below The Surface: Get the latest threat research and insights on
firmware and supply chain threats from the research team at Eclypsium.
https://eclypsium.com/research/#threatreport
#5 lore raw
Quoted 120 lines · Daniel Gutson
Quoted 108 lines · Greg Kroah-Hartman
Quoted 10 lines · Daniel Gutson

This patch exports the BIOS Write Enable (bioswe), BIOS
Lock Enable (biosle), and the SMM BIOS Write Protect (SMM_BIOSWP) fields of the BIOS Control register using the platform-integrity misc kernel module. The idea is to keep adding more flags, not only from the BC but also from other registers in following versions.

The goal is that the attributes are avilable to fwupd when SecureBoot is turned on.

The subject line doesn't match what this patch does, please fix that up.

But there are more core issues in this patch:

Quoted 91 lines
---
 drivers/mtd/spi-nor/controllers/Kconfig       |  1 +
 .../mtd/spi-nor/controllers/intel-spi-pci.c   | 75 ++++++++++++++-
 .../spi-nor/controllers/intel-spi-platform.c  |  2 +-
 drivers/mtd/spi-nor/controllers/intel-spi.c   | 91 ++++++++++++++++++-
 drivers/mtd/spi-nor/controllers/intel-spi.h   |  9 +-
 5 files changed, 171 insertions(+), 7 deletions(-)
drivers/mtd/spi-nor/controllers/Kconfig +1 -0
index 5c0e0ec2e6d1..e7eaef506fc2 100644
@@ -29,6 +29,7 @@ config SPI_NXP_SPIFI
 
 config SPI_INTEL_SPI
      tristate
+     depends on PLATFORM_INTEGRITY_DATA
 
 config SPI_INTEL_SPI_PCI
      tristate "Intel PCH/PCU SPI flash PCI driver (DANGEROUS)"
drivers/mtd/spi-nor/controllers/intel-spi-pci.c +50 -0
index c72aa1ab71ad..644b1a6091dc 100644
@@ -10,11 +10,19 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/platform-integrity.h>
 
 #include "intel-spi.h"
 
 #define BCR          0xdc
 #define BCR_WPD              BIT(0)
+#define BCR_BLE              BIT(1)
+#define BCR_SMM_BWP  BIT(5)
+
+struct cnl_spi_attr {
+     struct device_attribute dev_attr;
+     u32 mask;
+};
 
 static const struct intel_spi_boardinfo bxt_info = {
      .type = INTEL_SPI_BXT,
@@ -24,6 +32,70 @@ static const struct intel_spi_boardinfo cnl_info = {
      .type = INTEL_SPI_CNL,
 };
 
+#ifdef CONFIG_PLATFORM_INTEGRITY_DATA
+static ssize_t intel_spi_cnl_spi_attr_show(struct device *dev,
+                                        struct device_attribute *attr,
+                                        char *buf, u32 mask)
+{
+     u32 bcr;
+
+     if (dev->parent == NULL)
+             return -EIO;
+
+     if (pci_read_config_dword(container_of(dev->parent, struct pci_dev, dev),
+                               BCR, &bcr) != PCIBIOS_SUCCESSFUL)
+             return -EIO;
+
+     return sprintf(buf, "%d\n", (int)!!(bcr & mask));
+}
+
+static ssize_t bioswe_show(struct device *dev, struct device_attribute *attr,
+                        char *buf)
+{
+     return intel_spi_cnl_spi_attr_show(dev, attr, buf, BCR_WPD);
+}
+static DEVICE_ATTR_RO(bioswe);
+
+static ssize_t biosle_show(struct device *dev, struct device_attribute *attr,
+                        char *buf)
+{
+     return intel_spi_cnl_spi_attr_show(dev, attr, buf, BCR_BLE);
+}
+static DEVICE_ATTR_RO(biosle);
+
+static ssize_t smm_bioswp_show(struct device *dev, struct device_attribute *attr,
+                            char *buf)
+{
+     return intel_spi_cnl_spi_attr_show(dev, attr, buf, BCR_SMM_BWP);
+}
+static DEVICE_ATTR_RO(smm_bioswp);
+
+static struct attribute *cnl_attrs[] = {
+     &dev_attr_bioswe.attr,
+     &dev_attr_biosle.attr,
+     &dev_attr_smm_bioswp.attr,
Quoted 8 lines

drivers/mtd/spi-nor/controllers/intel-spi-pci.c static const struct intel_spi_boardinfo cnl_info = { · line 79

Quoted 3 lines
drivers/mtd/spi-nor/controllers/intel-spi-pci.c +3 -0
+     NULL
+};
+ATTRIBUTE_GROUPS(cnl);

If you are forcing the driver to create the groups, then you are forcing us to audit each driver and verify that the files are the same name and such. Put the files in the "common" code please, and if you really need a way to get the data out, make that a callback or something.

Quoted 9 lines

If I understand you correctly, you are asking the opposite that Arnd asked me in a
previous patch version: he told me no new callbacks, just use the device attribute API.
However I'm not sure I understand your proposal, do you mean to let the device attr
stay in the driver file, and do the group inside the common part? Therefore, to pass a dev attributes array to the common part?
If not, could you please explain your proposal again?

ping please.

Quoted 23 lines
Quoted 9 lines

Also, this name "platform integrity" is really really generic, while in reality you are describing something very specific. Are you sure you want that?

thanks,

greg k-h

--

Daniel Gutson
Engineering Director
Eclypsium, Inc.

Below The Surface: Get the latest threat research and insights on firmware and supply chain threats from the research team at Eclypsium.
https://eclypsium.com/research/#threatreport

Signature · 8 lines
Daniel Gutson
Engineering Director
Eclypsium, Inc.


Below The Surface: Get the latest threat research and insights on
firmware and supply chain threats from the research team at Eclypsium.
https://eclypsium.com/research/#threatreport
#6 lore raw
In reply to Daniel Gutson

drivers/mtd/spi-nor/controllers/Kconfig config SPI_NXP_SPIFI · line 32

Quoted 9 lines · Daniel Gutson
drivers/mtd/spi-nor/controllers/Kconfig +1 -0
index 5c0e0ec2e6d1..e7eaef506fc2 100644
@@ -29,6 +29,7 @@ config SPI_NXP_SPIFI
 
 config SPI_INTEL_SPI
 	tristate
+	depends on PLATFORM_INTEGRITY_DATA

So SPI_INTEL_SPI_PCI selects SPI_INTEL_SPI:

config SPI_INTEL_SPI_PCI

	tristate "Intel PCH/PCU SPI flash PCI driver (DANGEROUS)"
	depends on X86 && PCI
	select SPI_INTEL_SPI

without checking that PLATFORM_INTEGRITY_DATA is set/enabled.

"select" does not follow any kconfig dependency chains, so when PLATFORM_INTEGRITY_DATA is not enabled, this should be causing a kconfig warning, which is not OK.

Signature · 1 line
~Randy
#7 lore raw
Quoted 19 lines · Randy Dunlap

drivers/mtd/spi-nor/controllers/Kconfig config SPI_NXP_SPIFI · line 32

Quoted 9 lines · Daniel Gutson
drivers/mtd/spi-nor/controllers/Kconfig +1 -0
index 5c0e0ec2e6d1..e7eaef506fc2 100644
@@ -29,6 +29,7 @@ config SPI_NXP_SPIFI
 
 config SPI_INTEL_SPI
      tristate
+     depends on PLATFORM_INTEGRITY_DATA

So SPI_INTEL_SPI_PCI selects SPI_INTEL_SPI:

config SPI_INTEL_SPI_PCI
tristate "Intel PCH/PCU SPI flash PCI driver (DANGEROUS)" depends on X86 && PCI
select SPI_INTEL_SPI

Quoted 5 lines

without checking that PLATFORM_INTEGRITY_DATA is set/enabled.

"select" does not follow any kconfig dependency chains, so when PLATFORM_INTEGRITY_DATA is not enabled, this should be causing a kconfig warning, which is not OK.

Since now SPI_INTEL_SPI_PCI can be enabled without PLATFORM_INTEGRITY_DATA (thanks to the #ifdefs), I think I'll just remove the 'depends' and will leave this as it was.

Quoted 5 lines

--
~Randy

Signature · 8 lines
Daniel Gutson
Engineering Director
Eclypsium, Inc.


Below The Surface: Get the latest threat research and insights on
firmware and supply chain threats from the research team at Eclypsium.
https://eclypsium.com/research/#threatreport
Tested-by Richard Hughes on the v1 series
#8 lore raw
In reply to Daniel Gutson

Sorry, I forgot to restore

which I removed for experimenting purposes with git-send-email.

Quoted 32 lines · Daniel Gutson

This patch serie adds a misc kernel module and extends the intel-spi drivers to publish platform integrity data in the sys-fs.
Please check the comments in the following patches of this serie for further details.

Daniel Gutson (2):
Platform integrity information in sysfs (version 9)
This patch exports the BIOS Write Enable (bioswe), BIOS Lock Enable
(biosle), and the SMM BIOS Write Protect (SMM_BIOSWP) fields of the BIOS Control register using the platform-integrity misc kernel module. The idea is to keep adding more flags, not only from the BC but also from other registers in following versions.

 .../ABI/stable/sysfs-class-platform-integrity | 23 +++++
 MAINTAINERS                                   |  7 ++
 drivers/misc/Kconfig                          | 11 +++
 drivers/misc/Makefile                         |  1 +
 drivers/misc/platform-integrity.c             | 57 ++++++++++++
 drivers/mtd/spi-nor/controllers/Kconfig       |  1 +
 .../mtd/spi-nor/controllers/intel-spi-pci.c   | 75 +++++++++++++++-
 .../spi-nor/controllers/intel-spi-platform.c  |  2 +-
 drivers/mtd/spi-nor/controllers/intel-spi.c   | 90 ++++++++++++++++++-
 drivers/mtd/spi-nor/controllers/intel-spi.h   |  9 +-
 include/linux/platform-integrity.h            | 19 ++++
 11 files changed, 288 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/ABI/stable/sysfs-class-platform-integrity
 create mode 100644 drivers/misc/platform-integrity.c
 create mode 100644 include/linux/platform-integrity.h

--
2.25.1

Signature · 8 lines
Daniel Gutson
Engineering Director
Eclypsium, Inc.


Below The Surface: Get the latest threat research and insights on
firmware and supply chain threats from the research team at Eclypsium.
https://eclypsium.com/research/#threatreport