Skip to content

feat(cryptpilot-convert): pin systemd UEFI stub via --uki-stub-version - #133

Open
imlk0 wants to merge 2 commits into
masterfrom
stable-systemd-stub
Open

feat(cryptpilot-convert): pin systemd UEFI stub via --uki-stub-version#133
imlk0 wants to merge 2 commits into
masterfrom
stable-systemd-stub

Conversation

@imlk0

@imlk0 imlk0 commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Background

Different systemd-stub versions measure into PCR4/PCR8/PCR12 differently. Today the stub is sourced on demand from the distro repo (yum install systemd-boot-unsigned), so its version floats with the distro and the UKI measurement reference is unstable across builds.

Change

Add --uki-stub-version <distro|version> (only meaningful with --uki):

  • distro (default) — installs systemd-boot-unsigned from the distro repo. Preserves the legacy behavior; the default is unchanged.
  • <version-prefix> — downloads a pinned, unsigned stub from the public Arch Linux Archive, resolved to the highest matching package. The prefix must be followed by a segment boundary (. or -), so 261 resolves to the latest 261.x while 25 does not silently jump to 259.x — it errors and lists the available versions.
value resolved package fully pinned?
261 latest 261.x (e.g. 261.2-1) no (latest at build time)
261.2 261.2-1 no
261.2-1 261.2-1 yes

The pinned stub is downloaded (curl) and extracted (zstd + tar) on the host, placed at the canonical path …/boot/efi/linuxx64.efi.stub that dracut --uefi expects, then removed (restoring any pre-existing one) so the converted image's rootfs is byte-for-byte unchanged. The resolved exact version and stub sha256 are logged, so a loose prefix can be verified once and then pinned exactly.

curl/zstd/tar are installed at step 0 when the Arch path is selected, and prefetched with a clear error if still missing.

Why Arch

systemd upstream ships no prebuilt EFI binaries. The Arch Linux Archive is public, unsigned (fine for measurement), and permanently archives every historical package version — true version pinning. Fedora koji and other distro archives were also surveyed; Arch is the only one that satisfies public + unsigned + full historical pinning + reachability.

Verification

End-to-end on an Alinux 4 image, inside an alinux4 container (host e2fsck 1.46 is too old for the alinux4 ext4):

  • --uki-stub-version 261 -> systemd-261.2-1, stub sha256 2d9b8073…ba18 -> measurement.uki.SHA-384 19296c51…e9c8c25
  • --uki-stub-version 260 -> systemd-260.2-2, stub sha256 26e9f431…2d1b -> measurement.uki.SHA-384 afabccc6…1f7716ab

Distinct stubs yield distinct measurements — confirming version pinning is what stabilizes the PCR reference. The converted rootfs is left unchanged (the placed stub is removed; the dir does not survive). The embedded stub in the produced qcow2 matches the expected Arch stub byte-for-byte (identical .sbat section, sha256 f5591c24…66a16; the .sbat text names systemd 260.2 from Arch Linux).

bash -n, cargo fmt --check, cargo build, and make clippy pass.

Docs

boot.md / boot_zh.md (UKI mode), quick-start.md / quick-start_zh.md, and the spec changelog updated.

Also in this PR

  • docs(claude.md): formalize the project Git Commit Requirements — require a Signed-off-by trailer (the author's identity, via git commit -s or by hand) on every commit, require an Assisted-by: AGENT:MODEL [TOOLS] trailer as the only accepted AI attribution on Claude-authored commits, and forbid hand-editing cryptpilot.spec version/%changelog (versioning is produced by make bump-version-{major,minor,patch} at release time).

@ostest-bot

Copy link
Copy Markdown

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

@ostest-bot

Copy link
Copy Markdown

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

@ostest-bot

Copy link
Copy Markdown

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

@ostest-bot

Copy link
Copy Markdown

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

imlk0 added 2 commits August 31, 2026 14:48
Add a --uki-stub-version <distro|version> option (requires --uki) to
control the source of the systemd UEFI stub (linuxx64.efi.stub) used
to assemble the UKI:

- "distro" (default) installs systemd-boot-unsigned from the distro
  repo, preserving the legacy version-floating behavior.
- A version prefix (e.g. 261, 261.2-1) downloads a pinned, unsigned
  stub from the public Arch Linux Archive, resolved to the highest
  matching package. The prefix must be followed by a segment boundary
  ("." or "-") so a short prefix like "25" does not silently jump to
  259.x; on no match the error lists the available versions.

The pinned stub is downloaded (curl) and extracted (zstd + tar) on the
host, placed at the canonical path dracut --uefi expects, then removed
(restoring any pre-existing one) so the converted image's rootfs is
byte-for-byte unchanged. The resolved exact version and stub sha256 are
logged for measurement traceability.

Different systemd-stub versions measure into PCR4/PCR8/PCR12
differently; pinning the stub keeps the UKI measurement reference
values stable across builds.

Also install curl/zstd/tar when the Arch path is selected, and preflight
those tools with a clear actionable error.

Docs (boot.md/boot_zh.md, quick-start) updated.

Verified end-to-end on an Alinux 4 image: --uki-stub-version 261
resolves to systemd-261.2-1 (sha256 2d9b8073...) and 260 to
systemd-260.2-2 (sha256 26e9f431...), yielding distinct UKI
measurement.uki.SHA-384 values; the embedded stub in the produced
qcow2 matches the expected Arch stub byte-for-byte (.sbat).

Signed-off-by: Kun Lai <laikun@linux.alibaba.com>
Assisted-by: Claude:glm-5.2
Document the project's commit conventions in the Git Commit Requirements
section:

- Require a Signed-off-by trailer with the author's own identity on every
  commit (git commit -s, or added by hand).
- Require an Assisted-by trailer (AGENT_NAME:MODEL_VERSION [TOOLS]) as the
  only accepted form of AI attribution on Claude-authored commits.
- Never commit plan/spec files or anything that is gitignored.
- Never hand-edit cryptpilot.spec Version/Release/%changelog; version and
  changelog are produced at release time by make bump-version-{major,minor,patch}.

Signed-off-by: Kun Lai <laikun@linux.alibaba.com>
Assisted-by: Claude:glm-5.2
@imlk0
imlk0 force-pushed the stable-systemd-stub branch from 2bf56c0 to b899655 Compare August 31, 2026 06:51
@ostest-bot

Copy link
Copy Markdown

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

@ostest-bot

Copy link
Copy Markdown

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

@ostest-bot

Copy link
Copy Markdown

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

@ostest-bot

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /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