Repository navigation
composefs: Add experimental local layers (bootc internals local-layer run) - #7
jmarrero-bot wants to merge 4 commits into
Conversation
jmarrero-bot
left a comment
There was a problem hiding this comment.
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
- 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. - 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. - 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). - 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. - 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. - 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. - 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. - 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. - 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. - 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. - 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 0b6ac266docs/src/host-v1.schema.json: generated from spec.rs by just update-generatedtmt/plans/integration.fmf: generated plan for test 65tmt/tests/tests.fmf: generated test entrycrates/lib/src/bootc_composefs/switch.rs: passes None for the new parametercrates/lib/src/bootc_composefs/boot.rs: passes None for the new parametercrates/lib/src/bootc_composefs/mod.rs: module declarationcrates/lib/src/bootc_composefs/repo.rs: mechanical extraction of boot_image_for_pulled
1bdca6f to
6861ee1
Compare
jmarrero-bot
left a comment
There was a problem hiding this comment.
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
- 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 bybootc 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. - 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. - 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. - 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. - 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. - 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 fc4a5bfdocs/src/host-v1.schema.json: generated from spec.rstmt/plans/integration.fmf: generated plan for test 65tmt/tests/tests.fmf: generated test entrycrates/lib/src/bootc_composefs/switch.rs: passes None for the new parametercrates/lib/src/bootc_composefs/boot.rs: passes None for the new parametercrates/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
6861ee1 to
ecc0b32
Compare
ecc0b32 to
8b1ecb4
Compare
jmarrero-bot
left a comment
There was a problem hiding this comment.
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
- 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. - 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. - 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. - 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. - 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. - 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. - 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 branchdocs/src/host-v1.schema.json: generated schematmt/plans/integration.fmf: generated plan entrytmt/tests/tests.fmf: test registrationcrates/lib/src/bootc_composefs/boot.rs: passes None for the new parametercrates/lib/src/bootc_composefs/mod.rs: module declaration
|
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":
At 8b1ecb4: Generated-by: https://github.com/jmarrero-bot#llms |
8b1ecb4 to
c16f6c9
Compare
jmarrero-bot
left a comment
There was a problem hiding this comment.
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
- 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. - 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. - 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. - 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. - 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. - 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. - 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. - 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. - 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. - 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 branchdocs/src/host-v1.schema.json: generated schematmt/plans/integration.fmf: generated plan entrytmt/tests/tests.fmf: test registrationcrates/lib/src/bootc_composefs/boot.rs: passes None for the new parametercrates/lib/src/bootc_composefs/mod.rs: module declaration
|
Pushed c16f6c9 (was 8b1ecb4), after review of
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: |
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
c16f6c9 to
e913073
Compare
|
Rebased onto bootc main c3be524 (new head e913073), conflict-only: kept the local-layer lock ahead of main's |
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
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
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
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]>
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]>
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]>
Proof of concept:
bootc internals local-layer run -- CMD...on the composefs backend. It changes the system the way a ContainerfileRUN CMDon 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'sresolv.confbound read-only and/var/cachefrom/var/cache/bootc-local-layer. It is isolated from the host byChrootCmd::isolate: PID 1 of new PID, UTS and IPC namespaces, entered throughpivot_rootwith the old root detached, a procfs of its own with/proc/sys,/proc/irqand the like read-only, a fresh read-only sysfs (no/sys/fs/selinuxor cgroups), a minimal/dev(null, zero, full, random, urandom, tty, its own devpts and shm), a private/run, and withoutCAP_SYS_ADMIN,CAP_MKNOD,CAP_DAC_READ_SEARCHand 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'soverlay_upperandderive_image(jmarrero-forge/composefs-rs#2). The derived image goes through the normal deploy path. It boots withverity=requireon 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 aslocalLayerinbootc 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. Ausr-overlayis never captured:runnotes that its changes are discarded on reboot.bootc upgradere-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, soupgrade --tagthen a plainupgradekeeps 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/bootcbefore 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 switchto another image drops the layer. BLS only (a UKI pins the base's digest), and/varis 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,/varto 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/bf75e0f860a2f1b19d648d3aafd4b499Tested 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:switch.rs/update.rsand test 66 in the tmt fmf files) with composefs-rs 5a305ae (jmarrero-devspace-42222674203, log: https://gist.github.com/jmarrero-bot/bf75e0f860a2f1b19d648d3aafd4b499#file-r5-bootc-checks-and-tmt-log):cargo fmt --checkandcargo check --lockedat every commit passed; clippy with CI's flags passed except intests-integration, which is unchanged from main and fails there too (str::lenincontainer.rs);cargo test -p bootc-lib --lib(343 passed) andcargo xtask update-generated direct --checkpassed; the tmt plancomposefs-local-layer(test 65) passed (output: https://gist.github.com/jmarrero-bot/bf75e0f860a2f1b19d648d3aafd4b499#file-r5-tmt-test-65-output-txt).cargo check --lockedpassed at every commit;just unit-testsandjust validatepassed; the tmt plancomposefs-local-layer(test 65) passed (output: https://gist.github.com/jmarrero-bot/bf75e0f860a2f1b19d648d3aafd4b499#file-r4-tmt-test-65-output-txt), including the new probe below.cargo check --lockedpassed at every commit;just unit-testsandjust validatepassed;composefs-local-layer(test 65) passed (output: https://gist.github.com/jmarrero-bot/bf75e0f860a2f1b19d648d3aafd4b499#file-r3-tmt-test-65-output-txt). New steps: a probe run that tries/proc/1/root/etc, chrooting out of the root,/sys/fs/selinux/enforce,/proc/sys, the host's/dev/kmsgand checks PID 1 andCAP_SYS_ADMIN; nothing reached the host. A stale work directory is removed. A retry after dropping the staged record rebuilds the same deployment over the old state dir.bootc upgrade --tagrebuilds the layer on the tag, and a plainupgradeafter it says "already staged" and keeps the layer; the next boot has it. The existing steps (dnf -y install tmux, a failing run, rollback, no-op and rebuilding upgrades) still pass.local-layer run -- dnf -y install tmux, a failing run staging nothing, rollback and roll-forward, a no-opupgradeon an unchanged base and a rebuild on a new one, a secondrun), also on top of the bootloader: Switch to using bootupd to do BIOS bootc-dev/bootc#65 image-set branches (bootc#6, composefs-rs#1), where every derived image boots as an image set and reuses its/usr/lib/modulescomponent byte for byte. At ecc0b32,runwith ausr-overlayactive builds only the command's change.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 callssetsid()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"):
/proc/1/root, read-write host/devand/sys, every capability): now isolated as above;upgrade --tagthen a plainupgradedropped the layer: the pending layer now comes from the next deployment's metadata, andrunbuilds on a staged switch too instead of refusing;[local-layer]origin failed every GC: now it warns and keeps every image;/var/tmp: work directories are under the lock now, in a root-owned/var/lib/bootc-local-layer, and stale ones are removed;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.
bootc-dev/bootc, basemainPVTI_lADOFBIZ7c4BlZPrzhEkDaATo review:
/promoteon a line of its own, to open it upstream, ready for review. Either covers only the commits pushed so far.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./draftline (in the same comment or before) to open it upstream as a draft (/readyundoes that).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