Skip to content

Commit d0553dc

Browse files
committed
seccomp: set SPEC_ALLOW by default
If no seccomps flags are set in OCI runtime spec (not even the empty set), set SPEC_ALLOW by default. Otherwise, use the flags set. This mimics the crun behavior, and makes runc seccomp performance on par with crun. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent c7dc8b1 commit d0553dc

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

libcontainer/specconv/spec_linux.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,16 +1020,22 @@ func SetupSeccomp(config *specs.LinuxSeccomp) (*configs.Seccomp, error) {
10201020
newConfig := new(configs.Seccomp)
10211021
newConfig.Syscalls = []*configs.Syscall{}
10221022

1023-
// The list of flags defined in runtime-spec is a subset of the flags
1024-
// in the seccomp() syscall
1025-
for _, flag := range config.Flags {
1026-
switch flag {
1027-
case "SECCOMP_FILTER_FLAG_TSYNC":
1028-
// Tsync can be silently ignored
1029-
case specs.LinuxSeccompFlagLog, specs.LinuxSeccompFlagSpecAllow:
1030-
newConfig.Flags = append(newConfig.Flags, flag)
1031-
default:
1032-
return nil, fmt.Errorf("seccomp flag %q not yet supported by runc", flag)
1023+
if config.Flags == nil {
1024+
// No flags are set explicitly (not even the empty set);
1025+
// set the default of specs.LinuxSeccompFlagSpecAllow.
1026+
newConfig.Flags = []specs.LinuxSeccompFlag{specs.LinuxSeccompFlagSpecAllow}
1027+
} else {
1028+
// The list of flags defined in runtime-spec is a subset of the flags
1029+
// in the seccomp() syscall.
1030+
for _, flag := range config.Flags {
1031+
switch flag {
1032+
case "SECCOMP_FILTER_FLAG_TSYNC":
1033+
// Tsync can be silently ignored
1034+
case specs.LinuxSeccompFlagLog, specs.LinuxSeccompFlagSpecAllow:
1035+
newConfig.Flags = append(newConfig.Flags, flag)
1036+
default:
1037+
return nil, fmt.Errorf("seccomp flag %q not yet supported by runc", flag)
1038+
}
10331039
}
10341040
}
10351041

0 commit comments

Comments
 (0)