Skip to content

Commit 0a6e9ae

Browse files
author
Zhou Hao
committed
runtimetest: add validateSeccomp
Signed-off-by: Zhou Hao <zhouhao@cn.fujitsu.com>
1 parent c3755c1 commit 0a6e9ae

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)