runsc/fsgofer/filter: add Rules() for composable seccomp filters#12904
Open
copybara-service[bot] wants to merge 1 commit intomasterfrom
Open
runsc/fsgofer/filter: add Rules() for composable seccomp filters#12904copybara-service[bot] wants to merge 1 commit intomasterfrom
copybara-service[bot] wants to merge 1 commit intomasterfrom
Conversation
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
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.
runsc/fsgofer/filter: add Rules() for composable seccomp filters
Today
runsc/fsgofer/filterexports onlyInstall(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 andsetns(CLONE_NEWNET)for namespace switching but otherwise wants the stock seccomp baseline. The only option today is to forkconfig.goand 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.Install()now delegates toRules()internally. The implementation usesallowedSyscalls.Copy()to deep-copy the package-level rules before merging, which also fixes a latent issue where callingInstallmore than once would double-merge rules through the shared underlying map.FUTURE_COPYBARA_INTEGRATE_REVIEW=#12903 from shayonj:s/composable-seccomp c0b4b74