🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21661

[PATCH v4 21/33] driver core: Introduce a generic device trust level

#21661
From: Leon Romanovsky
Date: Tue, 24 Nov 2026 09:43
661 lines
31533 bytes
From: Leon Romanovsky <leonro@nvidia.com>

Attestation needs to hold devices before driver probing and DMA setup.
Authorization on individual buses does not provide a common policy that
drivers and infrastructure can use.

Introduce a shared admission policy and operating trust level. Keep the
accepted level fixed for the device's lifetime because unbind or failed
setup does not necessarily undo hardware configuration. Retain active trust
through teardown so cleanup uses the same assumptions as setup. Preserve
existing behavior when no trust boot options are supplied.

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 Documentation/admin-guide/kernel-parameters.txt |  14 ++
 drivers/base/Makefile                           |   2 +-
 drivers/base/base.h                             |  31 ++++
 drivers/base/core.c                             |   5 +-
 drivers/base/dd.c                               |  47 +++++-
 drivers/base/trust.c                            | 187 ++++++++++++++++++++++++
 drivers/usb/core/driver.c                       |   8 +
 drivers/usb/core/message.c                      |   5 +
 include/linux/device.h                          |   8 +
 include/linux/device/bus.h                      |  10 ++
 include/linux/device/trust.h                    |  49 +++++++
 11 files changed, 361 insertions(+), 5 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 0b3c140babd94..8a94482f0b19b 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1259,6 +1259,20 @@ Kernel parameters
 	dell_smm_hwmon.fan_max=
 			[HW] Maximum configurable fan speed.
 
+	device_trust	[KNL]
+			Enable device trust with blocked as the implicit default.
+
+	device_trust.default=
+			[KNL] Set initial trust policy for all devices, including
+			hotplugged devices.
+			Format: { default | blocked | adversarial | unrestricted }
+			No trust options selects legacy unrestricted mode, preserving
+			bus policy and existing authorization. Otherwise blocked is the
+			implicit default. An explicit value wins regardless of option
+			order. default preserves bus policy; other values replace it.
+			unrestricted disables runtime policy changes.
+			See Documentation/driver-api/driver-model/device-trust.rst.
+
 	dfltcc=		[HW,S390]
 			Format: { on | off | def_only | inf_only | always }
 			on:       s390 zlib hardware support for compression on
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 435710f643a5c..cb3bd5fa2287a 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -3,7 +3,7 @@
 
 obj-y			:= component.o core.o bus.o dd.o syscore.o \
 			   driver.o class.o platform.o \
-			   cpu.o firmware.o init.o map.o devres.o \
+			   cpu.o firmware.o init.o map.o devres.o trust.o \
 			   attribute_container.o transport_class.o \
 			   topology.o container.o property.o cacheinfo.o \
 			   swnode.o faux.o
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 61f49fc142f45..87e098790d099 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -10,6 +10,7 @@
  * shared outside of the drivers/base/ directory.
  *
  */
+#include <linux/device/trust.h>
 #include <linux/notifier.h>
 
 /**
@@ -88,6 +89,27 @@ struct driver_private {
 };
 #define to_driver(obj) container_of(obj, struct driver_private, kobj)
 
+/**
+ * enum device_trust_state - Device trust authorization and commitment
+ * @DEVICE_TRUST_SELECTABLE: No authorization or commitment. When runtime
+ *	policy changes are enabled, any policy can be selected. Selecting
+ *	blocked enters %DEVICE_TRUST_WAITING.
+ * @DEVICE_TRUST_WAITING: Blocked policy without commitment. Runtime
+ *	authorization requires adversarial or unrestricted and enters
+ *	%DEVICE_TRUST_AUTHORIZED; selecting default is rejected.
+ * @DEVICE_TRUST_AUTHORIZED: Adversarial or unrestricted selected from
+ *	%DEVICE_TRUST_WAITING. Policy is fixed, but no operating level has
+ *	been committed.
+ * @DEVICE_TRUST_COMMITTED: Policy and operating level accepted before
+ *	driver setup. Both remain fixed through setup failure and unbind.
+ */
+enum device_trust_state {
+	DEVICE_TRUST_SELECTABLE,
+	DEVICE_TRUST_WAITING,
+	DEVICE_TRUST_AUTHORIZED,
+	DEVICE_TRUST_COMMITTED,
+};
+
 /**
  * struct device_private - structure to hold the private to the driver core
  *			   portions of the device structure.
@@ -106,6 +128,7 @@ struct driver_private {
  * @device: pointer back to the struct device that this structure is
  *	    associated with.
  * @driver_lock: serializes binding and removal, including compatibility attach
+ * @trust_state: policy admission state
  * @dead: This device is currently either in the process of or has been
  *	  removed from the system. Any asynchronous events scheduled for this
  *	  device should exit without taking any action.
@@ -124,6 +147,7 @@ struct device_private {
 	struct device *device;
 	/* Taken after the device mutex, except by compatibility attach. */
 	struct mutex driver_lock;
