fix(fde): resolve default GRUB menuentry when grubenv has no saved_entry#126
Closed
Wilbert957 wants to merge 2 commits into
Closed
fix(fde): resolve default GRUB menuentry when grubenv has no saved_entry#126Wilbert957 wants to merge 2 commits into
Wilbert957 wants to merge 2 commits into
Conversation
`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. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@Wilbert957 ,您好,您的请求已接收,请耐心等待结果。 |
|
@Wilbert957 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。 |
Wilbert957
pushed a commit
to 0gfoundation/0g-tapp
that referenced
this pull request
Jun 24, 2026
…nce-value Document how to compute remote-attestation reference values from the built image with `cryptpilot-fde show-reference-value --disk`, including: - the prerequisite cryptpilot-fde fix (openanolis/cryptpilot#126) so it works on never-booted images (empty grubenv) without the convert workaround - how to build the fixed cryptpilot-fde from the 0gfoundation fork branch - flags (--disk, --hash-algo, --stage) and the AAEL reference-value outputs Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
load_from_grub_cfg only matched `linuxefi`/`initrdefi` and split on spaces, so it failed on Ubuntu grub.cfg, which uses `linux`/`initrd` directives that are tab-separated (`linux\t/vmlinuz... root=...`). The kernel path ended up empty and show-reference-value aborted with "Failed to read kernel file at /boot/ (Is a directory)". Match the directive by its first whitespace-delimited token (linux|linuxefi, initrd|initrdefi) and split paths/cmdline on any whitespace, so both the alinux UEFI (linuxefi) and Ubuntu (linux) layouts work. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author
|
Superseded: re-done against current master (0.8.0) at the correct location cryptpilot-fde/src/disk/grub.rs. The earlier branch was based on a stale 0.2.7 checkout. |
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(src/cmd/fde/disk.rs) hard-requiressaved_entryfrom the GRUB environment block:
But a never-booted image (a normal state for an image produced by
cryptpilot-convert) has an emptygrubenv—saved_entryis only written atruntime by
savedefault. GRUB's selection order isnext_entry > saved_entry > set default, and these images boot the defaultentry (
set default="0", i.e. the first menuentry). So the reference-valueextractor 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 is required.
default_menuentry_id(grub_cfg)extracts the id (thequoted token before the entry's opening brace), skipping non-entry lines such
as
menuentry_id_option=....load_kernel_artifactsuses the existingsaved_entrywhen present, otherwisethis fallback.
Testing
cargo checkpasses. Verified against a GCP/Ubuntu 24.04 image converted withcryptpilot-convertwhosegrubenvis empty and whosegrub.cfgusesset default="0".🤖 Generated with Claude Code