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 13 matching lines...) Expand all Loading... |
24 #include "base/logging.h" | 24 #include "base/logging.h" |
25 #include "base/message_loop/message_loop.h" | 25 #include "base/message_loop/message_loop.h" |
26 #include "base/posix/eintr_wrapper.h" | 26 #include "base/posix/eintr_wrapper.h" |
27 #include "base/posix/global_descriptors.h" | 27 #include "base/posix/global_descriptors.h" |
28 #include "base/posix/unix_domain_socket_linux.h" | 28 #include "base/posix/unix_domain_socket_linux.h" |
29 #include "base/process/kill.h" | 29 #include "base/process/kill.h" |
30 #include "base/rand_util.h" | 30 #include "base/rand_util.h" |
31 #include "components/nacl/common/nacl_switches.h" | 31 #include "components/nacl/common/nacl_switches.h" |
32 #include "components/nacl/loader/nacl_listener.h" | 32 #include "components/nacl/loader/nacl_listener.h" |
33 #include "components/nacl/loader/nacl_sandbox_linux.h" | 33 #include "components/nacl/loader/nacl_sandbox_linux.h" |
34 #include "components/nacl/loader/nonsfi/nonsfi_sandbox.h" | |
35 #include "content/public/common/zygote_fork_delegate_linux.h" | 34 #include "content/public/common/zygote_fork_delegate_linux.h" |
36 #include "crypto/nss_util.h" | 35 #include "crypto/nss_util.h" |
37 #include "ipc/ipc_descriptors.h" | 36 #include "ipc/ipc_descriptors.h" |
38 #include "ipc/ipc_switches.h" | 37 #include "ipc/ipc_switches.h" |
39 #include "sandbox/linux/services/libc_urandom_override.h" | 38 #include "sandbox/linux/services/libc_urandom_override.h" |
40 | 39 |
41 namespace { | 40 namespace { |
42 | 41 |
43 struct NaClLoaderSystemInfo { | 42 struct NaClLoaderSystemInfo { |
44 size_t prereserved_sandbox_size; | 43 size_t prereserved_sandbox_size; |
(...skipping 14 matching lines...) Expand all Loading... |
59 if (uses_nonsfi_mode) { | 58 if (uses_nonsfi_mode) { |
60 const bool can_be_no_sandbox = CommandLine::ForCurrentProcess()->HasSwitch( | 59 const bool can_be_no_sandbox = CommandLine::ForCurrentProcess()->HasSwitch( |
61 switches::kNaClDangerousNoSandboxNonSfi); | 60 switches::kNaClDangerousNoSandboxNonSfi); |
62 const bool setuid_sandbox_enabled = IsSandboxed(); | 61 const bool setuid_sandbox_enabled = IsSandboxed(); |
63 if (!setuid_sandbox_enabled) { | 62 if (!setuid_sandbox_enabled) { |
64 if (can_be_no_sandbox) | 63 if (can_be_no_sandbox) |
65 LOG(ERROR) << "DANGEROUS: Running non-SFI NaCl without SUID sandbox!"; | 64 LOG(ERROR) << "DANGEROUS: Running non-SFI NaCl without SUID sandbox!"; |
66 else | 65 else |
67 LOG(FATAL) << "SUID sandbox is mandatory for non-SFI NaCl"; | 66 LOG(FATAL) << "SUID sandbox is mandatory for non-SFI NaCl"; |
68 } | 67 } |
69 const bool bpf_sandbox_initialized = nacl::nonsfi::InitializeBPFSandbox(); | 68 const bool bpf_sandbox_initialized = InitializeBPFSandbox(); |
70 if (!bpf_sandbox_initialized) { | 69 if (!bpf_sandbox_initialized) { |
71 if (can_be_no_sandbox) { | 70 if (can_be_no_sandbox) { |
72 LOG(ERROR) | 71 LOG(ERROR) |
73 << "DANGEROUS: Running non-SFI NaCl without seccomp-bpf sandbox!"; | 72 << "DANGEROUS: Running non-SFI NaCl without seccomp-bpf sandbox!"; |
74 } else { | 73 } else { |
75 LOG(FATAL) << "Could not initialize NaCl's second " | 74 LOG(FATAL) << "Could not initialize NaCl's second " |
76 << "layer sandbox (seccomp-bpf) for non-SFI mode."; | 75 << "layer sandbox (seccomp-bpf) for non-SFI mode."; |
77 } | 76 } |
78 } | 77 } |
79 } else { | 78 } else { |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 // Now handle requests from the Zygote. | 422 // Now handle requests from the Zygote. |
424 while (true) { | 423 while (true) { |
425 bool request_handled = HandleZygoteRequest(kNaClZygoteDescriptor, | 424 bool request_handled = HandleZygoteRequest(kNaClZygoteDescriptor, |
426 system_info); | 425 system_info); |
427 // Do not turn this into a CHECK() without thinking about robustness | 426 // Do not turn this into a CHECK() without thinking about robustness |
428 // against malicious IPC requests. | 427 // against malicious IPC requests. |
429 DCHECK(request_handled); | 428 DCHECK(request_handled); |
430 } | 429 } |
431 NOTREACHED(); | 430 NOTREACHED(); |
432 } | 431 } |
OLD | NEW |