+	enum device_trust_state trust_state;
 	u8 dead:1;
 };
 #define to_device_private_parent(obj)	\
@@ -169,6 +193,13 @@ void bus_remove_driver(struct device_driver *drv);
 void device_release_driver_internal(struct device *dev, const struct device_driver *drv,
 				    struct device *parent);
 
+int device_private_init(struct device *dev);
+
+/* Unrestricted-only manual attachment uses the caller's subsystem serialization. */
+void device_trust_init_state(struct device *dev);
+int device_trust_prepare_unrestricted(struct device *dev,
+				      const struct device_driver *drv);
+
 void driver_detach(const struct device_driver *drv);
 void driver_deferred_probe_del(struct device *dev);
 void device_set_deferred_probe_reason(const struct device *dev, struct va_format *vaf);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 92d25bf4f8632..c0006b3aa38f7 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3613,7 +3613,7 @@ static void device_remove_sys_dev_entry(struct device *dev)
 	}
 }
 
-static int device_private_init(struct device *dev)
+int device_private_init(struct device *dev)
 {
 	dev->p = kzalloc_obj(*dev->p);
 	if (!dev->p)
@@ -3694,6 +3694,9 @@ int device_add(struct device *dev)
 	if (error)
 		goto name_error;
 
+	device_trust_init(dev);
+	device_trust_init_state(dev);
+
 	pr_debug("device: '%s': %s\n", dev_name(dev), __func__);
 
 	parent = get_device(dev->parent);
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 6ac1486b9fbb5..4c4723384dc66 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -541,6 +541,25 @@ static int __device_bind_driver(struct device *dev)
 	return 0;
 }
 
+static int device_bind_driver_locked(struct device *dev)
+{
+	bool admitted = dev->trust_level != DEVICE_TRUST_BLOCKED;
+	int ret;
+
+	if (dev->bus && dev->bus->trust_resolve)
+		return -EOPNOTSUPP;
+
+	ret = device_trust_prepare(dev, dev->driver);
+	if (ret)
+		return ret;
+
+	ret = __device_bind_driver(dev);
+	/* An early claimant remains active until its bus finishes cleanup. */
+	if (ret && !admitted)
+		device_trust_clear(dev);
+	return ret;
+}
+
 /**
  * device_bind_driver - bind a driver to one device.
  * @dev: device.
@@ -561,14 +580,14 @@ int device_bind_driver(struct device *dev)
 	int ret;
 
 	mutex_lock(&dev->p->driver_lock);
-	ret = __device_bind_driver(dev);
+	ret = device_bind_driver_locked(dev);
 	mutex_unlock(&dev->p->driver_lock);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(device_bind_driver);
 
 /**
- * device_driver_attach_unrestricted - attach a driver using subsystem serialization
+ * device_driver_attach_unrestricted - attach under a fixed unrestricted policy
  * @drv: driver to attach
  * @dev: device to attach it to
  *
@@ -583,6 +602,12 @@ EXPORT_SYMBOL_GPL(device_bind_driver);
  * It calls the bus or driver probe callback and publishes the binding without
  * performing the normal driver-core DMA, pinctrl or power-domain setup.
  *
+ * Requires an unrestricted operating level and either no device trust boot options
+ * or device_trust.default=unrestricted. Changes through trust_policy are disabled
+ * in both modes. The caller must exclude bus-specific policy changes.
+ * When driver boot rules exist, an explicit device boot rule must exclude
+ * them for @dev. Buses with a trust resolver must use device_driver_attach().
+ *
  * Return: 0 on success, -EAGAIN if registration or probing must be retried,
  * or another negative error before binding.
  */
