Chromium Code Reviews| 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 <signal.h> | 10 #include <signal.h> |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 #include "content/common/font_config_ipc_linux.h" | 33 #include "content/common/font_config_ipc_linux.h" |
| 34 #include "content/common/sandbox_linux/sandbox_debug_handling_linux.h" | 34 #include "content/common/sandbox_linux/sandbox_debug_handling_linux.h" |
| 35 #include "content/common/sandbox_linux/sandbox_linux.h" | 35 #include "content/common/sandbox_linux/sandbox_linux.h" |
| 36 #include "content/common/zygote_commands_linux.h" | 36 #include "content/common/zygote_commands_linux.h" |
| 37 #include "content/public/common/content_switches.h" | 37 #include "content/public/common/content_switches.h" |
| 38 #include "content/public/common/main_function_params.h" | 38 #include "content/public/common/main_function_params.h" |
| 39 #include "content/public/common/sandbox_linux.h" | 39 #include "content/public/common/sandbox_linux.h" |
| 40 #include "content/public/common/zygote_fork_delegate_linux.h" | 40 #include "content/public/common/zygote_fork_delegate_linux.h" |
| 41 #include "content/zygote/zygote_linux.h" | 41 #include "content/zygote/zygote_linux.h" |
| 42 #include "crypto/nss_util.h" | 42 #include "crypto/nss_util.h" |
| 43 #include "sandbox/linux/services/credentials.h" | |
| 43 #include "sandbox/linux/services/init_process_reaper.h" | 44 #include "sandbox/linux/services/init_process_reaper.h" |
| 44 #include "sandbox/linux/services/libc_urandom_override.h" | 45 #include "sandbox/linux/services/libc_urandom_override.h" |
| 45 #include "sandbox/linux/services/namespace_sandbox.h" | 46 #include "sandbox/linux/services/namespace_sandbox.h" |
| 46 #include "sandbox/linux/services/thread_helpers.h" | 47 #include "sandbox/linux/services/thread_helpers.h" |
| 47 #include "sandbox/linux/suid/client/setuid_sandbox_client.h" | 48 #include "sandbox/linux/suid/client/setuid_sandbox_client.h" |
| 48 #include "third_party/icu/source/i18n/unicode/timezone.h" | 49 #include "third_party/icu/source/i18n/unicode/timezone.h" |
| 49 #include "third_party/skia/include/ports/SkFontConfigInterface.h" | 50 #include "third_party/skia/include/ports/SkFontConfigInterface.h" |
| 50 | 51 |
| 51 #if defined(OS_LINUX) | 52 #if defined(OS_LINUX) |
| 52 #include <sys/prctl.h> | 53 #include <sys/prctl.h> |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 399 if (getpid() == 1) { | 400 if (getpid() == 1) { |
| 400 // The setuid sandbox has created a new PID namespace and we need | 401 // The setuid sandbox has created a new PID namespace and we need |
| 401 // to assume the role of init. | 402 // to assume the role of init. |
| 402 CHECK(CreateInitProcessReaper(post_fork_parent_callback)); | 403 CHECK(CreateInitProcessReaper(post_fork_parent_callback)); |
| 403 } | 404 } |
| 404 | 405 |
| 405 CHECK(SandboxDebugHandling::SetDumpableStatusAndHandlers()); | 406 CHECK(SandboxDebugHandling::SetDumpableStatusAndHandlers()); |
| 406 return true; | 407 return true; |
| 407 } | 408 } |
| 408 | 409 |
| 410 static void DropAllCapabilities(int proc_fd, base::Closure* done) { | |
|
jln (very slow on Chromium)
2015/02/25 21:32:48
DropAllCapabilitiesAndRun()
jln (very slow on Chromium)
2015/02/25 21:32:49
I don't think there is a way in base:: to make a c
rickyz (no longer on Chrome)
2015/03/21 01:35:31
Done.
| |
| 411 LOG(ERROR) << "proc_fd: " << proc_fd; | |
|
jln (very slow on Chromium)
2015/02/25 21:32:48
oops
rickyz (no longer on Chrome)
2015/03/21 01:35:31
Done.
| |
| 412 CHECK(sandbox::Credentials::DropAllCapabilities(proc_fd)); | |
| 413 done->Run(); | |
| 414 } | |
| 415 | |
| 409 static void EnterNamespaceSandbox(LinuxSandbox* linux_sandbox, | 416 static void EnterNamespaceSandbox(LinuxSandbox* linux_sandbox, |
| 410 base::Closure* post_fork_parent_callback) { | 417 base::Closure* post_fork_parent_callback) { |
| 411 linux_sandbox->EngageNamespaceSandbox(); | 418 linux_sandbox->EngageNamespaceSandbox(); |
| 412 | 419 |
| 413 if (getpid() == 1) { | 420 if (getpid() == 1) { |
| 414 CHECK(CreateInitProcessReaper(post_fork_parent_callback)); | 421 base::Closure callback = |
| 422 base::Bind(&DropAllCapabilities, linux_sandbox->proc_fd(), | |
| 423 post_fork_parent_callback); | |
| 424 CHECK(CreateInitProcessReaper(&callback)); | |
| 415 } | 425 } |
| 416 } | 426 } |
| 417 | 427 |
| 418 #if defined(SANITIZER_COVERAGE) | 428 #if defined(SANITIZER_COVERAGE) |
| 419 const size_t kSanitizerMaxMessageLength = 1 * 1024 * 1024; | 429 const size_t kSanitizerMaxMessageLength = 1 * 1024 * 1024; |
| 420 | 430 |
| 421 // A helper process which collects code coverage data from the renderers over a | 431 // A helper process which collects code coverage data from the renderers over a |
| 422 // socket and dumps it to a file. See http://crbug.com/336212 for discussion. | 432 // socket and dumps it to a file. See http://crbug.com/336212 for discussion. |
| 423 static void SanitizerCoverageHelper(int socket_fd, int file_fd) { | 433 static void SanitizerCoverageHelper(int socket_fd, int file_fd) { |
| 424 scoped_ptr<char[]> buffer(new char[kSanitizerMaxMessageLength]); | 434 scoped_ptr<char[]> buffer(new char[kSanitizerMaxMessageLength]); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS; | 605 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS; |
| 596 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged); | 606 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged); |
| 597 | 607 |
| 598 Zygote zygote(sandbox_flags, fork_delegates.Pass(), extra_children, | 608 Zygote zygote(sandbox_flags, fork_delegates.Pass(), extra_children, |
| 599 extra_fds); | 609 extra_fds); |
| 600 // This function call can return multiple times, once per fork(). | 610 // This function call can return multiple times, once per fork(). |
| 601 return zygote.ProcessRequests(); | 611 return zygote.ProcessRequests(); |
| 602 } | 612 } |
| 603 | 613 |
| 604 } // namespace content | 614 } // namespace content |
| OLD | NEW |