Skip to content

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

Open
copybara-service[bot] wants to merge 1 commit intomasterfrom
test/cl897168280
Open

runsc/fsgofer/filter: add Rules() for composable seccomp filters#12904
copybara-service[bot] wants to merge 1 commit 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

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
PiperOrigin-RevId: 897168280
@copybara-service copybara-service bot added the exported Issue was exported automatically label Apr 9, 2026
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.

1 participant