Skip to content

runtimetest: add validateSeccomp - #514

Merged
liangchenye merged 1 commit into
opencontainers:masterfrom
zhouhao3:runtimetest-seccomp
Jan 3, 2018
Merged

runtimetest: add validateSeccomp#514
liangchenye merged 1 commit into
opencontainers:masterfrom
zhouhao3:runtimetest-seccomp

Conversation

@zhouhao3

Copy link
Copy Markdown

Signed-off-by: Zhou Hao zhouhao@cn.fujitsu.com

@zhouhao3
zhouhao3force-pushed the runtimetest-seccomp branch 3 times, most recently from 0abf4c1 to 3a9ec3aCompareNovember 9, 2017 07:34
Comment threadcmd/runtimetest/main.go Outdated
if name == "getcwd" {
_, err := os.Getwd()
if err == nil {
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't see any runtime-oriented RFC 2119 requirements for linux.seccomp, which means we only have the config-oriented SeccSyscallsNamesRequired in specerror, which means we have no grounds for making this a fatal error in compliance testing. I think the best we can do (at least for 1.0.x configs) is warn the caller that the runtime is skipping some not-strictly-required-but-probably-expected functionality.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Before spec adds RFC requirements, we'd better just give a warn instead of error

Comment threadvalidation/validation_test.go Outdated
syscallArgs := seccomp.SyscallOpts{
Action: "errno",
Syscall: "getcwd",
Index: "0",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

what are Index, Value used for in this case?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

According to the code in parse_action.go:

	action, _ := parseAction(arguments[0])
if action == config.DefaultAction && args.argsAreEmpty() {
// default already set, no need to make changes
return nil
}

If args is empty, you can't add syscall.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If you really want to test the Action, you should change the defautAction not equal to the specified action.
Then, empty args will not be a problem.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

updated.

@zhouhao3
zhouhao3force-pushed the runtimetest-seccomp branch 4 times, most recently from 4b330b9 to 59c6c2dCompareNovember 10, 2017 07:14
@MashimiaoMashimiao added this to the v0.4.0 milestone Nov 15, 2017
Comment threadcmd/runtimetest/main.go Outdated
if name == "getcwd" {
_, err := os.Getwd()
if err == nil {
logrus.Warnf("when action is %v, return value should being passed to user space as the errno value without executing the system call", sys.Action)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think the warning is not suitable, that's not what we really want to tell users.
We want to tell them even seccomp is configured but this runtime can not apply it or similar warning

@zhouhao3
zhouhao3force-pushed the runtimetest-seccomp branch 2 times, most recently from 3f1f3ca to f363ae3CompareNovember 17, 2017 02:57
@Mashimiao

Mashimiao commented Nov 17, 2017

Copy link
Copy Markdown

LGTM

Approved with PullApprove

@zhouhao3
zhouhao3force-pushed the runtimetest-seccomp branch 2 times, most recently from 0a6e9ae to bd222f9CompareDecember 13, 2017 07:58
for _, sys := range spec.Linux.Seccomp.Syscalls {
if sys.Action == "SCMP_ACT_ERRON" {
for _, name := range sys.Names {
if name == "getcwd" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we write t.Skips for other names and actions? I don't want to give users the false impression that we're testing them by silently ignoring other values.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we write t.Skips…

This is probably blocking on passing the TAP instance down into the validators, which I do in #308. I don't see a clean way to handle this case before #308 lands; if maintainers want a stub in the meantime that's fine, and I don't really care if/how this gets handled in the stub.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Does that mean that all the action and name combinations will be exported as skipped information? Maybe I misunderstood.

@wkingwkingDec 26, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does that mean that all the action and name combinations will be exported as skipped information?

Yes, but only if a configuration uses them. That would make it easy for folks writing tests in validation to see that runtimetest was ignoring something which the configuration had requested.

Comment threadcmd/runtimetest/main.go Outdated
if name == "getcwd" {
_, err := os.Getwd()
if err == nil {
logrus.Warnf("Syscall action %v can not be properly applied in the runtime", sys.Action)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a non-TAP warning that will be gobbled by RuntimeInsideValidate. I think you want something like:

t.Skip(1, fmt.Sprintf("%s syscall returns errno", sys.Name))
iferr==nil {
t.Diagnostic("did not return an error")
} else {
t.Diagnosticf("returned %d (%s)", err.WhateverOtherErrno(), err.Error())
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I tried to modify it, what do you think?

Comment threadcmd/runtimetest/main.go Outdated
return nil
}
for _, sys := range spec.Linux.Seccomp.Syscalls {
if sys.Action == "SCMP_ACT_ERRON" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SCMP_ACT_ERRONSCMP_ACT_ERRNO.

@zhouhao3
zhouhao3force-pushed the runtimetest-seccomp branch 2 times, most recently from 87a2e04 to 4907259CompareDecember 27, 2017 06:45
if spec.Linux == nil || spec.Linux.Seccomp == nil {
return nil
}
t := tap.New()

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment threadcmd/runtimetest/main.go Outdated
if name == "getcwd" {
_, err := os.Getwd()
if err == nil {
t.Diagnostic("Syscall action ERRNO can not be properly applied in the runtime")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe the diagnostic could be:

getcwd did not return an error

Once #308 lands with a local test, that test will be the %s syscall returns errno you have in the skip below, so the total output will be:

not ok … - getcwd syscall returns errno
# getcwd did not return an error

Comment threadcmd/runtimetest/main.go Outdated
t.Diagnostic("Syscall action ERRNO can not be properly applied in the runtime")
}
} else {
t.Skip(i, fmt.Sprintf("%s syscall returns errno", name))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be t.Skip(1, …), since we're only skipping one test.

t.Skip(i, fmt.Sprintf("%s syscall returns errno", name))
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And here we want an else case saying that we're skipping the action:

} else {
t.Skip(1, fmt.Sprintf("syscall action %s", sys.Action))
}

or similar.

Signed-off-by: Zhou Hao <zhouhao@cn.fujitsu.com>
@zhouhao3

Copy link
Copy Markdown
Author

@liangchenye@Mashimiao PTAL

@Mashimiao

Mashimiao commented Jan 2, 2018

Copy link
Copy Markdown

LGTM

Approved with PullApprove

@zhouhao3

Copy link
Copy Markdown
Author

ping @liangchenye

@liangchenye

liangchenye commented Jan 3, 2018

Copy link
Copy Markdown
Member

LGTM

Approved with PullApprove

@liangchenye
liangchenye merged commit a002fc8 into opencontainers:masterJan 3, 2018
@zhouhao3
zhouhao3 deleted the runtimetest-seccomp branch January 3, 2018 02:28
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@zhouhao3@Mashimiao@liangchenye@wking