Repository navigation
refactor(native): hyperrs-elfsum crate + single native/ Cargo workspace - #106
Merged
Merged
Conversation
Fold the `meta` constants crate, `src/checksum.rs` and xtask's zero/hash/write logic into one crate. The `slot!` macro owns the `.note.sum` literal, `Slot::get` reads via `read_volatile` so the stamped digest cannot be constant-folded to zeros, and the `stamp` feature (blake3 + object) stays out of the release helper. Stamping/verification are now pure functions over `&[u8]`, covered by inline property tests. The digest algorithm is unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Move hyperrs-elfsum to native/hyperrs-elfsum and put guest-agent, hyperrs-elfsum, suidhelper and xtask in a single workspace with one Cargo.lock, target/, rust-toolchain.toml and nextest config. The lock is the union of the two old locks; no dependency versions changed. Release profiles now live at the workspace root. The helper keeps its profile as `release`; the guest agent's lto/panic=abort/codegen-units settings move to a `release-guest` profile so neither binary changes. CI: the guest-agent and suidhelper jobs become one workspace job that runs fmt, clippy and nextest across every crate (guest-agent and xtask were previously not tested in CI). Paths in the Mix compilers, install task, integration coverage export and release workflow follow the shared target/. release.yml now bumps hyperrs-elfsum instead of the deleted meta crate.
markovejnovic
marked this pull request as ready for review
October 31, 2026 20:14
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.
What
Folds the
metaconstants crate,src/checksum.rs, and xtask's zero/hash/write logic into one crate,hyperrs-elfsum(native/hyperrs-elfsum/).Digest,Slot::{get, hex}, and achecksum!()expression macro that declares the#[link_section = ".note.sum"] #[used]static in the calling crate and returns&'static Slot(invoke once per binary: two expansions make a 64-byte section, which stamping rejects withWrongSize).stampfeature (blake3 + object + thiserror, used by xtask):Elf::readvalidates once that.note.sumexists, is exactly 32 bytes, and lies inside the file; the resultingElfthen offers an infalliblestamp()(only for mutable buffers). Section bounds are checked byobject(section.data()), the size byTryFrom<&[u8]> for &[u8; 32]; errors are a typedError.xtask's
stamp.rsis now just build → static-link check →Elf::read(..)?.stamp()→ write.Why
link_sectionliteral now lives only inside the crate's macro, not hand-mirrored in the helper.Slot::getreads viaread_volatile. Before, the slot was a plain immutable all-zero static, which the compiler may constant-fold, soversioncould report zeros even after stamping (unverified on a real build; see below).The digest algorithm is unchanged (BLAKE3 of the file with the slot zeroed), so existing stamps and
Hyper.SuidHelper.Expectedstay compatible.Tests
Inline in the crate, per the new inline-tests direction:
WrongSize;checksum!()macro lands in.note.sumwith the right size.CI runs these via the new workspace job (below).
Verification status
hyperrs-elfsumtests (9/9) pass on macOS; clippy-D warningsclean for elfsum, xtask, and the helper (aarch64-musl, with and withoutinsecure_mode).cargo tree: the release helper linkshyperrs-elfsumwithout blake3/object.cargo xtask stamp && target/hyper-suidhelper versionshould print a non-zero checksum.Follow-ups (not in this PR)
Slot::get'sunsafeneeds a SAFETY comment.Cargo.tomlabovedefault-members("only touch the helper itself"), andxtask/src/stamp.rsmentions a verifier that re-hashes, which does not exist (the runtime check compares the helper's self-reported checksum).Second commit:
native/is one Cargo workspaceguest-agent,hyperrs-elfsum,suidhelper,suidhelper/xtask, sharing oneCargo.lock,target/,rust-toolchain.tomland.config/nextest.toml.cargo metadata --lockedpasses and no dependency versions changed.release(opt-level = "z",strip). The guest agent'slto/panic = "abort"/codegen-units = 1can't be set per package, so they move to arelease-guestprofile, which:guest_agent_buildnow uses. Neither binary's build settings change.Rust (guest-agent)andRust (suidhelper)are merged into oneRust (native workspace)job:fmt --all,clippy --workspace,nextest --workspacewith coverage. This adds the guest agent's tests and xtask, which CI didn't run before. Required status checks in branch protection need renaming.target/dirs are updated: the Mix stamp compiler,mix suidhelper.install, the guest-agent compiler, xtask'starget_dir(), the integration coverage export, andrelease.yml.release.ymlwas still bumping the deletedmeta/Cargo.toml(broken by the first commit); it now bumpsnative/hyperrs-elfsum/Cargo.toml.rustup target add x86_64-unknown-linux-muslsteps in the elixir/integration jobs are dropped; the nightly toolchain file already installs both musl targets.mix compile(stamp + guest build) andmix format(needs deps on this machine).