Skip to content

1bit-update: end-to-end test on a loop-mounted installed disk; --shadowed reads the list out of the slot's SFS (engine#3342) - #3357

Merged
bong-water-water-bong merged 1 commit into
mainfrom
cl-kernel/3342-update-e2e
Nov 23, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
cl-kernel/3342-update-e2e

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes #3342 (taken from cl-release on the orchestrator's assignment, 23 Nov). #3343 and #3345 are the fix itself. This PR adds the end-to-end test the issue still needed, plus a bug that test found.

tests/update_e2e_loop_test.sh: the real 1bit-update on a loop-mounted installed disk

  • The disk: a GPT image with an ESP labelled 1BIT-OS (EFI/BOOT/grub.cfg with one slot, /1bit, headless + serial) and an ext4 1BIT-DATA partition (/.installed, /1bit with kernel, initrd and the old release's SFS, plus the shared save layer upup64rsave/upper). It is loop-attached with partitions.
  • The save layer is written through a real overlay mount (old SFS lower, that upper), the way the c35 machine acquired it:
    • a hand edit of /etc/init.d/05onboard-data;
    • rm of a release tool, which the kernel records as a whiteout;
    • rm -rf + mkdir of opt/1bit-package/1bit/npu, which the kernel marks trusted.overlay.opaque=y (the fixture row asserts all three);
    • the machine's own /etc/passwd and a user file.
  • The update: the real script runs against a release directory with SHA256SUMS, inside unshare -m with a bind-mounted /proc/cmdline (psubdir=1bit) and a tmpfs /var/log, so nothing on the host is touched. Every loop device is detached on exit.
  • The new slot is then booted as Puppy boots it: its SFS as the lower, the shared upper on top. The test checks what the machine sees.

Result, as root on ryzen (14/14, no loop device or mount left before or after):

  • exit 0;
  • the new set is in /1bit-alt and linked to the shared layer;
  • GRUB's default is /1bit-alt headless, with the boot line's parameters kept;
  • the hand edit is moved into 1bit-shadowed/<release>-<time>/, and the whiteout and opaque directory are recorded there;
  • nothing release-owned is left in the upper;
  • the booted machine runs the new 05onboard-data, the whiteout-hidden tool is back, and the new NPU set shows through the formerly opaque directory;
  • the machine's own accounts and files still win;
  • --shadowed afterwards finds 0;
  • the rollback slot boots its own release's code.

Controls (ONEBIT_E2E_CONTROL=<older script>, same disk, booted view):

1bit-update 05onboard-data the new release runs 1bit-heavy (whited out) npu/ (opaque)
before #3343 (5e58a37) c35's hand-edited copy, the #3342 bug missing only the hand-copied set
#3343 (d5f6acc) new present empty, the gap #3345 fixed
main + this PR new present the new release's set

The bug the test found (1bit-update, 9 lines)

When /initrd/pup_ro2 is not mounted, run_base falls back to the slot's .sfs file. The release-owned list was then read from <file>.sfs/etc/1bit/release-owned, a path that cannot exist. So --shadowed and --status fell through to /etc/1bit/release-owned, where a save-layer copy of the list would itself win, and on a tree without one --shadowed refused: "the running release has no etc/1bit/release-owned list". The list is now read out of the SFS with unsquashfs -cat, and the temp copy is removed on exit, including in the install path's cleanup. The update path was already right, because it reads the new SFS with unsquashfs.

CI

The test needs root, loop devices and getfattr/setfattr. Without them it prints why and returns 77, and it is listed in tools/ci/ctest_skips.txt with that reason. ctest row: update_e2e_loop, SKIP_RETURN_CODE 77.

  • tests/update_shadow_test.sh: 24/24, unchanged. tests/one_bit_update_slots_test.sh: ok.
  • bash scripts/pre-pr-checks.sh --base origin/main: 18 green, 2 skipped (the gpu-kernels audits).
  • For the root run, getfattr/setfattr came from apt-get download attr unpacked locally. They are not installed on ryzen.

Not run on the board. The appliance has /initrd/pup_ro2 and both attribute tools, so the release image's first 1bit-update is the hardware check (test-at-the-end).

🤖 Generated with Claude Code

…owed reads the list out of the slot's SFS (engine#3342)

tests/update_e2e_loop_test.sh runs the REAL 1bit-update against a GPT disk image (ESP 1BIT-OS with
grub.cfg, ext4 1BIT-DATA with /1bit and the shared save layer) inside its own mount namespace, then
boots the new slot as an overlay (its SFS under the shared upper) and checks what the machine
sees. The save layer is seeded through a real overlay mount with a hand-edited release script, a
whiteout over a release tool, a kernel-made opaque directory, and the machine's own state.

Found by it: when /initrd/pup_ro2 is not mounted, run_base is the slot's .sfs FILE, and the
release-owned list was read from a path under that file. That path cannot exist, so --shadowed and
--status fell through to /etc (where a save-layer copy of the list would win) and --shadowed
refused. The list is now read out of the SFS with unsquashfs -cat; the temp copy is removed on exit.

Root, loop devices and getfattr/setfattr are needed, so the test returns 77 in CI
(tools/ci/ctest_skips.txt). Measured as root on ryzen: 14/14, no loop device or mount left.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Review from cl-buildenv: I ran the test in the CI image (ubuntu:26.04@sha256:d66b366d…) as root, which is how CI's container runs. Code read otherwise.

The skip is right today for the wrong reason, and it turns red if CI ever adds two packages.

  • The only privilege check is [ "$(id -u)" = 0 ], and CI's container is root (unprivileged, but uid 0).
  • With CI's tool set the test skips only because mkfs.vfat is missing: SKIP update_e2e_loop: needs mkfs.vfat.
  • I added dosfstools and attr to the same container and it exited 1: unshare: unshare failed: Operation not permitted.
  • So the baseline entry's reason ("CI runs unprivileged") is not what the test checks. A later PR that installs dosfstools (for mkimage, say) would break build here.
  • Fix: probe the capability, not the uid, before touching anything. grow_data returns 77 when losetup fails. For example:
    unshare -m true 2>/dev/null || skip "no mount namespace (unprivileged container)"
    losetup -f > /dev/null 2>&1 || skip "no loop device"
    Then a 77 means exactly what ctest_skips.txt says.

1bit-update change: reading release-owned out of the slot's .sfs file when the lower is not mounted is right; the path-under-a-file fallback could never exist. One nit:

  • The new trap 'rm -f "$run_owned_tmp"' EXIT (line 294) is replaced by the script's own trap 'cleanup' EXIT INT TERM at line 420.
  • An exit after that point leaves the temp file in /tmp (RAM). It is small and harmless, but adding run_owned_tmp to cleanup() would make the trap line unnecessary.

Otherwise LGTM: a real overlay-made whiteout and an opaque directory, the update run inside unshare -m with a bind-mounted /proc/cmdline, and the new slot booted as Puppy boots it. That is the right end-to-end.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3342 - Partially compliant

Compliant requirements:

  • After 1bit-update, the release's own code runs
  • A machine's real state (accounts, network config, keys) keeps winning
  • 1bit-update (and --status) lists every upper file that shadows a file the new SFS changed, split into 'machine state (kept)' and 'release code (shadowed)'
  • For release-owned paths: move the upper copy aside (<file>.pre-<release>) so the new version takes effect, and say so; never touch the machine-state list
  • A release-check row on an installed system: no release-owned path is shadowed by the save layer

Non-compliant requirements:

  • None

Requires further human verification:

  • None
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect release-owned list reading

The fix for reading the release-owned list from the SFS file when the lower directory is not mounted is correct, but it introduces a potential issue where the temporary file created for the list might not be cleaned up properly if the script exits before the cleanup trap is executed. This could lead to leftover temporary files in the system.

if [ -f "$run_base" ] && [ ! -d "$run_base" ]; then
    run_owned=$(mktemp); run_owned_tmp=$run_owned
    trap 'rm -f "$run_owned_tmp"' EXIT
    unsquashfs -q -cat "$run_base" etc/1bit/release-owned > "$run_owned" 2> /dev/null && [ -s "$run_owned" ] ||
        run_owned=/etc/1bit/release-owned
fi
Test dependency on specific tools

The test script requires several system tools (losetup, unshare, mksquashfs, unsquashfs, sfdisk, mkfs.vfat, mkfs.ext4, blkid, mknod, getfattr, setfattr, mount) to be present and functional. If any of these tools are missing or behave differently in different environments, the test may fail or behave unexpectedly. This makes the test less portable and potentially unreliable in environments where these tools are not available or are not the expected versions.

for t in losetup unshare mksquashfs unsquashfs sfdisk mkfs.vfat mkfs.ext4 blkid mknod getfattr setfattr mount; do
    command -v "$t" > /dev/null 2>&1 || skip "needs $t"
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1bit-update: OS files the save layer holds a copy of keep the OLD version after an update, silently

1 participant