fix(fde): fall back to default GRUB menuentry when grubenv has no saved_entry#128
Open
Wilbert957 wants to merge 1 commit into
Open
fix(fde): fall back to default GRUB menuentry when grubenv has no saved_entry#128Wilbert957 wants to merge 1 commit into
Wilbert957 wants to merge 1 commit into
Conversation
…ed_entry show-reference-value (load_kernel_artifacts) aborted with "saved_entry not found in GRUB environment" on freshly built / never-booted images, whose GRUB environment block is empty. GRUB's default selection order is next_entry > saved_entry > `set default`. On such images GRUB boots the default entry (`set default="0"`, i.e. the first menuentry), so fall back to resolving the first menuentry id from grub.cfg instead of failing. This lets reference values be computed for images that have not been booted yet, without mutating the image to fabricate a saved_entry.
|
@Wilbert957 ,您好,您的请求已接收,请耐心等待结果。 |
|
@Wilbert957 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。 |
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.
Problem
cryptpilot-fde show-reference-valuefails on a freshly built image that hasnever been booted:
load_kernel_artifacts(cryptpilot-fde/src/disk/grub.rs) hard-requiressaved_entryfrom the GRUB environment block. A never-booted image (a normalstate for an image produced by
cryptpilot-convert) has an emptygrubenv(
saved_entryis only written at runtime bysavedefault). GRUB's selectionorder is
next_entry > saved_entry > set default, and such images boot thedefault entry (
set default="0", i.e. the first menuentry), so the referenceextractor cannot determine the boot entry and errors out.
Fix
When
saved_entryis absent, fall back to GRUB's default entry by resolving thefirst
menuentryid fromgrub.cfg(matchingset default="0"), instead offailing. No image mutation required.
Testing
cargo fmt --check,cargo build -p cryptpilot-fdeandcargo clippy -p cryptpilot-fdepass. Verified with
cryptpilot-fde-host show-reference-value --disk <img>against aGCP/Ubuntu 24.04 image converted by
cryptpilot-convertwhosegrubenvis empty:reference values for kernel / initrd / grub / shim / kernel_cmdline are now produced
(previously it aborted).