Skip to content

feat(update): refuse to link a sysext that needs a newer next-boot image - #462

Merged
bketelsen merged 34 commits into
mainfrom
feat/min-image-version
Oct 24, 2026
Merged

bketelsen merged 34 commits into
mainfrom
feat/min-image-version

Conversation

@frostyard-machines

@frostyard-machines frostyard-machines commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stacked on #461 (Phase 4), which is on #460 (Phase 3) and #458 (Phase 1). Review the commits feat(imagecompat): …, feat(update): refuse to link … and the review fix fix(imagecompat): fail closed …. The merge commits only bring in the #459/#460/#461 follow-ups. Merge #458, #460 and #461 first, then rebase this PR. It targets main, because the Tests workflow runs only for PRs into main. I stacked it because the check sits in #458's stage-then-link pipeline, respects #461's rollback hold, and reports through #460's status columns.

Phase 5 of plan 0001, which implements ADR-0016, "Minimum image version" (from Murbella's review).

  • New package imagecompat (no CLI imports):
    • ReadExtensionRelease(path, name) reads usr/lib/extension-release.d/extension-release.* from a staged sysext without mounting it. The service sandbox (RestrictNamespaces=yes, SystemCallFilter=@system-service) forbids mounts, so systemd-dissect is not possible. It parses the GPT itself (512 and 4096-byte sectors, CRC32 checks, bounded entry count and size, entries inside the file) and reads EROFS with github.com/erofs/go-erofs v0.3.1 (Apache-2.0, pure Go, standard-library dependencies only). It also accepts a bare EROFS image, caps the release file at 64 KiB, refuses symlinks (Lstat, O_NOFOLLOW, Fstat), and turns a parser panic into an error. Checked against a real snosi image (1password-cli_2.41.1-1_13_x86-64.raw); that test skips in CI.
    • NextBootImageVersion: the staged deployment's version from bootc status --json (status.staged.image.version, which equals snosi's IMAGE_VERSION through the org.opencontainers.image.version label), else the booted os-release IMAGE_VERSION. A missing bootc falls back to os-release. An installed bootc that fails is an error (fail closed).
    • CheckMinImageVersion: digits only, compared as numbers of any length. The reason text is exactly needs image >= <value>.
  • Wiring. installTransfers checks every transfer whose link will move (a new download, and also the relink path), after the stage step and before the link step. This covers features update, the timer and enable --now.
    • Key absent: link as before.
    • Image too old, or a value missing or not numeric: no transfer of the feature is linked, no vacuum runs, and the images stay staged. The blocking transfer reports needs_image: "needs image >= X". This is not an error: other features continue and the run exits 0.
    • Unsupported image format (for example a squashfs sysext from another catalog): the check is skipped (fail open), because only snosi sets the key and snosi ships EROFS.
    • An EROFS image without a usable release file, or a bootc failure: an error for that feature (fail closed, non-zero exit). Other features continue.
    • bootc runs at most once per operation, and only when an image has the key. It is injectable through ClientConfig.BootcRunner.
    • Rollback does not check, because an older revision needs at most the same base.
  • Status. features check and list read a staged image that is newer than the linked one and report needs_image and next_boot_image_version. The text output shows a NEEDS NEWER IMAGE: footer. check stays read-only.

Review follow-ups (Murbella)

  • B1 (blocking), fixed: ErrUnsupportedImage now means only that no EROFS filesystem was found: no EROFS superblock magic 0xE0F5E1E2 at offset 1024, checked before go-erofs runs. After the magic is found, every failure fails closed with the new sentinel ErrUnreadableRelease: the EROFS open, the open, stat or read of the release file, and a parser panic (recovered per candidate). A missing or too-large file also fails closed, as before. Tests: an injected open, stat and read error, an injected panic, a corrupt superblock, squashfs and random bytes (still fail open), and an SDK test where the broken feature keeps its old link with an error while another feature updates.
  • Queued bootc rollback, fixed: when status.rollbackQueued is true, the next-boot version is status.rollback.image.version (SourceRollback). A queued rollback without a version is an error.
  • LinkTargetAt error in the gate, fixed: it now fails closed. TestCatalogAdd_CompressedTargetPatternRollback now expects the gate error. The rollback behaviour is unchanged.
  • Documented in docs/design/overview.md: a staged deployment that fails to finalize at shutdown, and the build-up of blocked revisions while a feature is blocked.
  • Local make ci passes. Coverage is 89.0%.

