Skip to content

Commit 32623da

Browse files
authored
Add pause syscall to seccomp SERVICE_BASICS allowlist (#241)
`std::process::exit()` has a [safeguard](https://github.com/rust-lang/rust/blob/fc0f51f5ca44d4586b0e309181382608cd6a8441/library/std/src/sys/exit.rs#L53) on linux against `libc::exit` thread unsafety which will pause a thread if it tried to exit simultaneously with another thread. This pause uses the [pause](https://man7.org/linux/man-pages/man2/pause.2.html) syscall. If this race condition is triggered with the default seccomp configuration, the process will be killed by seccomp. This has been observed in a production environment. This PR adds the `pause` syscall to the default seccomp allowlist to avoid this issue. I don't think this poses any meaningful additional security risk by allowing potential malicious code to invoke it - at most, it can suspend a thread indefinitely, which I believe could already be accomplished with the `futex` syscall, which is already in the `RUST_BASICS` allowlist.
1 parent 36c2b78 commit 32623da

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

foundations/src/security/common_syscall_allow_lists.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ allow_list! {
3333
..RUST_BASICS,
3434
exit,
3535
exit_group,
36+
#[cfg(target_arch = "x86_64")]
37+
pause, // `pause` can be invoked by std::process::exit() if multiple threads call it simultaneously
38+
#[cfg(target_arch = "aarch64")]
39+
ppoll if [ // glibc implements `pause` using ppoll with the following arguments on aarch64
40+
ArgCmp::Equal { arg_idx: 0, value: 0_u64.into() }, // fds = NULL
41+
ArgCmp::Equal { arg_idx: 1, value: 0_u64.into() }, // nfds = 0
42+
ArgCmp::Equal { arg_idx: 2, value: 0_u64.into() }, // timeout = NULL
43+
ArgCmp::Equal { arg_idx: 3, value: 0_u64.into() } // sigmask = NULL
44+
],
3645
kill if [ ArgCmp::Equal { arg_idx: 0, value: std::process::id().into() } ],
3746
tgkill if [ ArgCmp::Equal { arg_idx: 0, value: std::process::id().into() } ],
3847
getpid,

0 commit comments

Comments
 (0)