Skip to content

feat(guest): enable libseccomp in guest runtime#472

Merged
DorianZheng merged 2 commits into
mainfrom
worktree-abstract-sauteeing-meadow
May 4, 2026
Merged

feat(guest): enable libseccomp in guest runtime#472
DorianZheng merged 2 commits into
mainfrom
worktree-abstract-sauteeing-meadow

Conversation

@DorianZheng

Copy link
Copy Markdown
Member

Summary

  • Enable libcontainer's libseccomp feature so OCI seccomp profiles are actually applied. Today the guest prints WARN libcontainer::process::init::process: seccomp not available, unable to set seccomp privileges! and runs workloads with no filter.
  • Add scripts/build/build-libseccomp.sh that vendors libseccomp 2.5.5 + sabotage-linux/kernel-headers, builds libseccomp.a statically per target arch, cached under ~/.cache/boxlite/.
  • Wire it into build-guest.sh; add gperf (libseccomp's build dep) to all four platform setup scripts (setup-macos.sh, setup-ubuntu.sh, setup-musllinux.sh, setup-manylinux.sh).

Why

Without seccomp, BoxLite's "secure isolated execution environment" is missing a defense-in-depth layer the OCI spec already specifies. The fix is mechanical (one feature flag) but the cross-compile plumbing isn't — brew install FiloSottile/musl-cross ships musl libc headers but no Linux UAPI headers, so libseccomp's #include <asm/unistd.h> and <linux/audit.h> fail. Vendoring the sabotage-linux/kernel-headers tarball (~1.4 MB) gives a deterministic, portable header set across all platforms.

Cache layout under ~/.cache/boxlite/:

  • libseccomp/<target>/<version>/{lib,include} — built .a and headers
  • linux-headers/<version>/<arch>/include — sabotage UAPI export

Idempotent — re-runs hit cache in ~10 ms.

Test plan

  • `bash scripts/build/build-libseccomp.sh aarch64-unknown-linux-musl` on macOS Apple Silicon → 207 KB `.a`
  • `bash scripts/build/build-libseccomp.sh x86_64-unknown-linux-musl` on Ubuntu EC2 → 222 KB `.a`
  • Re-run hits cache (~10 ms)
  • `bash scripts/build/build-guest.sh --profile debug` succeeds on both arches
  • `nm` shows `seccomp_init`, `seccomp_load`, `seccomp_rule_add` linked into guest binary
  • Guest binary remains statically linked (`file` reports `statically linked` / `static-pie`)
  • `cargo clippy -p boxlite-guest -- -D warnings` clean
  • `cargo fmt --check` clean
  • End-to-end: `make runtime-debug` + run a box with a seccomp profile, confirm `Seccomp: 2` in `/proc/self/status` and the WARN line is gone
  • CI passes for both target arches and all four setup scripts

Enables the libseccomp feature on libcontainer so seccomp profiles
from the OCI spec are actually applied. Without this, the guest
prints "seccomp not available" and runs workloads with no filter.

The Rust libseccomp-sys crate needs libseccomp.a for the target
triple (musl) plus Linux UAPI headers that brew's musl-cross
doesn't ship. Add scripts/build/build-libseccomp.sh which builds
libseccomp 2.5.5 statically using sabotage-linux/kernel-headers
for the asm/linux includes, cached at ~/.cache/boxlite/.
build-guest.sh sources the helper before cargo build.

Add gperf to all four platform setup scripts.

Verified on aarch64 (macOS) and x86_64 (Linux).
Cache was previously at $HOME/.cache/boxlite/{libseccomp,linux-headers}/.
Moving it under target/native/ makes it per-checkout, gitignored
automatically, and cleaned by `cargo clean` along with everything else.

Layout:
  target/native/libseccomp/<target-triple>/<version>/{lib,include}/
  target/native/linux-headers/<version>/<arch>/include/

The "native" subdir is intended as an umbrella for any future vendored
C deps we build outside cargo (e.g. libcap-static, libbpf-static), so
target/ doesn't end up cluttered with one top-level dir per dep.

The BOXLITE_CACHE env var still wins, so CI can centralize a shared
cache if it wants to.
@DorianZheng DorianZheng merged commit 807bdf5 into main May 4, 2026
28 checks passed
@DorianZheng DorianZheng deleted the worktree-abstract-sauteeing-meadow branch May 4, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant