Repository: bitcoin/bitcoin (language: cpp)

Issue:
Syscall sandbox fails on Ubuntu 22.04
It doesn't even specify which "invalid syscall".
```
$ src/bitcoind -sandbox=log-and-abort
2022-02-17T13:45:57Z Bitcoin Core version v22.99.0-b223c3c21e89 (release build)
2022-02-17T13:45:57Z Assuming ancestors of block 00000000000000000008a89e854d57e5667df88f1cdef6fde2fbca1de5b639ad have valid signatures.
2022-02-17T13:45:57Z Setting nMinimumChainWork=00000000000000000000000000000000000000001fa4663bbbe19f82de910280
2022-02-17T13:45:57Z Experimental syscall sandbox enabled (-sandbox=log-and-abort): bitcoind will terminate if an unexpected (not allowlisted) syscall is invoked.
2022-02-17T13:45:57Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
2022-02-17T13:45:57Z Default data directory /…/.bitcoin
2022-02-17T13:45:57Z Using data directory /…/.bitcoin
2022-02-17T13:45:57Z Config file: /…/.bitcoin/bitcoin.conf (not found, skipping)
2022-02-17T13:45:57Z Command-line arg: sandbox="log-and-abort"
2022-02-17T13:45:57Z Using at most 125 automatic connections (1024 file descriptors available)
2022-02-17T13:45:57Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2022-02-17T13:45:57Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2022-02-17T13:45:57Z Script verification uses 1 additional threads
Bad system call (core dumped)
```
Nothing in `dmesg` either.


Discussion / hints:

Fix patch:
diff --git a/src/util/syscall_sandbox.cpp b/src/util/syscall_sandbox.cpp
index f513dba598774..f2a9cf664de68 100644
--- a/src/util/syscall_sandbox.cpp
+++ b/src/util/syscall_sandbox.cpp
@@ -68,6 +68,10 @@ bool g_syscall_sandbox_log_violation_before_terminating{false};
 #define __NR_copy_file_range 326
 #endif
 
+#ifndef  __NR_rseq
+#define __NR_rseq 334
+#endif
+
 // This list of syscalls in LINUX_SYSCALLS is only used to map syscall numbers to syscall names in
 // order to be able to print user friendly error messages which include the syscall name in addition
 // to the syscall number.
@@ -327,6 +331,7 @@ const std::map<uint32_t, std::string> LINUX_SYSCALLS{
     {__NR_request_key, "request_key"},
     {__NR_restart_syscall, "restart_syscall"},
     {__NR_rmdir, "rmdir"},
+    {__NR_rseq, "rseq"},
     {__NR_rt_sigaction, "rt_sigaction"},
     {__NR_rt_sigpending, "rt_sigpending"},
     {__NR_rt_sigprocmask, "rt_sigprocmask"},
@@ -723,6 +728,7 @@ class SeccompPolicyBuilder
         allowed_syscalls.insert(__NR_fork);       // create a child process
         allowed_syscalls.insert(__NR_tgkill);     // send a signal to a thread
         allowed_syscalls.insert(__NR_wait4);      // wait for process to change state, BSD style
+        allowed_syscalls.insert(__NR_rseq);       // register restartable sequence for thread
     }
 
     void AllowScheduling()


Test patch: