diff options
author | Anita Zhang <the.anitazha@gmail.com> | 2019-04-10 16:08:41 -0700 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-04-12 10:23:07 +0200 |
commit | 7bc5e0b12b7647ac203eeb81092c08724f9bbed3 (patch) | |
tree | 03c607ebb1ff27d2fb3899401b3292b26fc01e12 /src/shared/seccomp-util.h | |
parent | 03abeb0baf7fe97c98a98d745b75c7d33e2f632e (diff) | |
download | systemd-7bc5e0b12b7647ac203eeb81092c08724f9bbed3.tar.gz |
seccomp: check more error codes from seccomp_load()
We noticed in our tests that occasionally SystemCallFilter= would
fail to set and the service would run with no syscall filtering.
Most of the time the same tests would apply the filter and fail
the service as expected. While it's not totally clear why this happens,
we noticed seccomp_load() in the systemd code base would fail open for
all errors except EPERM and EACCES.
ENOMEM, EINVAL, and EFAULT seem like reasonable values to add to the
error set based on what I gather from libseccomp code and man pages:
-ENOMEM: out of memory, failed to allocate space for a libseccomp structure, or would exceed a defined constant
-EINVAL: kernel isn't configured to support the operations, args are invalid (to seccomp_load(), seccomp(), or prctl())
-EFAULT: addresses passed as args are invalid
Diffstat (limited to 'src/shared/seccomp-util.h')
-rw-r--r-- | src/shared/seccomp-util.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/shared/seccomp-util.h b/src/shared/seccomp-util.h index 14dbc42691..2566d2d17f 100644 --- a/src/shared/seccomp-util.h +++ b/src/shared/seccomp-util.h @@ -95,6 +95,12 @@ extern const uint32_t seccomp_local_archs[]; seccomp_local_archs[_i] != (uint32_t) -1; \ (arch) = seccomp_local_archs[++_i]) +/* EACCES: does not have the CAP_SYS_ADMIN or no_new_privs == 1 + * ENOMEM: out of memory, failed to allocate space for a libseccomp structure, or would exceed a defined constant + * EFAULT: addresses passed as args (by libseccomp) are invalid */ +#define ERRNO_IS_SECCOMP_FATAL(r) \ + IN_SET(abs(r), EPERM, EACCES, ENOMEM, EFAULT) + DEFINE_TRIVIAL_CLEANUP_FUNC(scmp_filter_ctx, seccomp_release); int parse_syscall_archs(char **l, Set **archs); |