OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/zygote/zygote_main.h" | 5 #include "content/zygote/zygote_main.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <pthread.h> | 9 #include <pthread.h> |
10 #include <string.h> | 10 #include <string.h> |
11 #include <sys/socket.h> | 11 #include <sys/socket.h> |
12 #include <sys/types.h> | 12 #include <sys/types.h> |
13 #include <unistd.h> | 13 #include <unistd.h> |
14 | 14 |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #include "base/bind.h" | 16 #include "base/bind.h" |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
19 #include "base/memory/scoped_vector.h" | 19 #include "base/memory/scoped_vector.h" |
20 #include "base/native_library.h" | 20 #include "base/native_library.h" |
21 #include "base/pickle.h" | 21 #include "base/pickle.h" |
22 #include "base/posix/eintr_wrapper.h" | 22 #include "base/posix/eintr_wrapper.h" |
23 #include "base/posix/unix_domain_socket_linux.h" | 23 #include "base/posix/unix_domain_socket_linux.h" |
24 #include "base/rand_util.h" | 24 #include "base/rand_util.h" |
| 25 #include "base/strings/string_number_conversions.h" |
25 #include "base/sys_info.h" | 26 #include "base/sys_info.h" |
26 #include "build/build_config.h" | 27 #include "build/build_config.h" |
27 #include "content/common/child_process_sandbox_support_impl_linux.h" | 28 #include "content/common/child_process_sandbox_support_impl_linux.h" |
28 #include "content/common/font_config_ipc_linux.h" | 29 #include "content/common/font_config_ipc_linux.h" |
29 #include "content/common/pepper_plugin_list.h" | 30 #include "content/common/pepper_plugin_list.h" |
30 #include "content/common/sandbox_linux/sandbox_linux.h" | 31 #include "content/common/sandbox_linux/sandbox_linux.h" |
31 #include "content/common/zygote_commands_linux.h" | 32 #include "content/common/zygote_commands_linux.h" |
32 #include "content/public/common/content_switches.h" | 33 #include "content/public/common/content_switches.h" |
33 #include "content/public/common/main_function_params.h" | 34 #include "content/public/common/main_function_params.h" |
34 #include "content/public/common/pepper_plugin_info.h" | 35 #include "content/public/common/pepper_plugin_info.h" |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 bool ZygoteMain(const MainFunctionParams& params, | 490 bool ZygoteMain(const MainFunctionParams& params, |
490 ScopedVector<ZygoteForkDelegate> fork_delegates) { | 491 ScopedVector<ZygoteForkDelegate> fork_delegates) { |
491 g_am_zygote_or_renderer = true; | 492 g_am_zygote_or_renderer = true; |
492 sandbox::InitLibcUrandomOverrides(); | 493 sandbox::InitLibcUrandomOverrides(); |
493 | 494 |
494 base::Closure *post_fork_parent_callback = NULL; | 495 base::Closure *post_fork_parent_callback = NULL; |
495 | 496 |
496 LinuxSandbox* linux_sandbox = LinuxSandbox::GetInstance(); | 497 LinuxSandbox* linux_sandbox = LinuxSandbox::GetInstance(); |
497 | 498 |
498 #if defined(ADDRESS_SANITIZER) | 499 #if defined(ADDRESS_SANITIZER) |
499 base::ScopedFD sancov_file_fd(__sanitizer_maybe_open_cov_file("zygote")); | 500 const std::string sancov_file_name = |
| 501 "zygote." + base::Uint64ToString(base::RandUint64()); |
| 502 base::ScopedFD sancov_file_fd( |
| 503 __sanitizer_maybe_open_cov_file(sancov_file_name.c_str())); |
500 int sancov_socket_fds[2] = {-1, -1}; | 504 int sancov_socket_fds[2] = {-1, -1}; |
501 CreateSanitizerCoverageSocketPair(sancov_socket_fds); | 505 CreateSanitizerCoverageSocketPair(sancov_socket_fds); |
502 linux_sandbox->sanitizer_args()->coverage_sandboxed = 1; | 506 linux_sandbox->sanitizer_args()->coverage_sandboxed = 1; |
503 linux_sandbox->sanitizer_args()->coverage_fd = sancov_socket_fds[1]; | 507 linux_sandbox->sanitizer_args()->coverage_fd = sancov_socket_fds[1]; |
504 linux_sandbox->sanitizer_args()->coverage_max_block_size = | 508 linux_sandbox->sanitizer_args()->coverage_max_block_size = |
505 kSanitizerMaxMessageLength; | 509 kSanitizerMaxMessageLength; |
506 // Zygote termination will block until the helper process exits, which will | 510 // Zygote termination will block until the helper process exits, which will |
507 // not happen until the write end of the socket is closed everywhere. Make | 511 // not happen until the write end of the socket is closed everywhere. Make |
508 // sure the init process does not hold on to it. | 512 // sure the init process does not hold on to it. |
509 base::Closure close_sancov_socket_fds = | 513 base::Closure close_sancov_socket_fds = |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 bool setuid_sandbox_engaged = sandbox_flags & kSandboxLinuxSUID; | 563 bool setuid_sandbox_engaged = sandbox_flags & kSandboxLinuxSUID; |
560 CHECK_EQ(must_enable_setuid_sandbox, setuid_sandbox_engaged); | 564 CHECK_EQ(must_enable_setuid_sandbox, setuid_sandbox_engaged); |
561 | 565 |
562 Zygote zygote(sandbox_flags, fork_delegates.Pass(), extra_children, | 566 Zygote zygote(sandbox_flags, fork_delegates.Pass(), extra_children, |
563 extra_fds); | 567 extra_fds); |
564 // This function call can return multiple times, once per fork(). | 568 // This function call can return multiple times, once per fork(). |
565 return zygote.ProcessRequests(); | 569 return zygote.ProcessRequests(); |
566 } | 570 } |
567 | 571 |
568 } // namespace content | 572 } // namespace content |
OLD | NEW |