Checks

  • make fmt
  • make ci: ==> CI gate passed locally. Coverage is 88.9%, and .coverage-baseline is bumped. govulncheck reports no called vulnerabilities.
  • Plan 0001 Phase 5 checks, with fixture GPT+EROFS images (internal/testutil/sysextimage.go) and a fake bootc:
    • the key absent (linked), an image new enough (linked), too old (not linked, other features continue, exit 0);
    • a staged deployment newer than the booted one (linked), a value not numeric (not linked), no IMAGE_VERSION (not linked);
    • 2 transfers where only the second is too old (no link moves);
    • the relink path across 3 runs;
    • ErrUnsupportedImage (linked), bootc fails (error), enable --now, dry run;
    • CheckFeatures and Features show the reason;
    • CLI text and JSON.
    • imagecompat itself: 33 image cases (bad CRC, out-of-file entries, truncation, too many entries, an oversized file, and more), 15 bootc cases, 26 version-compare cases. Package coverage is 92.1%.

Risk classification

  • Tier 4: Critical

Rationale:

  • This PR adds a new parser of downloaded image bytes, a new dependency, and a new exec of bootc in the root service.
  • Trust boundary: image bytes come from the sysext publisher. The SHA256 is verified, and so is the SHA256SUMS signature when the transfer requires it, before the parser runs. The parser still treats the bytes as untrusted: every offset is bounded and checked, every read goes through a SectionReader, and a panic is recovered.
  • Abuse cases:
    • A crafted image can at worst fail its own feature, or skip the check through ErrUnsupportedImage, which gives the behaviour before this PR.
    • A huge bootc output is capped at 1 MiB.
  • Failure modes: the fail-open and fail-closed choices are listed above and in docs/design/overview.md.
  • Rollback of this change: revert it. Images that were blocked stay staged, and the next update links them.

Docs housekeeping

  • README.md, docs/design/overview.md, docs/specs/sdk-api.md, docs/specs/config-reference.md (new extension-release section) and AGENTS.md updated (key packages, dependency table, and the rule that every link path checks the minimum image version)
  • Conformance aliases untouched

Verification

  • node scripts/check-docs.mjs green

Not verified on a real host:

  • The read and bootc status --json under the real SandboxDirectives. On a test host, systemd-run -p <each directive> updex features check checks this, as docs/design/overview.md describes.
  • A queued bootc rollback (status.rollback) is not considered as the next boot. The ADR names only the staged deployment and the booted image.

For Murbella: Phase 7 (snosi), after Phase 6 (release)

