Skip to content

composefs: Add experimental local layers (bootc internals local-layer run) - #7

Draft
jmarrero-bot wants to merge 4 commits into
mainfrom
bot/local-layer
Draft

jmarrero-bot wants to merge 4 commits into
mainfrom
bot/local-layer

Conversation

@jmarrero-bot

@jmarrero-bot jmarrero-bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Proof of concept: bootc internals local-layer run -- CMD... on the composefs backend. It changes the system the way a Containerfile RUN CMD on the booted image would, without podman, and stages the result as a normal deployment.

CMD runs in a staging root: a writable overlay (metacopy=off,redirect_dir=off, nodev) over a fresh mount of the deployment's base image (its SELinux-labeled boot image), with the host's resolv.conf bound read-only and /var/cache from /var/cache/bootc-local-layer. It is isolated from the host by ChrootCmd::isolate: PID 1 of new PID, UTS and IPC namespaces, entered through pivot_root with the old root detached, a procfs of its own with /proc/sys, /proc/irq and the like read-only, a fresh read-only sysfs (no /sys/fs/selinux or cgroups), a minimal /dev (null, zero, full, random, urandom, tty, its own devpts and shm), a private /run, and without CAP_SYS_ADMIN, CAP_MKNOD, CAP_DAC_READ_SEARCH and the other capabilities a package install doesn't need, in a session of its own (no controlling terminal) and with none of the caller's file descriptors but stdio. Whatever it leaves running is killed with its PID namespace. It is not a hardened sandbox: it runs as root, shares the host's network (by design, for repos), and can change what is bound in (/var/cache/bootc-local-layer). The overlay's upper becomes one OCI layer on the base's layers, through composefs-rs's overlay_upper and derive_image (jmarrero-forge/composefs-rs#2). The derived image goes through the normal deploy path. It boots with verity=require on every file, local ones included, rolls back like any deployment, and a failing command stages nothing.

The origin keeps tracking the upstream image and records the commands and the base's manifest digest in [local-layer], shown as localLayer in bootc status. Each run re-runs every recorded command on the base, building on the next boot's deployment: the staged one if there is one (a layer, an upgrade or a switch), else the booted one. A usr-overlay is never captured: run notes that its changes are discarded on reboot. bootc upgrade re-runs them on a new base, and is a no-op while the base is unchanged; it compares with the staged deployment's own layer, so upgrade --tag then a plain upgrade keeps the layer. GC keeps each live layer's base, and every image if a layer's origin can't be read. Runs, upgrades and switches on composefs take a lock in /run/bootc before reading the deployments, so one doesn't stage over another (a second one waits, and says so). A build removes the work directories that killed builds left in /var/lib/bootc-local-layer, and a deploy removes a state dir an interrupted one left for the same image. bootc switch to another image drops the layer. BLS only (a UKI pins the base's digest), and /var is not part of a layer.

This can't be promoted until composefs-rs ships derive_image: it takes composefs-rs from the forge branch through a [patch.crates-io] git dependency. Not done: rpm-ostree/dnf hooks with a spec file, a sysusers bridge for scriptlet users, /var to tmpfiles, read-only host repo config in the staging root, the repo-format upgrade and disk-space check that pulls do, reset. Design and the kernel-level test: jmarrero-forge/tracker#61, https://gist.github.com/jmarrero-bot/bf75e0f860a2f1b19d648d3aafd4b499

Tested on 16-core devspaces, with BOOTC_variant=composefs, grub, BLS, ext4, and CentOS Stream 10 (6.12.0-279), using composefs-rs from jmarrero-forge/composefs-rs#2:

Changed since 8b1ecb4, after review (squashed into "utils: Let ChrootCmd isolate a command from the host" and, for the test, "composefs: Add experimental local layers"): the command kept the caller's non-close-on-exec descriptors, so an inherited host directory fd could be written through (/proc/self/fd/N, openat), and kept the caller's controlling terminal (TIOCSTI). Its PID 1 now calls setsid() and marks every fd >= 3 close-on-exec right before exec (close_range(CLOSE_RANGE_CLOEXEC), with a fallback loop). Test 65 runs a probe under a Python pty wrapper that gives bootc a controlling terminal and a non-close-on-exec fd 7 on the host's /etc (with a control run showing both work outside): the command can't write through fd 7, open /dev/tty, or TIOCSTI.

