Skip to content

stage1: aarch64 sysctl tolerance, arch aliases, PCR replay file, drop init_on_free - #21

Merged
HarryR merged 10 commits into
mainfrom
aarch64-sysctl-arch-aliases
Nov 14, 2026
Merged

HarryR merged 10 commits into
mainfrom
aarch64-sysctl-arch-aliases

Conversation

@HarryR

@HarryR HarryR commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • init: sysctl -f now also skips, with a warning, a knob that exists but cannot be written (previously it only skipped missing ones). kernel/nmi_watchdog exists on aarch64 but rejects the write, which made init die. It is now -f. Every other hardening sysctl (panic_on_oops, softlockup_panic, ...) stays fatal-on-failure. nmi_watchdog=0 was never a hardening knob, so losing it on aarch64 does not weaken fail-closed behaviour.
  • Makefile: adds build-x86_64 / build-aarch64 / build-amd64 / build-arm64 aliases.
  • Makefile: the UKI's stage1 is now built alone (cargo build -p stage1), not with --workspace. Resolver 2 unifies shared-dependency features across every package in one cargo invocation, so co-building the host tools (mkuki, deploy) leaked their dependency features into the measured stage1 binary: building it alone changes the bytes (x86_64 bb12f3a0 -> ea7c72fd, aarch64 b040d7b1 -> 7720b36c) and so the UKI hash. (An earlier commit on this branch had dropped their --exclude; this supersedes both forms.)

Test plan

  • make ci, build-x86_64, build-aarch64
  • aarch64 chain boot: init logs nmi_watchdog=0 skipped (write failed) and continues

Self-test

  • HARNESS_TIMEOUT passes --timeout to the harness.
  • selftest-<arch>: test-chain in all 5 _stage2 admission modes plus smoke-args. A mode passes only if the leaf ran and received the stage1 attestation.
  • Part of workspace make selftest, which passed on x86_64 and aarch64 (the aarch64 runs show nmi_watchdog=0 skipped (write failed), after which init continues).

PCR replay file

tools/predict-pcrs.py (603dc62, f13596a) writes stage1.replay.json, a pcr-replay/v1 file (format and verifier: workspace tools/pcr-replay), from linux.efi alone: every event stage1 adds between stage0's handoff and the stage2 handoff, each with its derivation from the UKI and the digests computed here. Confirmed event by event against the Linux TCG event log of a QEMU stage0 -> stage1 -> stage2 boot:

PCR Events
5 "Exit Boot Services Invocation", "Exit Boot Services Returned with Success"
9 Linux EFI stub: LoadOptions (UTF-16LE .cmdline + NUL), then the initrd systemd-stub hands the kernel
11 systemd-stub: name + contents for .linux .osrel .cmdline .initrd .uname .sbat
14 input stage2: stage1's H_bank(sha256(stage2)) (bound to the next stage's entry)
  • The kernel is not measured into PCR4: stage0 loads the UKI through its Security2 override. It is covered by PCR14 (whole UKI, measured by stage0) and PCR11 (per section).
  • The PCR9 initrd is .initrd padded to 4 bytes followed by systemd-stub v259's generated cpio carrying .osrel as /.extra/os-release, expressed as a cpio_newc derivation and rebuilt byte for byte from systemd's cpio.c / stub.c.
  • UKIs with sections whose PCR9/PCR11 effect has not been verified against a real log (.ucode, .pcrsig, .profile, ...) are refused rather than guessed at.
  • build.sh writes stage1.replay.json next to linux.efi (replacing measurements.json); CI uploads it, so it ships in the attested release.
  • example-stage2 --dump-tpm (opt-in) prints the event log and all PCRs.

Verified with pcr-replay: QEMU x86_64 and aarch64 full chains; GCP n2d SEV and SEV-SNP full chains. The UKI rebuilds byte-identical.

Kernel cmdline: drop init_on_free=1

