| 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 22 matching lines...) Expand all Loading... |
| 33 #include "base/process/process_handle.h" | 33 #include "base/process/process_handle.h" |
| 34 #include "base/rand_util.h" | 34 #include "base/rand_util.h" |
| 35 #include "build/build_config.h" | 35 #include "build/build_config.h" |
| 36 #include "components/nacl/common/nacl_switches.h" | 36 #include "components/nacl/common/nacl_switches.h" |
| 37 #include "components/nacl/loader/sandbox_linux/nacl_sandbox_linux.h" | 37 #include "components/nacl/loader/sandbox_linux/nacl_sandbox_linux.h" |
| 38 #include "content/public/common/content_descriptors.h" | 38 #include "content/public/common/content_descriptors.h" |
| 39 #include "content/public/common/send_zygote_child_ping_linux.h" | 39 #include "content/public/common/send_zygote_child_ping_linux.h" |
| 40 #include "content/public/common/zygote_fork_delegate_linux.h" | 40 #include "content/public/common/zygote_fork_delegate_linux.h" |
| 41 #include "ipc/ipc_descriptors.h" | 41 #include "ipc/ipc_descriptors.h" |
| 42 #include "ipc/ipc_switches.h" | 42 #include "ipc/ipc_switches.h" |
| 43 #include "mojo/edk/embedder/embedder.h" | |
| 44 #include "sandbox/linux/services/credentials.h" | 43 #include "sandbox/linux/services/credentials.h" |
| 45 #include "sandbox/linux/services/namespace_sandbox.h" | 44 #include "sandbox/linux/services/namespace_sandbox.h" |
| 46 | 45 |
| 47 #if defined(OS_NACL_NONSFI) | 46 #if defined(OS_NACL_NONSFI) |
| 48 #include "components/nacl/loader/nonsfi/nonsfi_listener.h" | 47 #include "components/nacl/loader/nonsfi/nonsfi_listener.h" |
| 49 #include "native_client/src/public/nonsfi/irt_exception_handling.h" | 48 #include "native_client/src/public/nonsfi/irt_exception_handling.h" |
| 50 #else | 49 #else |
| 51 #include <link.h> | 50 #include <link.h> |
| 52 #include "components/nacl/loader/nacl_listener.h" | 51 #include "components/nacl/loader/nacl_listener.h" |
| 53 #endif | 52 #endif |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 111 |
| 113 // Finish layer-1 sandbox initialization and initialize the layer-2 sandbox. | 112 // Finish layer-1 sandbox initialization and initialize the layer-2 sandbox. |
| 114 CHECK(!nacl_sandbox->HasOpenDirectory()); | 113 CHECK(!nacl_sandbox->HasOpenDirectory()); |
| 115 nacl_sandbox->InitializeLayerTwoSandbox(uses_nonsfi_mode); | 114 nacl_sandbox->InitializeLayerTwoSandbox(uses_nonsfi_mode); |
| 116 nacl_sandbox->SealLayerOneSandbox(); | 115 nacl_sandbox->SealLayerOneSandbox(); |
| 117 nacl_sandbox->CheckSandboxingStateWithPolicy(); | 116 nacl_sandbox->CheckSandboxingStateWithPolicy(); |
| 118 | 117 |
| 119 base::GlobalDescriptors::GetInstance()->Set(kPrimaryIPCChannel, | 118 base::GlobalDescriptors::GetInstance()->Set(kPrimaryIPCChannel, |
| 120 browser_fd.release()); | 119 browser_fd.release()); |
| 121 | 120 |
| 122 // The Mojo EDK must be initialized before using IPC. | |
| 123 mojo::edk::Init(); | |
| 124 | |
| 125 base::MessageLoopForIO main_message_loop; | 121 base::MessageLoopForIO main_message_loop; |
| 126 #if defined(OS_NACL_NONSFI) | 122 #if defined(OS_NACL_NONSFI) |
| 127 CHECK(uses_nonsfi_mode); | 123 CHECK(uses_nonsfi_mode); |
| 128 nacl::nonsfi::NonSfiListener listener; | 124 nacl::nonsfi::NonSfiListener listener; |
| 129 listener.Listen(); | 125 listener.Listen(); |
| 130 #else | 126 #else |
| 131 CHECK(!uses_nonsfi_mode); | 127 CHECK(!uses_nonsfi_mode); |
| 132 NaClListener listener; | 128 NaClListener listener; |
| 133 listener.set_prereserved_sandbox_size(system_info.prereserved_sandbox_size); | 129 listener.set_prereserved_sandbox_size(system_info.prereserved_sandbox_size); |
| 134 listener.set_number_of_cores(system_info.number_of_cores); | 130 listener.set_number_of_cores(system_info.number_of_cores); |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 // Now handle requests from the Zygote. | 463 // Now handle requests from the Zygote. |
| 468 while (true) { | 464 while (true) { |
| 469 bool request_handled = HandleZygoteRequest( | 465 bool request_handled = HandleZygoteRequest( |
| 470 kNaClZygoteDescriptor, system_info, nacl_sandbox.get()); | 466 kNaClZygoteDescriptor, system_info, nacl_sandbox.get()); |
| 471 // Do not turn this into a CHECK() without thinking about robustness | 467 // Do not turn this into a CHECK() without thinking about robustness |
| 472 // against malicious IPC requests. | 468 // against malicious IPC requests. |
| 473 DCHECK(request_handled); | 469 DCHECK(request_handled); |
| 474 } | 470 } |
| 475 NOTREACHED(); | 471 NOTREACHED(); |
| 476 } | 472 } |
| OLD | NEW |