All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: ACPI: Allow internal devices to be marked as untrusted
@ 2022-01-20  0:04 Rajat Jain
  2022-01-20  2:25 ` Dmitry Torokhov
  2022-01-21 21:41 ` Bjorn Helgaas
  0 siblings, 2 replies; 20+ messages in thread
From: Rajat Jain @ 2022-01-20  0:04 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown, Bjorn Helgaas, linux-acpi,
	linux-pci, linux-kernel
  Cc: Rajat Jain, rajatxjain, dtor, jsbarnes

Today the pci_dev->untrusted is set for any devices sitting downstream
an external facing port (determined via "ExternalFacingPort" property).
This however, disallows any internal devices to be marked as untrusted.

There are use-cases though, where a platform would like to treat an
internal device as untrusted (perhaps because it runs untrusted
firmware, or offers an attack surface by handling untrusted network
data etc).

This patch introduces a new "UntrustedDevice" property that can be used
by the firmware to mark any device as untrusted.

Signed-off-by: Rajat Jain <rajatja@google.com>
---
 drivers/pci/pci-acpi.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index a42dbf448860..3d9e5fa49451 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -1350,12 +1350,25 @@ static void pci_acpi_set_external_facing(struct pci_dev *dev)
 		dev->external_facing = 1;
 }
 
+static void pci_acpi_set_untrusted(struct pci_dev *dev)
+{
+	u8 val;
+
+	if (device_property_read_u8(&dev->dev, "UntrustedDevice", &val))
+		return;
+
+	/* These PCI devices are not trustworthy */
+	if (val)
+		dev->untrusted = 1;
+}
+
 void pci_acpi_setup(struct device *dev, struct acpi_device *adev)
 {
 	struct pci_dev *pci_dev = to_pci_dev(dev);
 
 	pci_acpi_optimize_delay(pci_dev, adev->handle);
 	pci_acpi_set_external_facing(pci_dev);
+	pci_acpi_set_untrusted(pci_dev);
 	pci_acpi_add_edr_notifier(pci_dev);
 
 	pci_acpi_add_pm_notifier(adev, pci_dev);
-- 
2.34.1.703.g22d0c6ccf7-goog


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2022-02-02  2:06 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-20  0:04 [PATCH] PCI: ACPI: Allow internal devices to be marked as untrusted Rajat Jain
2022-01-20  2:25 ` Dmitry Torokhov
2022-01-20 15:08   ` Rajat Jain
2022-01-27 23:02   ` Rajat Jain
2022-01-21 21:41 ` Bjorn Helgaas
2022-01-22 14:46   ` Greg Kroah-Hartman
2022-01-24  6:27   ` Mika Westerberg
2022-01-25 10:58     ` Mika Westerberg
2022-01-25 11:15       ` Greg Kroah-Hartman
2022-01-25 12:55         ` Mika Westerberg
2022-01-25 14:45           ` Rafael J. Wysocki
2022-01-27 22:26             ` Rajat Jain
2022-01-28  7:48               ` Mika Westerberg
2022-01-28 21:34                 ` Rajat Jain
2022-01-30 14:30                   ` Rafael J. Wysocki
2022-01-31  6:41                     ` Mika Westerberg
2022-01-31 19:57                       ` Rajat Jain
2022-02-02  2:05                         ` Rajat Jain
2022-01-28  9:55               ` Jean-Philippe Brucker
2022-01-25 14:40       ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.