Repository: bitcoin/bitcoin (language: cpp)

Issue:
Syscall Sandbox Termination
I was testing v23.0rc2 compiled.

`./configure --without-miniupnpc --without-natpmp --enable-hardening --without-bdb --with-qrencode --with-zmq --with-sqlite=yes --disable-external-signer`

bitcoin.conf:

> assumevalid=0
> blockfilterindex=1
> coinstatsindex=1
> dbcache=1000
> prune=0
> sandbox=log-and-abort
> txindex=1
> cjdnsreachable=1
> discover=1
> i2psam=127.0.0.1:7656
> listen=1
> listenonion=1
> networkactive=1
> peerblockfilters=1
> proxy=127.0.0.1:9050
> addresstype=bech32m
> avoidpartialspends=1
> changetype=bech32m
> maxapsfee=0.001
> walletrbf=1
> shrinkdebugfile=1

I deleted my data directory (/home/user/.bitcoin) to start a fresh download of the blockchain to test any errors.  Ran out of space, and after deleting more and trying to start bitcoin-qt again:

> ERROR: The syscall "linkat" (syscall number 265) is not allowed by the syscall sandbox in thread "main". Please report.
> terminate called without an active exception
> Aborted

and in debug.log:

> 2022-03-11T13:00:02Z init message: Verifying blocks…
> 2022-03-11T13:00:02Z Verifying last 6 blocks at level 3
> 2022-03-11T13:00:02Z [0%]...[16%]...[33%]...[50%]...[66%]...[83%]...[99%]...[DONE].
> 2022-03-11T13:00:02Z No coin database inconsistencies in last 6 blocks (2938 transactions)
> 2022-03-11T13:00:02Z  block index            4963ms
> 2022-03-11T13:00:02Z Opening LevelDB in /home/user/.bitcoin/indexes/txindex
> 2022-03-11T13:00:02Z Opened LevelDB successfully
> 2022-03-11T13:00:02Z Using obfuscation key for /home/user/.bitcoin/indexes/txindex: 0000000000000000
> 2022-03-11T13:00:02Z Opening LevelDB in /home/user/.bitcoin/indexes/blockfilter/basic/db
> 2022-03-11T13:00:02Z txindex thread start
> 2022-03-11T13:00:02Z txindex is enabled at height 326934
> 2022-03-11T13:00:02Z txindex thread exit
> 2022-03-11T13:00:02Z Opened LevelDB successfully
> 2022-03-11T13:00:02Z Using obfuscation key for /home/user/.bitcoin/indexes/blockfilter/basic/db: 0000000000000000
> 2022-03-11T13:00:02Z Opening LevelDB in /home/user/.bitcoin/indexes/coinstats/db
> 2022-03-11T13:00:02Z basic block filter index thread start
> 2022-03-11T13:00:02Z basic block filter index is enabled at height 326934
> 2022-03-11T13:00:02Z basic block filter index thread exit
> 2022-03-11T13:00:02Z Opened LevelDB successfully
> 2022-03-11T13:00:02Z Using obfuscation key for /home/user/.bitcoin/indexes/coinstats/db: 0000000000000000
> 2022-03-11T13:00:02Z ERROR: Init: Cannot read current coinstatsindex state; index may be corrupted
> 2022-03-11T13:00:02Z Shutdown: In progress...
> 2022-03-11T13:00:02Z scheduler thread exit
> 2022-03-11T13:00:02Z Shutdown: done
> 2022-03-11T13:00:02Z ERROR: The syscall "linkat" (syscall number 265) is not allowed by the syscall sandbox in thread "main". Please report.

This was done on a Qubes 4.0 machine in a Debian 11 VM.


Discussion / hints:

Fix patch:
diff --git a/src/util/syscall_sandbox.cpp b/src/util/syscall_sandbox.cpp
index f2a9cf664de68..efc58914b67d4 100644
--- a/src/util/syscall_sandbox.cpp
+++ b/src/util/syscall_sandbox.cpp
@@ -592,6 +592,7 @@ class SeccompPolicyBuilder
         allowed_syscalls.insert(__NR_getcwd);          // get current working directory
         allowed_syscalls.insert(__NR_getdents);        // get directory entries
         allowed_syscalls.insert(__NR_getdents64);      // get directory entries
+        allowed_syscalls.insert(__NR_linkat);          // create relative to a directory file descriptor
         allowed_syscalls.insert(__NR_lstat);           // get file status
         allowed_syscalls.insert(__NR_mkdir);           // create a directory
         allowed_syscalls.insert(__NR_newfstatat);      // get file status


Test patch: