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/process/process_handle.h" | 31 #include "base/process/process_handle.h" |
32 #include "base/rand_util.h" | 32 #include "base/rand_util.h" |
33 #include "components/nacl/common/nacl_switches.h" | 33 #include "components/nacl/common/nacl_switches.h" |
34 #include "components/nacl/loader/nacl_listener.h" | 34 #include "components/nacl/loader/nacl_listener.h" |
35 #include "components/nacl/loader/nonsfi/irt_exception_handling.h" | |
36 #include "components/nacl/loader/sandbox_linux/nacl_sandbox_linux.h" | 35 #include "components/nacl/loader/sandbox_linux/nacl_sandbox_linux.h" |
37 #include "content/public/common/content_descriptors.h" | 36 #include "content/public/common/content_descriptors.h" |
38 #include "content/public/common/zygote_fork_delegate_linux.h" | 37 #include "content/public/common/zygote_fork_delegate_linux.h" |
39 #include "crypto/nss_util.h" | 38 #include "crypto/nss_util.h" |
40 #include "ipc/ipc_descriptors.h" | 39 #include "ipc/ipc_descriptors.h" |
41 #include "ipc/ipc_switches.h" | 40 #include "ipc/ipc_switches.h" |
42 #include "sandbox/linux/services/libc_urandom_override.h" | 41 #include "sandbox/linux/services/libc_urandom_override.h" |
43 | 42 |
44 namespace { | 43 namespace { |
45 | 44 |
(...skipping 30 matching lines...) Expand all Loading... |
76 // various operations. See the LinuxSandbox::METHOD_* methods. NaCl uses | 75 // various operations. See the LinuxSandbox::METHOD_* methods. NaCl uses |
77 // LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT in SFI mode, so this | 76 // LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT in SFI mode, so this |
78 // should only be closed in Non-SFI mode. | 77 // should only be closed in Non-SFI mode. |
79 // This file descriptor is insidiously used by a number of APIs. Closing it | 78 // This file descriptor is insidiously used by a number of APIs. Closing it |
80 // could lead to difficult to debug issues. Instead of closing it, replace | 79 // could lead to difficult to debug issues. Instead of closing it, replace |
81 // it with a dummy. | 80 // it with a dummy. |
82 const int sandbox_ipc_channel = | 81 const int sandbox_ipc_channel = |
83 base::GlobalDescriptors::kBaseDescriptor + kSandboxIPCChannel; | 82 base::GlobalDescriptors::kBaseDescriptor + kSandboxIPCChannel; |
84 | 83 |
85 ReplaceFDWithDummy(sandbox_ipc_channel); | 84 ReplaceFDWithDummy(sandbox_ipc_channel); |
86 | |
87 // Install crash signal handlers before disallowing system calls. | |
88 nacl::nonsfi::InitializeSignalHandler(); | |
89 } | 85 } |
90 | 86 |
91 // Finish layer-1 sandbox initialization and initialize the layer-2 sandbox. | 87 // Finish layer-1 sandbox initialization and initialize the layer-2 sandbox. |
92 CHECK(!nacl_sandbox->HasOpenDirectory()); | 88 CHECK(!nacl_sandbox->HasOpenDirectory()); |
93 nacl_sandbox->InitializeLayerTwoSandbox(uses_nonsfi_mode); | 89 nacl_sandbox->InitializeLayerTwoSandbox(uses_nonsfi_mode); |
94 nacl_sandbox->SealLayerOneSandbox(); | 90 nacl_sandbox->SealLayerOneSandbox(); |
95 nacl_sandbox->CheckSandboxingStateWithPolicy(); | 91 nacl_sandbox->CheckSandboxingStateWithPolicy(); |
96 | 92 |
97 base::GlobalDescriptors::GetInstance()->Set( | 93 base::GlobalDescriptors::GetInstance()->Set( |
98 kPrimaryIPCChannel, | 94 kPrimaryIPCChannel, |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 // Now handle requests from the Zygote. | 437 // Now handle requests from the Zygote. |
442 while (true) { | 438 while (true) { |
443 bool request_handled = HandleZygoteRequest( | 439 bool request_handled = HandleZygoteRequest( |
444 kNaClZygoteDescriptor, system_info, nacl_sandbox.get()); | 440 kNaClZygoteDescriptor, system_info, nacl_sandbox.get()); |
445 // Do not turn this into a CHECK() without thinking about robustness | 441 // Do not turn this into a CHECK() without thinking about robustness |
446 // against malicious IPC requests. | 442 // against malicious IPC requests. |
447 DCHECK(request_handled); | 443 DCHECK(request_handled); |
448 } | 444 } |
449 NOTREACHED(); | 445 NOTREACHED(); |
450 } | 446 } |
OLD | NEW |