eBPF-based security platform
docs: Describe the TPM-held writer and NV index guard
KP Singhbcede5a63ca9
diff --git a/Documentation/architecture.rst b/Documentation/architecture.rstindex 33ee7ee3..bb20c0f9 100644--- a/Documentation/architecture.rst+++ b/Documentation/architecture.rst@@ -300,8 +300,9 @@ and the node labels, is opened from the verified root descriptor with``/proc/self/fd`` names in particular are not used for them.bpffs and keyring guards. The identity map contains the bpffs and run-devicenumbers, runtime root hash, BPF keyring kind and serial, enrolled key-serials, the NV writer's public key and key serials, and the name of the-TPM's attestation key, which every later TPM handle is compared against.+serials, the selected NV index, the NV writer's public modulus and+nonsecret input, and the name of the TPM's attestation key, which+every later TPM handle is compared against.It is written and frozen before the admission gates attach.The task map is seeded with the authenticated bootstrap task, then frozenagainst userspace writes. Runtime exec and fork hooks maintain its marks.@@ -463,12 +464,17 @@ it never retries the previous boot's PCR extension. Thedeferred TPM writer limitation.The boot-scoped NV writer is separate from the operator's artifact key.-Trusted initialization imports it into a sealed kernel keyring and freezes-its public key and key IDs into the identity map. The mandatory key guard-permits signing only from tasks with authenticated runtime authority.-The key survives switch-root and TPM resets within that-kernel boot. `The TPM design <tpm.rst#write-policy>`__ describes its-provisioning, command-bound signatures and process-integrity assumptions.+Trusted initialization creates its private key inside the TPM and freezes+its public modulus and the nonsecret 32-byte input needed to recreate it.+Each one-shot command checks the recreated key, signs the exact NV+extension and flushes the handle. The input is not an access control:+another process may recreate the key and ask the TPM to sign. The+``tpm_command`` LSM hook instead denies an untrusted ``TPM2_NV_Extend``+to Shirudo's selected NV index. The selected index is frozen during+initialization. Other TPM signing and PCR extension remain available.+A TPM reset in the same host boot keeps the writer identity; a TPM Clear+does not. `The TPM design <tpm.rst#write-policy>`__ describes the policy+and the remaining limits.7) Target state---------------diff --git a/Documentation/config-images.rst b/Documentation/config-images.rstindex cd70df7e..bb8d0777 100644--- a/Documentation/config-images.rst+++ b/Documentation/config-images.rst@@ -338,8 +338,9 @@ it does not persist per-effect phases or predicted PCR before/after values.Direct TPM-command measurement spoofing remains separate work. Genuineoperations are measured and their history is replayed, but a PCR alonedoes not prove activation against an attacker able to issue measurement-commands. The separate upatch NV register requires a guarded boot-writer-signature; that authorization does not cover config PCR extensions.+commands. The separate upatch NV register requires a signed write and blocks+untrusted extension commands to its index. That guard does not cover+config PCR extensions.No IMA integration is added, and signatures do not prevent rollback.Attestation includes the config PCR even if ``--pcrs`` omits it. Thediff --git a/Documentation/getting-started.rst b/Documentation/getting-started.rstindex 53e5ac38..01d20e12 100644--- a/Documentation/getting-started.rst+++ b/Documentation/getting-started.rst@@ -149,8 +149,9 @@ initrd eventlog record. After boot, using the runtime invocation::Check ``mode: production``, ``keyring_mode: bpf``, ``tpm.bound_in: initrd``,consistent config state and an upatch register matching its eventlog. A TPM is-mandatory. For a development software TPM, put ``tpm.tcti`` in authenticated-runtime configuration; target environment overrides are refused.+mandatory. The authenticated target uses the kernel TPM device so its+NV extension commands pass through the LSM. Host-side TPM tests can use+a software TPM TCTI; target environment overrides are refused.5) Load and unload a local artifact-----------------------------------@@ -382,8 +383,8 @@ the initrd and the anchor. Neither command needs the other machine.``tpm2_reachable`` (pre-flight), ``tpm_error``No TPM 2.0, or the measurement register cannot be bound. Check- ``/dev/tpmrm0``, ``tpm.tcti`` for a software TPM, and- ``tpm.owner_auth`` on a TPM with an owner password.+ ``/dev/tpmrm0`` and ``tpm.owner_auth`` on a TPM with an+ owner password. Host-side software TPM tests may set ``tpm.tcti``.``verifier_rejected``Read the verifier log in the ``--report`` document and rebuilddiff --git a/Documentation/operations.rst b/Documentation/operations.rstindex ed1bc1e0..3aae6c65 100644--- a/Documentation/operations.rst+++ b/Documentation/operations.rst@@ -216,11 +216,12 @@ The authenticated NV-writer upgrade also requires updating the operatorverifier: the write policy and certified index Name change, and oldpublic-write-policy evidence is rejected. Install the updatedtarget profile and rebuild the initrd before rebooting. No secret file-needs migration or backup: the RSA writer is generated afresh at kernel-boot and stored in a protected asymmetric key. The kernel needs its-PKCS#8 private-key parser and RSA implementation; the TPM must verify-RSA-3072 RSASSA/SHA-256. The writer's public key lives in the frozen-identity map; there is no separate mutable binding-attempt record.+needs migration or backup: the TPM creates the RSA writer from a fresh+input at each boot, and Shirudo freezes that nonsecret input and the+public modulus. The kernel needs the ``tpm_command`` LSM hook to+reject untrusted extensions to Shirudo's NV index; it does not block+TPM signing. The TPM must create RSA-3072 RSASSA/SHA-256 keys. There+is no separate mutable binding-attempt record.4) Kernel updatesdiff --git a/Documentation/requirements.rst b/Documentation/requirements.rstindex 558c29e6..e30f15a3 100644--- a/Documentation/requirements.rst+++ b/Documentation/requirements.rst@@ -96,11 +96,13 @@ fixture.* - ``CONFIG_CRYPTO_SHA256``- ``excl_prog_hash``, ``payload_sha256``, the measurement registerand the eventlog digests.- * - ``CONFIG_PKCS8_PRIVATE_KEY_PARSER=y``, ``CONFIG_CRYPTO_RSA=y``- - Import and RSASSA-PKCS1-v1_5/SHA-256 signing with the- kernel-held RSA-3072 NV writer key. The TPM must also support- RSA-3072 public-key loading and RSASSA/SHA-256 verification;- there is no RSA-2048 or alternative-algorithm fallback.+ * - Kernel ``tpm_command`` LSM hook+ - The hook passes a copied command and its declared length before+ submission through either TPM device node. Shirudo refuses an+ untrusted ``TPM2_NV_Extend`` to its frozen NV index, including+ through an inherited descriptor. It allows other TPM signing+ and PCR extension. The TPM must create and use RSA-3072+ RSASSA/SHA-256 primary keys; there is no RSA-2048 fallback.* - ``CONFIG_TCG_TPM`` plus a TPM driver (``CONFIG_TCG_TIS``,``CONFIG_TCG_CRB``, or the platform's virtual TPM)- The measurement register and the attestation key. A TPM 2.0 is@@ -317,9 +319,9 @@ since the libguestfs appliance resolves names through DNS alone.post-quantum today, so the evidence is classical.* - NV write authorization- RSA-3072 RSASSA-PKCS1-v1_5 with SHA-256 through- ``PolicySigned``. The kernel holds the private key and shirudo- holds the public key in the frozen identity map to provision the TPM with- for each session.+ ``PolicySigned``. The TPM holds the private key. Shirudo freezes+ the public modulus and the input used to recreate the same+ primary key during this boot.* - TLS (registries, OTLP and S3 export)- TLS 1.3 on every libcurl client in both profiles. Hybrid ML-KEMgroups (X25519MLKEM768, SecP256r1MLKEM768) are required unless@@ -379,13 +381,14 @@ an exec clears them and the operator helper applies its own hardening.LuaJIT, glibc, libm and the compiler runtime statically as a PIE, so itruns on a distribution whose own OpenSSL predates ML-DSA and reachesthe TPM from an initrd that holds no tpm2-tss shared objects.-* A TPM 2.0 exposed as ``/dev/tpmrm0`` (discrete, firmware or cloud- vTPM), or a software TPM reachable through ``tpm.tcti``. TPM 1.2 is- refused; there is no opt-out.+* A TPM 2.0 exposed through the kernel device TCTI (discrete,+ firmware or cloud vTPM). Authenticated-image targets use that path so+ the LSM can check NV extension commands. Host tests may use a software+ TPM through another TCTI. TPM 1.2 is refused; there is no opt-out.* ``systemd`` 256 or newer for the boot units and the timers:``shirudo-initrd.service`` orders itself after ``tpm2.target``, whichan older systemd does not have, and ``init`` could then run before- the TPM is there. The test suite runs systemd 259. A systemd-based+ the TPM is there. The test suite runs systemd 259. A systemd-basedinitrd (dracut) for the production configuration, with``systemd-pcrphase-initrd.service``, which measures ``enter-initrd``and ``leave-initrd`` into PCR 11: the register's binding closes when@@ -459,8 +462,8 @@ suites when validating a deployment.* ``make -C testing test-tgt-register`` additionally needs libtpmsdevelopment headers on the build host (``libtpms-dev`` on Debian andUbuntu). The prepared guest installs libtpms and the command TCTI- runtime. Signing uses the guest's real kernel keyring, not a software- signing replacement.+ runtime. The guest uses the TPM-held NV writer and the kernel TPM+ device, not a software signing replacement.* ``make -C testing fuzz`` builds the parsers' libFuzzer targets with``clang`` and needs its fuzzer and sanitizer runtime(``libclang-rt-<version>-dev`` on Debian and Ubuntu).diff --git a/Documentation/threat-model.rst b/Documentation/threat-model.rstindex 554c3b0c..9d49b791 100644--- a/Documentation/threat-model.rst+++ b/Documentation/threat-model.rst@@ -267,14 +267,14 @@ T5 Silent state changeadopts the initrd's record without it, and two adopters both foundthe record missing and appended it twice. ``shirudo status`` replays this boot's records and flagsa register it cannot explain. There is no unmeasured mode: a target- without a TPM 2.0 does not initialise. The TPM behind the device- path is root's to replace in a mount namespace of its own, and an- emulator there can carry an index of the recorded name, policy and- reset count, since the init record is readable; every TPM handle a- command takes first recreates the attestation key and compares its- name with the one ``init`` froze in the identity map, which takes- the endorsement seed no emulator has, and refuses another TPM- before the register is read or written. An init run from the initrd+ without a TPM 2.0 does not initialise. Root can replace the TPM+ device path in its own mount namespace. Shirudo compares the+ attestation key Name returned by that device with the one frozen at+ init. This rejects a different Name but cannot authenticate the+ device by itself: a fake transport can replay the public Name.+ A remote verifier requires evidence signed by the pinned TPM key;+ an emulator alone cannot produce that signature. An init run from+ the initrdleaves its record under ``/run``, labelled, until the root's runappends it; a record forged or altered there fails the replay likeany other. The init record carries@@ -284,24 +284,35 @@ T5 Silent state changerecords for one reset, so the history a register holds cannot berestarted by rebinding it.- Both policy branches require a command-bound signature from the- kernel-held boot writer, guarded by ``lsm/key_permission`` using- the committed runtime task mark. The `TPM design <tpm.rst#write-policy>`__- specifies provisioning and authorization. Under the process-integrity- assumptions below, this prevents an attacker from appending an expected- positive event without doing the operation, even with a fabricated- exported eventlog. The private key never lives in the eventlog, a- regular file or a readable BPF map.- Trusted initialization, TPM identity and approved boot measurements- remain prerequisites. The NV Name commits to the writer's public- key, not proof of its custody. Trusted initialization briefly handles the private key and scrubs- it after import; later process- memory disclosures do not expose reusable writer authority.- Injected code can still request signatures. Kernel memory- disclosure, privileged kernel tracing and hibernation exposure- remain outside the key API's protection. RSA authorization is- classical. Existing process-security and executable-integrity- assumptions, including residual risks 2 and 5, still apply.+ Both policy branches require a signature over the exact+ ``TPM2_NV_Extend`` command from a TPM-held boot writer. Its private+ key never leaves the TPM, but the input used to recreate it is not+ secret. Root may recreate the writer and obtain a signature. A+ signature alone cannot alter the register: the TPM must receive an+ ``NV_Extend`` for Shirudo's index.++ The companion kernel passes copied command bytes and their declared+ length to ``tpm_command`` before submission. Shirudo's BPF program+ compares the ``NV_Extend`` index with the selected index frozen at+ init, and refuses that command unless the caller has the committed+ runtime task mark. It checks both TPM device nodes, including+ inherited descriptors. Other signing, extensions to other NV+ indices, and systemd's PCR extension remain available. Under the+ process-integrity assumptions below, root cannot append an+ expected positive event to Shirudo's register without doing the+ operation, even with a fabricated exported eventlog.+ `The TPM design <tpm.rst#write-policy>`__ gives the command checks.++ The NV Name commits to the writer's public key, not proof of TPM+ custody. Owner authorization may be configured for primary+ creation, but it is not a substitute for the LSM index check.+ Kernel memory disclosure alone does not reveal the writer private+ key. Injected code in an authorized task can still extend the+ register. Kernel code execution and direct TPM access that bypasses+ the kernel driver remain trusted-kernel failures. RSA+ authorization is classical. Existing process and executable+ integrity assumptions, including residual risks 2 and 5, still+ apply.T6 The boot windowEnforcement is BPF and does not survive a reboot by itself.@@ -505,7 +516,7 @@ Each of these is known, documented and bounded; none is silent.not prove who appended the digest or that the operation completed.The separate measurement-spoofing investigation is not fixed by imagemode. Static PCRs prevent runtime reset, not unauthorized extends.- The upatch NV register requires the guarded boot writer, but owner+ The upatch NV register has its own extension guard, but ownerundefinition and PCR interference can still deny service. Restrictingconfig PCR writers and handling operation/measurement ordering remainseparate work; no IMA integration is added.diff --git a/Documentation/tpm.rst b/Documentation/tpm.rstindex 675d8677..720d47fc 100644--- a/Documentation/tpm.rst+++ b/Documentation/tpm.rst@@ -13,7 +13,7 @@ target without believing anything the target says about itself. Thisdocument describes both as implemented, how they relate to systemd'sNvPCRs, which the register is modelled on, and what they do not yetdo. The code is authoritative: ``util/chain.c`` (register and event-digests), ``util/nv_writer.c`` (kernel-held writer),+digests), ``util/nv_writer.c`` (writer identity),``util/tpm.c`` (libtss2 calls), ``util/tpm_wire.c`` (policydigests, names and the TPM wire structures, used by both sides),``util/eventlog.c``, ``util/attest.c`` and ``builtin-attest.c``.@@ -74,55 +74,66 @@ The write policy is ``PolicyOR(written, init)``, followed bynothing that runs after it.Both branches require an RSA-3072 RSASSA-PKCS1-v1_5 signature with-SHA-256 from this boot's kernel-held NV writer key. The signature+SHA-256 from this boot's TPM-held NV writer key. The signaturecovers the live session's nonempty TPM nonce, a zero expiration,the SHA-256 command hash and the fixed reference``shirudo-nv-writer-v1``. The command hash covers ``NV_Extend``, bothhandle Names and the marshalled event. The first write uses theunwritten Name; subsequent writes use the written Name. The TPM-checks that exact command hash when executing the extend. A caller-with a pre-opened or passed TPM descriptor cannot authorize a new-extend without the guarded signing operation. Public appends would permit fabricated positive events:-measuring an expected load is not proof that the load happened.--Startup hardening locks all current and future process mappings before-command dispatch. Trusted initialization generates the key, imports-PKCS#8 into a kernel ``asymmetric`` key and scrubs its temporary copies;-the mapping locks remain active until process exit. Bootstrap creates-the signer in its lasting keyring with owner view/search permissions,-then restricts and seals the ring. Bootstrap is trusted: production-runs in the measured initrd before untrusted workloads. The public key,-private-key ID and keyring ID are frozen in the identity map before-attachment, with the name of the attestation key.-Failed writer creation or enforcement setup removes the writer's links-from the user and session keyrings.-There is no additional state key or mutable binding-attempt marker.-The keyring is already available to later invocations;-``lsm/key_permission`` must be attached and pinned before initialization-completes and untrusted workloads run.-The mandatory guard checks committed runtime task authority, never a-public label or mutable executable pointer. Search is refused even for-possessed NV keys: that permission authorizes signing or invalidation.-These denials are not counted because ordinary keyring traversal also-requests search. The asymmetric key has no private-payload read operation.--The key survives switch-root and a TPM reset during the same kernel-boot. Later-one-shot invocations hold only the public key and request signatures-through ``KEYCTL_PKEY_SIGN``. Sessions and external public-key handles-are flushed after use. Expiration zero does not impose a time limit:-an outstanding signature remains bound to its live session and exact-command until that session is destroyed.--The authenticated runtime and process guards protect the code that can-request signatures. The static target does not load host libraries or-OpenSSL provider configuration, and runtime exec rejects traced callers.-Code that compromises an authorized task can still use the signing-operation without extracting the private key.-Kernel memory disclosure, privileged kernel tracing,-hibernation images and compromise during key generation remain outside-the protection of the key API. RSA authorization is classical, unlike-the operator's ML-DSA-87 artifact signatures.+checks that exact command hash when executing the extend. A signature+alone does not change the register. A caller must also submit+``TPM2_NV_Extend`` to Shirudo's index, which the BPF LSM guard restricts.+Public appends would permit fabricated positive events: measuring an+expected load is not proof that the load happened.++Trusted initialization creates an RSA-3072 primary key in the local+TPM's owner hierarchy. It gives ``CreatePrimary`` a random 32-byte+input and freezes that input and the resulting public modulus in the+identity map. The private key never leaves the TPM. The fixed public+template requires ``fixedTPM``, ``fixedParent``,+``sensitiveDataOrigin``, ``userWithAuth`` and ``sign``, with+RSASSA/SHA-256 and exponent 65537. The public area and Name must+match that template and modulus. The initrd freezes this identity+before attaching the TPM command guard. The input is not secret:+another process may recreate the same key and ask the TPM to sign.+Shirudo protects the extension command, not access to the signer.++Each later one-shot invocation recreates the primary from the frozen+input, checks its public area and Name, asks the TPM to sign the+command-bound authorization, and flushes the handle. The owner hierarchy+authorization comes from authenticated ``tpm.owner_auth`` when it is+set. The same input recreates the same key after a TPM reset in the same+host boot. A new host boot chooses a new input. A TPM Clear changes the+owner seed and makes the old identity unusable, so Shirudo fails closed.+No persistent TPM slot or private-key file is needed.++The companion kernel's ``tpm_command`` LSM hook passes a copy of+each userspace TPM command and its declared header length before the+command is sent or queued. It covers writes to ``/dev/tpm0`` and+``/dev/tpmrm0``, including a descriptor opened before enforcement or+inherited by another process. Shirudo's BPF program checks the index+handle in ``TPM2_NV_Extend`` against the selected NV index frozen at+init. It refuses that command to a task without authenticated runtime+authority, including a command too short to identify its index.+The default index is ``SHIRUDO_NV_INDEX``; a build may select another,+and the guard reads the selected value from the frozen identity map.+Extensions to other NV indices, TPM signing, and systemd's PCR+extensions remain available. A signature made with Shirudo's writer+key is therefore not enough to change its register. The guard must+be attached and pinned before untrusted workloads start.++Every executable intentionally added to the verified runtime image gets+the same task authority. Code running in such a task can extend+Shirudo's register, so ``--extra-binary`` adds an authorized writer.+The static target does not load host libraries or OpenSSL provider+configuration, and runtime exec rejects traced callers. A kernel memory+read alone cannot extract the TPM private key. Kernel code execution,+direct hardware access around the TPM driver, and compromise of an+authorized task remain outside this guard. The eventlog's public key+does not by itself prove TPM custody to a remote verifier. RSA+authorization is classical, unlike the operator's ML-DSA-87 artifact+signatures. A live session nonce and exact command hash prevent reuse+of an old authorization for a different extension.The index's TPM name is the SHA-256 of its public area (handle, namealgorithm, attributes, policy digest, size), prefixed with the@@ -226,17 +237,21 @@ history.TPM access~~~~~~~~~~-The TCTI is ``SHIRUDO_TPM_TCTI`` in the environment, else ``tpm.tcti``-in ``shirudo.conf``, else ``device:/dev/tpmrm0``, the kernel resource-manager. Initialization requires the trusted local TPM channel-described above. Register writes send command-bound signatures, not-the writer's private key. The device behind the path is root's to-replace, so every handle a command takes first recreates the-attestation key and compares its name with the one ``init`` froze in-the identity map; a substitute TPM is refused before the register is-read or written, and cannot forge evidence signed by the operator's-pinned attestation key either. The selected transport-implementation remains part of shirudo's trusted process code.+An authenticated-image target takes the TCTI from ``tpm.tcti``+in authenticated configuration, or defaults to ``device:/dev/tpmrm0``,+the kernel resource manager. It accepts only a device TCTI so+commands pass through the kernel guard, and refuses environment+overrides. Host-side tests without an active target image may use+``SHIRUDO_TPM_TCTI`` to select a software TPM. Register writes+send command-bound signatures, not private-key bytes.++The device path alone does not authenticate the TPM behind it. Before+reading or writing the register, Shirudo recreates the attestation key+and compares its Name with the one ``init`` froze in the identity map.+This rejects a different reported Name, but the Name is public: a fake+transport could replay it. Remote verification requires signed evidence+from the pinned attestation key. The selected transport implementation+remains part of Shirudo's trusted process code.Migration requires an updated target and initrd, atrusted reboot, and the updated operator verifier. The new policy@@ -670,10 +685,10 @@ context and the deferred mitigations the plan.----------``make -C testing test-tgt-register`` runs ``testing/tpm/t0034-register.sh``-in a dedicated pre-init KVM guest. It provisions a real kernel signing-key and freezes its public metadata in a BPF identity map; no signing-or keyring implementation is replaced. The libtpms command transport-controls PCR phases and TPM resets while the guest kernel and writer+in a dedicated pre-init KVM guest. It creates the TPM-held writer+and freezes its nonsecret input and public modulus in a BPF identity+map. The libtpms command transport controls PCR phases and TPM resets+while the guest kernel and writersurvive. This preserves lifecycle, attestation and credential-activationcoverage, including index recreation, the closed first-write window,reset recovery and late binding. It is a protocol test before the LSM@@ -697,7 +712,7 @@ implementation, without a TPM.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+the guest uses the production TPM-held writer and installed``shirudo`` binary. ``testing/tpm/t1108-tpm-chain.sh`` exercises measuredloads and unloads, initialization reuse, prediction, attestation,credential activation and rejection of forged writer evidence.@@ -706,35 +721,33 @@ production runtime's certificate selection.``make -C testing test-tgt`` also exercises theproduction initrd and switch-root path in ``testing/t1122-initrd.sh``.-``testing/helper/test-nv-cphash`` creates a separate kernel-held key with-the production provisioning function and signs through ``keyctl``.-It reuses the production TPM connection, NV lifecycle, kernel signing-and signed-policy helpers; only the invalid inputs and assertions are-test-specific. Production still selects its signing key from the-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 scratch-NV index in the guest. Replayed and corrupted signatures must fail-without changing NV. ``PolicySigned`` accepts an authorization for-event A; extending event B must fail without changing the value. A-fresh session then extends A and the test checks the exact result,-removes the scratch index and unlinks its temporary keyring.-No linker wrapping, software private-key files or production-fault-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.+``testing/helper/test-nv-cphash`` creates a separate TPM-resident writer+with the production provisioning function. It tests nonce and command+binding directly through ESYS on a scratch NV index. Both the pre-init+and protected target VMs run it; the guard allows this separate index.+Replayed and corrupted signatures must fail without changing NV. ``PolicySigned`` accepts an authorization for event A; extending+event B must fail without changing the value. A fresh session then+extends A and the test checks the exact result and removes the scratch+index. No software private-key file or production fault-injection hook+is used.++``testing/tpm/t1127-nv-writer.sh`` compares the writer's public modulus+with the init record. It checks that untrusted root cannot directly+extend Shirudo's register through either TPM device, whether the write+blocks, is nonblocking, or uses an inherited connection. A short+``NV_Extend`` command is also refused. Unrelated TPM signing, another+NV index and PCR extension remain available. The test verifies that+trusted loads and unloads still change the register, while a denied+extension leaves it unchanged.++``testing/helper/test-tpm-preopened`` opens a TPM connection after+initialization and forks an unrelated process which inherits it.+The child submits a direct ``NV_Extend`` for Shirudo's index.+The LSM must refuse the command with ``EACCES``, and reads before and+after must return the same register value. A TPM policy error or+transport failure does not pass this test. The connection is inherited+after LSM attachment; this test does not open a descriptor before+attachment.Configuration image measurements================================@@ -768,5 +781,5 @@ consistency without operator approval. Neither this replay nor a staticPCR proves that only the trusted updater issued the TPM command: directmeasurement writers can record a selection without the correspondingoperation. Restricting writers remains separate work for the config PCR;-the upatch NV register requires the guarded writer described above.+the upatch NV register has the extension guard described above.No IMA integration is added.