b86bc5a: on GCE c3 Intel TDX, init_on_free=1 kills the TD during early boot on every boot (a silent reset at varying points: ACPI parsing, the boot-time memory clear, the swiotlb conversion). Found by bisecting the cmdline one TDX VM per step: every combination with it died (21/21 boots), every combination without it booted first time, including the full production set minus init_on_free. Cause not understood yet. init_on_alloc=1 stays, so every allocation is still zeroed; what is lost is wiping freed data at free time, which SEV-SNP / TDX memory encryption already covers against the host. One UKI per arch for every cloud, so the change applies everywhere; the reason is recorded next to the cmdline in build.sh.

Verified: GCP c3 TDX and n2d SEV-SNP full chains; QEMU x86_64 and aarch64 full chains.

Release attestation covers the zip contents

The release job unzips both arches and attests, in the same single step, the 2 zips and the files inside each zip (now 8 per arch with stage1.replay.json). Subjects come from a subject-checksums file named <arch>/<path-in-zip>, so same-named per-arch files stay distinguishable. A consumer can verify the zip and extract from it as before, or verify any extracted file on its own (gh attestation verify <file> --repo lockboot/<repo> --signer-workflow ...). The listing step was tested on real build outputs: each extracted file's digest matches the built file.

🤖 Generated with Claude Code

HarryR and others added 7 commits November 4, 2026 08:27
`sysctl -f` now also skips, with a warning, a knob that is present but
not writable, not only a missing one. kernel/nmi_watchdog exists on
aarch64 but has no NMI watchdog behind it and rejects the write, which
died init. It is now marked -f; all other hardening sysctls stay fatal.

Makefile: add build-x86_64/build-aarch64/build-amd64/build-arm64 aliases,
and drop the `--exclude mkuki --exclude deploy` from the musl stage1
build so the whole workspace is built for the target.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
stage0 now builds its Secure Boot varstores with tools/mkvarstore.py
(stdlib only), so nothing runs virt-fw-vars, and pip was installed only
for it. Synced from stage0's canonical copy (workspace `make sync-harness`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HARNESS_TIMEOUT passes qemu-test.sh --timeout through to the harness, so
an unattended boot that hangs fails instead of blocking. selftest-<arch>
is this repo's part of the workspace `make selftest`: test-chain in every
_stage2 admission mode (sha256, sign, sign_args, manifest, fallback) plus
smoke-args; a mode passes only if the leaf ran and received stage1's
attestation. 300 s per boot on both arches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The uki-v* prefix dates from the pre-split lockboot/lockboot repo, where
one workflow carried two release tracks (stage0-v* and uki-v*) and the
prefix told them apart. Each repo now releases one product, so every
release repo uses plain v* (as vaportpm already does). Workflow
trigger, release-job ref checks, and docs updated; release asset names
are unchanged. The next stage1 release must sort above the existing
v0.1.0 / v0.2.0 pre-releases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The release attestation covered only the GitHub artifact zips. A
consumer can verify a zip and extract from it, but could not verify an
extracted file on its own. The release job now unzips both arches and
attests, in the same single attestation step, the zips plus every file
inside them. Subjects come from a sha256sum-format checksums file
(subject-checksums), named <arch>/<path-in-zip>, so the per-arch copies of
same-named files stay distinguishable; verification matches by digest.
xargs -r keeps an empty listing from hashing stdin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/predict-pcrs.py derives what stage1 adds to the PCRs from
linux.efi alone (confirmed event by event against the Linux TCG log of
a QEMU stage0 -> stage1 -> stage2 boot):
- PCR5: "Exit Boot Services Invocation" / "...Returned with Success".
- PCR9: the Linux EFI stub's LoadOptions (UTF-16LE .cmdline + NUL) and
  the initrd systemd-stub v259 hands the kernel: .initrd padded to 4,
  then the stub's generated cpio carrying .osrel as /.extra/os-release
  (reconstructed byte for byte from systemd's cpio.c / stub.c).
- PCR11: systemd-stub's name + contents pair for .linux .osrel
  .cmdline .initrd .uname .sbat.
- PCR14: stage1's H_bank(sha256(stage2)), an input.
The kernel is not measured into PCR4 (stage0 loads the UKI through its
Security2 override); it is covered by PCR14 (whole UKI) and PCR11. UKIs
with sections whose PCR9/PCR11 effect has not been verified (.ucode,
.pcrsig, .profile, ...) are refused rather than guessed at.

--emit-measurements writes only the fixed extends; build.sh emits
measurements.json next to linux.efi and CI uploads it, so it ships in
the attested release. --stage0 pcrs.json --stage2-sha256 gives the full
state at the stage2 handoff (stage0's PCR14 for this UKI added if
absent, checked if present).

example-stage2 --dump-tpm (opt-in) prints the Linux event log and all
PCRs for --check.

Verified, all predicted PCRs in four banks: QEMU x86_64 and aarch64.
The UKI rebuilds byte-identical with the new build step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The musl stage1 rule ran `cargo build --workspace`, so every crate in
the workspace (incl. the host tools mkuki and deploy since 44eef04
dropped their --exclude) was built together for the payload target.
Resolver 2 unifies the features of shared dependencies across every
package in one invocation, so host-tool dependency features leaked into
the measured stage1 binary: building stage1 alone changes it (x86_64
bb12f3a0 -> ea7c72fd, aarch64 b040d7b1 -> 7720b36c), and with it the
UKI hash. A host-tool dependency bump could otherwise move PCR14/PCR11
with no change to stage1. mkuki and deploy already have their own rules.

Verified: make ci; full-chain QEMU boot on x86_64 and aarch64 with the
rebuilt UKIs, every reconstructed PCR matching in four banks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HarryR HarryR changed the title init: tolerate unwritable optional sysctls (aarch64); build arch aliases stage1: aarch64 sysctl tolerance, arch aliases, PCR measurements Nov 6, 2026
HarryR and others added 2 commits November 10, 2026 03:23
….json

tools/predict-pcrs.py now writes stage1's PCR replay file from the UKI: every event systemd-stub,
the kernel's EFI stub and ExitBootServices add between stage0's handoff and the stage2 handoff,
each with its derivation from linux.efi (PE sections, the stub's generated initrd cpio, the
LoadOptions string) and the digests computed here, plus the stage2 input (PCR14). Format and
verifier: workspace tools/pcr-replay. build.sh writes it; CI uploads it with the UKI.

Verified: make tools/build-uki/<arch>/linux.efi writes it on both arches; QEMU x86_64 and
aarch64 full chains reproduce (pcr-replay CHAIN VERIFIES, 30 events re-derived and verified);
GCP n2d SEV-SNP full chain verifies with the workspace GCP platform file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… TDX)

On GCE c3 Intel TDX, init_on_free=1 kills the TD during early boot on every boot: a silent reset
at varying points (ACPI parsing, the boot-time "mem auto-init: clearing system memory", the
swiotlb private->shared conversion). Found by bisecting this cmdline one TDX VM per step: every
combination with init_on_free=1 died (21/21 boots), every combination without it booted first
time, including the full production set minus init_on_free. Cause not understood yet.

init_on_alloc=1 stays, so every allocation is still zeroed; what is lost is wiping freed data at
free time, which the confidential-VM memory encryption (SEV-SNP / TDX) already covers against
the host. One UKI per arch for every cloud, so the option goes everywhere.

Verified: GCP c3 TDX and n2d SEV-SNP full chains (stage0 -> UKI -> stage2 pcr-dump) complete;
QEMU x86_64 and aarch64 full chains verify.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HarryR HarryR changed the title stage1: aarch64 sysctl tolerance, arch aliases, PCR measurements stage1: aarch64 sysctl tolerance, arch aliases, PCR replay file, drop init_on_free Nov 10, 2026
The fill-in template predates lockboot-deploy and was wrong for stage0 (https:// URL, no
"payload" wrapper), so stage0 rejected it as written. lockboot-deploy create generates the
_stage1 document; the template is no longer built or uploaded. linux.efi unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HarryR
HarryR marked this pull request as ready for review November 14, 2026 05:56
@HarryR
HarryR merged commit 4ed240e into main Nov 14, 2026
5 checks passed
@HarryR
HarryR deleted the aarch64-sysctl-arch-aliases branch November 14, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant