feat(seccomp): add seccomp-bpf filter support with TSYNC#93
Draft
noeljackson wants to merge 1 commit intoedera-dev:mainfrom
Draft
feat(seccomp): add seccomp-bpf filter support with TSYNC#93noeljackson wants to merge 1 commit intoedera-dev:mainfrom
noeljackson wants to merge 1 commit intoedera-dev:mainfrom
Conversation
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.
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.
Summary
Add optional seccomp-bpf filter support to
ExecutableSpec, allowing callers toprovide a BPF filter program that styrolite installs at the correct point in the
container setup sequence.
Changes:
seccompmodule withSeccompFilterstruct (BPF instruction tuples + install method)ExecutableSpec.seccompfield (Option<SeccompFilter>,serde(default)for backward compat)execute()afterPR_SET_NO_NEW_PRIVSand beforeexecvpe()lib.rsWhy
seccomp(2)withSECCOMP_FILTER_FLAG_TSYNCinstead ofprctl(PR_SET_SECCOMP):prctl(PR_SET_SECCOMP)only applies the filter to the calling thread. If the processhas 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)withSECCOMP_FILTER_FLAG_TSYNCatomically synchronizes the filter across all threads,closing this race window.
Backward compatible: Existing configs without a
seccompfield continue to workunchanged since the field defaults to
None.Test plan
cargo checkcompilesseccompfield deserialize correctly (serde default)