Repository navigation
build: reproducible IGVM builds and build info files - #1240
Draft
bschaatsbergen wants to merge 8 commits into
Draft
bschaatsbergen wants to merge 8 commits into
bschaatsbergen wants to merge 8 commits into
Conversation
The measured image contained the checkout path and CARGO_HOME through panic locations, so the same commit measured differently in another directory. Remap them the way cargo's unstable trim-paths does, via --config so that .cargo/config.toml keeps applying. Sort the fs modules so the archive order is fixed. Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
RELEASE only reached the inner make through MAKEFLAGS from a top-level make RELEASE=1, so cargo xbuild --release built the TPM at -O0 while make RELEASE=1 built it at -O3. Set it from PROFILE either way. Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
assert() embeds __FILE__, which cmake passes as an absolute path, so NVMem.c carried the checkout path into the kernel. Map the repository root and OUT_DIR the same way xbuild does for the Rust side. Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
git describe picks the abbreviation length from the number of objects in the repository, so a shallow and a full clone of the same commit embedded different version strings. Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
A launch measurement alone does not say which code it stands for. Write a .buildinfo.json next to every IGVM with the commit, recipe and component hashes, firmware hash, build options, toolchain versions and the launch digest, so whoever publishes an image can publish what went into it, like the buildinfo files of Debian and other distributions. Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
Build the recipe given on the command line and compare the launch digest and image hash with a build info file. The file is only compared against: the recipe must hash to the recorded one before anything is built, and unknown fields are rejected, so a file from a third party cannot choose what gets executed. On a mismatch, list which inputs differ so the reason does not have to be guessed. Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
Build the qemu image in one checkout and verify it from a second one at a different path with another CARGO_HOME. Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
State what has to match for two builds to give the same measurement, and how to check an image against its build info file. Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
This branch has not been deployed
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.
Fixes #1239.
Building the same commit twice could give two different launch measurements:
__FILE__), so builds in different directories or with a differentCARGO_HOMEdidn't match.make RELEASE=1andcargo xbuild --releasebuilt libtcgtpm differently.RELEASEonly reached the libtcgtpm make throughMAKEFLAGS, so one built the TPM at-O3and the other at-O0.With this proposal, the same commit, recipe, firmware and toolchain should produce the same IGVM file and the same measurement everywhere.
Changes
--remap-path-prefixfor the workspace root andCARGO_HOMEvia--config target.x86_64-unknown-none.rustflags. This merges with.cargo/config.toml, unlikeRUSTFLAGS, which would replace it.RELEASEfrom the cargo profile and builds with-ffile-prefix-map.git describeuses a fixed--abbrev, so clones of different depth embed the same version string.Build info and verification
Each build now writes a
.buildinfo.jsonnext to the IGVM file, similar to Debian's buildinfo files. It records the commit, recipe hash, component hashes, firmware hash, build options, toolchain versions and the launch digest, and is meant to be published alongside the image.cargo xbuild --verify <buildinfo> <recipe>rebuilds and compares. On a mismatch it prints which inputs differ.On match:
On mismatch:
The buildinfo file is only used for comparison. The recipe must match the recorded hash before anything is built, and unknown fields are rejected, so a third-party file can't control what gets executed.
Needs a decision
cargo xbuild --releasenow builds the vTPM C code at-O3 -DDEBUG=NO, same asmake RELEASE=1always did. This changes the measurement for that documented path.This does not address
Vendors building from a private fork. Reproducible builds make a published commit checkable; unpublished source needs a separate discussion.