refactor(firma-run): compile managed seccomp BPF via seccompiler - #415
Draft
lu-zero wants to merge 1 commit into
Draft
refactor(firma-run): compile managed seccomp BPF via seccompiler#415lu-zero wants to merge 1 commit into
lu-zero wants to merge 1 commit into
Conversation
Replace the hand-emitted classic-BPF opcode encoder in seccomp.rs with the seccompiler crate (rust-vmm/Firecracker). seccompiler handles the arch-check prologue and per-syscall jump table construction; the per-arch syscall-number table and the artifact/metadata/checksum contract are unchanged. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
lu-zero
force-pushed
the
seccomp/seccompiler-release
branch
from
August 1, 2026 16:44
ec5c6b7 to
dfdc5d0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
crates/firma-run/src/seccomp.rshand-emits classic-BPF opcodes byte-by-byte(manual
LD/JMP/RETencoding, manual arch-check prologue). That's theriskiest part of the file to review and extend by hand. This is draft 1 of 2
evaluating a port to the
seccompilercrate (rust-vmm/Firecracker) as the BPF compiler backend; draft 2 will follow
up with a fork that adds public syscall-name-to-number resolution.
What Changed
emit_bpf_program/emit_stmt/emit_jumpand the localTargetArchenum withseccompiler::SeccompFilter/SeccompAction/TargetArch, which generate the arch-check prologue and per-syscall jumptable.
SyscallId::number_for_archper-archsyscall-number table as-is (released
seccompilerhas no publicname-to-number resolution yet — that's what draft 2 addresses).
Vec<sock_filter>to the same raw byte layout(
u16code,u8jt,u8jf,u32k, native endian) the artifact fileand
bwrap --seccomp <fd>already expect, so the artifact/metadata/checksum contract in
linux-local-command-enforcement.mdis unchanged.compiler_versiontomanaged-seccomp-v2-seccompilersince theemitted BPF byte sequence differs from the hand-rolled emitter (same
semantics, different instruction encoding from seccompiler's compiler).
Manual / Extra Verification
scripts/seccomp/check-managed-compatibility.shpasses.cargo nextest run -p firma-run(384 tests) passes, including the existingBPF-reproducibility test (
compile_on_launch_is_reproducible_for_same_policy_and_arch)unmodified.
Risks / Notes
per action class is identical; only how the BPF bytes for that deny-list
get generated changed.
seccompiler(Apache-2.0 OR BSD-3-Clause, pure Rust, no system/linkdependency) as a Linux-only dependency of
firma-run.dprint checkis clean for every file this PR touches(
Cargo.toml,crates/firma-run/Cargo.toml,crates/firma-run/src/seccomp.rs,docs/architecture/linux-local-command-enforcement.md).just fmtstillfails repo-wide on 10 pre-existing files under
todo/, unrelated to thischange and already failing on
main.AI Assistance
Implemented with Claude Sonnet 5 (Claude Code) per explicit user request, after a
prior conversation turn reviewed the current seccomp implementation and
evaluated seccompiler vs libseccomp as replacement backends.