@@ -608,6 +633,10 @@ int device_driver_attach_unrestricted(const struct device_driver *drv,
 		goto unlock;
 	}
 
+	ret = device_trust_prepare_unrestricted(dev, drv);
+	if (ret)
+		goto unlock;
+
 	device_set_driver(dev, drv);
 	if (dev->bus->probe)
 		ret = dev->bus->probe(dev);
@@ -632,6 +661,7 @@ int device_driver_attach_unrestricted(const struct device_driver *drv,
 	devres_release_all(dev);
 	device_set_driver(dev, NULL);
 	dev_set_drvdata(dev, NULL);
+	WRITE_ONCE(dev->trust_level, DEVICE_TRUST_BLOCKED);
 	if (ret == -EPROBE_DEFER)
 		ret = -EAGAIN;
 unlock:
@@ -763,6 +793,14 @@ static int really_probe(struct device *dev, const struct device_driver *drv)
 	}
 
 re_probe:
+	ret = device_trust_prepare(dev, drv);
+	if (ret) {
+		device_links_no_driver(dev);
+		/* Report it like a probe error so a scan tries the next driver. */
+		ret = -ret;
+		goto done;
+	}
+
 	device_set_driver(dev, drv);
 
 	/* If using pinctrl, bind pins now before probing */
@@ -829,6 +867,7 @@ static int really_probe(struct device *dev, const struct device_driver *drv)
 		if (dev->bus && dev->bus->dma_cleanup)
 			dev->bus->dma_cleanup(dev);
 		device_unbind_cleanup(dev);
+		device_trust_clear(dev);
 
 		goto re_probe;
 	}
@@ -855,6 +894,7 @@ static int really_probe(struct device *dev, const struct device_driver *drv)
 pinctrl_bind_failed:
 	device_links_no_driver(dev);
 	device_unbind_cleanup(dev);
+	device_trust_clear(dev);
 done:
 	return ret;
 }
@@ -1196,7 +1236,7 @@ static int __device_attach(struct device *dev, bool allow_async)
 			ret = 1;
 			goto out_unlock;
 		}
