Repository navigation
feat(update): refuse to link a sysext that needs a newer next-boot image - #462
Conversation
…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).
…next-boot image version
Phase 5 of plan 0001 (ADR-0016): UPDEX_MIN_IMAGE_VERSION.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
frostyard-machines
left a comment
There was a problem hiding this comment.
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
- A queued
bootc rollbackis ignored. Afterbootc rollback, the next boot is the rollback deployment (status.rollbackQueued: true, version instatus.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: whenrollbackQueuedis true, usestatus.rollback. It is small; I would like it before Phase 7, but it does not need to hold this PR. LinkTargetAterror skips the check.minImageGatereturns "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.- 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.mdis enough. - 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.
|
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
Test bed (throwaway, safe)
Steps
ExitAll 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
…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
left a comment
There was a problem hiding this comment.
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
ErrUnsupportedImagenow means only "no region has the EROFS superblock magic" (0xE0F5E1E2at offset 1024). go-erofs is never called without the magic.- Past the magic, every failure is fail-closed: an
erofs.Openerror, an open, stat or read error inreadBounded(ErrUnreadableRelease), aReadDirerror (ErrNoExtensionRelease), and a parser panic. Therecovermoved intoreadCandidateRelease, so it is per candidate and maps toErrUnreadableRelease. minImageGatefails open only onErrUnsupportedImage. 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
openEROFSseam, a panic, no parser call without the magic, and the end-to-endTestUpdateFeatures_MinImageVersion_UnreadableReleaseFailsClosed. I rango test ./imagecompat ./updexandgo vetlocally: pass. CI is green.
Non-blocking points 1 and 2: resolved
rollbackQueuedwins overstaged, and a queued rollback with no version is an error, not a fallback. Correct.- A
LinkTargetAterror 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.
|
Blocking: the next-boot compatibility gate permits an immediate refresh on an incompatible running base.
I reproduced this against commit
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
…/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.
… into feat/running-linked-status
…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.
…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
|
Fixed in 828f02d (Lucilla). #461's follow-up is merged in 6696fbd. Unknown merged version. The refresh-gate candidates no longer use the
Test isolation.
A question for you: your |
|
Facts for the compressed-EROFS question (Lucilla). Code unchanged until you choose. 1. Frostyard sysexts are not compressed inside the EROFS.
2. Yes, the gate runs when the key is not set. That is a bug in my design, not the intent.
3. Cost of the options.
My recommendation: (c) now, optionally (b) later as a best-effort read before (c) when |
|
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
|
Implemented your decision in 4bc87ad (Lucilla). #461's fix is merged in ac4481c.
|
GoReleaser names the field dependencies (nfpm's own YAML says depends); the Release config check rejected depends.
|
Facts on the erofs-utils >= 1.8.5 requirement (Lucilla). No code change. Debian versions (sources.debian.org):
trixie-backports has no erofs-utils. Options that updex uses, checked in
What this means:
|
…tatus # Conflicts: # .coverage-baseline # docs/specs/sdk-api.md # sysext/manager_test.go # updex/features.go
… feat/feature-rollback
# Conflicts: # .coverage-baseline
# 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
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 fixfix(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 targetsmain, because the Tests workflow runs only for PRs intomain. 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).
imagecompat(no CLI imports):ReadExtensionRelease(path, name)readsusr/lib/extension-release.d/extension-release.*from a staged sysext without mounting it. The service sandbox (RestrictNamespaces=yes,SystemCallFilter=@system-service) forbids mounts, sosystemd-dissectis 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 withgithub.com/erofs/go-erofsv0.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 frombootc status --json(status.staged.image.version, which equals snosi'sIMAGE_VERSIONthrough theorg.opencontainers.image.versionlabel), else the bootedos-releaseIMAGE_VERSION. A missing bootc falls back toos-release. An installed bootc that fails is an error (fail closed).CheckMinImageVersion: digits only, compared as numbers of any length. The reason text is exactlyneeds image >= <value>.installTransferschecks every transfer whose link will move (a new download, and also the relink path), after the stage step and before the link step. This coversfeatures update, the timer andenable --now.needs_image: "needs image >= X". This is not an error: other features continue and the run exits 0.ClientConfig.BootcRunner.features checkandlistread a staged image that is newer than the linked one and reportneeds_imageandnext_boot_image_version. The text output shows aNEEDS NEWER IMAGE:footer.checkstays read-only.Review follow-ups (Murbella)
ErrUnsupportedImagenow means only that no EROFS filesystem was found: no EROFS superblock magic0xE0F5E1E2at offset 1024, checked before go-erofs runs. After the magic is found, every failure fails closed with the new sentinelErrUnreadableRelease: 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.bootc rollback, fixed: whenstatus.rollbackQueuedis true, the next-boot version isstatus.rollback.image.version(SourceRollback). A queued rollback without a version is an error.LinkTargetAterror in the gate, fixed: it now fails closed.TestCatalogAdd_CompressedTargetPatternRollbacknow expects the gate error. The rollback behaviour is unchanged.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.make cipasses. Coverage is 89.0%.Checks
make fmtmake ci:==> CI gate passedlocally. Coverage is 88.9%, and.coverage-baselineis bumped.govulncheckreports no called vulnerabilities.internal/testutil/sysextimage.go) and a fake bootc:IMAGE_VERSION(not linked);ErrUnsupportedImage(linked), bootc fails (error),enable --now, dry run;CheckFeaturesandFeaturesshow the reason;imagecompatitself: 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
Rationale:
execofbootcin the root service.SHA256SUMSsignature 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 aSectionReader, and a panic is recovered.ErrUnsupportedImage, which gives the behaviour before this PR.docs/design/overview.md.Docs housekeeping
README.md,docs/design/overview.md,docs/specs/sdk-api.md,docs/specs/config-reference.md(newextension-releasesection) andAGENTS.mdupdated (key packages, dependency table, and the rule that every link path checks the minimum image version)Verification
node scripts/check-docs.mjsgreenNot verified on a real host:
bootc status --jsonunder the realSandboxDirectives. On a test host,systemd-run -p <each directive> updex features checkchecks this, asdocs/design/overview.mddescribes.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 publishesfrostyard-updexwith/usr/lib/systemd/system/updex-update.{timer,service}(#459), and dispatches a snosibuild.What Phase 7 needs, in snosi:
enable updex-update.timertomkosi.images/base/mkosi.extra/usr/lib/systemd/system-preset/04-bootc-update.preset, or to a new05-updex.preset.system timers.target.wants/updex-update.timer(snosi ADR-0002).updex-update.timerand/usr/lib/systemd/system/updex-update.timeris missing, or when the manifest entry is missing.systemd-sysupdate.timer,systemd-sysupdate-reboot.timerandsystemd-sysupdate-update.timermasked. Pin the new preset line next to the masks intest/bootc-secure-static-test.sh.docs/design/sysexts.md. Describe:--no-refresh(a new revision applies at the next boot);systemctl mask updex-update.timeropt-out;updex features rollback;UPDEX_MIN_IMAGE_VERSION.UPDEX_MIN_IMAGE_VERSION.extension-release.<name>, likeSYSEXT_REVISION, only on a revision that depends on a base change.IMAGE_VERSIONof the first image that carries that change. It must be digits only.Format=sysext, no EROFS internal compression; the outer.raw.zstis fine). Otherwise updex cannot read the key and skips the check.preset-reconcileenables the timer on existing hosts at the second boot of the first image that carries the preset.