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 25 matching lines...) Expand all Loading... |
36 #include "components/nacl/loader/nonsfi/nonsfi_listener.h" | 36 #include "components/nacl/loader/nonsfi/nonsfi_listener.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 "crypto/nss_util.h" | 41 #include "crypto/nss_util.h" |
42 #include "ipc/ipc_descriptors.h" | 42 #include "ipc/ipc_descriptors.h" |
43 #include "ipc/ipc_switches.h" | 43 #include "ipc/ipc_switches.h" |
44 #include "sandbox/linux/services/libc_urandom_override.h" | 44 #include "sandbox/linux/services/libc_urandom_override.h" |
45 | 45 |
| 46 #if !defined(OS_NACL_NONSFI) |
| 47 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
| 48 #include "third_party/mojo/src/mojo/edk/embedder/simple_platform_support.h" |
| 49 #endif |
| 50 |
46 #if defined(OS_NACL_NONSFI) | 51 #if defined(OS_NACL_NONSFI) |
47 #include "native_client/src/public/nonsfi/irt_exception_handling.h" | 52 #include "native_client/src/public/nonsfi/irt_exception_handling.h" |
48 #else | 53 #else |
49 #include <link.h> | 54 #include <link.h> |
50 #include "components/nacl/loader/nonsfi/irt_exception_handling.h" | 55 #include "components/nacl/loader/nonsfi/irt_exception_handling.h" |
51 #endif | 56 #endif |
52 | 57 |
53 namespace { | 58 namespace { |
54 | 59 |
55 struct NaClLoaderSystemInfo { | 60 struct NaClLoaderSystemInfo { |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 // These are not used by nacl_helper_nonsfi. | 457 // These are not used by nacl_helper_nonsfi. |
453 CheckReservedAtZero(), | 458 CheckReservedAtZero(), |
454 sysconf(_SC_NPROCESSORS_ONLN) | 459 sysconf(_SC_NPROCESSORS_ONLN) |
455 #endif | 460 #endif |
456 }; | 461 }; |
457 | 462 |
458 #if !defined(OS_NACL_NONSFI) | 463 #if !defined(OS_NACL_NONSFI) |
459 CheckRDebug(argv[0]); | 464 CheckRDebug(argv[0]); |
460 #endif | 465 #endif |
461 | 466 |
| 467 // TODO(teravest): Enable mojo for nonsfi. http://crbug.com/473418 |
| 468 #if !defined(OS_NACL_NONSFI) |
| 469 mojo::embedder::Init( |
| 470 make_scoped_ptr(new mojo::embedder::SimplePlatformSupport())); |
| 471 #endif |
| 472 |
462 scoped_ptr<nacl::NaClSandbox> nacl_sandbox(new nacl::NaClSandbox); | 473 scoped_ptr<nacl::NaClSandbox> nacl_sandbox(new nacl::NaClSandbox); |
463 // Make sure that the early initialization did not start any spurious | 474 // Make sure that the early initialization did not start any spurious |
464 // threads. | 475 // threads. |
465 #if !defined(THREAD_SANITIZER) | 476 #if !defined(THREAD_SANITIZER) |
466 CHECK(nacl_sandbox->IsSingleThreaded()); | 477 CHECK(nacl_sandbox->IsSingleThreaded()); |
467 #endif | 478 #endif |
468 | 479 |
469 const bool is_init_process = 1 == getpid(); | 480 const bool is_init_process = 1 == getpid(); |
470 nacl_sandbox->InitializeLayerOneSandbox(); | 481 nacl_sandbox->InitializeLayerOneSandbox(); |
471 CHECK_EQ(is_init_process, nacl_sandbox->layer_one_enabled()); | 482 CHECK_EQ(is_init_process, nacl_sandbox->layer_one_enabled()); |
472 | 483 |
473 const std::vector<int> empty; | 484 const std::vector<int> empty; |
474 // Send the zygote a message to let it know we are ready to help | 485 // Send the zygote a message to let it know we are ready to help |
475 if (!UnixDomainSocket::SendMsg(kNaClZygoteDescriptor, | 486 if (!UnixDomainSocket::SendMsg(kNaClZygoteDescriptor, |
476 kNaClHelperStartupAck, | 487 kNaClHelperStartupAck, |
477 sizeof(kNaClHelperStartupAck), empty)) { | 488 sizeof(kNaClHelperStartupAck), empty)) { |
478 LOG(ERROR) << "*** send() to zygote failed"; | 489 LOG(ERROR) << "*** send() to zygote failed"; |
479 } | 490 } |
480 | 491 |
481 // Now handle requests from the Zygote. | 492 // Now handle requests from the Zygote. |
482 while (true) { | 493 while (true) { |
483 bool request_handled = HandleZygoteRequest( | 494 bool request_handled = HandleZygoteRequest( |
484 kNaClZygoteDescriptor, system_info, nacl_sandbox.get()); | 495 kNaClZygoteDescriptor, system_info, nacl_sandbox.get()); |
485 // Do not turn this into a CHECK() without thinking about robustness | 496 // Do not turn this into a CHECK() without thinking about robustness |
486 // against malicious IPC requests. | 497 // against malicious IPC requests. |
487 DCHECK(request_handled); | 498 DCHECK(request_handled); |
488 } | 499 } |
489 NOTREACHED(); | 500 NOTREACHED(); |
490 } | 501 } |
OLD | NEW |