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

seccompfilter: Use SCMP_ACT_KILL_PROCESS only on compatible kernels #234

Conversation

mbargull
Copy link
Contributor

Supersedes gh-232.

seccompfilter: Conditional SCMP_ACT_KILL_PROCESS

As before, this only uses SCMP_ACT_KILL_PROCESS for libseccomp versions
which define it.
Additionally, it is only used if at run time the kernel reports it as a
supported action. For this SECCOMP_GET_ACTION_AVAIL must be available
(supported from Linux 4.14 onward and backported to CentOS 7's kernel)
and SECCOMP_RET_KILL_PROCESS (Linux 4.14+, but not in CentOS 7).

This also adds/changes the following:

  • Add a CentOS 7 VM/Vagrant-based test run for compatibility (regression) testing on older kernels.
  • Add a test case for --enable-seccomp.
  • Small adjustments to allow CI tests to run on CentOS 7, run out of tree, complete faster.

Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
@mbargull
Copy link
Contributor Author

(The commit with the actual fix is not yet pushed to let the test-centos CI job at least fail once.)

@mbargull
Copy link
Contributor Author

https://github.com/rootless-containers/slirp4netns/pull/234/checks?check_run_id=1402162438#step:5:705

  env:
    LIBSECCOMP_COMMIT: v2.4.3
    LIBSLIRP_COMMIT: v4.1.0
...
PASS: tests/test-slirp4netns-ready-fd.sh
PASS: tests/test-slirp4netns-configure.sh
PASS: tests/test-slirp4netns-exit-fd.sh
PASS: tests/test-slirp4netns-cidr.sh
PASS: tests/test-slirp4netns-outbound-addr.sh
PASS: tests/test-slirp4netns-disable-host-loopback.sh
PASS: tests/test-slirp4netns-disable-dns.sh
PASS: tests/test-slirp4netns-api-socket.sh
FAIL: tests/test-slirp4netns-seccomp.sh
PASS: tests/test-slirp4netns.sh

As intended: FAIL: tests/test-slirp4netns-seccomp.sh

As before, this only uses SCMP_ACT_KILL_PROCESS for libseccomp versions
which define it.
Additionally, it is only used if at run time the kernel reports it as a
supported action. For this SECCOMP_GET_ACTION_AVAIL must be available
(supported from Linux 4.14 onward and backported to CentOS 7's kernel)
and SECCOMP_RET_KILL_PROCESS (Linux 4.14+, but not in CentOS 7).

Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
@mbargull mbargull force-pushed the conditional-SCMP_ACT_KILL_PROCESS branch from ea29112 to 189e1ed Compare November 15, 2020 09:41
Comment on lines +23 to +24
LIBSECCOMP_COMMIT: v2.3.3
LIBSLIRP_COMMIT: v4.1.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the VM setup takes approx. twice as much time as an actual build+test, I opted for a single CI job because it seemed more economical. (But it is also just in the realm of 2 min. setup + 1 min. for each run.)

env:
LIBSECCOMP_COMMIT: v2.3.3
LIBSLIRP_COMMIT: v4.1.0
BENCHMARK_IPERF3_DURATION: 3
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It probably makes sense to not run the full 4 x 60 seconds benchmark in each CI job. I only reduced the time for the duration for the newly added VM-based job.

Comment on lines +50 to +52
LIBSLIRP_COMMIT: v4.2.0
# Fails with --disable-dns from libslirp >=4.3.0
# (no timeout in test-slirp4netns-disable-dns.sh).
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 did not investigate this further, so can't tell if it's kernel or ncat version related, but with libslirp 4.3.1 the --disable-dns did not show the expected timeout.

Copy link
Member

Choose a reason for hiding this comment

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

timeout of what?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/rootless-containers/slirp4netns/blob/v1.1.6/tests/test-slirp4netns-disable-dns.sh#L33-L35 does not get a timeout message to grep for (the ncat seems to succeed).

Comment on lines +36 to +40
touch ./build-and-test
chmod a+x ./build-and-test
'

cat > ./build-and-test <<'EOS'
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 have only included this static build-and-test script inline here because I wasn't sure if you'd prefer to have the Vagrantfile as self-contained as possible or if a separate script file would be okay/preferable.

"${src_dir}/slirp4netns/configure" --prefix="${prefix}"
make -j "$( nproc )"

make ci 'CLANGTIDY=echo skipping:' 'CLANGFORMAT=echo skipping:'
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 did not look into how to install clang-tidy/clang-format on CentOS and thus just "disabled" those targets by replacing the command with dummy echos.

@@ -11,7 +11,7 @@ mkdir /run/foo
mount -t tmpfs tmpfs /run/foo
mount --make-rshared /run

unshare -n sleep infinity &
unshare -r -n sleep infinity &
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this the tests (also on Ubuntu) are prolonged by 40s due to the 2 x 40 x 0.5s waiting from wait_for_network_namespace and wait_for_network_device.

Copy link
Member

Choose a reason for hiding this comment

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

This seems to need investigation. I don't think we should need -r here.

cc @giuseppe

Copy link
Collaborator

Choose a reason for hiding this comment

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

the user should already have enough privileges to run these tests, why does the new user namespace make a difference?

Copy link
Contributor Author

@mbargull mbargull Nov 16, 2020

Choose a reason for hiding this comment

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

I have no idea, unfortunately (not my area of expertise). I only noticed this while running the tests.
I reverted the associated commit for now.
@AkihiroSuda, @giuseppe can you open an issue to track this?
(Asking you because you can give more context than unknowledgeable me.)

Comment on lines +46 to +47
result="$(nsenter --preserve-credentials -U -n --target=$child ip a show dev tun11)"
echo "$result" | grep -om1 '^\s*inet .*/' | grep -qF 10.0.135.228
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 older ip on CentOS 7 does not support -json so I had to work around this to make this test runnable on CentOS 7. Please let me know if this needs further adjustment.

@mbargull
Copy link
Contributor Author

If there are any changes/cleanup/refactoring (within the actual seccompfilter.c change or CI setup/matrix, inline scripts, etc.) you deem helpful, please do feel free to push to this branch. (Allow edit by maintainers box is checked ;) .)

@AkihiroSuda
Copy link
Member

Can we have 189e1ed as a separate PR?

This reverts commit 0587bbf.

Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
@AkihiroSuda
Copy link
Member

@mbargull Could you open a separate PR for 189e1ed ?

@mbargull
Copy link
Contributor Author

@mbargull Could you open a separate PR for 189e1ed ?

Done in gh-235.

Is there anything else for me to help with in this PR?

@AkihiroSuda
Copy link
Member

Thanks for opening #235, but that one is not 189e1ed ("seccompfilter: Conditional SCMP_ACT_KILL_PROCESS") and it seems controversial. I'd like to merge 189e1ed ahead of other commits.

@AkihiroSuda
Copy link
Member

Ah, sorry, I didn't notice the unshare -r commit was already reverted in this PR, I think I can merge this PR now. (Is unshare -r still needed?)

@AkihiroSuda AkihiroSuda merged commit 4bce8d8 into rootless-containers:master Nov 25, 2020
@mbargull
Copy link
Contributor Author

Oh, very sorry, for the mix up!
But why do we want to have that commit without any tests then? The point of all other commits is to accompany that one to have a test. I am confused.

@mbargull
Copy link
Contributor Author

Ah, sorry, I didn't notice the unshare -r commit was already reverted in this PR, I think I can merge this PR now. (Is unshare -r still needed?)

Ah, yes, nevermind my previous comments then :). Thank you!

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.

3 participants