-		ret = __device_bind_driver(dev);
+		ret = device_bind_driver_locked(dev);
 		if (ret == 0)
 			ret = 1;
 		else {
@@ -1448,6 +1488,7 @@ static void __device_release_driver(struct device *dev, struct device *parent)
 			dev->bus->dma_cleanup(dev);
 
 		device_unbind_cleanup(dev);
+		device_trust_clear(dev);
 		device_links_driver_cleanup(dev);
 
 		klist_remove(&dev->p->knode_driver);
diff --git a/drivers/base/trust.c b/drivers/base/trust.c
new file mode 100644
index 0000000000000..57f0fcbe1f716
--- /dev/null
+++ b/drivers/base/trust.c
@@ -0,0 +1,187 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/export.h>
+#include <linux/init.h>
+#include <linux/string.h>
+
+#include "base.h"
+
+static enum device_trust_policy device_trust_default_policy __ro_after_init =
+	DEVICE_TRUST_POLICY_UNRESTRICTED;
+static bool device_trust_configured __ro_after_init;
+
+static void __init device_trust_configure(void)
+{
+	if (device_trust_configured)
+		return;
+
+	device_trust_default_policy = DEVICE_TRUST_POLICY_BLOCKED;
+	device_trust_configured = true;
+}
+
+static int __init device_trust_detect_setup(char *str)
+{
+	if (!*str || *str == '=' || *str == '.')
+		device_trust_configure();
+	return !*str;
+}
+__setup("device_trust", device_trust_detect_setup);
+
+void device_trust_init_state(struct device *dev)
+{
+	if (dev->trust_committed_level != DEVICE_TRUST_BLOCKED)
+		dev->p->trust_state = DEVICE_TRUST_COMMITTED;
+	else
+		dev->p->trust_state = dev->trust_policy == DEVICE_TRUST_POLICY_BLOCKED ?
+			DEVICE_TRUST_WAITING : DEVICE_TRUST_SELECTABLE;
+}
+
+static int __device_trust_prepare(struct device *dev,
+				  const struct device_driver *drv, bool unrestricted_only)
+{
+	enum device_trust_policy policy;
+	enum device_trust_level level;
+	int ret;
+
+	policy = dev->trust_policy;
+
+	if (policy == DEVICE_TRUST_POLICY_BLOCKED)
+		return -EPERM;
+	if (dev->bus && dev->bus->trust_resolve) {
+		ret = dev->bus->trust_resolve(dev, drv, policy, &level);
+		if (ret)
+			return ret;
+	} else {
+		level = policy == DEVICE_TRUST_POLICY_ADVERSARIAL ?
+			DEVICE_TRUST_ADVERSARIAL : DEVICE_TRUST_UNRESTRICTED;
+	}
+	if (level == DEVICE_TRUST_BLOCKED)
+		return -EPERM;
+	if (unrestricted_only && level != DEVICE_TRUST_UNRESTRICTED)
+		return -EPERM;
+	if (dev->p->trust_state == DEVICE_TRUST_COMMITTED &&
+	    dev->trust_committed_level != level)
+		return -EINVAL;
+
+	WRITE_ONCE(dev->trust_committed_level, level);
+	dev->p->trust_state = DEVICE_TRUST_COMMITTED;
+	WRITE_ONCE(dev->trust_level, level);
+	return 0;
+}
+
+/**
+ * device_trust_prepare - Admit a driver before operating a device
+ * @dev: initialized device with its bus, name and initial policy set
+ * @drv: driver claiming or probing the device
+ *
+ * The caller must hold the device lock. Buses may admit a claim before
+ * device_add(); registration preserves the resulting policy and commitment.
+ * Clear the active level after the driver has stopped operating the device.
+ *
+ * Return: 0 on admission, or a negative error before driver setup.
+ */
+int device_trust_prepare(struct device *dev, const struct device_driver *drv)
+{
+	int ret;
+
+	device_lock_assert(dev);
+	if (!dev->p) {
+		ret = device_private_init(dev);
+		if (ret)
+			return ret;
+		device_trust_init(dev);
+		device_trust_init_state(dev);
+	}
+	return __device_trust_prepare(dev, drv, false);
+}
+EXPORT_SYMBOL_GPL(device_trust_prepare);
+
+int device_trust_prepare_unrestricted(struct device *dev,
+				      const struct device_driver *drv)
+{
+	if (device_trust_default_policy != DEVICE_TRUST_POLICY_UNRESTRICTED)
+		return -EPERM;
+
+	return __device_trust_prepare(dev, drv, true);
+}
+
+/**
+ * device_trust_clear - End a device's active operating level
+ * @dev: device whose driver setup and cleanup have finished
+ *
+ * The caller must hold the device lock. Lifetime commitment is retained.
+ */
+void device_trust_clear(struct device *dev)
+{
+	device_lock_assert(dev);
+	WRITE_ONCE(dev->trust_level, DEVICE_TRUST_BLOCKED);
+}
+EXPORT_SYMBOL_GPL(device_trust_clear);
+
+/**
+ * device_get_trust_level - Return a device's active trust level
+ * @dev: device to inspect
+ *
+ * The value is stable from the start of DMA configuration through the end of
+ * DMA cleanup. An unbound device has %DEVICE_TRUST_BLOCKED as its active
+ * trust level.
+ *
+ * Return: The active trust level for the current bind transaction.
+ */
+enum device_trust_level device_get_trust_level(const struct device *dev)
+{
+	return READ_ONCE(dev->trust_level);
+}
+EXPORT_SYMBOL_GPL(device_get_trust_level);
+
+/**
+ * device_is_adversarial - Test whether a device is operated as an adversary
+ * @dev: device to inspect
+ *
+ * Return: True when the active trust level is %DEVICE_TRUST_ADVERSARIAL.
+ */
+bool device_is_adversarial(const struct device *dev)
+{
+	return device_get_trust_level(dev) == DEVICE_TRUST_ADVERSARIAL;
+}
+EXPORT_SYMBOL_GPL(device_is_adversarial);
+
+static const char * const device_trust_policy_names[] = {
+	[DEVICE_TRUST_POLICY_DEFAULT] = "default",
+	[DEVICE_TRUST_POLICY_BLOCKED] = "blocked",
+	[DEVICE_TRUST_POLICY_ADVERSARIAL] = "adversarial",
+	[DEVICE_TRUST_POLICY_UNRESTRICTED] = "unrestricted",
+};
+
+static int __init device_trust_default_setup(char *str)
+{
+	int policy = match_string(device_trust_policy_names,
+				  ARRAY_SIZE(device_trust_policy_names), str);
+
+	device_trust_configure();
+	if (policy < 0) {
+		pr_warn("device_trust: ignoring invalid default policy '%s'\n", str);
+		return 1;
+	}
+
+	device_trust_default_policy = policy;
+	return 1;
+}
+__setup("device_trust.default=", device_trust_default_setup);
+
+/**
+ * device_trust_init - Apply global boot policy before registration
+ * @dev: unregistered device with its initial policy set
+ */
+void device_trust_init(struct device *dev)
+{
+	if (dev->trust_committed_level != DEVICE_TRUST_BLOCKED)
+		return;
+
+	if (device_trust_configured &&
+	    device_trust_default_policy != DEVICE_TRUST_POLICY_DEFAULT)
+		dev->trust_policy = device_trust_default_policy;
+}
+EXPORT_SYMBOL_GPL(device_trust_init);
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 9dd022c1ca151..1d488111a70fb 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -582,6 +582,12 @@ int usb_driver_claim_interface(struct usb_driver *driver,
 		iface->claim_owner = driver->driver.owner;
 	}
 
+	retval = device_trust_prepare(dev, &driver->driver);
+	if (retval) {
+		usb_put_claim_owner(iface);
+		goto unlock;
+	}
+
 	dev->driver = &driver->driver;
 	usb_set_intfdata(iface, data);
 	iface->needs_binding = 0;
@@ -619,6 +625,7 @@ int usb_driver_claim_interface(struct usb_driver *driver,
 		if (driver->supports_autosuspend)
 			pm_runtime_disable(dev);
 		pm_runtime_set_suspended(dev);
+		device_trust_clear(dev);
 	}
 
 unlock:
@@ -634,6 +641,7 @@ static void usb_unbind_claim(struct usb_interface *iface)
 	usb_unbind_interface(dev);
 	dev_set_drvdata(dev, NULL);
 	dev->driver = NULL;
+	device_trust_clear(dev);
 	usb_put_claim_owner(iface);
 }
 
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index e7a23e406f8a2..ca6976e266f02 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -2237,6 +2237,8 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
 		pm_runtime_no_callbacks(&intf->dev);
 		dev_set_name(&intf->dev, "%d-%s:%d.%d", dev->bus->busnum,
 				dev->devpath, configuration, ifnum);