Changed since ecc0b32, after review (all bot commits; the prep commit is retitled from "utils: Let ChrootCmd mount a private /run"):

  • the command could write the host (/proc/1/root, read-write host /dev and /sys, every capability): now isolated as above;
  • upgrade --tag then a plain upgrade dropped the layer: the pending layer now comes from the next deployment's metadata, and run builds on a staged switch too instead of refusing;
  • a malformed [local-layer] origin failed every GC: now it warns and keeps every image;
  • a killed run left its upper in /var/tmp: work directories are under the lock now, in a root-owned /var/lib/bootc-local-layer, and stale ones are removed;
  • a retry after an interrupted stage of the same content failed on the old state dir: removed before deploying.

Logs and the writeup: https://gist.github.com/jmarrero-bot/bf75e0f860a2f1b19d648d3aafd4b499

Generated-by: https://github.com/jmarrero-bot#llms


Review draft in jmarrero-forge, not upstream yet. This section is removed when the PR is opened upstream.

  • Upstream: bootc-dev/bootc, base main
  • Board item: PVTI_lADOFBIZ7c4BlZPrzhEkDaA
  • Fork CI: off; the devspace testing described above is this PR's CI, and upstream CI runs once it is opened there

To review:

  • Approve, or comment /promote on a line of its own, to open it upstream, ready for review. Either covers only the commits pushed so far.
  • If upstream requires DCO, approving also signs off: promote adds Signed-off-by: Joseph Marrero Corchado <[email protected]> to the commits lacking it (the bot's and yours; anyone else's only if you ask), with you as committer.
  • Add a /draft line (in the same comment or before) to open it upstream as a draft (/ready undoes that).
  • Close to drop it.
  • Edit the title and description freely: they become the upstream PR's. Review comments are squashed into the commits they concern, with a reply here.

Bot run: session e7bb5c51, agents a39db7b3 +2 · claude-opus-5-5 130.3M in (98% cached) / 399k out · ~$47.61 inference + ~$5.02 compute (est., list prices) · 16h 53m wall · 31.9 core-h, Actions runs 41087353823, 40986594430, 40983763578

Bot run: session e7bb5c51, agents a39db7b3 +4 · claude-opus-5-5 197.9M in (97% cached) / 533k out · ~$74.96 inference + ~$8.57 compute (est., list prices) · 18h 9m wall · 54.4 core-h, Actions runs 41105190942, 41087353823, 40986594430, 40983763578

@jmarrero-bot jmarrero-bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Review guide for head 910e9883ec: where to look closely and what is safe to skim. It is advice from the bot's reviewer and doesn't replace reading the diff; the review app walks it.

Proof of concept for tracker#61 option D: bootc internals local-layer run -- CMD runs CMD chrooted in a writable overlay over the base image's boot EROFS, turns the upper into one OCI layer (composefs-rs overlay_upper + derive_image from the forge branch), and deploys the derived image through deploy_pulled, the deploy tail split out of do_upgrade. The origin records the commands and base digest in [local-layer]; upgrade rebuilds the layer on a new base, GC keeps each live layer's base, switch drops it. The two prep commits (ChrootCmd private /run, the do_upgrade split) are mechanical and keep plain upgrade/switch behavior; the split adds only an error-context layer. The main risk is the staged deployment: both local-layer run and the upgrade short-circuit read the layer from the booted deployment only, so a layer (or an extra command) that is only staged is silently dropped by the next run or upgrade, and run also replaces a staged upgrade or switch. Smaller points: the host resolv.conf is bound read-write, processes the commands leave behind are not contained, and the tmt test never runs anything with a deployment already staged. The build commit takes composefs-rs from a forge git branch, which upstream cargo-deny rejects, so this cannot be promoted as is (the body says so).