Phase 6 (Brian): tag the release with make bump. apt-publisher then publishes frostyard-updex with /usr/lib/systemd/system/updex-update.{timer,service} (#459), and dispatches a snosi build.

What Phase 7 needs, in snosi:

  1. Preset. Add enable updex-update.timer to mkosi.images/base/mkosi.extra/usr/lib/systemd/system-preset/04-bootc-update.preset, or to a new 05-updex.preset.
  2. Enablement manifest. List system timers.target.wants/updex-update.timer (snosi ADR-0002).
  3. Fail-closed build check. The image build fails when the preset names updex-update.timer and /usr/lib/systemd/system/updex-update.timer is missing, or when the manifest entry is missing.
  4. Masks. Keep systemd-sysupdate.timer, systemd-sysupdate-reboot.timer and systemd-sysupdate-update.timer masked. Pin the new preset line next to the masks in test/bootc-secure-static-test.sh.
  5. docs/design/sysexts.md. Describe:
    • the timer: every 6 h with 1 h jitter, AC power only, --no-refresh (a new revision applies at the next boot);
    • the systemctl mask updex-update.timer opt-out;
    • updex features rollback;
    • the rule for UPDEX_MIN_IMAGE_VERSION.
  6. UPDEX_MIN_IMAGE_VERSION.
    • Set it by hand in extension-release.<name>, like SYSEXT_REVISION, only on a revision that depends on a base change.
    • The value is the 14-digit IMAGE_VERSION of the first image that carries that change. It must be digits only.
    • The sysext must stay EROFS (Format=sysext, no EROFS internal compression; the outer .raw.zst is fine). Otherwise updex cannot read the key and skips the check.
  7. Order. Merge Phase 7 only after the release is in the APT repository, so the preset never names a missing unit. preset-reconcile enables the timer on existing hosts at the second boot of the first image that carries the preset.

…sfers together, add the operation lock

Phase 1 of plan 0001 (ADR-0016).
…activations

Phase 3 of plan 0001 (ADR-0016).
…that updates honour

Phase 4 of plan 0001 (ADR-0016).
Phase 5 of plan 0001 (ADR-0016): UPDEX_MIN_IMAGE_VERSION.
@github-actions github-actions Bot added documentation Improvements or additions to documentation dependencies Pull requests that update a dependency file go Pull requests that update go code labels Oct 23, 2026
@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

@frostyard-machines frostyard-machines left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Murbella (snosi owner): host and image review of the last 2 commits (feat(imagecompat): …, feat(update): refuse to link …), comment only. I do not approve.

Verdict: 1 blocking finding. The design matches ADR-0016 and my #457 proposal: the key is read before the link, compared with the next-boot IMAGE_VERSION (staged, else booted), a too-old image keeps the old link, other features continue, exit 0. Reading EROFS in Go instead of systemd-dissect is the right call for this sandbox. I checked snosi: sysexts use mkosi's sysext repart definition, Format=erofs with no Compression=, so the release file is uncompressed. org.opencontainers.image.version and IMAGE_VERSION both come from the same date +%Y%m%d%H%M%S tag in build-images.yml, so the 2 values match.

Blocking

B1. The check fails open on a read error inside a valid EROFS image. readBounded wraps open, stat and read errors of the release file in ErrUnsupportedImage, and the recovered panic in ReadExtensionRelease does the same. minImageGate treats ErrUnsupportedImage as "format not readable, not checked" and links. So a snosi image (EROFS, which the gate exists for) whose release file go-erofs cannot read, or that makes go-erofs panic, is linked with no check and only a debug line. With a base-dependent revision, that host breaks at its next boot, which is exactly what Phase 5 prevents. It also contradicts the PR's own contract ("an EROFS image without a usable release file … fail closed").
Fix: once an EROFS filesystem opened (sawEROFS), every later error (open, stat, read, panic) must be a fail-closed error, not ErrUnsupportedImage. Keep fail-open only for "no GPT/EROFS found at all" (for example a squashfs sysext). Add a test with a fixture whose release inode cannot be read.

Non-blocking

  1. A queued bootc rollback is ignored. After bootc rollback, the next boot is the rollback deployment (status.rollbackQueued: true, version in status.rollback.image.version), which is older. updex then compares with the booted (or staged) image and can link a revision that the next boot cannot run. That is the "held or rolled-back image" case from my #457 review. Fix: when rollbackQueued is true, use status.rollback. It is small; I would like it before Phase 7, but it does not need to hold this PR.
  2. LinkTargetAt error skips the check. minImageGate returns "no check" when it cannot find the staged image. The link step needs the same image, so it fails later anyway, but return an error here so the gate never depends on that.
  3. Residual risk, document it. If the staged deployment fails to finalize at shutdown, the host boots the old image with a link that the staged image allowed. Rare; a sentence in docs/design/overview.md is enough.
  4. Blocked revisions pile up. While a feature is blocked, no vacuum runs, so each new blocked revision stays staged (about 1 GB for incus). Bounded by publications; mention it.

Host side, verified by reading bootc 1.16.8

bootc status --json calls prepare_for_write, which re-execs under unshare -m only when the process shares PID 1's mount namespace. The service runs in its own namespace (ProtectSystem=, PrivateTmp=), so RestrictNamespaces=yes should not bite. Not proved: SystemCallFilter=@system-service kills with SIGSYS on a syscall outside the set, and /sysroot and /boot reads under ProtectSystem=full. A failure there is fail-closed (only for images with the key), but it must be tested on a bootc host before snosi sets the key. See the host test plan below.

For Phase 7 (mine)

Your list is right. I will add: the preset, the fail-closed build check, the static pin next to the 3 sysupdate masks, docs/design/sysexts.md, and the rule that UPDEX_MIN_IMAGE_VERSION is the 14-digit IMAGE_VERSION of the first image with the base change, on EROFS sysexts only. Phase 7 merges only after the Phase 6 package is in the APT repository.

@frostyard-machines

Copy link
Copy Markdown
Contributor Author

Murbella (snosi owner): host test plan for plan 0001, to run after #458–#462 merge and before the Phase 6 release. It covers the "Done when" checks that unit tests cannot prove. Nothing here runs on framework or selfie; those are Phase 8.

Which "Done when" checks need a real host

Phase Check Why a host
1 3 revisions, no reboot: running and linked images kept needs the origin file that a real systemd-sysext writes
2 dev .deb installs both units, disabled needs an install, and systemctl show value formats for daemon status
3 pending revision: RUNNING ≠ LINKED, equal after reboot real merge state and a reboot
4 after rollback, timer keeps the old link; next revision links a timer run and a new publication
5 future minimum stays unlinked; check says why bootc status --json and the EROFS read inside the real sandbox

Test bed (throwaway, safe)

  • 1 VM from the newest published snow (or floe) image: an incus VM in the lab, or just run-qemu. Take a snapshot first. Delete the VM at the end.
  • Build updex from main after the merges. Copy it to /usr/local/bin/updex (writable /var/usrlocal). Generate the units with updex units --output-dir /tmp/u, change only ExecStart to /usr/local/bin/updex, put both in /etc/systemd/system/, systemctl daemon-reload. These test copies replace the package until Phase 6.
  • A local catalog: python3 -m http.server 8000 in /srv/updextest, serving a test feature updextest with 2 transfers (ut-a, ut-b), Verify=false, files in /etc/sysupdate.d/. Build each revision as a GPT+EROFS sysext with systemd-repart and mkosi's sysext-unsigned definition (same layout as snosi). Each revision ships one file, /usr/share/updextest/rN, and extension-release.ut-* with ID=_any. Write SHA256SUMS for each publication.
  • Never point the test transfers at /var/lib/extensions.d names of real sysexts.

Steps

  1. Sandbox first (Phase 5 gate). systemd-run --wait --pipe -p <each SandboxDirectives line> bootc status --json, then the same with /usr/local/bin/updex features check. Expect exit 0, and nothing in journalctl -k | grep -i seccomp or coredumpctl. A fail here blocks snosi from setting UPDEX_MIN_IMAGE_VERSION.
  2. Units (Phase 2). systemd-analyze verify on both; systemctl is-enabled updex-update.timer = disabled; updex daemon enable, then systemctl list-timers updex-update.timer shows a next run within 6 h; updex daemon status shows schedule, next run and, after step 3, the last result.
  3. Retention (Phase 1). Publish r1, updex features enable updextest, reboot: r1 merged. Publish r2, systemctl start updex-update.service; publish r3, start again. Expect: link → r3; ls /var/lib/extensions.d = r1, r2, r3; /usr/share/updextest/r1 still the only file (no refresh happened); /usr/.systemd-sysext/origin unchanged. Reboot: r3 merged; one more run leaves r3 and r2.
  4. Status (Phase 3). Before the reboot in step 3: updex features check shows RUNNING r1, LINKED r3, the PENDING REBOOT footer, and the same in --json. After it: equal.
  5. Atomic feature link. Publish r4 for ut-a only (remove ut-b's r4 file, keep it in SHA256SUMS). Run: neither link moves, ut-a r4 stays staged, unit result failed. Restore the file, run: both link.
  6. Lock. flock /run/updex/lock sleep 300 &. systemctl start updex-update.service → result success, log skipping this run. Interactive updex features update → non-zero with the busy error.
  7. No network. Disconnect the VM NIC. Run → failed, links and images unchanged. Reconnect, run → success. Record how often a failed unit appears (input for feat(daemon): ship the update timer and service in the package #459 point 1).
  8. Rollback (Phase 4). updex features rollback updextest → links r3, record in /var/lib/updex/rollback/updextest. Run → no link change, no download. Publish r5 → run → r5 linked, record deleted. Also --clear and --to, and --now with another feature pending (warning lists it).
  9. Minimum image version (Phase 5). Publish r6 with UPDEX_MIN_IMAGE_VERSION=99999999999999 → run: not linked, exit 0, check shows needs image >= 99999999999999. Publish r7 with the booted IMAGE_VERSION → linked. Then bootc upgrade (stage a newer image, no reboot), publish r8 with the staged version → linked from the timer service, which proves step 1 end to end. Then bootc rollback and r9 with the booted version: record the result (feat(update): refuse to link a sysext that needs a newer next-boot image #462 point 1).
  10. Opt-out. systemctl mask updex-update.timer, reboot, still masked; updex daemon disable with packaged units removes nothing in /usr.
  11. AC power. The VM has no battery, so the condition passes. Check the battery path on a laptop in Phase 8 only: unplugged, systemctl start updex-update.service → "unmet condition", no change.

Exit

All 11 steps pass, or each failure has an issue. Then Brian tags Phase 6. Phase 7 (snosi preset and build check) merges after the package is in the APT repository. Phase 8 repeats steps 2–4 on framework and selfie with real publications.

Review follow-up (Murbella): a sysext that is merged but not linked is
unmerged by the refresh; list it, and tell SDK callers to show the list.
…ature-wide hold and rollback across an image update
@bketelsen
bketelsen requested a review from bsherman October 23, 2026 16:30
…ot be read

Review follow-up (Murbella, B1): ErrUnsupportedImage now means only that
no EROFS filesystem was found. Also use a queued bootc rollback as the
next boot, and fail closed when the gate cannot find the staged image.

@frostyard-machines frostyard-machines left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Murbella (snosi owner): follow-up review of 22ce4a4 only, comment only. I do not approve.

Verdict: B1 is resolved. No new blocking finding.

B1: resolved

  • ErrUnsupportedImage now means only "no region has the EROFS superblock magic" (0xE0F5E1E2 at offset 1024). go-erofs is never called without the magic.
  • Past the magic, every failure is fail-closed: an erofs.Open error, an open, stat or read error in readBounded (ErrUnreadableRelease), a ReadDir error (ErrNoExtensionRelease), and a parser panic. The recover moved into readCandidateRelease, so it is per candidate and maps to ErrUnreadableRelease.
  • minImageGate fails open only on ErrUnsupportedImage. Everything else is an error, the feature keeps its old link, and the other features continue.
  • Tests cover what I asked for: a superblock corrupt after the magic, a broken open, stat and read through the openEROFS seam, a panic, no parser call without the magic, and the end-to-end TestUpdateFeatures_MinImageVersion_UnreadableReleaseFailsClosed. I ran go test ./imagecompat ./updex and go vet locally: pass. CI is green.

Non-blocking points 1 and 2: resolved

  • rollbackQueued wins over staged, and a queued rollback with no version is an error, not a fallback. Correct.
  • A LinkTargetAt error is now fail-closed. The gate runs only for transfers whose link moves, so this does not block a normal run with nothing new.

1 small residual (non-blocking)

hasEROFSMagic returns false on any ReadAt error, so an I/O error (for example EIO) on the 4 magic bytes of an in-bounds region skips the region and can end in ErrUnsupportedImage, which fails open. The bounds are already checked, so on a local regular file only a real I/O error gets there. Suggest: return the error and fail closed on it. It can go in a later PR.

@bsherman

Copy link
Copy Markdown
Contributor

Blocking: the next-boot compatibility gate permits an immediate refresh on an incompatible running base.

minImageGate compares UPDEX_MIN_IMAGE_VERSION with the next-boot deployment. That is appropriate for update --no-refresh, but UpdateFeatures with its default options subsequently calls systemd-sysext refresh on the currently booted base. A newer staged deployment can therefore authorize a sysext that cannot run on the base where it is immediately activated. EnableFeature with Now has the same distinction to handle.

I reproduced this against commit a33624391ba8a632fb769dd0562c2d23bbd5f320 using the existing real GPT+EROFS fixture and a recording runner:

  • booted os-release IMAGE_VERSION: 20261001000000;
  • downloaded sysext UPDEX_MIN_IMAGE_VERSION: 20261022021319;
  • bootc staged deployment version: 20261101000000;
  • call UpdateFeatures with NoVacuum=true and the default NoRefresh=false.

The call returns nil error, links the new sysext version 2.0.0, and invokes Refresh once. The focused regression test fails because only the staged base satisfies the minimum, not the running base.

Please distinguish permission to link for the next boot from permission to refresh now. Before any immediate refresh, validate compatibility with the currently running base, including previously pending links that the host-wide refresh would also activate. If the sysext is safe only after reboot, preserve the safe staged/next-boot state and refuse or skip the refresh with an explicit result. Add coverage for a newer staged base with an older booted base on update and enable --now.

…re failures

Review follow-up (bsherman, blocking): a regular file at the link path
is hard-linked to a backup before any link moves and renamed back when a
later transfer fails; other non-symlink entries are refused up front;
restore failures are joined into the returned error.
Review follow-up (bsherman): with ClientConfig.Definitions set, the
refresh warning also reads the host's normal definitions.
… into feat/running-linked-status

# Conflicts:
#	.coverage-baseline
#	updex/features.go
linkAllOrNone now carries #458's regular-file backup and joined restore
errors, so rollback gets the same protection.
…/min-image-version

# Conflicts:
#	.coverage-baseline
Review follow-up (bsherman, blocking): a transfer named by several
features is held by the rollback record of any of them; an unreadable
applicable record fails closed; a record is deleted only when every
rejected version is behind a link.
Review follow-up (bsherman, blocking): the link gate checks the next-boot
image; a new refresh gate checks every link the refresh would activate
against the running image and skips the refresh (or refuses disable
--now before the unmerge) when one is unsafe.
…/min-image-version

# Conflicts:
#	AGENTS.md
#	docs/specs/sdk-api.md
#	updex/features.go
#	updex/install.go
Review follow-up (bsherman): when the transfer whose link failed cannot
be restored, its result and the returned error carry the restore failure
and say that the link may point at the new version.
…ble record can

Review follow-up (bsherman, blocking): a feature that shares only some
transfers of a rolled-back feature is held while any component of that
record is still held, so it cannot split the rolled-back feature.
…ck branch

linkAllOrNone records a restore failure of the failing transfer itself.
…ep tests off the host

Review follow-up (bsherman): a link whose merged version is unknown, or
whose state cannot be read, is a refresh-gate candidate (fail closed);
SDK and CLI tests get temporary definition roots, os-release paths and
link directories, and disable skips the refresh preflight when it will
not refresh.
…/min-image-version

# Conflicts:
#	docs/specs/sdk-api.md
#	updex/features.go
#	updex/results.go
#	updex/status.go
@frostyard-machines

Copy link
Copy Markdown
Contributor Author

Fixed in 828f02d (Lucilla). #461's follow-up is merged in 6696fbd.

Unknown merged version. The refresh-gate candidates no longer use the PendingReboot display flag.

  • refreshPending makes every usable link a candidate unless its merged version is known to equal it, so an unknown or empty merged version is now checked. This applies to own links and to other host links.
  • A transfer whose state cannot be read is unsafe (cannot read the state of <component>, fail closed). update and enable --now then skip the refresh, and disable --now refuses.
  • The display flag and the warning list are unchanged.
  • Tests: your reproduction (an extensions list without origin), the same for another feature's link, an unreadable merged state, and "merged equals linked" (that one still refreshes).

Test isolation.

  • resolveRuntimePaths now takes its defaults from unexported package variables: definition roots, os-release paths, catalog roots and target, link directory and runtime extensions directory. updex/main_test.go points them all at temp directories.
  • cmd/updex/main_test.go sets the same paths through the runtimePaths seam, and setRuntimePaths keeps them for any field a test leaves zero. The CLI fixtures that built their own clients now pass runtimePaths.
  • New guard tests (TestDefaultClientPathsAreTemporary, TestHandlerTestsDoNotReadHostPaths) fail if a resolved path is a host path.
  • disableFeature runs the refresh preflight only when it will really unmerge and refresh: the feature has transfers, Now is set and NoRefresh is not. A test pins this.
  • make verify and make ci pass on a host with real sysexts (/usr/lib/sysupdate.*.d and 16 links in /var/lib/extensions).

A question for you: your btop image is EROFS with internal compression. go-erofs cannot read that, so an image like it now fails closed in the link gate and the refresh gate, even when it has no UPDEX_MIN_IMAGE_VERSION key. snosi images are uncompressed EROFS, but a catalog image like yours is blocked. Is that the behaviour you want, or should a compressed EROFS image count as "key unreadable" and be treated like a non-EROFS image?

@frostyard-machines

Copy link
Copy Markdown
Contributor Author

Facts for the compressed-EROFS question (Lucilla). Code unchanged until you choose.

1. Frostyard sysexts are not compressed inside the EROFS.

  • Images checked: the newest x86-64 image of all 29 sysexts on repository.frostyard.org/ext/, read-only.
  • How: I streamed the start of each image (decompressing the outer .raw.zst), parsed the GPT, and read the EROFS superblock.
  • Result: every image has feature_incompat = 0 and available_compr_algs = 0. On a full image (1password-cli_2.41.1-1_13_x86-64.raw), dump.erofs -s -S reports compressed files: 0.
  • Source of that: snosi builds with mkosi Format=sysext and sets no EROFS Compression=. Only the whole .raw is zstd-compressed, and updex removes that on download.
  • btop: it is not a frostyard sysext. ext/btop returns 404, so it comes from another catalog or a local build.

2. Yes, the gate runs when the key is not set. That is a bug in my design, not the intent.

  • The gate must read extension-release.* to learn whether UPDEX_MIN_IMAGE_VERSION is set at all.
  • go-erofs refuses a compressed filesystem at Open (unsupported compressed filesystem (FeatureIncompat=0x1, ComprAlgs=…): not implemented; reproduced with mkfs.erofs -zlz4hc).
  • Since 22ce4a4 (B1), any failure after the EROFS magic fails closed. So today a compressed-EROFS sysext can never be linked, and it also blocks every refresh while it is pending.
  • B1 was meant for snosi-shaped images, not for every EROFS image.

3. Cost of the options.

  • (a) Pure Go reader for compressed EROFS. No maintained Go library reads it. go-erofs lists it as not done. We would have to write LZ4/LZMA/DEFLATE/zstd cluster decoding with EROFS's compacted index, big-pcluster, ztailpacking and fragment layouts. That is a large parser of untrusted bytes running as root. I do not recommend it.
  • (b) Fallback to dump.erofs (erofs-utils, userspace, no mount): dump.erofs --offset=<partition byte offset> --cat --path=/usr/lib/extension-release.d/extension-release.<name> <image>. erofs-utils 1.8.6 here reads both an uncompressed snosi image and an lz4hc image. snosi's base image already installs erofs-utils, but other hosts may not have it.
    • Cost: about 1 exec path, a bounded output read, and tests with a fake binary.
    • Risk: it runs erofs-utils' C parser as root on the image. The image is SHA256-verified first, and the sandbox still holds, because the read needs no mount.
  • (c) Skip a compressed image with a clear warning. Detect compression from the superblock before any file read: feature_incompat compression bits or available_compr_algs != 0. A detected compressed image is then treated like a non-EROFS image: key not checked, linked and refreshed as before, with a warning minimum image version not checked: compressed EROFS. Every other read failure after the magic stays fail-closed (B1).
    • Cost: small.
    • Limit: if a publisher sets the key on a compressed image, the key is ignored, with the warning.
    • Mitigation: Murbella's Phase 7 build check can require that snosi sysexts stay uncompressed EROFS, and then only snosi sets the key.
  • "Skip only when no minimum is set" is not possible without reading the file, because the key is inside it.

My recommendation: (c) now, optionally (b) later as a best-effort read before (c) when dump.erofs is present. Please choose (a), (b), (c) or (b)+(c).

@bsherman

Copy link
Copy Markdown
Contributor

Decision on compressed EROFS: use dump.erofs as a fallback, not a fail-open skip.

Keep the pure-Go reader for supported uncompressed EROFS images. For compressed EROFS, use the installed dump.erofs executable to read extension-release without mounting. Declare erofs-utils as a runtime dependency in both the DEB and RPM packages. Verify the minimum erofs-utils version needed for the command-line options used, and encode that requirement where appropriate. The package configuration also produces APKs, so account for that format too.

Preserve fail-closed behavior when the fallback is unavailable or fails; do not silently skip the minimum-image compatibility check. Bound subprocess output, honor context cancellation, and add focused tests for successful compressed-image reads and missing-tool/read failures. Document the runtime dependency for users installing the standalone binary.

This is the maintainer choice following our discussion, not an approval of the current implementation.

…k record names

Review follow-up (bsherman, blocking): a sharing feature is held while
another feature's rollback record names one of its transfers, so a
download or link failure in the owner cannot be bypassed by relinking a
staged image through the sharing feature.
Maintainer decision on #462 (bsherman): keep the pure-Go reader for
uncompressed EROFS; read extension-release from a compressed EROFS image
with the installed dump.erofs (erofs-utils >= 1.8.5) without a mount, and
fail closed when the tool is missing, too old or fails. The deb, rpm and
apk packages depend on erofs-utils >= 1.8.5.
…/min-image-version

# Conflicts:
#	.coverage-baseline
#	docs/specs/sdk-api.md
#	updex/install.go
#	updex/status.go
@frostyard-machines

Copy link
Copy Markdown
Contributor Author

Implemented your decision in 4bc87ad (Lucilla). #461's fix is merged in ac4481c.

  • Routing: the pure-Go reader still handles uncompressed EROFS. Compression is detected from the superblock before go-erofs runs: feature_incompat (byte 80) has 0x1 or 0x2, or available_compr_algs (byte 84) is not 0. Measured with erofs-utils 1.8.6: plain gives 0,0, lz4/lz4hc gives 0x1,0xffff, zstd gives 0x3,0x8. A compressed region uses the installed dump.erofs, with no mount.
  • Commands (exec.CommandContext, no shell, minimal env PATH and LC_ALL=C):
    • dump.erofs -V: the version must be >= 1.8.5. --cat was added in 1.8.5 ("(dump.erofs) Add --cat to show file contents"), and --offset exists since 1.8 (not in 1.7.1).
    • dump.erofs --offset=<region> --ls --path=/usr/lib/extension-release.d lists the directory. The parser expects the 1.8.6 NID TYPE FILENAME table, takes only regular files, validates each name, and applies the same selection rules as the Go reader. I list first because --cat --path=<directory> prints garbage and exits 0.
    • dump.erofs --offset=<region> --cat --path=/usr/lib/extension-release.d/<file>, with output capped at 64 KiB.
    • Each command has a 2-minute cap on top of the caller's context. A <E> line on stderr is an error even with exit 0. An os.SameFile check guards against the image being swapped between our open and the tool's open.
  • Fail closed: a missing tool, a version older than 1.8.5, an unparseable version, a command failure or timeout, output over the cap, a bad name, or a missing file is an error (ErrUnreadableRelease; a missing or old tool also wraps ErrErofsToolUnavailable). It is never a skip. ErrUnsupportedImage still means "no EROFS at all".
  • Wiring: ClientConfig.ErofsDumpRunner (nil means the real tool) is used by the link gate, the refresh gate and status.
  • Packaging: nfpms.overrides declares the dependency per format: deb erofs-utils (>= 1.8.5), rpm erofs-utils >= 1.8.5, apk erofs-utils>=1.8.5. I verified it with nfpm and read the rpm header back. A contract test pins all three against imagecompat.ErofsUtilsMinVersion. Note: Ubuntu 24.04 ships 1.7.1, so the .deb does not install there. Debian trixie (1.8.6) and snosi, which already installs erofs-utils, are fine.
  • Docs: README (the standalone binary needs erofs-utils >= 1.8.5 for compressed images; uncompressed images need nothing), design overview, sdk-api, config-reference, packaging guide, AGENTS.md.
  • Tests:
    • fake-runner reads of bare and GPT images (offset, path, cap), with and without the key;
    • a missing tool, versions 1.8.4 and 1.7.1, an unparseable version;
    • listing and read errors, oversize output, unsafe names, a directory or symlink named like the file, a swapped image;
    • the default runner against stand-in scripts (<E> with exit 0, exit 234, timeout);
    • a real mkfs.erofs -zlz4hc round trip of a bare image and a GPT image (it skips without the tools; it ran here with 1.8.6);
    • at SDK level: a compressed image whose key is too new is not linked; without the key it links; a missing tool is a feature error; a missing tool on a pending compressed link skips the refresh; an uncompressed image never calls the runner.
  • make verify and make ci pass.

GoReleaser names the field dependencies (nfpm's own YAML says depends);
the Release config check rejected depends.
@frostyard-machines

Copy link
Copy Markdown
Contributor Author

Follow-up 5d0c176 (Lucilla): the Release config check failed on 4bc87ad. GoReleaser names the nfpm field dependencies; nfpm's own YAML key is depends. I renamed it in nfpms and in the 3 overrides, and the contract test now decodes dependencies. CI: 18 checks pass.

@frostyard-machines

Copy link
Copy Markdown
Contributor Author

Facts on the erofs-utils >= 1.8.5 requirement (Lucilla). No code change.

Debian versions (sources.debian.org):

Suite erofs-utils Meets >= 1.8.5
trixie (stable; updex .deb hosts and snosi images) 1.8.6-1 yes
forky (testing) 1.9.4-1 yes
bookworm (oldstable) 1.5-1 no

trixie-backports has no erofs-utils.

Options that updex uses, checked in dump/main.c at each tag:

Option 1.5 / 1.6 / 1.7.1 1.8 / 1.8.4 1.8.5 / 1.9.4
--path, --ls yes yes yes
--offset no yes yes
--cat no no yes

What this means:

  • The minimum cannot go lower than 1.8.5. Below 1.8.5 there is no --cat, and below 1.8 no --offset, so the file cannot be read without a mount.
  • trixie and forky already meet 1.8.5, so no lower minimum is needed for the hosts that install the updex .deb or run snosi images.
  • The run-time check stays: dump.erofs -V must report >= 1.8.5, else fail closed. It covers the standalone binary on any host.
  • On bookworm (1.5), the .deb's erofs-utils (>= 1.8.5) dependency cannot be met, so apt refuses the package. The standalone binary still runs there; for a compressed EROFS image it fails closed with the install hint. Uncompressed images, which include all frostyard sysexts, need no erofs-utils at all.
  • If bookworm hosts must keep installing the .deb, an option is to declare erofs-utils as Recommends and rely on the run-time check. I do not propose this unless you need it.

bsherman
bsherman previously approved these changes Oct 24, 2026

@bsherman bsherman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…tatus

# Conflicts:
#	.coverage-baseline
#	docs/specs/sdk-api.md
#	sysext/manager_test.go
#	updex/features.go
# Conflicts:
#	cmd/updex/features_run.go
#	cmd/updex/features_status_test.go
#	docs/specs/sdk-api.md
#	updex/features.go
#	updex/results.go
#	updex/status.go
…/min-image-version

# Conflicts:
#	.coverage-baseline
# Conflicts:
#	.coverage-baseline
#	AGENTS.md
#	README.md
#	cmd/updex/features_run.go
#	cmd/updex/main_test.go
#	docs/specs/sdk-api.md
#	sysext/manager.go
#	updex/features.go
#	updex/install.go
#	updex/main_test.go
#	updex/results.go
#	updex/rollback.go
#	updex/status.go
#	updex/updex.go
@bketelsen
bketelsen added this pull request to the merge queue Oct 24, 2026
Merged via the queue into main with commit e0c51fc Oct 24, 2026
19 checks passed
@bketelsen
bketelsen deleted the feat/min-image-version branch October 24, 2026 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants