seccomp: allow unshare by default #41244
Open
+2
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
- What I did
This pull request adds the unshare syscall to the default seccomp.json policy.
The unshare(2) syscall is currently only available when CAP_SYS_ADMIN
has been given. This is overly restrictive because not all CLONE_* flags
require CAP_SYS_ADMIN.
The virtiofsd daemon needs unshare(CLONE_FS) so that each thread has its
own working directory. This allows the program to use chdir(2) in a
thread-safe way:
https://git.qemu.org/?p=qemu.git;a=blob;f=tools/virtiofsd/fuse_virtio.c;h=3b6d16a0417ae560ee46dfec9254039487251007;hb=HEAD#l450
- How I did it
The seccomp.json file is updated, moving unshare to the default syscalls.
Both containers-golang and systemd already enable unshare by default:
https://github.com/seccomp/containers-golang/blob/master/seccomp.json
https://github.com/systemd/systemd/blob/master/src/shared/seccomp-util.c
- How to verify it
Run a container image that executes a program that uses unshare(2) (make sure it does not have CAP_SYS_ADMIN). The syscall fails with EPERM due to the seccomp policy violation.
With this patch applied the unshare(2) syscall executes.
The following program can be used:
- Description for the changelog
Add the unshare syscall to the default seccomp.json policy