Repository navigation
Build the same enclave image on every machine - #7
Merged
Merged
Conversation
The same commit measured to two PCR0s: 458969f7 from CI, 7bdd3f85 from a workstation. Taking both images apart, the kernel, the command line, the boot ramdisk and every file of the rootfs but two were identical. The two were the ZFS modules, spl.ko and zfs.ko: ZFS's assertions carry __FILE__, so the modules recorded where they were compiled, /build/source in a sandboxed Nix and /tmp/nix-build-zfs-kernel-…/source in one without a sandbox. The module build now maps its build directory to /build, the sandbox's own path. A sandboxed build is unchanged by it, and a workstation's now measures to CI's PCR0: 458969f7 from both. PCR0 for every image already built in a sandbox stays what it was. eif_build's clock is also frozen rather than started at the epoch: with the @ faketime let it run, and BuildTime's nanoseconds differed between builds. That is metadata, which no PCR covers, but it kept the files from being identical; `nix build .#eif-qemu --rebuild` now passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The same commit (
c4a0b96) measured to two PCR0s:458969f7…built by CI, and7bdd3f85…built on a workstation. PCR0 is what KMS releases the key against and what clients pin, so it has to come out the same for anyone who rebuilds.What differed
I extracted both EIFs section by section:
kernel,cmdlineandramdisk1were identical.ramdisk2, every file but two was identical:lib/zfs/spl.koandlib/zfs/zfs.ko.ZFS's assertions use
__FILE__, so the modules contain the directory they were compiled in. That is/build/source/module/…in a sandboxed Nix (CI) and/tmp/nix-build-zfs-kernel-2.4.3-6.6.150.drv-0/source/module/…in a Nix without a sandbox (the workstation runs nix-portable).The fix
nix/kernel-zfs.nix: the ZFS module build getsKCFLAGS=-ffile-prefix-map=$NIX_BUILD_TOP=/build, which maps the build directory to the sandbox's own path. A sandboxed build is unchanged by it.nix/eif.nix:faketime '1970-01-01 00:00:01'instead of'@…'. With@, faketime starts the clock there and lets it run, soBuildTimein the image metadata differed in its nanoseconds. No PCR covers that metadata, but it kept the two files from being byte-identical.What was run (on the workstation, Nix without a sandbox)
nix build .#eif-qemugives PCR0458969f7226521dfacf5aa0a1988d1193420d6e441d188d0e51dd11e53b585711f288e4a4924572768427653df3e05c3, CI's published value. Every measured section is byte-identical to CI's image.nix build .#eif-qemu --rebuildpasses: two builds produce the same file.What was not run
.#eif, the production image, separately. It takes its ZFS modules from the samekernel-zfs.nix.🤖 Generated with Claude Code