@@ -6,11 +6,12 @@ import (
66 "errors"
77 "fmt"
88
9- "github.com/opencontainers/runc/libcontainer/configs"
10- "github.com/opencontainers/runc/libcontainer/seccomp/patchbpf"
11-
129 libseccomp "github.com/seccomp/libseccomp-golang"
10+ "github.com/sirupsen/logrus"
1311 "golang.org/x/sys/unix"
12+
13+ "github.com/opencontainers/runc/libcontainer/configs"
14+ "github.com/opencontainers/runc/libcontainer/seccomp/patchbpf"
1415)
1516
1617var (
@@ -67,7 +68,7 @@ func InitSeccomp(config *configs.Seccomp) error {
6768 if call == nil {
6869 return errors .New ("encountered nil syscall while initializing Seccomp" )
6970 }
70- if err := matchCall (filter , call ); err != nil {
71+ if err := matchCall (filter , call , defaultAction ); err != nil {
7172 return err
7273 }
7374 }
@@ -142,7 +143,7 @@ func getCondition(arg *configs.Arg) (libseccomp.ScmpCondition, error) {
142143}
143144
144145// Add a rule to match a single syscall
145- func matchCall (filter * libseccomp.ScmpFilter , call * configs.Syscall ) error {
146+ func matchCall (filter * libseccomp.ScmpFilter , call * configs.Syscall , defAct libseccomp. ScmpAction ) error {
146147 if call == nil || filter == nil {
147148 return errors .New ("cannot use nil as syscall to block" )
148149 }
@@ -151,17 +152,23 @@ func matchCall(filter *libseccomp.ScmpFilter, call *configs.Syscall) error {
151152 return errors .New ("empty string is not a valid syscall" )
152153 }
153154
154- // If we can't resolve the syscall, assume it's not supported on this kernel
155- // Ignore it, don't error out
156- callNum , err := libseccomp .GetSyscallFromName (call .Name )
155+ // Convert the call's action to the libseccomp equivalent
156+ callAct , err := getAction (call .Action , call .ErrnoRet )
157157 if err != nil {
158+ return fmt .Errorf ("action in seccomp profile is invalid: %w" , err )
159+ }
160+ if callAct == defAct {
161+ // This rule is redundant, silently skip it
162+ // to avoid error from AddRule.
158163 return nil
159164 }
160165
161- // Convert the call's action to the libseccomp equivalent
162- callAct , err := getAction (call .Action , call .ErrnoRet )
166+ // If we can't resolve the syscall, assume it is not supported
167+ // by this kernel. Warn about it, don't error out.
168+ callNum , err := libseccomp .GetSyscallFromName (call .Name )
163169 if err != nil {
164- return fmt .Errorf ("action in seccomp profile is invalid: %w" , err )
170+ logrus .Debugf ("unknown seccomp syscall %q ignored" , call .Name )
171+ return nil
165172 }
166173
167174 // Unconditional match - just add the rule
0 commit comments