Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions cmd/runtimetest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,30 @@ func validateMaskedPaths(spec *rspec.Spec) error {
return nil
}

func validateSeccomp(spec *rspec.Spec) error {
if spec.Linux == nil || spec.Linux.Seccomp == nil {
return nil
}
t := tap.New()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This TAP-within-a-TAP approach is a bit strange, but I think it might work… We can drop this once #308 lands and the t instance is getting passed around.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some other modifications can wait until #308 land. Thank you for your advice.

for _, sys := range spec.Linux.Seccomp.Syscalls {
if sys.Action == "SCMP_ACT_ERRNO" {
for _, name := range sys.Names {
if name == "getcwd" {
_, err := os.Getwd()
if err == nil {
t.Diagnostic("getcwd did not return an error")
}
} else {
t.Skip(1, fmt.Sprintf("%s syscall returns errno", name))
}
}
} else {
t.Skip(1, fmt.Sprintf("syscall action %s", sys.Action))
}
}
return nil
}

func validateROPaths(spec *rspec.Spec) error {
if spec.Linux == nil {
return nil
Expand Down Expand Up @@ -864,6 +888,10 @@ func run(context *cli.Context) error {
test: validateOOMScoreAdj,
description: "oom score adj",
},
{
test: validateSeccomp,
description: "seccomp",
},
{
test: validateROPaths,
description: "read only paths",
Expand Down
20 changes: 20 additions & 0 deletions validation/linux_seccomp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

import (
"github.com/opencontainers/runtime-tools/generate/seccomp"
"github.com/opencontainers/runtime-tools/validation/util"
)

func main() {
g := util.GetDefaultGenerator()
syscallArgs := seccomp.SyscallOpts{
Action: "errno",
Syscall: "getcwd",
}
g.SetDefaultSeccompAction("allow")
g.SetSyscallAction(syscallArgs)
err := util.RuntimeInsideValidate(g, nil)
if err != nil {
util.Fatal(err)
}
}