Hotspots

  1. risky · logic — crates/lib/src/bootc_composefs/local_layer.rs:380-388 (910e988): The new layer always starts from the booted deployment. A second run before rebooting loses the first run's command, and a run with a staged upgrade or switch silently replaces it. Build on the staged deployment's layer when it tracks the same image, and refuse (or say so) when a non-layered upgrade or switch is staged.
  2. risky · logic — crates/lib/src/bootc_composefs/update.rs:724-769 (910e988): Only the booted deployment's layer counts here. With a layer that is only staged (booted plain), an upgrade to a new base takes the plain path and stages the plain image, dropping the layer; with booted [A] and a staged [A, B], it rebuilds [A] only. Pick the staged layer when the staged deployment is not a switch.
  3. look-closely · perf — crates/lib/src/bootc_composefs/update.rs:362-384 (910e988): Only pulled.repo is moved out. The base's untransformed FileSystem and boot entries stay alive through the whole build and deploy. Destructure pulled and drop the rest before build_derived. Also, unlike validate_update, this path never removes stale state dirs (deploy_pulled's collision check still applies).
  4. note · logic — crates/lib/src/bootc_composefs/update.rs:386-406 (0bce58d): The split moves the deploy tail unchanged: the collision check, boot setup, drop(mounted_fs)/drop(repo) before the exclusive GC lock, state, staging and GC all keep their order. The only visible difference for plain upgrade/switch is the extra 'Deploying image' error context.
  5. look-closely · security — crates/lib/src/bootc_composefs/local_layer.rs:193-199 (910e988): The host's resolv.conf is bound read-write, so a command or scriptlet that writes /etc/resolv.conf in the staging root changes the host's file. That undercuts the private /run isolation. Remount the bind read-only (MS_REMOUNT|MS_BIND|MS_RDONLY) after binding.
  6. look-closely · logic — crates/lib/src/bootc_composefs/local_layer.rs:291-314 (910e988): There is no PID namespace or cgroup, so a daemon a command leaves behind (gpg-agent from dnf, say) keeps the ChrootCmd mount namespace and the overlay alive and can keep writing the upper while import_upper reads it. Lazy unmounts hide this. Run the commands in a new PID namespace (or a scope) and make sure none remain before importing.
  7. note · error-handling — crates/lib/src/bootc_composefs/local_layer.rs:393-399 (910e988): Unlike pull_composefs_repo, run neither calls composefs_oci::upgrade_repo nor checks disk space before adding a deployment and running GC. On a host with old-format config splitstreams, that GC may not reach the base's layer objects.
  8. note · logic — crates/lib/src/bootc_composefs/local_layer.rs:70-77 (910e988): The escaping of ';' and '#' is sound: both can only appear inside JSON strings, serde_json escapes newlines, and the unit test round-trips through tini. Nothing to change; noting that it was checked.
  9. note · logic — crates/lib/src/bootc_composefs/gc.rs:590-601 (910e988): list_deployments covers staged, booted, rollback and pinned, so a rollback's base is kept too, and the migration loop below tags it. The derived image itself is live through the origin's manifest digest. A malformed [local-layer] section makes GC (and status) fail rather than warn.
  10. look-closely · test-gap — tmt/tests/booted/test-composefs-local-layer.nu:59-76 (910e988): Every run and upgrade starts with nothing staged, so the staged-layer bugs above are not exercised. Also not covered: no mounts or /var/tmp work dirs left after the failed run, switch dropping the layer, upgrade --check, and that the rebuilt base equals the new image's digest.
  11. note · api — Cargo.toml:136-141 (4d04ca9): deny.toml allows git sources only from composefs/composefs-rs and bcvk, so upstream's cargo-deny job fails on this forge branch. That is expected for a POC that can't be promoted. Also nit: a stray double blank line.

Safe to skim

  • Cargo.lock: lock file: composefs crates switched to the forge git source at composefs-rs#2's head 0b6ac266
  • docs/src/host-v1.schema.json: generated from spec.rs by just update-generated
  • tmt/plans/integration.fmf: generated plan for test 65
  • tmt/tests/tests.fmf: generated test entry
  • crates/lib/src/bootc_composefs/switch.rs: passes None for the new parameter
  • crates/lib/src/bootc_composefs/boot.rs: passes None for the new parameter
  • crates/lib/src/bootc_composefs/mod.rs: module declaration
  • crates/lib/src/bootc_composefs/repo.rs: mechanical extraction of boot_image_for_pulled

@jmarrero-bot
jmarrero-bot force-pushed the bot/local-layer branch 3 times, most recently from 1bdca6f to 6861ee1 Compare October 30, 2026 18:27

@jmarrero-bot jmarrero-bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Review guide for head 6861ee12ac: where to look closely and what is safe to skim. It is advice from the bot's reviewer and doesn't replace reading the diff; the review app walks it.

Round 2. Proof of concept for tracker#61 option D: bootc internals local-layer run -- CMD runs CMD chrooted in a writable overlay over the base image's boot EROFS, turns the upper into one OCI layer (composefs-rs overlay_upper + derive_image, pinned to the forge branch at fc4a5bf), and deploys the derived image through deploy_pulled, the deploy tail split out of do_upgrade. The two prep commits are unchanged from round 1; the split moves the deploy tail without changing plain upgrade/switch. The round-1 staged-deployment bug is fixed by pending_layer and staged_is_switch, which both run and the upgrade short-circuit now use, and the host resolv.conf bind is read-only. Read the pending_layer logic and the upgrade short-circuit closely. Known gaps: processes the commands leave behind are not contained (no PID namespace); run neither upgrades old-format repos nor checks disk space; upgrade --tag keeps the layer, and the next run or upgrade then treats the staged deployment as a switch. The two heads before this one did not compile. This head builds, but the PR body still reports results from earlier heads as in progress and lacks the new not-done items. cargo-deny upstream rejects the forge git source, so this cannot be promoted as is.

Hotspots

  1. look-closely · logic — crates/lib/src/bootc_composefs/local_layer.rs:148-170 (6861ee1): Any difference in the staged image ref counts as a switch, including a layered deployment staged by bootc upgrade --tag. After such an upgrade, run refuses ('a switch is staged'), and a plain upgrade takes the plain path and stages the image without the layer. Either don't treat a staged deployment that has a local layer as a switch, or make --tag drop the layer like switch does.
  2. look-closely · logic — crates/lib/src/bootc_composefs/update.rs:723-755 (6861ee1): The pending layer (staged, else booted) now drives the no-op checks and the rebuild, which fixes round 1's dropped staged layers. With nothing new upstream and a layer run staged, it prints 'Update already staged', which is fine but worded for an upgrade. Check that --check, --apply and download-only behave the same as on the plain path.
  3. note · logic — crates/lib/src/bootc_composefs/local_layer.rs:412-423 (6861ee1): run now refuses while a switch is staged, and builds on the staged layer, or on a staged plain upgrade's image digest. GC keeps that base because the new deployment's origin names it.
  4. look-closely · logic — crates/lib/src/bootc_composefs/local_layer.rs:322-346 (6861ee1): Still no PID namespace or cgroup: a daemon a command leaves behind keeps the ChrootCmd mount namespace and the overlay alive, and can keep writing the upper while import_upper reads it. This is accepted for the POC but is not in the PR body's not-done list.
  5. note · error-handling — crates/lib/src/bootc_composefs/local_layer.rs:428-434 (6861ee1): Unlike pull_composefs_repo, run neither calls upgrade_repo nor checks disk space before adding a deployment and running GC. Acknowledged by the author, but not listed in the body.
  6. note · test-gap — tmt/tests/booted/test-composefs-local-layer.nu:62-84 (6861ee1): Now covers a second run on top of the staged layer, and no work dirs left after a failed run. Still not covered: switch dropping the layer, upgrade --check, and upgrade --tag.

Safe to skim

  • Cargo.lock: lock file: composefs crates pinned to the forge branch at composefs-rs#2's head fc4a5bf
  • docs/src/host-v1.schema.json: generated from spec.rs
  • tmt/plans/integration.fmf: generated plan for test 65
  • tmt/tests/tests.fmf: generated test entry
  • crates/lib/src/bootc_composefs/switch.rs: passes None for the new parameter
  • crates/lib/src/bootc_composefs/boot.rs: passes None for the new parameter
  • crates/lib/src/bootc_composefs/repo.rs: mechanical extraction of boot_image_for_pulled (unchanged since round 1)
  • crates/utils/src/chroot.rs: prep commit unchanged since round 1: optional tmpfs /run

@jmarrero-bot jmarrero-bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Review guide for head 8b1ecb4f0f: where to look closely and what is safe to skim. It is advice from the bot's reviewer and doesn't replace reading the diff; the review app walks it.

POC of bootc internals local-layer run on the composefs backend. It runs a command in a staging root (a writable overlay over a fresh mount of the base boot image), turns the upper into a layer with composefs-rs derive_image, and deploys the result through the deploy_pulled split. The origin records the commands and base digest, upgrade rebuilds the layer on a new base, and GC roots the base. composefs-rs comes from the forge branch through a git patch. This round replaced the mount-namespace-only chroot with ChrootCmd::isolate (new PID/UTS/IPC namespaces through a second fork in pre_exec, pivot_root, own procfs, read-only sysfs, minimal /dev, dropped capabilities), made the pending layer follow the next deployment's metadata, made GC fail safe, added a lock across run/upgrade/switch with stale work-dir cleanup, and removed a stale state dir before deploying. The main risk is the pre_exec code: it runs between fork and exec, forks again and must stay async-signal-safe. The lock also touches the general upgrade and switch paths.

