Skip to content

runsc/fsgofer/filter: add Rules() for composable seccomp filters#12904

Merged
copybara-service[bot] merged 2 commits intomasterfrom
test/cl897168280
Apr 15, 2026
Merged

runsc/fsgofer/filter: add Rules() for composable seccomp filters#12904
copybara-service[bot] merged 2 commits intomasterfrom
test/cl897168280

Conversation

@copybara-service
Copy link
Copy Markdown

runsc/fsgofer/filter: add Rules() for composable seccomp filters

Today runsc/fsgofer/filter exports only Install(opt Options) error, which builds and installs the seccomp program in one shot with no way to compose additional rules. I am looking into building a custom gofer over LisaFS that needs a small number of extra syscalls such as outbound TCP and setns(CLONE_NEWNET) for namespace switching but otherwise wants the stock seccomp baseline. The only option today is to fork config.go and its arch-specific files and manually track upstream changes, which is a security concern because if upstream tightens a rule forks silently diverge and may run with a wider-than-intended syscall surface.

This change adds Rules(opt Options) seccomp.SyscallRules, which returns the merged baseline without installing it so custom gofers can compose their own rules on top.

rules := filter.Rules(opts)
rules.Merge(myNetworkingRules)
// build and install seccomp program with the merged rules

Install() now delegates to Rules() internally. The implementation uses allowedSyscalls.Copy() to deep-copy the package-level rules before merging, which also fixes a latent issue where calling Install more than once would double-merge rules through the shared underlying map.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#12903 from shayonj:s/composable-seccomp c0b4b74

Add an exported Rules(opt Options) function that returns the merged
seccomp SyscallRules for a gofer process without installing them.
This allows custom gofer implementations to obtain the stock baseline
rules and merge their own additional rules before installing:

  rules := filter.Rules(opts)
  rules.Merge(myNetworkingRules)
  // build and install program with rules

The existing Install() function now delegates to Rules() internally.
A deep copy is used to ensure the package-level rule variables are
not mutated across calls.
@copybara-service copybara-service bot added the exported Issue was exported automatically label Apr 9, 2026
@copybara-service copybara-service bot force-pushed the test/cl897168280 branch 2 times, most recently from c5224dc to 69a3328 Compare April 15, 2026 17:25
@copybara-service copybara-service bot merged commit 7afc87c into master Apr 15, 2026
@copybara-service copybara-service bot deleted the test/cl897168280 branch April 15, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exported Issue was exported automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants