Chromium Code Reviews| Index: components/nacl/loader/nacl_helper_linux.cc |
| diff --git a/components/nacl/loader/nacl_helper_linux.cc b/components/nacl/loader/nacl_helper_linux.cc |
| index 26578c02de1a9ee59081bff9b858e305c092458b..3aa00d8161eeac18f5ec36f2db6ac32fad7dfc6d 100644 |
| --- a/components/nacl/loader/nacl_helper_linux.cc |
| +++ b/components/nacl/loader/nacl_helper_linux.cc |
| @@ -43,6 +43,40 @@ struct NaClLoaderSystemInfo { |
| long number_of_cores; |
| }; |
| +// This is a poor man's check on whether we are sandboxed. |
| +bool IsSandboxed() { |
| + int proc_fd = open("/proc/self/exe", O_RDONLY); |
| + if (proc_fd >= 0) { |
| + close(proc_fd); |
| + return false; |
| + } |
| + return true; |
| +} |
| + |
| +void InitializeSandbox(bool uses_nonsfi_mode) { |
| + if (uses_nonsfi_mode) { |
| + if (getenv("NACL_DANGEROUS_DISABLE_NONSFI_SANDBOX")) { |
|
hamaji
2014/04/04 14:36:58
We need to whitelist this (and other NACL-prefixed
Mark Seaborn
2014/04/04 15:45:37
Is there anything specific you want it for?
I'll
hamaji
2014/04/04 18:57:48
Yes. Our app has a hack to attach GDB appropriatel
|
| + LOG(ERROR) << "DANGEROUS: Running non-SFI NaCl without sandbox!"; |
| + return; |
| + } |
| + const bool setuid_sandbox_enabled = IsSandboxed(); |
| + CHECK(setuid_sandbox_enabled) |
| + << "SUID sandbox is mandatory for non-SFI NaCl"; |
| + // TODO(hamaji): Add a strict seccomp sandbox for non-SFI NaCl. |
|
Mark Seaborn
2014/04/04 15:45:37
Nit: I suspect you wouldn't be changing this part
hamaji
2014/04/04 18:57:48
I was planning to change this to nacl::nonsfi::Ini
|
| + // https://code.google.com/p/chromium/issues/detail?id=359285 |
| + bool bpf_sandbox_initialized = InitializeBPFSandbox(); |
|
Mark Seaborn
2014/04/04 15:45:37
When I talked with Julien yesterday, he pointed ou
hamaji
2014/04/04 18:57:48
It seems the sandbox is enabled even with --disabl
|
| + CHECK(bpf_sandbox_initialized) |
| + << "Could not initialize NaCl's second " |
| + << "layer sandbox (seccomp-bpf) for non-SFI mode."; |
| + } else { |
| + bool bpf_sandbox_initialized = InitializeBPFSandbox(); |
| + if (!bpf_sandbox_initialized) { |
| + LOG(ERROR) << "Could not initialize NaCl's second " |
| + << "layer sandbox (seccomp-bpf) for SFI mode."; |
| + } |
| + } |
| +} |
| + |
| // The child must mimic the behavior of zygote_main_linux.cc on the child |
| // side of the fork. See zygote_main_linux.cc:HandleForkRequest from |
| // if (!child) { |
| @@ -53,11 +87,7 @@ void BecomeNaClLoader(const std::vector<int>& child_fds, |
| // don't need zygote FD any more |
| if (IGNORE_EINTR(close(kNaClZygoteDescriptor)) != 0) |
| LOG(ERROR) << "close(kNaClZygoteDescriptor) failed."; |
| - bool sandbox_initialized = InitializeBPFSandbox(); |
| - if (!sandbox_initialized) { |
| - LOG(ERROR) << "Could not initialize NaCl's second " |
| - << "layer sandbox (seccomp-bpf)."; |
| - } |
| + InitializeSandbox(uses_nonsfi_mode); |
| base::GlobalDescriptors::GetInstance()->Set( |
| kPrimaryIPCChannel, |
| child_fds[content::ZygoteForkDelegate::kBrowserFDIndex]); |
| @@ -186,16 +216,6 @@ bool HandleGetTerminationStatusRequest(PickleIterator* input_iter, |
| return true; |
| } |
| -// This is a poor man's check on whether we are sandboxed. |
| -bool IsSandboxed() { |
| - int proc_fd = open("/proc/self/exe", O_RDONLY); |
| - if (proc_fd >= 0) { |
| - close(proc_fd); |
| - return false; |
| - } |
| - return true; |
| -} |
| - |
| // Honor a command |command_type|. Eventual command parameters are |
| // available in |input_iter| and eventual file descriptors attached to |
| // the command are in |attached_fds|. |