Skip to content

Commit c5c4fb3

Browse files
committed
Merge bitcoin/bitcoin#24758: Disable the syscall sandbox for bitcoin-qt and remove gui-related syscalls
fabdf9f Remove gui-only syscalls (MarcoFalke) fa0c2aa init: Disable syscall sandbox in the bitcoin-qt process (MarcoFalke) Pull request description: It is basically impossible (and a bit out of scope) for us to maintain a sandbox for the qt library. I am not sure if it is possible to only sandbox a few threads in a process, but I doubt this will add no practical benefit anyway, so I am disabling the sandbox for the whole bitcoin-qt process. See also bitcoin/bitcoin#24690 (comment) ACKs for top commit: laanwj: Code review ACK fabdf9f Tree-SHA512: 944ded03ee25f7dfd0bfeea9c3f97f575f2d470aa03b387b07f3e3bec5cb886e4aaa17e4a9fb359d3e670e6da69adc9111673d13e6561ec55b3161bb67dfe760
2 parents f3e3563 + fabdf9f commit c5c4fb3

File tree

5 files changed

+6
-9
lines changed

5 files changed

+6
-9
lines changed

src/init.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ bool AppInitBasicSetup(const ArgsManager& args)
792792
return true;
793793
}
794794

795-
bool AppInitParameterInteraction(const ArgsManager& args)
795+
bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandbox)
796796
{
797797
const CChainParams& chainparams = Params();
798798
// ********************************************************* Step 2: parameter interactions
@@ -1058,6 +1058,9 @@ bool AppInitParameterInteraction(const ArgsManager& args)
10581058
if (!SetupSyscallSandbox(log_syscall_violation_before_terminating)) {
10591059
return InitError(Untranslated("Installation of the syscall sandbox failed."));
10601060
}
1061+
if (use_syscall_sandbox) {
1062+
SetSyscallSandboxPolicy(SyscallSandboxPolicy::INITIALIZATION);
1063+
}
10611064
LogPrintf("Experimental syscall sandbox enabled (-sandbox=%s): bitcoind will terminate if an unexpected (not allowlisted) syscall is invoked.\n", sandbox_arg);
10621065
}
10631066
#endif // USE_SYSCALL_SANDBOX

src/init.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ bool AppInitBasicSetup(const ArgsManager& args);
4141
* @note This can be done before daemonization. Do not call Shutdown() if this function fails.
4242
* @pre Parameters should be parsed and config file should be read, AppInitBasicSetup should have been called.
4343
*/
44-
bool AppInitParameterInteraction(const ArgsManager& args);
44+
bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandbox = true);
4545
/**
4646
* Initialization sanity checks: ecc init, sanity checks, dir lock.
4747
* @note This can be done before daemonization. Do not call Shutdown() if this function fails.

src/node/interfaces.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class NodeImpl : public Node
9090
uint32_t getLogCategories() override { return LogInstance().GetCategoryMask(); }
9191
bool baseInitialize() override
9292
{
93-
return AppInitBasicSetup(gArgs) && AppInitParameterInteraction(gArgs) && AppInitSanityChecks() &&
93+
return AppInitBasicSetup(gArgs) && AppInitParameterInteraction(gArgs, /*use_syscall_sandbox=*/false) && AppInitSanityChecks() &&
9494
AppInitLockDataDirectory() && AppInitInterfaces(*m_context);
9595
}
9696
bool appInitMain(interfaces::BlockAndHeaderTipInfo* tip_info) override

src/util/syscall_sandbox.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,6 @@ class SeccompPolicyBuilder
592592
allowed_syscalls.insert(__NR_getcwd); // get current working directory
593593
allowed_syscalls.insert(__NR_getdents); // get directory entries
594594
allowed_syscalls.insert(__NR_getdents64); // get directory entries
595-
allowed_syscalls.insert(__NR_inotify_rm_watch);// remove an existing watch from an inotify instance
596-
allowed_syscalls.insert(__NR_linkat); // create relative to a directory file descriptor
597595
allowed_syscalls.insert(__NR_lstat); // get file status
598596
allowed_syscalls.insert(__NR_mkdir); // create a directory
599597
allowed_syscalls.insert(__NR_newfstatat); // get file status
@@ -823,7 +821,6 @@ bool SetupSyscallSandbox(bool log_syscall_violation_before_terminating)
823821
return false;
824822
}
825823
}
826-
SetSyscallSandboxPolicy(SyscallSandboxPolicy::INITIALIZATION);
827824
return true;
828825
}
829826

src/util/syscall_sandbox.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ void SetSyscallSandboxPolicy(SyscallSandboxPolicy syscall_policy);
4545

4646
#if defined(USE_SYSCALL_SANDBOX)
4747
//! Setup and enable the experimental syscall sandbox for the running process.
48-
//!
49-
//! SetSyscallSandboxPolicy(SyscallSandboxPolicy::INITIALIZATION) is called as part of
50-
//! SetupSyscallSandbox(...).
5148
[[nodiscard]] bool SetupSyscallSandbox(bool log_syscall_violation_before_terminating);
5249

5350
//! Invoke a disallowed syscall. Use for testing purposes.

0 commit comments

Comments
 (0)