Hotspots

  1. risky · security — crates/utils/src/chroot.rs:220-310 (722ba1e): The isolated pre_exec path: unshare, minimal /dev and read-only sysfs before the fork, then in PID 1 procfs, pivot_root with the old root detached, and the capability drop. Anything left reachable here is a way to the host; the tmt probe covers /proc/1/root, chroot escape, selinuxfs, /proc/sys, /dev/kmsg and CAP_SYS_ADMIN.
  2. look-closely · logic — crates/utils/src/chroot.rs:448-545 (722ba1e): Second fork inside pre_exec: the intermediate closes every fd but a liveness pipe (so Command::spawn's exec pipe isn't held), waits for PID 1 and exits with its status. Parent-death races are closed with getppid and the pipe. Check exit-status mapping and that only async-signal-safe calls run.
  3. note · security — crates/utils/src/chroot.rs:43-70 (722ba1e): The capabilities dropped (SYS_ADMIN, MKNOD, DAC_READ_SEARCH and the like). SETFCAP, CHOWN, SETUID/SETGID and SYS_CHROOT stay for rpm and scriptlets; the network is shared by design.
  4. look-closely · logic — crates/lib/src/bootc_composefs/local_layer.rs:166-181 (8b1ecb4): pending_layer now follows the next deployment's own layer metadata: staged if any, else booted. A staged deployment without a layer (a switch) has dropped it. This fixes upgrade --tag followed by a plain upgrade losing the layer.
  5. look-closely · logic — crates/lib/src/bootc_composefs/local_layer.rs:295-371 (8b1ecb4): BuildLock (flock in /run, blocking) and the root-owned work dir whose build.* entries are removed as stale while the lock is held. Every composefs upgrade and switch now takes the lock too.
  6. note · logic — crates/lib/src/bootc_composefs/update.rs:425-437 (8b1ecb4): After the collision check, a state dir for the target id can only be left by an interrupted deploy, so it is removed, as validate_update does before a pull.
  7. note · error-handling — crates/lib/src/bootc_composefs/gc.rs:590-610 (8b1ecb4): An unreadable [local-layer] section now warns and keeps every bootc image tag for that GC instead of failing it.

Safe to skim

  • Cargo.lock: lock file: libc for utils, composefs-rs pinned to the forge branch
  • docs/src/host-v1.schema.json: generated schema
  • tmt/plans/integration.fmf: generated plan entry
  • tmt/tests/tests.fmf: test registration
  • crates/lib/src/bootc_composefs/boot.rs: passes None for the new parameter
  • crates/lib/src/bootc_composefs/mod.rs: module declaration

@jmarrero-bot

Copy link
Copy Markdown
Author

Review fixes pushed (ecc0b32 → 8b1ecb4), squashed into the bot's commits; the prep commit is now "utils: Let ChrootCmd isolate a command from the host":

  • High: the command could write the host. It now runs as PID 1 of new PID/UTS/IPC namespaces, entered with pivot_root, with its own procfs (/proc/sys, /proc/irq... read-only), read-only sysfs without selinuxfs, a minimal /dev, a private /run and fewer capabilities. Still not a hardened sandbox: root, shared network by design.
  • upgrade --tag then upgrade no longer drops the layer: the pending layer comes from the next deployment's own metadata.
  • GC warns and keeps every image on a malformed [local-layer].
  • Work dirs moved to /var/lib/bootc-local-layer, cleaned under a lock that run, upgrade and switch take before reading status.
  • A retry after an interrupted stage removes the stale state dir (was in Not done).

At 8b1ecb4: cargo check --locked per commit, just unit-tests, just validate and tmt plan 65 (extended with a host-escape probe and the steps above) pass: https://gist.github.com/jmarrero-bot/bf75e0f860a2f1b19d648d3aafd4b499#file-r3-bootc-checks-and-tmt-log

Generated-by: https://github.com/jmarrero-bot#llms

@jmarrero-bot jmarrero-bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Review guide for head c16f6c96a2: where to look closely and what is safe to skim. It is advice from the bot's reviewer and doesn't replace reading the diff; the review app walks it.

