Skip to content

Commit bd222f9

Browse files
author
Zhou Hao
committed
runtimetest: add validateSeccomp
Signed-off-by: Zhou Hao <[email protected]>
1 parent c3755c1 commit bd222f9

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

cmd/runtimetest/main.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,25 @@ func validateMaskedPaths(spec *rspec.Spec) error {
576576
return nil
577577
}
578578

579+
func validateSeccomp(spec *rspec.Spec) error {
580+
if spec.Linux == nil || spec.Linux.Seccomp == nil {
581+
return nil
582+
}
583+
for _, sys := range spec.Linux.Seccomp.Syscalls {
584+
if sys.Action == "SCMP_ACT_ERRON" {
585+
for _, name := range sys.Names {
586+
if name == "getcwd" {
587+
_, err := os.Getwd()
588+
if err == nil {
589+
logrus.Warnf("Syscall action %v can not be properly applied in the runtime", sys.Action)
590+
}
591+
}
592+
}
593+
}
594+
}
595+
return nil
596+
}
597+
579598
func validateROPaths(spec *rspec.Spec) error {
580599
if spec.Linux == nil {
581600
return nil
@@ -864,6 +883,10 @@ func run(context *cli.Context) error {
864883
test: validateOOMScoreAdj,
865884
description: "oom score adj",
866885
},
886+
{
887+
test: validateSeccomp,
888+
description: "seccomp",
889+
},
867890
{
868891
test: validateROPaths,
869892
description: "read only paths",

validation/linux_seccomp.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package main
2+
3+
import (
4+
"github.com/opencontainers/runtime-tools/generate/seccomp"
5+
"github.com/opencontainers/runtime-tools/validation/util"
6+
)
7+
8+
func main() {
9+
g := util.GetDefaultGenerator()
10+
syscallArgs := seccomp.SyscallOpts{
11+
Action: "errno",
12+
Syscall: "getcwd",
13+
}
14+
g.SetDefaultSeccompAction("allow")
15+
g.SetSyscallAction(syscallArgs)
16+
err := util.RuntimeInsideValidate(g, nil)
17+
if err != nil {
18+
util.Fatal(err)
19+
}
20+
}

0 commit comments

Comments
 (0)