File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -493,6 +493,25 @@ func validateMaskedPaths(spec *rspec.Spec) error {
493493 return nil
494494}
495495
496+ func validateSeccomp (spec * rspec.Spec ) error {
497+ if spec .Linux == nil || spec .Linux .Seccomp == nil {
498+ return nil
499+ }
500+ for _ , sys := range spec .Linux .Seccomp .Syscalls {
501+ if sys .Action == "SCMP_ACT_ERRON" {
502+ for _ , name := range sys .Names {
503+ if name == "getcwd" {
504+ _ , err := os .Getwd ()
505+ if err == nil {
506+ return fmt .Errorf ("when action is %v, return value should being passed to user space as the errno value without executing the system call" , sys .Action )
507+ }
508+ }
509+ }
510+ }
511+ }
512+ return nil
513+ }
514+
496515func validateROPaths (spec * rspec.Spec ) error {
497516 if spec .Linux == nil {
498517 return nil
@@ -772,6 +791,10 @@ func run(context *cli.Context) error {
772791 test : validateOOMScoreAdj ,
773792 description : "oom score adj" ,
774793 },
794+ {
795+ test : validateSeccomp ,
796+ description : "seccomp" ,
797+ },
775798 {
776799 test : validateROPaths ,
777800 description : "read only paths" ,
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import (
1515 "github.com/stretchr/testify/assert"
1616
1717 "github.com/opencontainers/runtime-tools/generate"
18+ "github.com/opencontainers/runtime-tools/generate/seccomp"
1819 "github.com/opencontainers/runtime-tools/specerror"
1920)
2021
@@ -88,6 +89,18 @@ func TestValidateBasic(t *testing.T) {
8889 assert .Nil (t , runtimeInsideValidate (g ))
8990}
9091
92+ func TestValidateSeccomp (t * testing.T ) {
93+ g := getDefaultGenerator ()
94+ syscallArgs := seccomp.SyscallOpts {
95+ Action : "errno" ,
96+ Syscall : "getcwd" ,
97+ }
98+ g .SetDefaultSeccompAction ("allow" )
99+ g .SetSyscallAction (syscallArgs )
100+
101+ assert .Nil (t , runtimeInsideValidate (g ))
102+ }
103+
91104func TestValidateSysctls (t * testing.T ) {
92105 g := getDefaultGenerator ()
93106 g .AddLinuxSysctl ("net.ipv4.ip_forward" , "1" )
You can’t perform that action at this time.
0 commit comments