Fixes the top three findings from the code review:
bug-1 (critical) — mount invisible outside podman unshare
The rootless overlay mount only exists inside podman unshare's user namespace, so every read of the rootfs previously saw an empty directory and slim build always failed with a misleading "missing /vmlinuz" error. Now the vmlinuz check (test -f), the vmlinuz copy (cp), and the find | cpio pipeline all run under podman unshare; cpio's stdout is piped across the namespace boundary and gzipped in the parent. This also eliminates the initrd.tmp round-trip and excludes ./vmlinuz from the archive.
bug-2 (major) — image stayed mounted on build failure
The unmount now runs on all code paths (result is captured, unmount happens unconditionally, then the result propagates). The unmount exit status is checked instead of discarded.
bug-3 (major) — slim run reported every qemu failure as success
timeout's exit 124 is treated as the expected smoke-test timeout; exit 126/127 produce a clear "is qemu installed?" error; any other non-zero status or signal bails.
Verification
slim build alpine:3.15 (no kernel): bails with clear error and prints Unmounted image.; namespace overlay-mount count returns to baseline
slim build mock-vm (image with fake /vmlinuz + /init): succeeds end-to-end (previously always failed); initrd is valid gzip, contains the full rootfs + init, excludes vmlinuz; extraction round-trip OK
slim run mock-vm with invalid kernel: Error: QEMU exited with code 1, slim exits 1
qemu hidden from PATH: Error: Failed to start qemu-system-x86_64 (is it installed and in PATH?)
cargo fmt --check, cargo clippy -- -D warnings, cargo build, cargo test all pass
Out of scope (separate findings, untouched): registry_dir refactor/path validation (sec-2/bug-7), CI fixes (sec-1/bug-4/bug-9), dead dependencies, CLI flag cleanup.
@hulthe please review — will not merge until approved.
Fixes the top three findings from the code review:
## bug-1 (critical) — mount invisible outside `podman unshare`
The rootless overlay mount only exists inside `podman unshare`'s user namespace, so every read of the rootfs previously saw an empty directory and `slim build` always failed with a misleading "missing /vmlinuz" error. Now the vmlinuz check (`test -f`), the vmlinuz copy (`cp`), and the `find | cpio` pipeline all run under `podman unshare`; cpio's stdout is piped across the namespace boundary and gzipped in the parent. This also eliminates the `initrd.tmp` round-trip and excludes `./vmlinuz` from the archive.
## bug-2 (major) — image stayed mounted on build failure
The unmount now runs on all code paths (result is captured, unmount happens unconditionally, then the result propagates). The unmount exit status is checked instead of discarded.
## bug-3 (major) — `slim run` reported every qemu failure as success
`timeout`'s exit 124 is treated as the expected smoke-test timeout; exit 126/127 produce a clear "is qemu installed?" error; any other non-zero status or signal bails.
## Verification
- `slim build alpine:3.15` (no kernel): bails with clear error **and** prints `Unmounted image.`; namespace overlay-mount count returns to baseline
- `slim build mock-vm` (image with fake `/vmlinuz` + `/init`): succeeds end-to-end (previously always failed); initrd is valid gzip, contains the full rootfs + `init`, excludes `vmlinuz`; extraction round-trip OK
- `slim run mock-vm` with invalid kernel: `Error: QEMU exited with code 1`, slim exits 1
- qemu hidden from PATH: `Error: Failed to start qemu-system-x86_64 (is it installed and in PATH?)`
- `cargo fmt --check`, `cargo clippy -- -D warnings`, `cargo build`, `cargo test` all pass
Out of scope (separate findings, untouched): registry_dir refactor/path validation (sec-2/bug-7), CI fixes (sec-1/bug-4/bug-9), dead dependencies, CLI flag cleanup.
@hulthe please review — will not merge until approved.
- build: the rootless overlay mount only exists inside podman unshare's
user namespace; run the vmlinuz check/copy and the find|cpio pipeline
there, streaming cpio's stdout to the parent for gzipping (also drops
the initrd.tmp round-trip and excludes vmlinuz from the archive)
- build: unmount the image on all code paths, not just success
- run: treat timeout's exit 124 as the expected smoke-test timeout and
error on any other non-zero status (a missing qemu binary no longer
reports success)
Fixes bug-1, bug-2, bug-3 from the code review.
hulthe
approved these changes 2026-08-25 22:47:10 +02:00
marvin
merged commit 8dd5267bb4 into master2026-08-25 22:47:37 +02:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fixes the top three findings from the code review:
bug-1 (critical) — mount invisible outside
podman unshareThe rootless overlay mount only exists inside
podman unshare's user namespace, so every read of the rootfs previously saw an empty directory andslim buildalways failed with a misleading "missing /vmlinuz" error. Now the vmlinuz check (test -f), the vmlinuz copy (cp), and thefind | cpiopipeline all run underpodman unshare; cpio's stdout is piped across the namespace boundary and gzipped in the parent. This also eliminates theinitrd.tmpround-trip and excludes./vmlinuzfrom the archive.bug-2 (major) — image stayed mounted on build failure
The unmount now runs on all code paths (result is captured, unmount happens unconditionally, then the result propagates). The unmount exit status is checked instead of discarded.
bug-3 (major) —
slim runreported every qemu failure as successtimeout's exit 124 is treated as the expected smoke-test timeout; exit 126/127 produce a clear "is qemu installed?" error; any other non-zero status or signal bails.Verification
slim build alpine:3.15(no kernel): bails with clear error and printsUnmounted image.; namespace overlay-mount count returns to baselineslim build mock-vm(image with fake/vmlinuz+/init): succeeds end-to-end (previously always failed); initrd is valid gzip, contains the full rootfs +init, excludesvmlinuz; extraction round-trip OKslim run mock-vmwith invalid kernel:Error: QEMU exited with code 1, slim exits 1Error: Failed to start qemu-system-x86_64 (is it installed and in PATH?)cargo fmt --check,cargo clippy -- -D warnings,cargo build,cargo testall passOut of scope (separate findings, untouched): registry_dir refactor/path validation (sec-2/bug-7), CI fixes (sec-1/bug-4/bug-9), dead dependencies, CLI flag cleanup.
@hulthe please review — will not merge until approved.