+		/* A sibling may claim the interface before it is registered */
+		device_trust_init(&intf->dev);
 		/*
 		 * Make sure the interface does not outlive its parent (e.g.
 		 * as needed for usb_queue_reset_device() and
@@ -2319,6 +2321,9 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
 			get_device(&intf->dev);
 			if (unconfigure)
 				usb_set_configuration(dev, -1);
+			device_lock(&intf->dev);
+			device_trust_clear(&intf->dev);
+			device_unlock(&intf->dev);
 			module_put(claim_owner);
 			put_device(&intf->dev);
 			if (unconfigure) {
diff --git a/include/linux/device.h b/include/linux/device.h
index 5433b2609ab30..702eb66b81bf3 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -30,6 +30,7 @@
 #include <linux/device/class.h>
 #include <linux/device/devres.h>
 #include <linux/device/driver.h>
+#include <linux/device/trust.h>
 #include <linux/cleanup.h>
 #include <asm/device.h>
 
@@ -695,6 +696,10 @@ enum struct_device_flags {
  * @removable:  Whether the device can be removed from the system. This
  *              should be set by the subsystem / bus driver that discovered
  *              the device.
+ * @trust_policy: Requested operating policy, resolved before driver probe.
+ * @trust_level: Active trust level through driver setup and cleanup, see
+ *		device_get_trust_level().
+ * @trust_committed_level: Operating level retained across bind transactions.
  * @flags:	DEV_FLAG_XXX flags. Use atomic bitfield operations to modify.
  *
  * At the lowest level, every device in a Linux system is represented by an
@@ -798,6 +803,9 @@ struct device {
 	struct device_physical_location *physical_location;
 
 	enum device_removable	removable;
+	enum device_trust_policy trust_policy;
+	enum device_trust_level trust_level;
+	enum device_trust_level trust_committed_level;
 
 	DECLARE_BITMAP(flags, DEV_FLAG_COUNT);
 };
diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
index 9ef7538a9a7f2..ba2b5743a47cd 100644
--- a/include/linux/device/bus.h
+++ b/include/linux/device/bus.h
@@ -17,6 +17,7 @@
 #include <linux/kobject.h>
 #include <linux/klist.h>
 #include <linux/pm.h>
+#include <linux/device/trust.h>
 
 struct device_driver;
 struct fwnode_handle;
@@ -59,6 +60,11 @@ struct fwnode_handle;
  * @resume:	Called to bring a device on this bus out of sleep mode.
  * @num_vf:	Called to find out how many virtual functions a device on this
  *		bus supports.
+ * @trust_resolve: Resolve a requested trust policy to an active trust level
+ *		immediately before driver probe. The device lock is held and
+ *		@drv is the candidate driver, which dev->driver does not name
+ *		yet. Return 0 on success or a negative errno. This callback
+ *		must not enable the device.
  * @dma_configure:	Called to setup DMA configuration on a device on
  *			this bus.
  * @dma_cleanup:	Called to cleanup DMA configuration on a device on
@@ -102,6 +108,10 @@ struct bus_type {
 
 	int (*num_vf)(struct device *dev);
 
+	int (*trust_resolve)(struct device *dev,
+			     const struct device_driver *drv,
+			     enum device_trust_policy policy,
+			     enum device_trust_level *level);
 	int (*dma_configure)(struct device *dev);
 	void (*dma_cleanup)(struct device *dev);
 
diff --git a/include/linux/device/trust.h b/include/linux/device/trust.h
new file mode 100644
index 0000000000000..ff80b7a079eb8
--- /dev/null
+++ b/include/linux/device/trust.h
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _DEVICE_TRUST_H_
+#define _DEVICE_TRUST_H_
+
+#include <linux/types.h>
+
+struct device;
+struct device_driver;
+
+/**
+ * enum device_trust_level - active trust level for a device
+ * @DEVICE_TRUST_BLOCKED: The device cannot be operated by a driver
+ * @DEVICE_TRUST_ADVERSARIAL: Classify the operating device as potentially malicious
+ * @DEVICE_TRUST_UNRESTRICTED: Operate the device with the usual kernel privileges
+ *
+ * Active trust levels are discrete states, not an ordered privilege scale.
+ * Adversarial classification alone adds no protections; these depend on bus,
+ * DMA and driver support.
+ */
+enum device_trust_level {
+	DEVICE_TRUST_BLOCKED,
+	DEVICE_TRUST_ADVERSARIAL,
+	DEVICE_TRUST_UNRESTRICTED,
+};
+
+/**
+ * enum device_trust_policy - requested device trust policy
+ * @DEVICE_TRUST_POLICY_DEFAULT: Let the bus select the active trust level
+ * @DEVICE_TRUST_POLICY_BLOCKED: Request that the device remain blocked
+ * @DEVICE_TRUST_POLICY_ADVERSARIAL: Request adversarial classification
+ * @DEVICE_TRUST_POLICY_UNRESTRICTED: Request normal operation
+ *
+ * A requested policy is resolved to an active trust level before a driver is
+ * probed.
+ */
+enum device_trust_policy {
+	DEVICE_TRUST_POLICY_DEFAULT,
+	DEVICE_TRUST_POLICY_BLOCKED,
+	DEVICE_TRUST_POLICY_ADVERSARIAL,
+	DEVICE_TRUST_POLICY_UNRESTRICTED,
+};
+
+void device_trust_init(struct device *dev);
+int device_trust_prepare(struct device *dev, const struct device_driver *drv);
+void device_trust_clear(struct device *dev);
+enum device_trust_level device_get_trust_level(const struct device *dev);
+bool device_is_adversarial(const struct device *dev);
+
+#endif /* _DEVICE_TRUST_H_ */

