mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Merge bitcoin/bitcoin#27896: Remove the syscall sandbox
32e2ffc393Remove the syscall sandbox (fanquake) Pull request description: After initially being merged in #20487, it's no-longer clear that an internal syscall sandboxing mechanism is something that Bitcoin Core should have/maintain, especially when compared to better maintained/supported alterantives, i.e [firejail](https://github.com/netblue30/firejail). There is more related discussion in #24771. Note that given where it's used, the sandbox also gets dragged into the kernel. If it's removed, this should not require any sort of deprecation, as this was only ever an opt-in, experimental feature. Closes #24771. ACKs for top commit: davidgumberg: crACK32e2ffc393achow101: ACK32e2ffc393dergoegge: ACK32e2ffc393Tree-SHA512: 8cf71c5623bb642cb515531d4a2545d806e503b9d57bfc15a996597632b06103d60d985fd7f843a3c1da6528bc38d0298d6b8bcf0be6f851795a8040d71faf16
This commit is contained in:
41
src/init.cpp
41
src/init.cpp
@@ -80,7 +80,6 @@
|
||||
#include <util/result.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/string.h>
|
||||
#include <util/syscall_sandbox.h>
|
||||
#include <util/syserror.h>
|
||||
#include <util/thread.h>
|
||||
#include <util/threadnames.h>
|
||||
@@ -630,10 +629,6 @@ void SetupServerArgs(ArgsManager& argsman)
|
||||
hidden_args.emplace_back("-daemonwait");
|
||||
#endif
|
||||
|
||||
#if defined(USE_SYSCALL_SANDBOX)
|
||||
argsman.AddArg("-sandbox=<mode>", "Use the experimental syscall sandbox in the specified mode (-sandbox=log-and-abort or -sandbox=abort). Allow only expected syscalls to be used by bitcoind. Note that this is an experimental new feature that may cause bitcoind to exit or crash unexpectedly: use with caution. In the \"log-and-abort\" mode the invocation of an unexpected syscall results in a debug handler being invoked which will log the incident and terminate the program (without executing the unexpected syscall). In the \"abort\" mode the invocation of an unexpected syscall results in the entire process being killed immediately by the kernel without executing the unexpected syscall.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||
#endif // USE_SYSCALL_SANDBOX
|
||||
|
||||
// Add the hidden options
|
||||
argsman.AddHiddenArgs(hidden_args);
|
||||
}
|
||||
@@ -844,7 +839,7 @@ bool AppInitBasicSetup(const ArgsManager& args, std::atomic<int>& exit_status)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandbox)
|
||||
bool AppInitParameterInteraction(const ArgsManager& args)
|
||||
{
|
||||
const CChainParams& chainparams = Params();
|
||||
// ********************************************************* Step 2: parameter interactions
|
||||
@@ -991,40 +986,6 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb
|
||||
if (args.GetIntArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) > 1)
|
||||
return InitError(Untranslated("Unknown rpcserialversion requested."));
|
||||
|
||||
#if defined(USE_SYSCALL_SANDBOX)
|
||||
if (args.IsArgSet("-sandbox") && !args.IsArgNegated("-sandbox")) {
|
||||
const std::string sandbox_arg{args.GetArg("-sandbox", "")};
|
||||
bool log_syscall_violation_before_terminating{false};
|
||||
if (sandbox_arg == "log-and-abort") {
|
||||
log_syscall_violation_before_terminating = true;
|
||||
} else if (sandbox_arg == "abort") {
|
||||
// log_syscall_violation_before_terminating is false by default.
|
||||
} else {
|
||||
return InitError(Untranslated("Unknown syscall sandbox mode (-sandbox=<mode>). Available modes are \"log-and-abort\" and \"abort\"."));
|
||||
}
|
||||
// execve(...) is not allowed by the syscall sandbox.
|
||||
const std::vector<std::string> features_using_execve{
|
||||
"-alertnotify",
|
||||
"-blocknotify",
|
||||
"-signer",
|
||||
"-startupnotify",
|
||||
"-walletnotify",
|
||||
};
|
||||
for (const std::string& feature_using_execve : features_using_execve) {
|
||||
if (!args.GetArg(feature_using_execve, "").empty()) {
|
||||
return InitError(Untranslated(strprintf("The experimental syscall sandbox feature (-sandbox=<mode>) is incompatible with %s (which uses execve).", feature_using_execve)));
|
||||
}
|
||||
}
|
||||
if (!SetupSyscallSandbox(log_syscall_violation_before_terminating)) {
|
||||
return InitError(Untranslated("Installation of the syscall sandbox failed."));
|
||||
}
|
||||
if (use_syscall_sandbox) {
|
||||
SetSyscallSandboxPolicy(SyscallSandboxPolicy::INITIALIZATION);
|
||||
}
|
||||
LogPrintf("Experimental syscall sandbox enabled (-sandbox=%s): bitcoind will terminate if an unexpected (not allowlisted) syscall is invoked.\n", sandbox_arg);
|
||||
}
|
||||
#endif // USE_SYSCALL_SANDBOX
|
||||
|
||||
// Also report errors from parsing before daemonization
|
||||
{
|
||||
KernelNotifications notifications{};
|
||||
|
||||
Reference in New Issue
Block a user