diff options
| author | Werner Fink | 2025-04-07 13:51:07 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2025-04-19 18:07:19 +0300 |
| commit | 8abd2ee0526ba576aefefa51870443ef01a4b2dd (patch) | |
| tree | c036b3736dac025b336d0af7f3da8971304f1cca /lib-src | |
| parent | 2cf545f47dc945b8ebff641af7e15798ddd419c2 (diff) | |
| download | emacs-8abd2ee0526ba576aefefa51870443ef01a4b2dd.tar.gz emacs-8abd2ee0526ba576aefefa51870443ef01a4b2dd.zip | |
Fix seccomp-filter for newer Linux kernels
* lib-src/seccomp-filter.c (MAP_DROPPABLE): Define if undefined.
(main): Use MAP_DROPPABLE flag. Allow `tcgetattr' call of glibc
on physical terminal devices. (Bug#77232)
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/seccomp-filter.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib-src/seccomp-filter.c b/lib-src/seccomp-filter.c index d6421f0ebdb..e9f41afbaba 100644 --- a/lib-src/seccomp-filter.c +++ b/lib-src/seccomp-filter.c | |||
| @@ -42,6 +42,7 @@ variants of those files that can be used to sandbox Emacs before | |||
| 42 | #include <stdlib.h> | 42 | #include <stdlib.h> |
| 43 | #include <stdint.h> | 43 | #include <stdint.h> |
| 44 | #include <stdio.h> | 44 | #include <stdio.h> |
| 45 | #include <asm/termbits.h> /* mandatory accordingly to latest ioctl_tty(2) */ | ||
| 45 | #include <time.h> | 46 | #include <time.h> |
| 46 | 47 | ||
| 47 | #include <asm/prctl.h> | 48 | #include <asm/prctl.h> |
| @@ -64,6 +65,11 @@ variants of those files that can be used to sandbox Emacs before | |||
| 64 | #define ARCH_CET_STATUS 0x3001 | 65 | #define ARCH_CET_STATUS 0x3001 |
| 65 | #endif | 66 | #endif |
| 66 | 67 | ||
| 68 | /* https://github.com/torvalds/linux/commit/9651fcedf7b92d3f7f1ab179e8ab55b85ee10fc1 */ | ||
| 69 | #ifndef MAP_DROPPABLE | ||
| 70 | #define MAP_DROPPABLE 0x08 | ||
| 71 | #endif | ||
| 72 | |||
| 67 | static ATTRIBUTE_FORMAT_PRINTF (2, 3) _Noreturn void | 73 | static ATTRIBUTE_FORMAT_PRINTF (2, 3) _Noreturn void |
| 68 | fail (int error, const char *format, ...) | 74 | fail (int error, const char *format, ...) |
| 69 | { | 75 | { |
| @@ -187,7 +193,7 @@ main (int argc, char **argv) | |||
| 187 | some versions of the dynamic loader still use it. Also | 193 | some versions of the dynamic loader still use it. Also |
| 188 | allow allocating thread stacks. */ | 194 | allow allocating thread stacks. */ |
| 189 | SCMP_A3_32 (SCMP_CMP_MASKED_EQ, | 195 | SCMP_A3_32 (SCMP_CMP_MASKED_EQ, |
| 190 | ~(MAP_SHARED | MAP_PRIVATE | MAP_FILE | 196 | ~(MAP_SHARED | MAP_PRIVATE | MAP_FILE | MAP_DROPPABLE |
| 191 | | MAP_ANONYMOUS | MAP_FIXED | MAP_DENYWRITE | 197 | | MAP_ANONYMOUS | MAP_FIXED | MAP_DENYWRITE |
| 192 | | MAP_STACK | MAP_NORESERVE), | 198 | | MAP_STACK | MAP_NORESERVE), |
| 193 | 0)); | 199 | 0)); |
| @@ -274,6 +280,11 @@ main (int argc, char **argv) | |||
| 274 | SCMP_A0_32 (SCMP_CMP_EQ, STDIN_FILENO), | 280 | SCMP_A0_32 (SCMP_CMP_EQ, STDIN_FILENO), |
| 275 | SCMP_A1_32 (SCMP_CMP_EQ, TIOCGPGRP)); | 281 | SCMP_A1_32 (SCMP_CMP_EQ, TIOCGPGRP)); |
| 276 | 282 | ||
| 283 | /* Allow `tcgetattr' call of glibc on physical terminal devices. */ | ||
| 284 | RULE (SCMP_ACT_ALLOW, SCMP_SYS (ioctl), | ||
| 285 | SCMP_A0_32 (SCMP_CMP_EQ, STDERR_FILENO), | ||
| 286 | SCMP_A1_32 (SCMP_CMP_EQ, TCGETS)); | ||
| 287 | |||
| 277 | /* Allow reading (but not setting) file flags. */ | 288 | /* Allow reading (but not setting) file flags. */ |
| 278 | RULE (SCMP_ACT_ALLOW, SCMP_SYS (fcntl), | 289 | RULE (SCMP_ACT_ALLOW, SCMP_SYS (fcntl), |
| 279 | SCMP_A1_32 (SCMP_CMP_EQ, F_GETFL)); | 290 | SCMP_A1_32 (SCMP_CMP_EQ, F_GETFL)); |