From 9435aeeb301eacf744add312a0f6e291e396636e Mon Sep 17 00:00:00 2001 From: Justin Cormack Date: Wed, 28 Mar 2018 15:31:26 -0700 Subject: [PATCH] The set of bounding capabilities is the largest group No capabilities can be granted outside the bounding set, so there is no point looking at any other set for the largest scope. Signed-off-by: Justin Cormack --- contrib/seccomp/seccomp_default.go | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/contrib/seccomp/seccomp_default.go b/contrib/seccomp/seccomp_default.go index fe5f43273..11b446a6e 100644 --- a/contrib/seccomp/seccomp_default.go +++ b/contrib/seccomp/seccomp_default.go @@ -444,25 +444,8 @@ func DefaultProfile(sp *specs.Spec) *specs.LinuxSeccomp { }) } - // make a map of enabled capabilities - caps := make(map[string]bool) + admin := false for _, c := range sp.Process.Capabilities.Bounding { - caps[c] = true - } - for _, c := range sp.Process.Capabilities.Effective { - caps[c] = true - } - for _, c := range sp.Process.Capabilities.Inheritable { - caps[c] = true - } - for _, c := range sp.Process.Capabilities.Permitted { - caps[c] = true - } - for _, c := range sp.Process.Capabilities.Ambient { - caps[c] = true - } - - for c := range caps { switch c { case "CAP_DAC_READ_SEARCH": s.Syscalls = append(s.Syscalls, specs.LinuxSyscall{ @@ -471,6 +454,7 @@ func DefaultProfile(sp *specs.Spec) *specs.LinuxSeccomp { Args: []specs.LinuxSeccompArg{}, }) case "CAP_SYS_ADMIN": + admin = true s.Syscalls = append(s.Syscalls, specs.LinuxSyscall{ Names: []string{ "bpf", @@ -558,7 +542,7 @@ func DefaultProfile(sp *specs.Spec) *specs.LinuxSeccomp { } } - if !caps["CAP_SYS_ADMIN"] { + if !admin { switch runtime.GOARCH { case "s390", "s390x": s.Syscalls = append(s.Syscalls, specs.LinuxSyscall{