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

seccomp: do not ignore SPEC_ALLOW flag #3580

Merged
merged 2 commits into from
Sep 13, 2022

Conversation

kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Aug 29, 2022

Commit 58ea21d added support for seccomp flags such as
SPEC_ALLOW, but it does not work, as since commit 7a8d716
we do not use libseccomp-golang's Load(), but handle flags separately in patchbfp.

This fixes setting SPEC_ALLOW flag.

Add a comment to not forget to amend filterFlags when adding new flags.

Add a test case that the flags are set as expected (see the second commit for details).

Fixes: #3582

Commit 58ea21d added support for seccomp flags such as
SPEC_ALLOW, but it does not work as expected, because since commit
7a8d716 we do not use libseccomp-golang's Load(), but
handle flags separately in patchbfp.

This fixes setting SPEC_ALLOW flag.

Add a comment to not forget to amend filterFlags when adding new flags.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@AkihiroSuda
Copy link
Member

AkihiroSuda commented Aug 30, 2022

Would it be possible to have a test?

@@ -641,8 +646,13 @@ func filterFlags(config *configs.Seccomp, filter *libseccomp.ScmpFilter) (flags
flags |= uint(C.C_FILTER_FLAG_LOG)
}
}

// TODO: Support seccomp flags not yet added to libseccomp-golang...
Copy link
Contributor

Choose a reason for hiding this comment

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

is this the only flag not supported by libseccomp-golang? If not, is this comment still relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently, libseccomp-golang is on par with the runtime-spec, thus I removed this comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently correct, but I'd like support for SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV (Linux 5.19, torvalds/linux@c2aa2dfef243).

opencontainers/runtime-spec#1161

Not yet in libseccomp: seccomp/libseccomp#387

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, but I guess we'll support it in libseccomp and libseccomp-golang first, when here in runc.

@kolyshkin
Copy link
Contributor Author

Would it be possible to have a test?

I can't think of a way to check if SPEC_ALLOW (or any other flag) is set in a particular ebpf loaded into the kernel, thus no way to test this. If anyone knows such a way, please share.

@kolyshkin
Copy link
Contributor Author

Would it be possible to have a test?

I can't think of a way to check if SPEC_ALLOW (or any other flag) is set in a particular ebpf loaded into the kernel, thus no way to test this. If anyone knows such a way, please share.

Also, we already have a test, added in #3390. The problem is, it doesn't check whether the flags are actually set -- merely that they are accepted.

Hmm, we can actually use strace to check which flags are being set! Let me see...

@kolyshkin
Copy link
Contributor Author

It is still possible to use strace from the test, but I did something different -- modified the code to actually debug print the flags value, and amended the seccomp flags setting test to check if the flags value is as expected.

@AkihiroSuda PTAL

@kolyshkin kolyshkin changed the title seccomp: fix SPEC_ALLOW flag support seccomp: fix SPEC_ALLOW flag being ignored Aug 30, 2022
@kolyshkin kolyshkin changed the title seccomp: fix SPEC_ALLOW flag being ignored seccomp: do not ignore SPEC_ALLOW flag Aug 30, 2022
@AkihiroSuda
Copy link
Member

Thanks, LGTM but a couple of nits

Add a debug print of seccomp flags value, so the test can check
those (without using something like strace, that is).

Amend the flags setting test with the numeric values expected, and the
logic to check those.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
Copy link
Contributor Author

Thanks, LGTM but a couple of nits

Addressed.

@kolyshkin kolyshkin requested review from AkihiroSuda and removed request for haircommander August 31, 2022 02:18
@kolyshkin
Copy link
Contributor Author

CentOS 7 failure is a flake (#3540); restarted.

@alban
Copy link
Contributor

alban commented Sep 7, 2022

I am not a maintainer and I didn't test it but the patch looks good to me.

@mrunalp mrunalp merged commit 91c0a7a into opencontainers:main Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants