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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 | 431 |
432 int main(int argc, char* argv[]) { | 432 int main(int argc, char* argv[]) { |
433 base::CommandLine::Init(argc, argv); | 433 base::CommandLine::Init(argc, argv); |
434 base::AtExitManager exit_manager; | 434 base::AtExitManager exit_manager; |
435 base::RandUint64(); // acquire /dev/urandom fd before sandbox is raised | 435 base::RandUint64(); // acquire /dev/urandom fd before sandbox is raised |
436 | 436 |
437 #if !defined(OS_NACL_NONSFI) | 437 #if !defined(OS_NACL_NONSFI) |
438 // NSS is only needed for SFI NaCl. | 438 // NSS is only needed for SFI NaCl. |
439 // Allows NSS to fopen() /dev/urandom. | 439 // Allows NSS to fopen() /dev/urandom. |
440 sandbox::InitLibcUrandomOverrides(); | 440 sandbox::InitLibcUrandomOverrides(); |
441 #if defined(USE_NSS) | 441 #if defined(USE_NSS_CERTS) |
442 // Configure NSS for use inside the NaCl process. | 442 // Configure NSS for use inside the NaCl process. |
443 // The fork check has not caused problems for NaCl, but this appears to be | 443 // The fork check has not caused problems for NaCl, but this appears to be |
444 // best practice (see other places LoadNSSLibraries is called.) | 444 // best practice (see other places LoadNSSLibraries is called.) |
445 crypto::DisableNSSForkCheck(); | 445 crypto::DisableNSSForkCheck(); |
446 // Without this line on Linux, HMAC::Init will instantiate a singleton that | 446 // Without this line on Linux, HMAC::Init will instantiate a singleton that |
447 // in turn attempts to open a file. Disabling this behavior avoids a ~70 ms | 447 // in turn attempts to open a file. Disabling this behavior avoids a ~70 ms |
448 // stall the first time HMAC is used. | 448 // stall the first time HMAC is used. |
449 crypto::ForceNSSNoDBInit(); | 449 crypto::ForceNSSNoDBInit(); |
450 // Load shared libraries before sandbox is raised. | 450 // Load shared libraries before sandbox is raised. |
451 // NSS is needed to perform hashing for validation caching. | 451 // NSS is needed to perform hashing for validation caching. |
452 crypto::LoadNSSLibraries(); | 452 crypto::LoadNSSLibraries(); |
453 #endif // defined(USE_NSS) | 453 #endif // defined(USE_NSS_CERTS) |
454 #endif // defined(OS_NACL_NONSFI) | 454 #endif // defined(OS_NACL_NONSFI) |
455 const NaClLoaderSystemInfo system_info = { | 455 const NaClLoaderSystemInfo system_info = { |
456 #if !defined(OS_NACL_NONSFI) | 456 #if !defined(OS_NACL_NONSFI) |
457 // These are not used by nacl_helper_nonsfi. | 457 // These are not used by nacl_helper_nonsfi. |
458 CheckReservedAtZero(), | 458 CheckReservedAtZero(), |
459 sysconf(_SC_NPROCESSORS_ONLN) | 459 sysconf(_SC_NPROCESSORS_ONLN) |
460 #endif | 460 #endif |
461 }; | 461 }; |
462 | 462 |
463 #if !defined(OS_NACL_NONSFI) | 463 #if !defined(OS_NACL_NONSFI) |
(...skipping 28 matching lines...) Expand all Loading... |
492 // Now handle requests from the Zygote. | 492 // Now handle requests from the Zygote. |
493 while (true) { | 493 while (true) { |
494 bool request_handled = HandleZygoteRequest( | 494 bool request_handled = HandleZygoteRequest( |
495 kNaClZygoteDescriptor, system_info, nacl_sandbox.get()); | 495 kNaClZygoteDescriptor, system_info, nacl_sandbox.get()); |
496 // Do not turn this into a CHECK() without thinking about robustness | 496 // Do not turn this into a CHECK() without thinking about robustness |
497 // against malicious IPC requests. | 497 // against malicious IPC requests. |
498 DCHECK(request_handled); | 498 DCHECK(request_handled); |
499 } | 499 } |
500 NOTREACHED(); | 500 NOTREACHED(); |
501 } | 501 } |
OLD | NEW |