From: Dan Williams <djbw@kernel.org>
To: linux-coco@lists.linux.dev
Cc: linux-pci@vger.kernel.org, driver-core@lists.linux.dev,
ankita@nvidia.com, Alistair Francis <alistair.francis@wdc.com>,
Lukas Wunner <lukas@wunner.de>,
Donald Hunter <donald.hunter@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
"Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>
Subject: [PATCH 05/15] device core: Add "device evidence" 'validate' command
Date: Sun, 5 Jul 2026 15:08:09 -0700 [thread overview]
Message-ID: <20260705220819.2472765-6-djbw@kernel.org> (raw)
In-Reply-To: <20260705220819.2472765-1-djbw@kernel.org>
When DMA is to be enabled for a PCI TDISP device the CC VM passes a digest
of the device evidence used to make the trust decision. Require the CC VM
to ack and not invalidate the evidence before the next DMA enable event.
Each evidence gathering conveys a current "generation" number that rolls
each time the evidence is requested to be refreshed by the CC VM. The
validate command is a debug aid setups that should not be racing evidence
gathering, device RUN state transitions and DMA enable events.
Note that this generation number does count host side events that
invalidate the evidence. That TOCTOU race belongs to the TSM to resolve and
tell the CC VM that the digests it used to enable DMA are stale.
Cc: Alistair Francis <alistair.francis@wdc.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Donald Hunter <donald.hunter@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Danilo Krummrich <dakr@kernel.org>
Suggested-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
Signed-off-by: Dan Williams <djbw@kernel.org>
---
.../netlink/specs/device-evidence.yaml | 17 ++++++++
drivers/base/device-evidence-netlink.h | 2 +
include/linux/device/evidence.h | 5 ++-
include/uapi/linux/device-evidence.h | 1 +
drivers/base/device-evidence-netlink.c | 14 +++++++
drivers/base/evidence.c | 42 +++++++++++++++++++
6 files changed, 80 insertions(+), 1 deletion(-)
diff --git a/Documentation/netlink/specs/device-evidence.yaml b/Documentation/netlink/specs/device-evidence.yaml
index 44b278bc20e1..65ed0ed87bba 100644
--- a/Documentation/netlink/specs/device-evidence.yaml
+++ b/Documentation/netlink/specs/device-evidence.yaml
@@ -184,3 +184,20 @@ operations:
- generation
- length
- val
+ -
+ name: validate
+ doc: |
+ Assert that userspace accepts the evidence at 'generation' (e.g. as a
+ precondition for enabling DMA). If 'generation' matches the device's
+ current evidence generation the acceptance is recorded; it is
+ implicitly revoked when the evidence is regenerated.
+ attribute-set: object
+ flags: [admin-perm]
+ do:
+ request:
+ attributes:
+ - subsys
+ - dev-name
+ - generation
+ reply:
+ attributes: []
diff --git a/drivers/base/device-evidence-netlink.h b/drivers/base/device-evidence-netlink.h
index a7a3110630a6..659a0a2c9c49 100644
--- a/drivers/base/device-evidence-netlink.h
+++ b/drivers/base/device-evidence-netlink.h
@@ -17,6 +17,8 @@ int device_evidence_nl_read_post(struct netlink_callback *cb);
int device_evidence_nl_read_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
+int device_evidence_nl_validate_doit(struct sk_buff *skb,
+ struct genl_info *info);
extern struct genl_family device_evidence_nl_family;
diff --git a/include/linux/device/evidence.h b/include/linux/device/evidence.h
index 5036fbe63e30..eea1bda609b0 100644
--- a/include/linux/device/evidence.h
+++ b/include/linux/device/evidence.h
@@ -29,15 +29,18 @@ struct device_evidence_object {
* struct device_evidence - Retrieved device evidence
* @slot: certificate slot used by a link TSM for connect
* @generation: refresh_evidence() invocation detection
+ * @validated_generation: generation last accepted by userspace via "validate"
* @digest_algo: payload size of DEVICE_EVIDENCE_FLAG_DIGEST requests
* @lock: synchronize dumps vs refresh_evidence()
* @obj: array of evidence objects a TSM might populate
*
- * An increment of @generation causes in flight dumps to fail with -EAGAIN.
+ * An increment of @generation causes in flight dumps to fail with -EAGAIN and
+ * implicitly revokes a prior userspace validation.
*/
struct device_evidence {
int slot;
u32 generation;
+ u32 validated_generation;
enum hash_algo digest_algo;
struct rw_semaphore lock;
struct device_evidence_object obj[DEVICE_EVIDENCE_TYPE_MAX + 1];
diff --git a/include/uapi/linux/device-evidence.h b/include/uapi/linux/device-evidence.h
index b184174a695d..180d45fdf6cf 100644
--- a/include/uapi/linux/device-evidence.h
+++ b/include/uapi/linux/device-evidence.h
@@ -102,6 +102,7 @@ enum {
enum {
DEVICE_EVIDENCE_CMD_READ = 1,
+ DEVICE_EVIDENCE_CMD_VALIDATE,
__DEVICE_EVIDENCE_CMD_MAX,
DEVICE_EVIDENCE_CMD_MAX = (__DEVICE_EVIDENCE_CMD_MAX - 1)
diff --git a/drivers/base/device-evidence-netlink.c b/drivers/base/device-evidence-netlink.c
index 3a739601f107..3148fc523ed1 100644
--- a/drivers/base/device-evidence-netlink.c
+++ b/drivers/base/device-evidence-netlink.c
@@ -20,6 +20,13 @@ static const struct nla_policy device_evidence_read_nl_policy[DEVICE_EVIDENCE_A_
[DEVICE_EVIDENCE_A_OBJECT_NONCE] = NLA_POLICY_MAX_LEN(DEVICE_EVIDENCE_MAX_NONCE_SIZE),
};
+/* DEVICE_EVIDENCE_CMD_VALIDATE - do */
+static const struct nla_policy device_evidence_validate_nl_policy[DEVICE_EVIDENCE_A_OBJECT_GENERATION + 1] = {
+ [DEVICE_EVIDENCE_A_OBJECT_SUBSYS] = { .type = NLA_NUL_STRING, },
+ [DEVICE_EVIDENCE_A_OBJECT_DEV_NAME] = { .type = NLA_NUL_STRING, },
+ [DEVICE_EVIDENCE_A_OBJECT_GENERATION] = { .type = NLA_U32, },
+};
+
/* Ops table for device_evidence */
static const struct genl_split_ops device_evidence_nl_ops[] = {
{
@@ -31,6 +38,13 @@ static const struct genl_split_ops device_evidence_nl_ops[] = {
.maxattr = DEVICE_EVIDENCE_A_OBJECT_NONCE,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DUMP,
},
+ {
+ .cmd = DEVICE_EVIDENCE_CMD_VALIDATE,
+ .doit = device_evidence_nl_validate_doit,
+ .policy = device_evidence_validate_nl_policy,
+ .maxattr = DEVICE_EVIDENCE_A_OBJECT_GENERATION,
+ .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
+ },
};
struct genl_family device_evidence_nl_family __ro_after_init = {
diff --git a/drivers/base/evidence.c b/drivers/base/evidence.c
index 8e019669db07..3a7942b2362a 100644
--- a/drivers/base/evidence.c
+++ b/drivers/base/evidence.c
@@ -446,6 +446,48 @@ int device_evidence_nl_read_dumpit(struct sk_buff *skb,
return device_evidence_read(skb, cb);
}
+int device_evidence_nl_validate_doit(struct sk_buff *skb,
+ struct genl_info *info)
+{
+ const struct device_evidence_ops *ops;
+ struct device_evidence *evidence;
+ struct device_evidence_ctx _ctx;
+ u32 generation;
+ int rc;
+
+ if (GENL_REQ_ATTR_CHECK(info, DEVICE_EVIDENCE_A_OBJECT_GENERATION)) {
+ NL_SET_ERR_MSG(info->extack, "missing evidence generation");
+ return -EINVAL;
+ }
+ generation = nla_get_u32(info->attrs[DEVICE_EVIDENCE_A_OBJECT_GENERATION]);
+
+ ACQUIRE(mutex_intr, lock)(&device_evidence_lock);
+ if ((rc = ACQUIRE_ERR(mutex_intr, &lock)))
+ return rc;
+
+ struct device_evidence_ctx *ctx __free(put_ctx) =
+ device_evidence_ctx_setup(info, &_ctx);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ ops = ctx->subsys->ops;
+ evidence = ops->evidence_read_begin(ctx->dev);
+ if (IS_ERR(evidence)) {
+ NL_SET_ERR_MSG(info->extack, "failed to acquire evidence context");
+ return PTR_ERR(evidence);
+ }
+
+ if (generation == evidence->generation) {
+ evidence->validated_generation = evidence->generation;
+ } else {
+ NL_SET_ERR_MSG(info->extack, "evidence generation is stale");
+ rc = -ESTALE;
+ }
+
+ ops->evidence_read_end(evidence);
+ return rc;
+}
+
static int __init device_evidence_nl_init(void)
{
return genl_register_family(&device_evidence_nl_family);
--
2.54.0
next prev parent reply other threads:[~2026-07-05 22:08 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-05 22:08 [PATCH 00/15] Device Evidence and Trust for PCI Security Protocol (TDISP) Dan Williams
2026-07-05 22:08 ` [PATCH 01/15] netlink: specs: Introduce multi-message blobs for SPDM Dan Williams
2026-07-05 22:08 ` [PATCH 02/15] tools: ynl: Teach pyynl to handle blobs Dan Williams
2026-07-05 22:08 ` [PATCH 03/15] tools: ynl: Teach ynl_gen_c to validate and dump 'blob' attributes Dan Williams
2026-07-05 22:08 ` [PATCH 04/15] device core: Introduce "device evidence" over netlink Dan Williams
2026-07-05 22:08 ` Dan Williams [this message]
2026-07-05 22:08 ` [PATCH 06/15] PCI/TSM: Add device evidence support Dan Williams
2026-07-05 22:08 ` [PATCH 07/15] modules: Document the global async_probe parameter Dan Williams
2026-07-05 22:08 ` [PATCH 08/15] device core: Initial device trust infrastructure Dan Williams
2026-07-06 13:45 ` Jason Gunthorpe
2026-07-05 22:08 ` [PATCH 09/15] PCI, device core: Move "untrusted" concept to DEVICE_TRUST_ADVERSARY Dan Williams
2026-07-06 13:49 ` Jason Gunthorpe
2026-07-05 22:08 ` [PATCH 10/15] PCI/TSM: Add device interface security LOCKED support Dan Williams
2026-07-05 22:08 ` [PATCH 11/15] PCI/TSM: Add device interface security RUN support Dan Williams
2026-07-05 22:08 ` [PATCH 12/15] PCI/TSM: Add device interface security DMA enable/disable Dan Williams
2026-07-05 22:08 ` [PATCH 13/15] PCI, device core: Add private memory access for DEVICE_TRUST_TCB Dan Williams
2026-07-06 12:42 ` Aneesh Kumar K.V
2026-07-05 22:08 ` [PATCH 14/15] PCI/TSM: Create MMIO descriptors via TDISP Report Dan Williams
2026-07-05 22:08 ` [PATCH 15/15] PCI/TSM: Add relative MMIO offset support? Dan Williams
2026-07-06 12:51 ` [PATCH 00/15] Device Evidence and Trust for PCI Security Protocol (TDISP) Jason Gunthorpe
2026-07-06 20:55 ` Dan Williams (nvidia)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260705220819.2472765-6-djbw@kernel.org \
--to=djbw@kernel.org \
--cc=alistair.francis@wdc.com \
--cc=aneesh.kumar@kernel.org \
--cc=ankita@nvidia.com \
--cc=dakr@kernel.org \
--cc=donald.hunter@gmail.com \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox