aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src/seccomp-filter.c
diff options
context:
space:
mode:
authorPhilipp Stephani2021-04-19 21:10:20 +0200
committerPhilipp Stephani2021-04-19 21:11:21 +0200
commit27af0a3dc8b6b45879904bbc5d54b0677f84a5ff (patch)
tree17e77e80807b653ec4dfea9294e82ea2c9bbe2cb /lib-src/seccomp-filter.c
parentab287a148fc274d79fb13004aa7ab76fe1058450 (diff)
downloademacs-27af0a3dc8b6b45879904bbc5d54b0677f84a5ff.tar.gz
emacs-27af0a3dc8b6b45879904bbc5d54b0677f84a5ff.zip
Seccomp filter: deal with arch_prctl(ARCH_CET_STATUS, ...).
The dynamic loader of GNU libc 2.28 uses this system call to initialize CPU information, see https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/x86/cpu-features.c;hb=glibc-2.28#l28. Simulating an older kernel by returning EINVAL should be the most harmless rule here. The ARCH_CET_STATUS symbol isn't yet exposed by the kernel headers; see the FIXME at the top of https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/x86/include/asm/prctl.h;hb=glibc-2.28. * lib-src/seccomp-filter.c (ARCH_CET_STATUS): Define if not already present. Inline the value because there doesn't seem to be a header file exporting this constant yet. (main): Make ARCH_CET_STATUS subfunction of arch_prctl return EINVAL.
Diffstat (limited to 'lib-src/seccomp-filter.c')
-rw-r--r--lib-src/seccomp-filter.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib-src/seccomp-filter.c b/lib-src/seccomp-filter.c
index 8f8a990661c..31d0809f8f0 100644
--- a/lib-src/seccomp-filter.c
+++ b/lib-src/seccomp-filter.c
@@ -60,6 +60,10 @@ variants of those files that can be used to sandbox Emacs before
60 60
61#include "verify.h" 61#include "verify.h"
62 62
63#ifndef ARCH_CET_STATUS
64#define ARCH_CET_STATUS 0x3001
65#endif
66
63static ATTRIBUTE_FORMAT_PRINTF (2, 3) _Noreturn void 67static ATTRIBUTE_FORMAT_PRINTF (2, 3) _Noreturn void
64fail (int error, const char *format, ...) 68fail (int error, const char *format, ...)
65{ 69{
@@ -345,6 +349,8 @@ main (int argc, char **argv)
345 RULE (SCMP_ACT_ALLOW, SCMP_SYS (set_tid_address)); 349 RULE (SCMP_ACT_ALLOW, SCMP_SYS (set_tid_address));
346 RULE (SCMP_ACT_ALLOW, SCMP_SYS (arch_prctl), 350 RULE (SCMP_ACT_ALLOW, SCMP_SYS (arch_prctl),
347 SCMP_A0_32 (SCMP_CMP_EQ, ARCH_SET_FS)); 351 SCMP_A0_32 (SCMP_CMP_EQ, ARCH_SET_FS));
352 RULE (SCMP_ACT_ERRNO (EINVAL), SCMP_SYS (arch_prctl),
353 SCMP_A0_32 (SCMP_CMP_EQ, ARCH_CET_STATUS));
348 RULE (SCMP_ACT_ALLOW, SCMP_SYS (statfs)); 354 RULE (SCMP_ACT_ALLOW, SCMP_SYS (statfs));
349 355
350 /* We want to allow starting the Emacs binary itself with the 356 /* We want to allow starting the Emacs binary itself with the