| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // A mini-zygote specifically for Native Client. | 5 // A mini-zygote specifically for Native Client. |
| 6 | 6 |
| 7 #include "components/nacl/loader/nacl_helper_linux.h" | 7 #include "components/nacl/loader/nacl_helper_linux.h" |
| 8 | 8 |
| 9 #include <errno.h> | 9 #include <errno.h> |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "base/memory/scoped_ptr.h" | 25 #include "base/memory/scoped_ptr.h" |
| 26 #include "base/message_loop/message_loop.h" | 26 #include "base/message_loop/message_loop.h" |
| 27 #include "base/posix/eintr_wrapper.h" | 27 #include "base/posix/eintr_wrapper.h" |
| 28 #include "base/posix/global_descriptors.h" | 28 #include "base/posix/global_descriptors.h" |
| 29 #include "base/posix/unix_domain_socket_linux.h" | 29 #include "base/posix/unix_domain_socket_linux.h" |
| 30 #include "base/process/kill.h" | 30 #include "base/process/kill.h" |
| 31 #include "base/rand_util.h" | 31 #include "base/rand_util.h" |
| 32 #include "components/nacl/common/nacl_switches.h" | 32 #include "components/nacl/common/nacl_switches.h" |
| 33 #include "components/nacl/loader/nacl_listener.h" | 33 #include "components/nacl/loader/nacl_listener.h" |
| 34 #include "components/nacl/loader/nacl_sandbox_linux.h" | 34 #include "components/nacl/loader/nacl_sandbox_linux.h" |
| 35 #include "components/nacl/loader/nonsfi/nonsfi_sandbox.h" |
| 35 #include "content/public/common/zygote_fork_delegate_linux.h" | 36 #include "content/public/common/zygote_fork_delegate_linux.h" |
| 36 #include "crypto/nss_util.h" | 37 #include "crypto/nss_util.h" |
| 37 #include "ipc/ipc_descriptors.h" | 38 #include "ipc/ipc_descriptors.h" |
| 38 #include "ipc/ipc_switches.h" | 39 #include "ipc/ipc_switches.h" |
| 39 #include "sandbox/linux/services/credentials.h" | 40 #include "sandbox/linux/services/credentials.h" |
| 40 #include "sandbox/linux/services/libc_urandom_override.h" | 41 #include "sandbox/linux/services/libc_urandom_override.h" |
| 41 #include "sandbox/linux/services/thread_helpers.h" | 42 #include "sandbox/linux/services/thread_helpers.h" |
| 42 #include "sandbox/linux/suid/client/setuid_sandbox_client.h" | 43 #include "sandbox/linux/suid/client/setuid_sandbox_client.h" |
| 43 | 44 |
| 44 namespace { | 45 namespace { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 if (uses_nonsfi_mode) { | 86 if (uses_nonsfi_mode) { |
| 86 const bool can_be_no_sandbox = CommandLine::ForCurrentProcess()->HasSwitch( | 87 const bool can_be_no_sandbox = CommandLine::ForCurrentProcess()->HasSwitch( |
| 87 switches::kNaClDangerousNoSandboxNonSfi); | 88 switches::kNaClDangerousNoSandboxNonSfi); |
| 88 const bool setuid_sandbox_enabled = IsSandboxed(); | 89 const bool setuid_sandbox_enabled = IsSandboxed(); |
| 89 if (!setuid_sandbox_enabled) { | 90 if (!setuid_sandbox_enabled) { |
| 90 if (can_be_no_sandbox) | 91 if (can_be_no_sandbox) |
| 91 LOG(ERROR) << "DANGEROUS: Running non-SFI NaCl without SUID sandbox!"; | 92 LOG(ERROR) << "DANGEROUS: Running non-SFI NaCl without SUID sandbox!"; |
| 92 else | 93 else |
| 93 LOG(FATAL) << "SUID sandbox is mandatory for non-SFI NaCl"; | 94 LOG(FATAL) << "SUID sandbox is mandatory for non-SFI NaCl"; |
| 94 } | 95 } |
| 95 const bool bpf_sandbox_initialized = InitializeBPFSandbox(); | 96 const bool bpf_sandbox_initialized = nacl::nonsfi::InitializeBPFSandbox(); |
| 96 if (!bpf_sandbox_initialized) { | 97 if (!bpf_sandbox_initialized) { |
| 97 if (can_be_no_sandbox) { | 98 if (can_be_no_sandbox) { |
| 98 LOG(ERROR) | 99 LOG(ERROR) |
| 99 << "DANGEROUS: Running non-SFI NaCl without seccomp-bpf sandbox!"; | 100 << "DANGEROUS: Running non-SFI NaCl without seccomp-bpf sandbox!"; |
| 100 } else { | 101 } else { |
| 101 LOG(FATAL) << "Could not initialize NaCl's second " | 102 LOG(FATAL) << "Could not initialize NaCl's second " |
| 102 << "layer sandbox (seccomp-bpf) for non-SFI mode."; | 103 << "layer sandbox (seccomp-bpf) for non-SFI mode."; |
| 103 } | 104 } |
| 104 } | 105 } |
| 105 } else { | 106 } else { |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 // Now handle requests from the Zygote. | 455 // Now handle requests from the Zygote. |
| 455 while (true) { | 456 while (true) { |
| 456 bool request_handled = HandleZygoteRequest(kNaClZygoteDescriptor, | 457 bool request_handled = HandleZygoteRequest(kNaClZygoteDescriptor, |
| 457 system_info); | 458 system_info); |
| 458 // Do not turn this into a CHECK() without thinking about robustness | 459 // Do not turn this into a CHECK() without thinking about robustness |
| 459 // against malicious IPC requests. | 460 // against malicious IPC requests. |
| 460 DCHECK(request_handled); | 461 DCHECK(request_handled); |
| 461 } | 462 } |
| 462 NOTREACHED(); | 463 NOTREACHED(); |
| 463 } | 464 } |
| OLD | NEW |