summaryrefslogtreecommitdiff
path: root/lib-src/seccomp-filter.c
Commit message (Collapse)AuthorAge
* Be more systematic about parens in C source codePaul Eggert2024-01-20
| | | | | | | | | Be more systematic about putting space before paren in calls, and in avoiding unnecessary parentheses in macros. This was partly inspired by my wading through gcc -E output while debugging something else, and seeing too many parens. This patch does not change the generated .o files on my platform.
* ; Add 2024 to copyright yearsPo Lu2024-01-02
|
* ; Add 2023 to copyright years.Eli Zaretskii2023-01-01
|
* Support newer glib versions (Bug#59061)Philipp Stephani2022-12-09
| | | | * lib-src/seccomp-filter.c (main): Allow pidfd_open system call
* Add gettid to seccomp-filterPhilipp Stephani2022-10-11
| | | | | * lib-src/seccomp-filter.c (main): gettid is necessary on RHEL 9.0 (bug#56359).
* Port bwrap/allows-stdout test to Ubuntu 22.04.1Paul Eggert2022-10-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this patch, Ubuntu 22.04.1 x86-64 "make check" reports a failure in test/src/emacs-tests.el’s emacs-tests/bwrap/allows-stdout. One can reproduce the bug without using the Emacs executable, by running this script: #!/bin/bash export LC_ALL=C exec strace -f -o /tmp/tr bwrap --ro-bind / / --seccomp 20 -- \ cat /dev/null 20< lib-src/seccomp-filter-exec.bpf This script exits with status 159, because "cat" didn’t get started (it got a SIGSYS signal early on). The command "journalctl -g SECCOMP" indicated that rseq (syscall 334) was the problem. This syscall is issued by /lib64/ld-linux-x86-64.so.2 before ‘main’ is called. There’s another problem with the clone3 syscall, which is used by pthread_create starting in glibc 2.34. pthread_create is called by g_child_watch_source_new, which is called by init_process_emacs. * lib-src/seccomp-filter.c (main): Allow rseq, clone3. This causes the test to pass. Perhaps a fancier, more accurate patch could be written by someone who has the time.
* Don’t truncate seccomp-filter diagnosticPaul Eggert2022-10-02
| | | | | * lib-src/seccomp-filter.c (fail): Do not truncate diagnostic arbitrarily to 1000 bytes when ERROR is nonzero.
* Prefer static_assert to verify in seccomp-filterPaul Eggert2022-10-02
| | | | | | | | | Prefer static_assert in just one file for now; the idea is to do it elsewhere eventually. static_assert is standard (starting with C23) whereas verify is not, and static_assert can be used even in pre-C23 files due to Gnulib’s support for it. * lib-src/seccomp-filter.c: Do not include verify.h. Prefer static_assert to verify.
* Port better to C23 bool+true+false keywordsPaul Eggert2022-09-28
| | | | | | | | | | | | | | | | | | | | C23 is adding the C++ keywords bool, true, and false; prefer them to <stdbool.h> if they are available. * admin/merge-gnulib (GNULIB_MODULES): Add stdbool, which emulates C23 on pre-C23 platforms. (AVOIDED_MODULES): Remove stdbool; Gnulib has renamed this module to stdbool-c99 and nobody uses it so it does not need to be avoided. * m4/c-bool.m4: New file, from Gnulib stdbool module. * lib-src/seccomp-filter.c, src/conf_post.h, src/dynlib.h: * src/emacs-module.c, src/nsterm.m, src/systhread.h: * test/src/emacs-module-resources/mod-test.c: Use the C23 style and use bool without including <stdbool.h>. The Gnulib stdbool module causes config.h to include stdbool.h on pre-C23 platforms. * src/emacs-module.h.in: Don’t include <stdbool.h> if C23 or later, or if it has already been included.
* Do not include <attribute.h> from <config.h>Paul Eggert2022-03-08
| | | | | | | | | | | | This is because mod-test.c shouldn’t use source code from lib, but it does need to include <config.h>. * lib-src/ebrowse.c, lib-src/emacsclient.c, lib-src/etags.c: * lib-src/make-docfile.c, lib-src/movemail.c: * lib-src/seccomp-filter.c, src/dynlib.h, src/lisp.h: * src/syssignal.h, src/sysstdio.h, src/systhread.h, src/tparam.h: Include <attribute.h>. * src/conf_post.h: Do not include <attribute.h>. All uses of attribute.h macros replaced with their _GL_ equivalents.
* * lib-src/seccomp-filter.c (main): Use faccessat2 only if defined.Andreas Schwab2022-03-05
|
* Seccomp: improve support for newer versions of glibc (Bug#51073)Philipp Stephani2022-01-22
| | | | | | | * lib-src/seccomp-filter.c (main): Allow 'pread64' and 'faccessat2' system calls. Newer versions of glibc use these system call (starting with commits 95c1056962a3f2297c94ce47f0eaf0c5b6563231 and 3d3ab573a5f3071992cbc4f57d50d1d29d55bde2, respectively).
* ; Add 2022 to copyright years.Eli Zaretskii2022-01-01
|
* Fix Seccomp filter for newer GNU/Linux systems (Bug#51073).Philipp Stephani2021-10-09
| | | | | | | | On some systems, process startup calls prctl(PR_CAPBSET_READ) via 'cap_get_bound'. We can just return EINVAL. * lib-src/seccomp-filter.c (main): Add a rule for prctl(PR_CAPBSET_READ, ...).
* Improve compatibility with musl-libc (Bug#48789)Philipp Stephani2021-08-29
| | | | | * lib-src/seccomp-filter.c (export_filter): Remove use of nonstandard macro TEMP_FAILURE_RETRY.
* Ensure that argument to 'verify' is a constant expression.Philipp Stephani2021-04-22
| | | | | | | Casting NULL is not a constant expression (Bug#47951). * lib-src/seccomp-filter.c (main): Turn check for null pointer representation into a runtime assertion.
* Seccomp filter: deal with arch_prctl(ARCH_CET_STATUS, ...).Philipp Stephani2021-04-19
| | | | | | | | | | | | | | | | | 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.
* Fix Seccomp filter on CentOS 8.3 (Bug#47828).Philipp Stephani2021-04-18
| | | | * lib-src/seccomp-filter.c (main): mmap: Also allow MAP_SHARED.
* * lib-src/seccomp-filter.c: Add missing headers.Philipp Stephani2021-04-12
|
* Add a variant of the Seccomp filter file that allows 'execve'.Philipp Stephani2021-04-11
| | | | | | | | | | | | | | | | This is useful when starting Emacs with a Seccomp filter enabled, e.g. using 'bwrap'. * lib-src/seccomp-filter.c (main): Generate new Seccomp files. * lib-src/Makefile.in (all) (seccomp-filter.bpf seccomp-filter.pfc seccomp-filter-exec.bpf seccomp-filter-exec.pfc): Generate new Seccomp files. * .gitignore: Ignore new Seccomp files. * test/src/emacs-tests.el (emacs-tests/bwrap/allows-stdout): New unit test.
* * lib-src/seccomp-filter.c (main): Also allow O_NOFOLLOW.Philipp Stephani2021-04-11
|
* Seccomp filter: allow reading the current time (Bug#47708).Philipp Stephani2021-04-11
| | | | * lib-src/seccomp-filter.c (main): Allow reading the current time.
* Remove SCMP_FLTATR_CTL_LOG attribute from Seccomp filter.Philipp Stephani2021-04-11
| | | | | | | Whether or not we log failing syscalls isn't security-critical, and we shouldn't care. * lib-src/seccomp-filter.c (main): Remove log attribute.
* * lib-src/seccomp-filter.c: Print trailing newline.Philipp Stephani2021-04-11
|
* ; Fix copyright yearsGlenn Morris2021-04-10
|
* Add a helper binary to create a basic Secure Computing filter.Philipp Stephani2021-04-10
The binary uses the 'seccomp' helper library. The library isn't needed to load the generated Secure Computing filter. * configure.ac: Check for 'seccomp' header and library. * lib-src/seccomp-filter.c: New helper binary to generate a generic Secure Computing filter for GNU/Linux. * lib-src/Makefile.in (DONT_INSTALL): Add 'seccomp-filter' helper binary if possible. (all): Add Secure Computing filter file if possible. (seccomp-filter$(EXEEXT)): Compile helper binary. (seccomp-filter.bpf seccomp-filter.pfc): Generate filter files. * test/src/emacs-tests.el (emacs-tests/seccomp/allows-stdout) (emacs-tests/seccomp/forbids-subprocess): New unit tests. * test/Makefile.in (src/emacs-tests.log): Add dependency on the helper binary.