eBPF-based security platform
testing: verify NV writer isolation and measured operations
Leonard Cohnen8fc98de94017
diff --git a/Documentation/tpm.rst b/Documentation/tpm.rstindex c1e82549..7a0091fa 100644--- a/Documentation/tpm.rst+++ b/Documentation/tpm.rst@@ -691,8 +691,11 @@ Post-init integration tests run only against a real kernel in the KVMguest with swtpm attached through ``/dev/tpmrm0``(``make -C testing test-tgt``). There is no software signing fixture:the guest uses the production kernel-held writer and installed-``shirudo`` binary. ``testing/tpm/t1127-nv-writer.sh`` runs the command-binding-tests below and checks that the production register is unchanged.+``shirudo`` binary. ``testing/tpm/t1108-tpm-chain.sh`` exercises measured+loads and unloads, initialization reuse, prediction, attestation+and rejection of forged writer evidence.+Prediction uses the offline command fixture rather than overriding the+production runtime's certificate selection.``make -C testing test-tgt`` also exercises theproduction initrd and switch-root path in ``testing/t1122-initrd.sh``.@@ -701,7 +704,8 @@ the production provisioning function and signs through ``keyctl``.It reuses the production TPM connection, NV lifecycle, kernel signingand signed-policy helpers; only the invalid inputs and assertions aretest-specific. Production still selects its signing key from the-frozen identity.+frozen identity, and the guard test checks that the shared signing+primitive cannot bypass that key's LSM protection.It tests nonce and command binding directly through ESYS on a scratchNV index in the guest. Replayed and corrupted signatures must failwithout changing NV. ``PolicySigned`` accepts an authorization for@@ -711,6 +715,20 @@ removes the scratch index and unlinks its temporary keyring.No linker wrapping, software private-key files or productionfault-injection hooks are used.+``testing/tpm/t1127-nv-writer.sh`` exercises the actual kernel key guard,+including public-key inspection in the init record and refused private-key reads,+signing, updates, permission changes, revocation and invalidation.+Its identity lookup opens the frozen map read-only, as+required by the map-FD guard.+Separately, ``testing/helper/test-tpm-preopened`` opens a TPM connection+after initialization and forks an unrelated writer which inherits it.+The child submits the former public ``PolicyNvWritten``/``PolicyOR``+sequence directly through ESYS, without requesting a kernel signature.+``NV_Extend`` must return the TPM's session-1 policy failure, and reads+before and after must succeed with identical values. A userspace+``EACCES`` or transport failure does not pass this test. This exercises+an inherited connection, not a descriptor opened before LSM attachment.+Configuration image measurements================================diff --git a/Makefile.shirudo b/Makefile.shirudoindex b83603d4..7da892d4 100644--- a/Makefile.shirudo+++ b/Makefile.shirudo@@ -626,6 +626,8 @@ TEST_HELPERS := $(VERITY_TEST_HELPERS) \testing/helper/test-upatch-link-lockdown \testing/helper/test-exec-churn \testing/upatch/kernel-obs/exec/exec-paths+TEST_HELPERS += testing/helper/test-nv-writer+TEST_HELPERS += testing/helper/test-tpm-preopenedtesting/helper/test-json-parser: testing/helper/test-json-parser.c util/json.o util/hex.o \util/string.o util/malloc.o@@ -661,6 +663,15 @@ REGISTER_OBJS := util/config_attest.o util/config_update.o util/config_measure.oREGISTER_LIBS := $(LIBCRYPTO_LIBS) $(LIBSSL_LIBS) $(TSS2_LIBS) \$(LIBBPF_A) $(LIBELF_LIBS) $(ZLIB_LIBS)+testing/helper/test-nv-writer: testing/helper/test-nv-writer.c $(REGISTER_OBJS)+ @printf ' CC $@\n'+ $(Q)$(CC) $(CFLAGS) -o $@ $^ $(REGISTER_LIBS)++testing/helper/test-tpm-preopened: testing/helper/test-tpm-preopened.c \+ $(REGISTER_OBJS)+ @printf ' CC $@\n'+ $(Q)$(CC) $(CFLAGS) -o $@ $^ $(REGISTER_LIBS)+testing/helper/test-keys: testing/helper/test-keys.c util/keys.o \util/upatch.o $(REGISTER_OBJS)@printf ' CC $@\n'diff --git a/contrib/build-test-vm-bundle.sh b/contrib/build-test-vm-bundle.shindex b1087722..1f15aefc 100755--- a/contrib/build-test-vm-bundle.sh+++ b/contrib/build-test-vm-bundle.sh@@ -329,6 +329,8 @@ testing/helper/test-config-updatetesting/helper/tpmsim-cmdtesting/helper/test-tpm-wiretesting/helper/test-nv-cphash+testing/helper/test-nv-writer+testing/helper/test-tpm-preopenedtesting/helper/test-configtesting/helper/test-bpf-loadtesting/helper/test-bpf-cmddiff --git a/testing/helper/test-nv-writer.c b/testing/helper/test-nv-writer.cnew file mode 100644index 00000000..48f5f9d7--- /dev/null+++ b/testing/helper/test-nv-writer.c@@ -0,0 +1,108 @@+// SPDX-License-Identifier: BSD-2-Clause+/* Copyright (c) 2026 Authors of shirudo */++#include <errno.h>+#include <linux/keyctl.h>+#include <stdio.h>+#include <string.h>+#include <sys/syscall.h>+#include <unistd.h>++#include <bpf/bpf.h>++#include "identity.h"+#include "eventlog.h"+#include "nv_writer.h"+#include "paths.h"++int main(int argc, char **argv)+{+ __u8 data[SHIRUDO_TPM_NV_RSA_BYTES] = {};+ __u8 signature[SHIRUDO_TPM_NV_RSA_BYTES];+ struct keyctl_pkey_params params = {};+ struct bpf_obj_get_opts opts = {+ .sz = sizeof(opts),+ .file_flags = BPF_F_RDONLY,+ };+ struct shirudo_identity id = {};+ const char *operation;+ key_serial_t target;+ __u32 zero = 0;+ int fd, cmd;+ long ret;++ if (argc != 2)+ return 2;+ fd = bpf_obj_get_opts(SHIRUDO_IDENTITY_PIN, &opts);+ if (fd < 0) {+ perror("open read-only identity");+ return 2;+ }+ ret = bpf_map_lookup_elem(fd, &zero, &id);+ close(fd);+ if (ret || id.nv_writer_ring <= 0 ||+ id.nv_writer_key <= 0) {+ fprintf(stderr, "cannot read NV writer identity\n");+ return 2;+ }+ if (!strcmp(argv[1], "public")) {+ struct shirudo_eventlog_init rec;++ if (eventlog_boot_init(&rec) ||+ memcmp(id.nv_writer_public, rec.writer_public, sizeof(data))) {+ fprintf(stderr, "writer modulus differs between identity and init record\n");+ return 1;+ }+ return 0;+ }+ if (!strcmp(argv[1], "sign")) {+ params.key_id = id.nv_writer_key;+ params.in_len = 32;+ params.out_len = sizeof(signature);+ ret = syscall(__NR_keyctl, KEYCTL_PKEY_SIGN, ¶ms,+ "enc=pkcs1 hash=sha256", data, signature);+ if (ret == -1 && (errno == EACCES || errno == ENOKEY))+ return 0;+ fprintf(stderr, "writer signing was not denied: %ld/%d\n", ret, errno);+ return 1;+ }+ if (!strcmp(argv[1], "sign-shared")) {+ int rc;++ rc = nv_writer_sign_key(id.nv_writer_key, data, signature);+ if (rc == -EACCES || rc == -ENOKEY)+ return 0;+ fprintf(stderr, "shared writer signing was not denied: %d\n", rc);+ return 1;+ }+ operation = argv[1];+ target = id.nv_writer_key;+ if (!strncmp(operation, "ring-", 5)) {+ target = id.nv_writer_ring;+ operation += 5;+ }+ if (!strcmp(operation, "private-read"))+ cmd = KEYCTL_READ;+ else if (!strcmp(operation, "update"))+ cmd = KEYCTL_UPDATE;+ else if (!strcmp(operation, "clear"))+ cmd = KEYCTL_CLEAR;+ else if (!strcmp(operation, "revoke"))+ cmd = KEYCTL_REVOKE;+ else if (!strcmp(operation, "invalidate"))+ cmd = KEYCTL_INVALIDATE;+ else if (!strcmp(operation, "setperm"))+ cmd = KEYCTL_SETPERM;+ else+ return 2;+ errno = 0;+ ret = syscall(__NR_keyctl, cmd, target,+ cmd == KEYCTL_SETPERM ? 0x00030000L : (long)data,+ sizeof(data), 0);+ explicit_bzero(data, sizeof(data));+ if (ret == -1 && (errno == EACCES || errno == ENOKEY))+ return 0;+ fprintf(stderr, "writer operation %s was not refused: %ld/%d\n",+ argv[1], ret, errno);+ return 1;+}diff --git a/testing/helper/test-register-cli.c b/testing/helper/test-register-cli.cindex d2e7b7f8..3ef86c56 100644--- a/testing/helper/test-register-cli.c+++ b/testing/helper/test-register-cli.c@@ -9,13 +9,15 @@#include "identity.h"#include "log.h"-/* Protocol fixtures precede authenticated runtime initialization. */+/* Protocol setup and offline prediction do not enter the runtime. */int main(int argc, const char **argv){harden_stdio();log_init();if (harden_self())return 1;+ if (argc > 2 && !strcmp(argv[1], "attest") && !strcmp(argv[2], "predict"))+ return cmd_attest(argc - 1, argv + 1);if (shirudo_enforcement_active() != 0) {fputs("register CLI fixture requires an uninitialized target\n", stderr);return 1;diff --git a/testing/helper/test-tpm-preopened.c b/testing/helper/test-tpm-preopened.cnew file mode 100644index 00000000..57fc2166--- /dev/null+++ b/testing/helper/test-tpm-preopened.c@@ -0,0 +1,116 @@+// SPDX-License-Identifier: BSD-2-Clause+/* Copyright (c) 2026 Authors of shirudo */++#include <stdio.h>+#include <string.h>+#include <sys/wait.h>+#include <unistd.h>++#include "tpm_internal.h"+#include "chain.h"+#include "eventlog.h"+#include "paths.h"++static int tpm_failed(TSS2_RC rc, const char *operation)+{+ if (rc == TSS2_RC_SUCCESS)+ return 0;+ fprintf(stderr, "%s: rc=0x%08x\n", operation, (__u32)rc);+ return 1;+}++static int unauthorized_extend(struct shirudo_tpm *tpm)+{+ __u8 branch_written[32], branch_init[32], policy[32], values[64];+ TPM2B_MAX_NV_BUFFER event = { .size = 32 };+ TPML_DIGEST branches = { .count = 2 };+ struct shirudo_eventlog_init rec;+ ESYS_TR session = ESYS_TR_NONE;+ __u8 before[32], after[32];+ ESYS_TR nv = ESYS_TR_NONE;+ TSS2_RC trc;+ int rc = 1;++ if (eventlog_boot_init(&rec)) {+ fputs("cannot read the boot binding\n", stderr);+ return 1;+ }+ memcpy(values, rec.pcr_before, 32);+ memcpy(values + 32, rec.phase_before, 32);+ if (tpm_register_policy(SHIRUDO_CHAIN_PCR_MASK, values, 2, rec.writer_public,+ branch_written, branch_init, policy)) {+ fputs("cannot reconstruct the policy branches\n", stderr);+ return 1;+ }+ chain_upatch_event("shirudo-upatch", "not-installed",+ (__u8[32]) {}, event.buffer);+ if (tpm_nv_read(tpm, SHIRUDO_NV_INDEX, before) ||+ tpm_failed(Esys_TR_FromTPMPublic(tpm->esys, SHIRUDO_NV_INDEX, ESYS_TR_NONE,+ ESYS_TR_NONE, ESYS_TR_NONE, &nv),+ "TR_FromTPMPublic") ||+ tpm_policy_session_start(tpm, &session) ||+ tpm_failed(Esys_PolicyNvWritten(tpm->esys, session, ESYS_TR_NONE,+ ESYS_TR_NONE, ESYS_TR_NONE, TPM2_YES),+ "PolicyNvWritten"))+ goto out;+ branches.digests[0].size = 32;+ memcpy(branches.digests[0].buffer, branch_written, 32);+ branches.digests[1].size = 32;+ memcpy(branches.digests[1].buffer, branch_init, 32);+ if (tpm_failed(Esys_PolicyOR(tpm->esys, session, ESYS_TR_NONE, ESYS_TR_NONE,+ ESYS_TR_NONE, &branches), "PolicyOR"))+ goto out;+ trc = Esys_NV_Extend(tpm->esys, nv, nv, session, ESYS_TR_NONE,+ ESYS_TR_NONE, &event);+ if (trc != (TPM2_RC_POLICY_FAIL | TPM2_RC_S | TPM2_RC_1)) {+ fprintf(stderr, "unsigned NV_Extend: expected policy failure, got 0x%08x\n",+ (__u32)trc);+ goto out;+ }+ if (tpm_nv_read(tpm, SHIRUDO_NV_INDEX, after))+ goto out;+ if (memcmp(before, after, 32)) {+ fputs("unsigned NV_Extend changed the production register\n", stderr);+ goto out;+ }+ rc = 0;+out:+ if (session != ESYS_TR_NONE &&+ tpm_failed(Esys_FlushContext(tpm->esys, session), "FlushContext"))+ rc = 1;+ if (nv != ESYS_TR_NONE && tpm_failed(Esys_TR_Close(tpm->esys, &nv), "TR_Close"))+ rc = 1;+ if (!rc)+ puts("inherited-TPM: unsigned NV_Extend rejected by TPM; value unchanged");+ return rc;+}++int main(void)+{+ struct shirudo_tpm *tpm = NULL;+ int status, rc = 1;+ pid_t pid;++ if (tpm_open(&tpm))+ return 2;+ pid = fork();+ if (pid < 0) {+ perror("fork");+ goto out;+ }+ if (!pid) {+ rc = unauthorized_extend(tpm);+ fflush(stdout);+ tpm_close(tpm);+ _exit(rc);+ }+ if (waitpid(pid, &status, 0) != pid)+ perror("waitpid");+ else if (WIFEXITED(status))+ rc = WEXITSTATUS(status);+ else+ fputs("unsigned NV writer terminated abnormally\n", stderr);+out:+ tpm_close(tpm);+ return rc;+}diff --git a/testing/tpm/t1108-tpm-chain.sh b/testing/tpm/t1108-tpm-chain.shindex 6ff38df7..7ae3018d 100644--- a/testing/tpm/t1108-tpm-chain.sh+++ b/testing/tpm/t1108-tpm-chain.sh@@ -2,11 +2,8 @@# SPDX-License-Identifier: BSD-2-Clause# Copyright (c) 2026 Authors of shirudo#-# t1108 -- TPM measurement register: on a host with a bound register, the-# eventlog replayed from zero must reproduce the live NV value (that is-# exactly the chain_matches_eventlog verdict `status` computes). Needs a-# usable TPM; init refuses to run without one, so a host with no chain-# has no shirudo state and the test skips (it runs on the CI vTPM runner).+# t1108 -- measured operations and attestation through the installed+# binary, real kernel-held writer and the VM's TPM device.cd "$(dirname "$0")/..". ./integration-lib.sh@@ -24,8 +21,165 @@ print(t.get(sys.argv[1], "") if t.get(sys.argv[1], None) is not None else "")[ -n "$(tpm_chain chain)" ] ||test_skip_all "no bound register (init not run / no usable TPM)"+FIXTURES=${SHIRUDO_TEST_FIXTURES_DIR:?target fixture directory is not set}+NAME=shirudo-test-lifecycle+LOAD="$FIXTURES/$NAME.upatch"+UNLOAD="$FIXTURES/$NAME.unload.upatch"+PIN="/run/shirudo/bpffs/upatches/$NAME/link"+CERT="$FIXTURES/cert.der"+PREDICT=./helper/test-register-cli+NONCE=0102030405060708090a0b0c0d0e0f10+W=$(mktemp -d) || exit 1++cleanup() {+ result=$?+ if [ -e "$PIN" ]; then+ "$SHIRUDO_BIN" upatch unload "$UNLOAD" --no-precheck || result=1+ fi+ rm -f "$W"/* || result=1+ rmdir "$W" || result=1+ exit "$result"+}+trap cleanup EXIT HUP INT TERM++evidence_field() {+ python3 - "$W/evidence.json" "$1" <<'PY'+import json, sys+d = json.load(open(sys.argv[1]))+keys = sys.argv[2].split(".")+if keys[0] == "init":+ d = next(r for r in d["eventlog"] if r.get("type") == "init")+ keys = keys[1:]+for key in keys:+ d = d[key]+print(d)+PY+}++PAYLOAD=$("$SHIRUDO_BIN" upatch info "$LOAD" --json | report_field payload_sha256) || exit 1+test_expect_success 'eventlog replay reproduces the live register value' '[ "$(tpm_chain chain_matches_eventlog)" = "True" ]'+test_expect_success 'initialization reuses the kernel writer and register without another event' '+ before=$(tpm_chain chain) &&+ lines=$(wc -l </var/lib/shirudo/eventlog) &&+ "$SHIRUDO_BIN" init &&+ [ "$(tpm_chain chain)" = "$before" ] &&+ [ "$(wc -l </var/lib/shirudo/eventlog)" = "$lines" ]+'++test_expect_success 'a real signed load extends the register by exactly its measured event' '+ before=$(tpm_chain chain) &&+ expected=$(python3 -c "import hashlib; event=hashlib.sha256(b\"shirudo-upatch\0\" + bytes.fromhex(\"$PAYLOAD\") + b\"$NAME\").digest(); print(hashlib.sha256(bytes.fromhex(\"$before\") + event).hexdigest())") &&+ "$SHIRUDO_BIN" upatch load "$LOAD" --no-precheck &&+ [ -e "$PIN" ] &&+ [ "$(tpm_chain chain)" = "$expected" ] &&+ [ "$(tpm_chain chain_matches_eventlog)" = "True" ]+'++test_expect_success 'a real signed unload extends the register and remains replayable' '+ before=$(tpm_chain chain) &&+ expected=$(python3 -c "import hashlib; event=hashlib.sha256(b\"shirudo-unload\0\" + bytes.fromhex(\"$PAYLOAD\") + b\"$NAME\").digest(); print(hashlib.sha256(bytes.fromhex(\"$before\") + event).hexdigest())") &&+ "$SHIRUDO_BIN" upatch unload "$UNLOAD" --no-precheck &&+ [ ! -e "$PIN" ] &&+ [ "$(tpm_chain chain)" = "$expected" ] &&+ [ "$(tpm_chain chain_matches_eventlog)" = "True" ]+'++test_expect_success 'the installed binary emits evidence that verifies against the live register' '+ "$SHIRUDO_BIN" attest --nonce="$NONCE" --out="$W/evidence.json" &&+ AK=$(evidence_field ak.name) &&+ EK=$(evidence_field ek.name) &&+ CHAIN=$(tpm_chain chain) &&+ "$SHIRUDO_BIN" attest verify --evidence="$W/evidence.json" --nonce="$NONCE" \+ --ak-name="$AK" --ek-name="$EK" --expect-chain="$CHAIN" \+ --strict-anchor >"$W/report" &&+ grep -qx "verdict: ok" "$W/report" &&+ grep -q "^ok: register: public area is bound to PCRs 9 and 11" "$W/report"+'++AK=$(evidence_field ak.name) || exit 1+EK=$(evidence_field ek.name) || exit 1+CHAIN=$(tpm_chain chain) || exit 1+WRITER=$(evidence_field init.nv_writer_public) || exit 1+PCR_BEFORE=$(evidence_field init.pcr_before) || exit 1+PHASE_BEFORE=$(evidence_field init.phase_before) || exit 1+NV_NAME=$(evidence_field init.nv_name) || exit 1++test_expect_success 'prediction reconstructs the certified name from the real writer and binding' '+ [ "${#WRITER}" = 768 ] &&+ "$PREDICT" attest predict --cert="$CERT" --writer-public="$WRITER" \+ --bind-pcr=9="$PCR_BEFORE" --bind-pcr=11="$PHASE_BEFORE" >"$W/predict" &&+ grep -qx "register_name: $NV_NAME" "$W/predict" &&+ grep -qx "pcr9_after_anchor: $(tr A-F a-f </sys/class/tpm/tpm0/pcr-sha256/9)" "$W/predict"+'++test_expect_success 'prediction requires the public key and rejects invalid encodings' '+ ! "$PREDICT" attest predict --cert="$CERT" \+ --bind-pcr=9="$PCR_BEFORE" --bind-pcr=11="$PHASE_BEFORE" &&+ ! "$PREDICT" attest predict --cert="$CERT" --writer-public=00 \+ --bind-pcr=9="$PCR_BEFORE" --bind-pcr=11="$PHASE_BEFORE" &&+ area=$(./helper/test-tpm-wire writer-public "$WRITER") &&+ ! "$PREDICT" attest predict --cert="$CERT" --writer-public="$area" \+ --bind-pcr=9="$PCR_BEFORE" --bind-pcr=11="$PHASE_BEFORE"+'++test_expect_success 'a fabricated positive event cannot establish an expected register state' '+ python3 - "$W/evidence.json" "$W/forged.json" "$PAYLOAD" >"$W/forged-chain" <<"PY"+import hashlib, json, sys+d = json.load(open(sys.argv[1]))+event = hashlib.sha256(b"shirudo-upatch\0" + bytes.fromhex(sys.argv[3]) + b"absent-fix").digest()+d["eventlog"].append({"type": "upatch_load", "digest": event.hex(),+ "upatch": {"name": "absent-fix", "payload_sha256": sys.argv[3]}})+print(hashlib.sha256(bytes.fromhex(d["register"]["value"]) + event).hexdigest())+json.dump(d, open(sys.argv[2], "w"))+PY+ ! "$SHIRUDO_BIN" attest verify --evidence="$W/forged.json" --nonce="$NONCE" \+ --ak-name="$AK" --expect-chain="$(cat "$W/forged-chain")" \+ >"$W/forged-report" &&+ grep -q "^FAIL: eventlog:" "$W/forged-report" &&+ grep -q "^FAIL: state:" "$W/forged-report"+'++test_expect_success 'the certified name binds the writer public key and its exact encoding' '+ python3 - "$W/evidence.json" "$W" <<"PY"+import copy, json, struct, sys+d = json.load(open(sys.argv[1]))+record = next(r for r in d["eventlog"] if r.get("type") == "init")+key = bytes.fromhex(record["nv_writer_public"])+header = struct.pack(">HHIHHHHHIH", 1, 11, 0x40000, 0, 16, 20, 11, 3072, 65537, 384)+changed = bytearray(key)+changed[25] ^= 1+cases = [("swapped", bytes(changed)), ("header", header + key), ("short", key[:-1]),+ ("even", key[:-1] + bytes([key[-1] & 0xfe])), ("zero", bytes(384)), ("missing", None)]+for name, public in cases:+ doc = copy.deepcopy(d)+ init = next(r for r in doc["eventlog"] if r.get("type") == "init")+ if public is None:+ del init["nv_writer_public"]+ else:+ init["nv_writer_public"] = public.hex()+ json.dump(doc, open(f"{sys.argv[2]}/writer-{name}.json", "w"))+PY+ failed=0 &&+ for kind in swapped header short even zero missing; do+ rc=0+ "$SHIRUDO_BIN" attest verify --evidence="$W/writer-$kind.json" \+ --nonce="$NONCE" --ak-name="$AK" --allow-runtime-events \+ >"$W/writer-$kind.report" || rc=$?+ case "$kind" in+ header|short|missing)+ [ "$rc" = 2 ] || failed=1+ ;;+ *)+ [ "$rc" = 1 ] &&+ grep -q "^FAIL: register: public area" "$W/writer-$kind.report" || failed=1+ ;;+ esac+ done &&+ [ "$failed" = 0 ]+'+test_donediff --git a/testing/tpm/t1127-nv-writer.sh b/testing/tpm/t1127-nv-writer.shindex 8725d8b4..981a7587 100644--- a/testing/tpm/t1127-nv-writer.sh+++ b/testing/tpm/t1127-nv-writer.sh@@ -5,10 +5,55 @@cd "$(dirname "$0")/..". ./integration-lib.shtarget_guard+[ -x helper/test-nv-writer ] ||+ test_skip_all "test-nv-writer not built"+[ -x helper/test-tpm-preopened ] ||+ test_skip_all "test-tpm-preopened not built"[ -x helper/test-nv-cphash ] ||test_skip_all "test-nv-cphash not built"W=$(mktemp -d)-trap 'rm -f "$W/status.json" "$W/cphash.log"; rmdir "$W"' EXIT HUP INT TERM+trap 'rm -f "$W/status.json" "$W/preopened.log" "$W/cphash.log"; rmdir "$W"' EXIT HUP INT TERM++test_expect_success 'the writer public area is available in the init record' '+ ./helper/test-nv-writer public+'++test_expect_success 'root cannot read the kernel-held private writer key' '+ ./helper/test-nv-writer private-read+'++test_expect_success 'root cannot ask the kernel-held NV writer to sign' '+ ./helper/test-nv-writer sign &&+ ./helper/test-nv-writer sign-shared+'++test_expect_success 'root cannot update, revoke or invalidate the NV signing key' '+ ./helper/test-nv-writer update &&+ ./helper/test-nv-writer revoke &&+ ./helper/test-nv-writer invalidate+'++test_expect_success 'root cannot change the NV signing key permissions' '+ ./helper/test-nv-writer setperm+'++test_expect_success 'root cannot clear, revoke, invalidate or change the writer keyring' '+ ./helper/test-nv-writer ring-clear &&+ ./helper/test-nv-writer ring-revoke &&+ ./helper/test-nv-writer ring-invalidate &&+ ./helper/test-nv-writer ring-setperm+'++test_expect_success 'the TPM rejects an unsigned production-register extension over an inherited connection' '+ ./helper/test-tpm-preopened >"$W/preopened.log" &&+ grep -qx "inherited-TPM: unsigned NV_Extend rejected by TPM; value unchanged" \+ "$W/preopened.log"+'++test_expect_success 'trusted status still reads the TPM after denied key access' '+ "$SHIRUDO_BIN" status --json >"$W/status.json" &&+ grep -q "\"chain_matches_eventlog\":true" "$W/status.json"+'test_expect_success 'kernel signatures enforce nonce and command binding on the vTPM' 'before=$("$SHIRUDO_BIN" status --json |