POC of bootc internals local-layer run on the composefs backend: a command runs in a staging root through ChrootCmd::isolate, its upper dir becomes a layer via composefs-rs derive_image, and the result is deployed through the deploy_pulled split. This round closes two holes in isolate(): the executing child now marks every inherited fd >= 3 close-on-exec before exec (an inherited host directory fd could be used through openat or /proc/self/fd to write outside the root), and calls setsid() so the command has no controlling terminal (no TIOCSTI into the caller's). Test 65 gains a pty wrapper probe with a control run. Risk stays in the pre_exec code, which must remain async-signal-safe between fork and exec; after setsid, terminal job control (Ctrl-Z, SIGWINCH) no longer reaches the command, while Ctrl-C still kills it through the monitor's death signal.

Hotspots

  1. risky · security — crates/utils/src/chroot.rs:307-314 (a62ce66): New this round: setsid() and CLOSE_RANGE_CLOEXEC on every fd >= 3 in PID 1, after the capability drop and right before exec. This is what keeps an inherited host directory fd and the caller's controlling terminal (TIOCSTI) away from the command; the std exec-error pipe is already CLOEXEC so spawn errors still report.
  2. risky · security — crates/utils/src/chroot.rs:226-306 (a62ce66): The isolated pre_exec path: unshare, minimal /dev and read-only sysfs before the fork, then in PID 1 procfs, pivot_root with the old root detached, and the capability drop. Anything left reachable here is a way to the host.
  3. look-closely · logic — crates/utils/src/chroot.rs:542-583 (a62ce66): close_fd_range: close_range, with a per-fd fallback for kernels without close_range (5.9) or CLOSE_RANGE_CLOEXEC (5.11), bounded by the larger of the hard RLIMIT_NOFILE and 2^20 (fs.nr_open's default), so up to ~1M fcntl calls on those kernels only.
  4. look-closely · logic — crates/utils/src/chroot.rs:465-534 (a62ce66): Second fork inside pre_exec: the monitor stays in the caller's session (so Ctrl-C and SIGHUP kill it, and PDEATHSIG then kills PID 1), closes every fd but the liveness pipe and exits with PID 1's status. The SAFETY comment's pthread_atfork sentence is worded as if only this path registers handlers; any registered in the process run, safely, since it is single-threaded.
  5. look-closely · test-gap — tmt/tests/booted/test-composefs-local-layer.nu:76-99 (c16f6c9): Python pty wrapper (controlling terminal plus a non-CLOEXEC fd 7 on the host /etc) and the probe. The /proc/self/fd/7 write and the /dev/tty open would both leak without the fix; the TIOCSTI line can't fail open on kernels with legacy TIOCSTI disabled, and the control doesn't exercise it.
  6. note · test-gap — tmt/tests/booted/test-composefs-local-layer.nu:145-156 (c16f6c9): Control run outside bootc, then the probe through bootc under the wrapper; output comes through the pty, so lines are trimmed of the trailing CR and the command's stderr ends up in stdout.
  7. look-closely · logic — crates/lib/src/bootc_composefs/local_layer.rs:166-181 (c16f6c9): pending_layer now follows the next deployment's own layer metadata: staged if any, else booted. A staged deployment without a layer (a switch) has dropped it. This fixes upgrade --tag followed by a plain upgrade losing the layer.
  8. look-closely · logic — crates/lib/src/bootc_composefs/local_layer.rs:295-371 (c16f6c9): BuildLock (flock in /run, blocking) and the root-owned work dir whose build.* entries are removed as stale while the lock is held. Every composefs upgrade and switch now takes the lock too.
  9. note · logic — crates/lib/src/bootc_composefs/update.rs:425-437 (c16f6c9): After the collision check, a state dir for the target id can only be left by an interrupted deploy, so it is removed, as validate_update does before a pull.
  10. note · error-handling — crates/lib/src/bootc_composefs/gc.rs:590-610 (c16f6c9): An unreadable [local-layer] section now warns and keeps every bootc image tag for that GC instead of failing it.

Safe to skim

  • Cargo.lock: lock file: libc for utils, composefs-rs pinned to the forge branch
  • docs/src/host-v1.schema.json: generated schema
  • tmt/plans/integration.fmf: generated plan entry
  • tmt/tests/tests.fmf: test registration
  • crates/lib/src/bootc_composefs/boot.rs: passes None for the new parameter
  • crates/lib/src/bootc_composefs/mod.rs: module declaration

@jmarrero-bot

Copy link
Copy Markdown
Author

Pushed c16f6c9 (was 8b1ecb4), after review of ChrootCmd::isolate():

  • Fixed: the isolated command no longer gets the caller's file descriptors past stdio. Its PID 1 marks fd >= 3 close-on-exec right before exec, so an inherited host directory fd can't be used to write outside the root.
  • Fixed: the command now runs in a session of its own (setsid), so it has no controlling terminal: /dev/tty gives ENXIO and TIOCSTI is refused.
  • Not changed: the nested fork. Its SAFETY comment now says why the pthread_atfork handlers are fine (the process is single-threaded there).

Test 65 gained a pty-wrapper probe for both. All bot commits; the fix is squashed into "utils: Let ChrootCmd isolate a command from the host", the test change into "composefs: Add experimental local layers".

On a 16-core devspace, the following all passed: cargo check --locked at every commit, just unit-tests, just validate, and tmt composefs-local-layer. Logs: checks and tmt, test 65 output.

Commands that change a root which isn't booted, such as a package manager
installing into a staging root, shouldn't be able to change the host. With
only a new mount namespace they can: /proc/1/root is the host's root, the
host's /dev and /sys are bound read-write, the host's /run leads to its
systemd, D-Bus and udev, and the command has every capability.

isolate() runs the command as PID 1 of new PID, UTS and IPC namespaces, in
the root through pivot_root with the old root detached (so chrooting again
can't climb out to it), with a procfs of its own (/proc/sys, /proc/irq and
the like read-only), a fresh /run, a read-only sysfs without the host's
selinuxfs and cgroup mounts, a minimal /dev, and without the capabilities a
package install doesn't need. It runs in a session of its own, so it has
no controlling terminal to push input into, and gets no file descriptor of
the caller's but stdio, since one for a host directory would reach outside
the root. Whatever it leaves running is killed with its namespace. It
still shares the host's network, so it isn't meant as a hardened sandbox.

Only the children of a process enter the PID namespace it unshares, so the
spawned process forks once more and waits for the command, exiting with
its status.

Prep for running commands against a composefs image in a staging root.

Generated-by: AI
Deploying an image that is already in the composefs repository (the
collision check, boot entry, state, staging and GC) is now deploy_pulled(),
and preparing its boot image is boot_image_for_pulled(), so that an image
that wasn't pulled, but derived in the repository from one that was, can
be deployed the same way.

Prep for local layers.

Generated-by: AI
Proof of concept only: local layers need composefs-rs's overlay_upper and
derive_image, which are a draft on the jmarrero-forge/composefs-rs
bot/local-layer branch, so take composefs-ctl and its sibling crates from
that branch instead of crates.io. It is otherwise composefs-rs main, which
bootc builds against unchanged.

Generated-by: AI
`bootc internals local-layer run -- CMD...` changes a composefs system the
way a Containerfile `RUN CMD` on the booted image would, without a container
runtime, and keeps the result as a normal deployment. CMD runs chrooted in a
staging root, a writable overlay over a fresh mount of the deployment's base
image, isolated from the host (ChrootCmd::isolate) but on its network. The
overlay's upper becomes one OCI layer on top of the base's layers
(composefs-oci's overlay_upper and derive_image), and that derived image is
deployed like any other. So it boots with fs-verity on every file, the
local ones included, rolls back like any deployment, and a failing command
stages nothing.

The origin keeps tracking the upstream image and records the commands and
the base's manifest digest in a [local-layer] section, shown as localLayer
in `bootc status`. Each run re-runs every recorded command on the base, and
`bootc upgrade` re-runs them on a new base (and is a no-op while the base
is unchanged), so a layer is never stacked on a stale one. Both build on
what the next boot has: the staged deployment's layer if one is staged, else
the booted one's. A staged deployment without a layer, such as a `bootc
switch` to another image, has dropped it. GC keeps the base of each live
local layer, which is what the next run or upgrade builds on, and keeps
every image if a layer's origin can't be read.

The staging overlay sits on a fresh mount of the image rather than on `/`:
a composefs mount is already an overlay, and a second level is as deep as
the kernel stacks overlays, so it can't go on top of a usr-overlay. BLS
only, since a UKI pins the base image's digest. /var is not part of a layer.

Runs, upgrades and switches take a lock in /run before reading the
deployments, so that one doesn't stage over another, and a build removes
the work directories that killed ones left in /var/lib/bootc-local-layer.
A deploy also removes a state dir that an interrupted one left for the same
image, as validate_update does before a pull, since a rebuilt layer can
have the same content as before.

Generated-by: AI
@jmarrero-bot

Copy link
Copy Markdown
Author

Rebased onto bootc main c3be524 (new head e913073), conflict-only: kept the local-layer lock ahead of main's let mut host (aboot discard) in switch.rs/update.rs, and ordered test 65 before main's 66 in the tmt fmf files. Retested on jmarrero-devspace-42222674203: fmt, cargo check --locked per commit, clippy with CI flags (only tests-integration fails, unchanged from main), cargo test -p bootc-lib --lib (343 passed), update-generated --check, tmt plan 65 (composefs, grub, BLS, ext4) passed. Logs: https://gist.github.com/jmarrero-bot/bf75e0f860a2f1b19d648d3aafd4b499#file-r5-bootc-checks-and-tmt-log

@jmarrero-bot jmarrero-bot moved this from In Progress to Draft in Workstream Nov 6, 2026
jmarrero-bot added a commit that referenced this pull request Nov 11, 2026
The section added in bootc-dev#2436 says sysext and confext are not supported
and not recommended on bootc hosts. That overstates it: the bootc
project wants to work together with sysext, and whether it works well
today is mostly down to the distribution (its systemd version, SELinux
labeling and the like), not bootc itself. Say that instead, and point
at #7, where a more integrated approach is being discussed.

The overlayfs stacking-depth caveat stays as something to be aware of.
Its /etc note now names the real setup-root-conf.toml option and says
when /etc actually leaves room for confext: the old wording suggested
etc = none avoids the limit, but under transient root /etc is still
inside that overlay.

Generated-by: AI
jmarrero-bot added a commit that referenced this pull request Nov 11, 2026
The section added in bootc-dev#2436 says sysext and confext are not supported
and not recommended on bootc hosts. That overstates it: the bootc
project wants to work together with sysext, and whether it works well
today is mostly down to the distribution (its systemd version, SELinux
labeling and the like), not bootc itself. Say that instead, and point
at #7, where a more integrated approach is being discussed.

The overlayfs stacking-depth caveat stays as something to be aware of.
Its /etc note now names the real setup-root-conf.toml option and says
when /etc actually leaves room for confext: the old wording suggested
etc = none avoids the limit, but under transient root /etc is still
inside that overlay.

Generated-by: AI
jmarrero-bot added a commit that referenced this pull request Nov 12, 2026
The section added in bootc-dev#2436 says sysext and confext are not supported
and not recommended on bootc hosts. That overstates it: the bootc
project wants to work together with sysext, and whether it works well
today is mostly down to the distribution (its systemd version, SELinux
labeling and the like), not bootc itself. Say that instead, and point
at #7, where a more integrated approach is being discussed.

The transient overlay and OS-specific sections stay, as things to be
aware of. The /etc note now names the real setup-root-conf.toml option
and says when /etc actually leaves room for confext: the old wording
suggested etc = none avoids the limit, but under transient root /etc
is still inside that overlay.

Generated-by: AI
jmarrero-bot added a commit that referenced this pull request Nov 12, 2026
The section added in bootc-dev#2436 says sysext and confext are not supported
and not recommended on bootc hosts. That overstates it: the bootc
project wants to work together with sysext, and whether it works well
today is mostly down to the distribution (its systemd version, SELinux
labeling and the like), not bootc itself. Say that instead, and point
at #7, where a more integrated approach is being discussed.

The transient overlay and OS-specific sections stay, as things to be
aware of. The /etc note now names the real setup-root-conf.toml option
and says when /etc actually leaves room for confext: the old wording
suggested etc = none avoids the limit, but under transient root /etc
is still inside that overlay.

Generated-by: AI
Signed-off-by: Joseph Marrero Corchado <[email protected]>
jmarrero-bot added a commit that referenced this pull request Nov 12, 2026
The section added in bootc-dev#2436 says sysext and confext are not supported
and not recommended on bootc hosts. That overstates it: the bootc
project wants to work together with sysext, and whether it works well
today is mostly down to the distribution (its systemd version, SELinux
labeling and the like), not bootc itself. Say that instead, and point
at #7, where a more integrated approach is being discussed.

The transient overlay and OS-specific sections stay, as things to be
aware of. The /etc note now names the real setup-root-conf.toml option
and says when /etc actually leaves room for confext: the old wording
suggested etc = none avoids the limit, but under transient root /etc
is still inside that overlay.

Generated-by: AI
Signed-off-by: Joseph Marrero Corchado <[email protected]>
jmarrero-bot added a commit that referenced this pull request Nov 16, 2026
The section added in bootc-dev#2436 says sysext and confext are not supported
and not recommended on bootc hosts. That overstates it: the bootc
project wants to work together with sysext, and whether it works well
today is mostly down to the distribution (its systemd version, SELinux
labeling and the like), not bootc itself. Say that instead, and point
at #7, where a more integrated approach is being discussed.

The transient overlay and OS-specific sections stay, as things to be
aware of. The /etc note now names the real setup-root-conf.toml option
and says when /etc actually leaves room for confext: the old wording
suggested etc = none avoids the limit, but under transient root /etc
is still inside that overlay.

Generated-by: AI
Signed-off-by: Joseph Marrero Corchado <[email protected]>
@jmarrero-bot jmarrero-bot moved this from Draft to In Progress in Workstream Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant