Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix seccomp unit tests output #1254

Merged
merged 2 commits into from
Sep 17, 2019

Conversation

serban300
Copy link
Contributor

@serban300 serban300 commented Sep 11, 2019

Signed-off-by: Serban Iorga [email protected]

Reason for This PR

Fixes #1247

Description of Changes

Fix #1247

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.

PR Checklist

[Author TODO: Meet these criteria. Where there are two options, keep one.]
[Reviewer TODO: Verify that these criteria are met. Request changes if not]

  • All commits in this PR are signed (git commit -s).
  • This PR is linked to an issue
  • The description of changes is clear and encompassing.
  • No docs need to be updated as part of this PR.
  • Code-level documentation for touched code is included in this PR.
  • No API changes are included in this PR
  • The changes in this PR have no user impact.

sandreim
sandreim previously approved these changes Sep 11, 2019
seccomp/src/lib.rs Outdated Show resolved Hide resolved
sandreim
sandreim previously approved these changes Sep 12, 2019
seccomp/src/lib.rs Outdated Show resolved Hide resolved
// apply filter
// We need to execute the seccomp thread inside a catch_unwind block in order to
// avoid printing unneeded warnings in case of a seccomp denial.
let seccomp_result = panic::catch_unwind(|| {
Copy link
Member

Choose a reason for hiding this comment

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

The problem with this approach is that we won't be able to get the error message from asserts. It also seems we are testing more than one thing in this helper function.

I find it a bit shaky to test that SIGSYS was triggered using a boolean. We can't know for sure if the boolean value was not updated because the thread was killed for another reason or because of SIGSYS.

I don't really have another approach of testing it right now. We should check if having separate tests for negative testing is feasible and if in these tests we can count on should_panic macro.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that the logic is a bit shaky since there is no way to identify a SIGSYS for sure. But should_panic won't change this. Testing this with unit tests is a bit of a stretch. Maybe we should remove the unit tests that rely on this logic.

Copy link
Member

Choose a reason for hiding this comment

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

I suppose the unit test was added as a regression test. I am fine with not testing this with unit tests as long as we have an integration test that checks for regressions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we can do this either. We would need to start firecracker with some very specific seccomp rules and these are not configurable from the outside.

Copy link
Member

Choose a reason for hiding this comment

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

Could this be plugged into the existing seccomp integration test in integration_tests/security?

Copy link
Contributor

Choose a reason for hiding this comment

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

While this test is not 100% conclusive (it can, in some cases, provide false negatives) it's still better than nothing.
Unless we find a better solution I say we keep the test and maybe add a comment specifying why this test doesn't fully guarantee SIGSYS correctness.

Better to get some validation than no validation 😄

Copy link
Member

Choose a reason for hiding this comment

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

Looks like we aren't the only humans having problem with these kinds of tests: rust-lang/rust#32512

It doesn't look like it's fixed just yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logic gets much cleaner if we use SECCOMP_RET_ERRNO . Credits to @alexandruag for the idea.

@andreeaflorescu @acatangiu @sandreim
Please take another look on the changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm learning seccomp with these reviews 😄

We have some seccomp unit tests that rely on SECCOMP_RET_KILL. By
changing them to use SECCOMP_RET_ERRNO instead we make them simpler
and more reliable.

Signed-off-by: Serban Iorga <[email protected]>
Copy link
Contributor

@acatangiu acatangiu left a comment

Choose a reason for hiding this comment

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

🥇

@sandreim sandreim self-requested a review September 17, 2019 08:39
@serban300 serban300 merged commit 835f53c into firecracker-microvm:master Sep 17, 2019
@serban300 serban300 deleted the fix-seccomp-ut branch May 10, 2021 07:21
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.

Panic messages in seccomp tests ouput
4 participants