-- 
2.56.1
Technical Details
Message-ID: <20261124-device-trust-core-v4-21-037eb0d17b1f@nvidia.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370184-linux-kernel-netdev=dewy.ru
References: <20261124-device-trust-core-v4-0-037eb0d17b1f@nvidia.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370184-linux-kernel-netdev=dewy.ru
From: leon@kernel.org (Leon Romanovsky)
Newsgroups: linux.kernel.netdev
Subject: [PATCH v4 21/33] driver core: Introduce a generic device trust level
Date: Tue, 24 Nov 2026 11:43:52 +0200
Organization: Usenet Network
Message-ID: <20261124-device-trust-core-v4-21-037eb0d17b1f@nvidia.com>
References: <20261124-device-trust-core-v4-0-037eb0d17b1f@nvidia.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="4104184"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:dcXAbnvnmfMa65iRZp3WTZFubr8= sha256:R/4UkkFILw+jzDw964wv80Iw854CFuOKdUlI7tweANc=
	sha1:yM8gFZ6bJUa8O3OTRpUKc5xAFeQ= sha256:ty23VwqzfHBy49Ircuap+5MaBTBotAhu3FWWRPmP0yc=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 9FC4B125DEE; Tue, 24 Nov 2026 12:47:50 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.301
X-Spam-Status: No, score=-2.301 tagged_above=-9999 required=6.31
	tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001,
	DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3,
	SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id YLx-I1L3tOuf;
	Tue, 24 Nov 2026 12:47:46 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-370184-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 49302125DEA; Tue, 24 Nov 2026 12:47:38 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id CD91D44C63; Tue, 24 Nov 2026 09:47:06 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795513543;
	b=mX5nK8a9sG5ArMOPJSI2excr+3hgbfzW8bFKibVfrbTqR4sFCNzjmOptEJwx9LYpIoFy
	 aHjLTUqtABRWzuARPC914eIQcc2mMBSmSSuogjJ/yjndDPmZOKuadelPPptEeFih/NFCY
	 23cFEs0VpBcZQUqxM9exk17nfeIQM5jila0MeaA3WjsbbADnUleZktiML7yQEo/iRguBt
	 qATsG7ekRYHWEDq2sNVsumAa2KOE/NPJS46DleMYtgB+1td4EDyWCUxFgpZL45TAUJuki
	 Mc2TVWhAOCQ0BaUKCmxah26kfgK1dXYf5pm3/LvcmWhfFmGgoJAK6TD05OAqWYT0eXA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795513543;
	h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Type:X-Mailer:
	 Content-Transfer-Encoding;
	bh=7A95a3zzmqez7L1VrQSL7bCJkCoP0qTyJOrz2/9XY40=;
	b=V+gD4uyYVaMaLR3iyJjszJyR99mqNdYkMm95gg4OLhMqIbselGiEbAO2v2Lc7DFW2JoC
	 7iaZFYYAl/bP6eBa3y5Yhk0wQnU2E1Lsx9MdSxfXcKP6mBluzBHjAO2rPE0CWszJCEfO7
	 hXpqsEsYDKuoXNv3gI8w43iiABEsu5mRR8q/QAmeN5rjdt+WQyOr+dYtNQ9iBPyRSTnI/
	 rwBdaGzHlJCKUe44V638SQMlNUMzotS5mLuVU0ZhJ2BCQkuVfWQ/oOhP6z7krO1/V51Tv
	 Mh2wDyd+eA5uOqOg6OjteoeNTp14LtpXHRmpEYxRMBTKoniyPxonii5ZeiYGBAu/o+g==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=M3Eixy7x;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D0C7606DA9F;
	Tue, 24 Nov 2026 09:45:43 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=M3Eixy7x
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795513542;
	b=tkZWlp219T3UPxRZdUoBqJvVNAC2mpvk5GN9lv7wulKs7xMuR7uxGDA4NDM6nDATa3zO
	 dGOulmo2LLnoD2j9K8Mrvk/vF9KvvRhXN31QUalcQmeUTQiO0WGeLE/c+nD8jwdWCrcpC
	 3Sz1oClZd3O+/wNSq3A9g7JAqDVqBzoyNKD/HSinYtkfwz8iKt4VWcHMLkKSGzilL1V8C
	 bGqcsaLrWLgyNM9+rmbr42CYilKjb8RGZ+96fY3ecsVdjNO4yiWSW3qEfVmBW2v40to3u
	 B2n7VfcxM/vqJDbij0corWEh2iq1fkqyv5entRW3xqk5jEiNX+zTBtlHe1/GI4s+rQA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795513542;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Type:X-Mailer:
	 Content-Transfer-Encoding;
	bh=7A95a3zzmqez7L1VrQSL7bCJkCoP0qTyJOrz2/9XY40=;
	b=E9As1noKeFHEKJDVfFbQ8inR/FxYWSHLfUAjIc0DL7jShKg7HjuESbl/R+cAl0Ns3FlV
	 60uUAn9PH2h6NKXCFvddIBG4NzPAZAXHSu6+L6FAkpO3wrh0zPPLYWBmHj7WhfmzlScRT
	 8dsOvkKFoF1NxzAP2ZeycE47jOaExx4p4sN5PBI7vee/iZGFjq4atsQieCCxRJKaqTTSF
	 DDS60uUnIeie4P80XyS8TDZd4nnh8xfQA8MFx+WRpyWV+8BAJ8CF+1/4DlDUnnpfnXgxT
	 kAXxnbJpgRsxv7i+8nLh5Vm+gR7xHZVTy2zGE8pYuKwQADzWV+Ia6YbEFYdCjl9gLYA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=M3Eixy7x;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 981C4606A339;
	Tue, 24 Nov 2026 09:45:42 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id F34711F000CA;
	Tue, 24 Nov 2026 09:45:40 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795513542;
	bh=7A95a3zzmqez7L1VrQSL7bCJkCoP0qTyJOrz2/9XY40=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=M3Eixy7x59Xw33A1NHFW9l1i/u7HOtweKeSagx6PkrrcOrx09cELk++Qw58UVjFs4
	 KLpgNp/BPmIptY3+dszn/omQCpb1R4u2VYsI9a89QahOiL1509Teij7uVYd82hh5tc
	 AgVm4XWFgrnJjvQ9F+dkOtfxtYkRclT8sQQj5j10XvyFaSbXVU5Zv+n6OGB42Wcoxy
	 7rvdqtpZ9F6FwhyYT2Wq2wjGglgCkiWJ3RjI1I2PyZy8sGONo1mxt6YrQ2KnC9QVCO
	 KtDpeXPULuphxXLN5UYNMvkJr6uV8DxUPG8+mWleR+NFbmVFgpxoCaCCw+ugDEUkqN
	 IKZXTgg4sUzyw==
X-Cc: linux-kernel@vger.kernel.org,
	driver-core@lists.linux.dev,
	linux-input@vger.kernel.org,
	netdev@vger.kernel.org,
	linux-wireless@vger.kernel.org,
	linux-usb@vger.kernel.org,
	linux-bluetooth@vger.kernel.org,
	linux-acpi@vger.kernel.org,
	linux-doc@vger.kernel.org,
	linux-pci@vger.kernel.org,
	iommu@lists.linux.dev,
	linux-coco@lists.linux.dev,
	Alexey Kardashevskiy <aik@amd.com>,
	Luiz Augusto von Dentz <luiz.von.dentz@intel.com>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	linux-sound@vger.kernel.org,
	Jason Gunthorpe <jgg@ziepe.ca>
X-Mailer: git-send-email 2.56.1
X-In-Reply-To: <20261124-device-trust-core-v4-0-037eb0d17b1f@nvidia.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Mailer: b4 0.15-dev-18f8f