Commit 8dea07ad authored by rickyz's avatar rickyz Committed by Commit bot

Make NaCl process non-dumpable.

This can be disabled with the allow-sandbox-debugging flag.

BUG=455964

Review URL: https://codereview.chromium.org/901683003

Cr-Commit-Position: refs/heads/master@{#315139}
parent 0540e174
include_rules = [ include_rules = [
"+components/nacl", "+components/nacl",
"+content/public/app/startup_helper_win.h", "+content/public/app/startup_helper_win.h",
"+content/public/common",
"+crypto", "+crypto",
"+sandbox/linux/bpf_dsl", "+sandbox/linux/bpf_dsl",
"+sandbox/linux/seccomp-bpf", "+sandbox/linux/seccomp-bpf",
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/prctl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
...@@ -22,6 +23,7 @@ ...@@ -22,6 +23,7 @@
#include "components/nacl/common/nacl_switches.h" #include "components/nacl/common/nacl_switches.h"
#include "components/nacl/loader/nonsfi/nonsfi_sandbox.h" #include "components/nacl/loader/nonsfi/nonsfi_sandbox.h"
#include "components/nacl/loader/sandbox_linux/nacl_bpf_sandbox_linux.h" #include "components/nacl/loader/sandbox_linux/nacl_bpf_sandbox_linux.h"
#include "content/public/common/content_switches.h"
#include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
#include "sandbox/linux/services/proc_util.h" #include "sandbox/linux/services/proc_util.h"
#include "sandbox/linux/services/thread_helpers.h" #include "sandbox/linux/services/thread_helpers.h"
...@@ -50,6 +52,21 @@ base::ScopedFD GetProcSelfTask(int proc_fd) { ...@@ -50,6 +52,21 @@ base::ScopedFD GetProcSelfTask(int proc_fd) {
return proc_self_task.Pass(); return proc_self_task.Pass();
} }
bool MaybeSetProcessNonDumpable() {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kAllowSandboxDebugging)) {
return true;
}
if (prctl(PR_SET_DUMPABLE, 0, 0, 0, 0) != 0) {
PLOG(ERROR) << "Failed to set non-dumpable flag";
return false;
}
return prctl(PR_GET_DUMPABLE) == 0;
}
} // namespace } // namespace
NaClSandbox::NaClSandbox() NaClSandbox::NaClSandbox()
...@@ -91,6 +108,7 @@ void NaClSandbox::InitializeLayerOneSandbox() { ...@@ -91,6 +108,7 @@ void NaClSandbox::InitializeLayerOneSandbox() {
// Get sandboxed. // Get sandboxed.
CHECK(setuid_sandbox_client_->ChrootMe()); CHECK(setuid_sandbox_client_->ChrootMe());
CHECK(MaybeSetProcessNonDumpable());
CHECK(IsSandboxed()); CHECK(IsSandboxed());
layer_one_enabled_ = true; layer_one_enabled_ = true;
} }
......
...@@ -209,6 +209,7 @@ void NaClForkDelegate::Init(const int sandboxdesc, ...@@ -209,6 +209,7 @@ void NaClForkDelegate::Init(const int sandboxdesc,
// Append any switches that need to be forwarded to the NaCl helper. // Append any switches that need to be forwarded to the NaCl helper.
static const char* kForwardSwitches[] = { static const char* kForwardSwitches[] = {
switches::kAllowSandboxDebugging,
switches::kDisableSeccompFilterSandbox, switches::kDisableSeccompFilterSandbox,
switches::kEnableNaClDebug, switches::kEnableNaClDebug,
switches::kNaClDangerousNoSandboxNonSfi, switches::kNaClDangerousNoSandboxNonSfi,
......
...@@ -19,7 +19,7 @@ CONTENT_EXPORT extern const char kAllowFileAccessFromFiles[]; ...@@ -19,7 +19,7 @@ CONTENT_EXPORT extern const char kAllowFileAccessFromFiles[];
CONTENT_EXPORT extern const char kAllowInsecureWebSocketFromHttpsOrigin[]; CONTENT_EXPORT extern const char kAllowInsecureWebSocketFromHttpsOrigin[];
CONTENT_EXPORT extern const char kAllowLoopbackInPeerConnection[]; CONTENT_EXPORT extern const char kAllowLoopbackInPeerConnection[];
CONTENT_EXPORT extern const char kAllowNoSandboxJob[]; CONTENT_EXPORT extern const char kAllowNoSandboxJob[];
extern const char kAllowSandboxDebugging[]; CONTENT_EXPORT extern const char kAllowSandboxDebugging[];
extern const char kAuditAllHandles[]; extern const char kAuditAllHandles[];
extern const char kAuditHandles[]; extern const char kAuditHandles[];
CONTENT_EXPORT extern const char kBlinkPlatformLogChannels[]; CONTENT_EXPORT extern const char kBlinkPlatformLogChannels[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment