-
Notifications
You must be signed in to change notification settings - Fork 593
Description
The specification doesn't specify anything if a syscall can't be resolved (or if it's a "pseudo" syscall).
runc silently drop those entries:
https://github.com/opencontainers/runc/blob/ecd55a4135e0a26de884ce436442914f945b1e76/libcontainer/seccomp/seccomp_linux.go#L168-L173
This seems like a fairly strong assumption to make, since for runc it ultimately depends on the version of libseccomp you have. On ubuntu 18.04, I have libseccomp2=2.3.1-2.1ubuntu4, which doesn't seem to include the patch from @justincormack:
seccomp/libseccomp@d9102f1
For instance, the seccomp profile used by Docker is supposed to whitelist preadv2:
https://github.com/moby/moby/blob/master/profiles/seccomp/default.json#L226
But since my libseccomp is missing the patch, it won't work:
$ docker run -i ubuntu:18.04 sh -c '{ apt-get -qq update && apt-get install -y gcc >/dev/null 2>&1; } && gcc -D_GNU_SOURCE -xc - && /a.out' <<EOF
#include <unistd.h>
#include <sys/syscall.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
int main() {
errno = 0;
long ret = syscall(__NR_preadv2, -1, NULL, 0, 0, 0);
fprintf(stderr, "%ld\n%s\n", ret, strerror(errno));
}
EOF
-1
Operation not permitted
If I remove seccomp with --security-opt seccomp=unconfined, it "works" as expected:
-1
Bad file descriptor
preadv2 is obviously a toy example, but this would be a surprising behavior if defaultAction == SCMP_ACT_ALLOW and you want to blacklist a syscall that libseccomp doesn't know about, the syscall would be silently allowed as far as I can see.