Skip to content

feat(seccomp): add seccomp-bpf filter support with TSYNC#93

Draft
noeljackson wants to merge 1 commit intoedera-dev:mainfrom
noeljackson:feat/seccomp-bpf
Draft

feat(seccomp): add seccomp-bpf filter support with TSYNC#93
noeljackson wants to merge 1 commit intoedera-dev:mainfrom
noeljackson:feat/seccomp-bpf

Conversation

@noeljackson
Copy link

Summary

Add optional seccomp-bpf filter support to ExecutableSpec, allowing callers to
provide a BPF filter program that styrolite installs at the correct point in the
container setup sequence.

Changes:

  • New seccomp module with SeccompFilter struct (BPF instruction tuples + install method)
  • ExecutableSpec.seccomp field (Option<SeccompFilter>, serde(default) for backward compat)
  • Filter installation in execute() after PR_SET_NO_NEW_PRIVS and before execvpe()
  • Module export in lib.rs

Why seccomp(2) with SECCOMP_FILTER_FLAG_TSYNC instead of prctl(PR_SET_SECCOMP):

prctl(PR_SET_SECCOMP) only applies the filter to the calling thread. If the process
has multiple threads (e.g. from a runtime or async executor), other threads can continue
making blocked syscalls until they individually install the filter. seccomp(2) with
SECCOMP_FILTER_FLAG_TSYNC atomically synchronizes the filter across all threads,
closing this race window.

Backward compatible: Existing configs without a seccomp field continue to work
unchanged since the field defaults to None.

Test plan

  • cargo check compiles
  • Existing configs without seccomp field deserialize correctly (serde default)
  • Config with seccomp filter installs and blocks syscalls as expected
  • Verify TSYNC: filter applies to all threads, not just the calling thread

Add optional seccomp-bpf filter installation to ExecutableSpec. The
caller provides a filter program as BPF instruction tuples and styrolite
installs it at the correct point in the execution sequence -- after
PR_SET_NO_NEW_PRIVS and capability setup, but before execvpe().

Uses seccomp(2) with SECCOMP_FILTER_FLAG_TSYNC instead of
prctl(PR_SET_SECCOMP) to synchronize the filter across all threads,
preventing a race where a pre-existing thread could call a blocked
syscall before the filter is applied.

The seccomp field on ExecutableSpec is Optional and serde(default),
so existing configs without seccomp continue to work unchanged.
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