Skip to content

Conversation

@zhouhao3
Copy link

@zhouhao3 zhouhao3 commented Nov 9, 2017

Signed-off-by: Zhou Hao [email protected]

@zhouhao3 zhouhao3 force-pushed the runtimetest-seccomp branch 3 times, most recently from 0abf4c1 to 3a9ec3a Compare November 9, 2017 07:34
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
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.

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

syscallArgs := seccomp.SyscallOpts{
Action: "errno",
Syscall: "getcwd",
Index: "0",

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
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.

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
Author

Choose a reason for hiding this comment

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

updated.

@zhouhao3 zhouhao3 force-pushed the runtimetest-seccomp branch 4 times, most recently from 4b330b9 to 59c6c2d Compare November 10, 2017 07:14
@Mashimiao Mashimiao added this to the v0.4.0 milestone Nov 15, 2017
@zhouhao3 zhouhao3 force-pushed the runtimetest-seccomp branch from 59c6c2d to 2138ac8 Compare November 16, 2017 03:27
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)

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 zhouhao3 force-pushed the runtimetest-seccomp branch 2 times, most recently from 3f1f3ca to f363ae3 Compare November 17, 2017 02:57
@Mashimiao
Copy link

Mashimiao commented Nov 17, 2017

LGTM

Approved with PullApprove

@zhouhao3 zhouhao3 force-pushed the runtimetest-seccomp branch 2 times, most recently from 0a6e9ae to bd222f9 Compare December 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
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
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
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.

Copy link
Contributor

@wking wking Dec 26, 2017

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.

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
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))
if err == nil {
  t.Diagnostic("did not return an error")
} else {
  t.Diagnosticf("returned %d (%s)", err.WhateverOtherErrno(), err.Error())
}

Copy link
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?

return nil
}
for _, sys := range spec.Linux.Seccomp.Syscalls {
if sys.Action == "SCMP_ACT_ERRON" {
Copy link
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 zhouhao3 force-pushed the runtimetest-seccomp branch 2 times, most recently from 87a2e04 to 4907259 Compare December 27, 2017 06:45
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.

if name == "getcwd" {
_, err := os.Getwd()
if err == nil {
t.Diagnostic("Syscall action ERRNO can not be properly applied in the runtime")
Copy link
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

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
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
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.

@zhouhao3 zhouhao3 force-pushed the runtimetest-seccomp branch from 4907259 to 5bb8754 Compare December 28, 2017 05:42
@zhouhao3
Copy link
Author

zhouhao3 commented Jan 2, 2018

@liangchenye @Mashimiao PTAL

@Mashimiao
Copy link

Mashimiao commented Jan 2, 2018

LGTM

Approved with PullApprove

@zhouhao3
Copy link
Author

zhouhao3 commented Jan 3, 2018

ping @liangchenye

@liangchenye
Copy link
Member

liangchenye commented Jan 3, 2018

LGTM

Approved with PullApprove

@liangchenye liangchenye merged commit a002fc8 into opencontainers:master Jan 3, 2018
@zhouhao3 zhouhao3 deleted the runtimetest-seccomp branch January 3, 2018 02:28
Sign up for free to 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