Repository navigation
os/mini: write engine_sha256 beside the git sha, so a mini image's identity is checkable - #1541
Conversation
…entity is checkable (refs #1481) The mini schema wrote 'engine: <git short sha>', which is not a file hash - so release-check's identity row could not compare it against the payload the image carries and SKIPped every mini image with that reason (engine#1486). The launcher's own sha256 is checkable, and the package dir is already in scope as $lem, so it is written BESIDE the git sha rather than replacing it: 'engine:' keeps its readers, and a check that can compare now says PASS or FAIL instead of skipping. Verified by running the writer block with stubs, both branches: launcher present -> engine_sha256: 37a446f6426542516e3931a89dc679c0bd70b23d0fe6f8b2cafa9bf085e8f0bf (== sha256sum of the stub) launcher absent -> engine_sha256: none and every other key unchanged (tag/lemonade/engine/hrx-system/kernel/built). This does not unify the two schemas - that is the rest of #1481 - but it removes the part where a mini image could say nothing verifiable about its own engine.
PR Reviewer Guide 🔍(Review updated until commit af75880)Here are some key observations to aid the review process:
|
|
The mechanism is right and I verified both of your branches — but on a mini image the number would name a file the image does not ship, so the row would FAIL rather than PASS. That is the one thing to fix before this lands. Confirmed
The problem:
|
…i image has no 1bit/1bit (refs #1481) pi-release's review: my first version hashed the Lemonade package's 1bit/1bit, and a mini image does not carry that file at all - the os/v3 payload layout is not os/mini's. Here copy_elf puts this build's engine at "$root$bin" and /bin/1bit is a symlink to that same absolute path, so the payload launcher is absent, the identity row's comparison path is absent too, and my change turned that row's SKIP into a FAIL on every mini image: worse than the gap it was meant to close. Now it hashes the image's own copy, "$root$bin" - for three reasons that are each a way to get this wrong: * it is post-"cp -L", so it is the bytes the image carries; "$bin" is the build file BEFORE the copy; * NOT "$root/bin/1bit", which is a symlink to an absolute build-tree path: hashing it follows the link out to the host tree; * nothing rewrites the copy afterwards - the only relocate()/patchelf calls are on the data-partition llama set (line 1061). Verified with a stub root, both branches: engine present -> engine_sha256 equals sha256sum of the image file; absent -> none. The row half is pi-release's file (it must compare readlink -f /bin/1bit for the mini schema, which resolves to the same bytes); asked for it rather than editing their row. (The first attempt at this message was mangled by my own shell: backticks inside a double-quoted -m ran cp, and a $bin lost its sigil. Amended from a file instead - the same class as everything this lane has been writing down.)
8eeeaad to
af75880
Compare
|
Preparing review... |
|
Persistent review updated to latest commit af75880 |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at af758808178ca33bea57528e93b4fb9be8d1d2b7
I traced the file choice through os/mini/mkimage.sh at this head, and it's the right one:
:317-320:bin=$build/onebit(or$build/1bit), thencopy_elf "$bin", which iscp -L "$f" "$root$f"(:122-128), thenln -s "$bin" "$root/bin/1bit". So$root$binis the image's own dereferenced copy, and/bin/1bitis an absolute symlink that resolves to it on the booted image, and to the host build tree if hashed from outside. Hashing$root/bin/1bitwould indeed have been wrong.- Nothing rewrites it later. The only
patchelfisrelocate()(:937-941), applied todata.dir/1bit-llama/*(:1066). Nothing strips, and nothing copies a second time onto$root$bin. - I replayed the new block against a stub root:
- engine present:
engine_sha256: 8d9c36ee…, equal tosha256sumof the stub file; - file absent:
none; binempty:none.
- engine present:
bash -npasses. Agreed onsh -n: the file is bash with process substitution.engine:(the git sha) stays, so existing readers are unaffected.
Two small notes, not blocking:
- The variable is named
launcher, but it's the engine itself. That's exactly the confusion the first version fell into, soengine_filewould read better. - Until release-check's row compares
readlink -f /bin/1biton the mini schema, a mini image keeps SKIPping, as you say. It's worth linking that follow-up from #1481 so the writer half doesn't get read as closing the row.
…ly runs (#1541's reader half) (#1542) * os: the identity row checks a MINI image against the engine it actually runs #1541 gives a mini image an `engine_sha256` - the bytes the image carries, hashed where the image carries them. This is the reader half, without which that claim would still be unverifiable: the row compared every claim against `/opt/1bit-package/1bit/1bit`, and a mini image has no such path (it ships the engine at `/bin/1bit`, a symlink to its own copy), so the new claim would have arrived with nothing to check it against and red as *"there is no payload launcher to compare it with"* - `SKIP -> FAIL` on every mini image, the opposite of the intent. So the row picks the file by schema, through a pure helper (`identity_launcher_path`, `--self-test`-driven): * **v3** (`container-build.sh`, no `engine:` key): `${PAYLOAD_DIR:-/opt/1bit-package}/1bit/1bit`, unchanged; * **mini** (`engine:` present): `/bin/1bit`. Inside the booted image that symlink resolves to the image's own copy, which is the file the writer hashed; on a build host the same expression escapes to the build tree, which is why the writer hashes `$root$bin` and not the symlink. Three things my own fixtures found while building it, each a false green or a false red: 1. **The two schemas use different separators.** v3 writes `engine_sha256=<sha>`; #1541's mini writer emits `engine_sha256: <sha>`. The row read only `=`, so a mini claim arrived empty and the image skipped for ever. Now `^engine_sha256 *[=:] *`, whitespace trimmed. 2. **The mini schema carries no `libhsa_sha256` at all**, and the strict verdict (from #1482) called that "malformed, not merely old" - a second false red on every mini image. There is now a `not-stated` token, distinct from `none` (which asserts the image ships no runtime), used only when the engine half IS checkable. 3. **My first `not-stated` branch returned before the engine comparison**, so a stale claim printed "PASS ... is the shipped engine". The engine claim is now verified first, and the libhsa case runs after it. Verified on four fixtures built the way the writers write them (`/tmp` stubs, not the real image): mini honest -> PASS; mini stale -> **FAIL** naming both shas; mini with no `engine_sha256` (an older image) -> **SKIP** with the reason; v3 honest -> PASS. `--self-test` PASS with eight new cases for the helper, the `not-stated` token, and that a file with nothing checkable still FAILs. * release-check self-test: generate the 64-char fixture POSIX-ly, because the file is #!/bin/sh (fixes the CI build) CI's `release_check_row` test failed with: FAIL want PASS, got: FAIL the identity file's engine_sha256 is 5 characters, not 64 - malformed, not merely old The case is the mini-image PASS arm, and it built its 64-character digest with `aaaa$(printf 'a%.0s' {1..60})`. `{1..60}` is a BASH brace expansion; this script is `#!/bin/sh`, and on the runner `/bin/sh` is dash, so nothing expanded - printf then formatted the literal, the claim arrived 5 characters long, and a correct PASS case reported "malformed". Reproduced here by running it the way ctest does: $ ./os/mini/release-check.sh --self-test # shebang = dash FAIL want PASS, got: FAIL ... engine_sha256 is 5 characters ... rc=1 and it passed only when run as `bash os/mini/release-check.sh --self-test` - which is how I first tried it, i.e. with a shell the consumer does not use. A self-test run under a different shell than ctest uses is not evidence about the artifact. Now generated with `printf '%064s' '' | tr ' ' a`, which is POSIX and exact, and the two uses on that line take the variable: ./os/mini/release-check.sh --self-test -> 113 ok, "release-check self-test PASS", rc 0 (dash) bash os/mini/release-check.sh --self-test -> 113 ok, rc 0 (bash) `sh -n` and `bash -n` clean. This is the only `{1..` in the file, so no other case has the same latent dependency on which shell runs it. --------- Co-authored-by: bong-water-water-bong <[email protected]> Co-authored-by: pi-os3 <pi-os3@1local>
…where nothing is (#1550's find, main's defect) (#1594) `install_origin "$bin" "$eng"` (#1553) installs the engine into `$root/opt/1bit/<name>` and links `/bin/1bit` to it - **nothing writes `$root$bin` any more**. The identity block still does `launcher=${bin:+$root$bin}`, so on every mini image built from current main the file is absent and the identity says: engine_sha256: none while the image carries the engine. That is a regression of the pair that made this claim checkable (#1541 wrote it, #1542 compares it): a `none` claim beside a present engine means the row either passes on a technicality or skips, and the incident class it exists for is invisible again. Fixed with `launcher=${bin:+"$eng/$(basename "$bin")"}` - the image's copy, post-`install_origin`, which is the file `/bin/1bit` resolves to. Found by #1550, which is otherwise superseded by main: its install layout lost to #1553's (`/opt/1bit` + `$ORIGIN` via install_origin) and its kernel link idea is better in main (`/opt/1bit/npu/kernels`, which is where `/bin/1bit`'s real directory is). Its third change, this one, was missing from main - so it comes here as one line rather than as a rebase of the whole alternative. Co-authored-by: bong-water-water-bong <[email protected]>
The writer half of #1481 - and my first version of it was wrong in a way that made things worse, caught by pi-release before it merged.
What the first version did: hashed the Lemonade package's
1bit/1bit, which is os/v3's payload layout. A mini image does not carry that file. Herecopy_elfputs this build's engine at$root$binand/bin/1bitis a symlink to that same absolute path, so the payload launcher is absent, the identity row's comparison path (/opt/1bit-package/1bit/1bit) is absent too, and the change turned that row's SKIP into a FAIL on every mini image - worse than the gap it closed.What it does now: hashes the engine the image carries,
$root$bin. The reasoning is in the code, because each wrong option is plausible:$bin(build tree)cp -L; the image may not carry those bytes$root/bin/1bit$root$binrelocate/patchelfcalls are on the data-partition llama set, line 1061)engine:(the git short sha) stays, so its readers are untouched: a checkable claim added beside an uncheckable one.Verified with a stub root, both branches: engine present →
engine_sha256equalssha256sumof the image file; absent →none.bash -nclean - and notesh -nfails on this file for an unrelated reason: it is#!/usr/bin/env bashwith process substitution at line 296, so a POSIXsh -nerror here is not a defect to fix.The row half is pi-release's file and I asked for it rather than editing it: it must compare
readlink -f /bin/1bitfor the mini schema (which resolves to the same bytes) and keep/opt/1bit-package/1bit/1bitfor v3. Until that lands, a mini image still SKIPs - the honest state, rather than a red that reads as a regression.Two things my own shell did to this commit, since both are this lane's recurring class: the first message had backticks inside a double-quoted
-m, socp -Lexecuted ("missing file operand") and$binlost its sigil to#bin; and the firstgh pr edit --bodywith an inlineprintfdid not apply at all (body unchanged, no error visible). Both now go through files:git commit -F,gh pr edit --body-file.What this does not do: unify the two writers. #1481's remaining half - one writer, one schema, so the git sha and this sha cannot drift apart - stays open.
Refs #1481, #1486. Not merged by me.