Skip to content

fix(fde): fall back to default GRUB menuentry when grubenv has no saved_entry#128

Open
Wilbert957 wants to merge 1 commit into
openanolis:masterfrom
0gfoundation:fix/srv-default-entry
Open

fix(fde): fall back to default GRUB menuentry when grubenv has no saved_entry#128
Wilbert957 wants to merge 1 commit into
openanolis:masterfrom
0gfoundation:fix/srv-default-entry

Conversation

@Wilbert957

Copy link
Copy Markdown

Problem

cryptpilot-fde show-reference-value fails on a freshly built image that has
never been booted:

saved_entry not found in GRUB environment

load_kernel_artifacts (cryptpilot-fde/src/disk/grub.rs) hard-requires
saved_entry from the GRUB environment block. A never-booted image (a normal
state for an image produced by cryptpilot-convert) has an empty grubenv
(saved_entry is only written at runtime by savedefault). GRUB's selection
order is next_entry > saved_entry > set default, and such images boot the
default entry (set default="0", i.e. the first menuentry), so the reference
extractor cannot determine the boot entry and errors out.

Fix

When saved_entry is absent, fall back to GRUB's default entry by resolving the
first menuentry id from grub.cfg (matching set default="0"), instead of
failing. No image mutation required.

Testing

cargo fmt --check, cargo build -p cryptpilot-fde and cargo clippy -p cryptpilot-fde
pass. Verified with cryptpilot-fde-host show-reference-value --disk <img> against a
GCP/Ubuntu 24.04 image converted by cryptpilot-convert whose grubenv is empty:
reference values for kernel / initrd / grub / shim / kernel_cmdline are now produced
(previously it aborted).

…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.
@shankailun-aliyun

Copy link
Copy Markdown

@Wilbert957 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@Wilbert957 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start

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.

2 participants