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 <string.h> | 11 #include <string.h> |
| 11 #include <sys/socket.h> | 12 #include <sys/socket.h> |
| 12 #include <sys/types.h> | 13 #include <sys/types.h> |
| 13 #include <unistd.h> | 14 #include <unistd.h> |
| 14 | 15 |
| 15 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 16 #include "base/bind.h" | 17 #include "base/bind.h" |
| 17 #include "base/command_line.h" | 18 #include "base/command_line.h" |
| 18 #include "base/compiler_specific.h" | 19 #include "base/compiler_specific.h" |
| 19 #include "base/memory/scoped_vector.h" | 20 #include "base/memory/scoped_vector.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 #if defined(ENABLE_WEBRTC) | 58 #if defined(ENABLE_WEBRTC) |
| 58 #include "third_party/libjingle/overrides/init_webrtc.h" | 59 #include "third_party/libjingle/overrides/init_webrtc.h" |
| 59 #endif | 60 #endif |
| 60 | 61 |
| 61 #if defined(ADDRESS_SANITIZER) | 62 #if defined(ADDRESS_SANITIZER) |
| 62 #include <sanitizer/asan_interface.h> | 63 #include <sanitizer/asan_interface.h> |
| 63 #endif | 64 #endif |
| 64 | 65 |
| 65 namespace content { | 66 namespace content { |
| 66 | 67 |
| 68 namespace { | |
| 69 | |
| 70 void DoChrootSignalHandler(int) { | |
| 71 ignore_result(chroot("/")); | |
|
mdempsky
2014/09/19 23:07:46
Do we want to do anything special if this returns?
| |
| 72 } | |
| 73 | |
| 74 // This is a quick hack to allow testing sandbox crash reports in protection | |
| 75 // binaries. | |
| 76 // This installs a signal handler for SIGUSR2 that performs a chroot(). | |
| 77 // In most of our BPF policies, it is a "watched" system call which will | |
| 78 // trigger a SIGSYS signal whose handler will crash. | |
| 79 // This has been added during the investigation of https://crbug.com/415842. | |
| 80 void InstallSandboxCrashTestHandler() { | |
| 81 struct sigaction act = {}; | |
| 82 act.sa_handler = DoChrootSignalHandler; | |
| 83 CHECK_EQ(0, sigemptyset(&act.sa_mask)); | |
| 84 act.sa_flags = 0; | |
| 85 | |
| 86 PCHECK(0 == sigaction(SIGUSR2, &act, NULL)); | |
| 87 } | |
| 88 | |
| 89 } | |
| 90 | |
| 67 // See http://code.google.com/p/chromium/wiki/LinuxZygote | 91 // See http://code.google.com/p/chromium/wiki/LinuxZygote |
| 68 | 92 |
| 69 static void ProxyLocaltimeCallToBrowser(time_t input, struct tm* output, | 93 static void ProxyLocaltimeCallToBrowser(time_t input, struct tm* output, |
| 70 char* timezone_out, | 94 char* timezone_out, |
| 71 size_t timezone_out_len) { | 95 size_t timezone_out_len) { |
| 72 Pickle request; | 96 Pickle request; |
| 73 request.WriteInt(LinuxSandbox::METHOD_LOCALTIME); | 97 request.WriteInt(LinuxSandbox::METHOD_LOCALTIME); |
| 74 request.WriteString( | 98 request.WriteString( |
| 75 std::string(reinterpret_cast<char*>(&input), sizeof(input))); | 99 std::string(reinterpret_cast<char*>(&input), sizeof(input))); |
| 76 | 100 |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 // issues, one can specify --allow-sandbox-debugging to let the process be | 428 // issues, one can specify --allow-sandbox-debugging to let the process be |
| 405 // dumpable. | 429 // dumpable. |
| 406 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 430 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 407 if (!command_line.HasSwitch(switches::kAllowSandboxDebugging)) { | 431 if (!command_line.HasSwitch(switches::kAllowSandboxDebugging)) { |
| 408 prctl(PR_SET_DUMPABLE, 0, 0, 0, 0); | 432 prctl(PR_SET_DUMPABLE, 0, 0, 0, 0); |
| 409 if (prctl(PR_GET_DUMPABLE, 0, 0, 0, 0)) { | 433 if (prctl(PR_GET_DUMPABLE, 0, 0, 0, 0)) { |
| 410 LOG(ERROR) << "Failed to set non-dumpable flag"; | 434 LOG(ERROR) << "Failed to set non-dumpable flag"; |
| 411 return false; | 435 return false; |
| 412 } | 436 } |
| 413 } | 437 } |
| 438 | |
| 439 InstallSandboxCrashTestHandler(); | |
| 414 #endif | 440 #endif |
| 415 | 441 |
| 416 return true; | 442 return true; |
| 417 } | 443 } |
| 418 | 444 |
| 419 #if defined(ADDRESS_SANITIZER) | 445 #if defined(ADDRESS_SANITIZER) |
| 420 const size_t kSanitizerMaxMessageLength = 1 * 1024 * 1024; | 446 const size_t kSanitizerMaxMessageLength = 1 * 1024 * 1024; |
| 421 | 447 |
| 422 // A helper process which collects code coverage data from the renderers over a | 448 // A helper process which collects code coverage data from the renderers over a |
| 423 // socket and dumps it to a file. See http://crbug.com/336212 for discussion. | 449 // socket and dumps it to a file. See http://crbug.com/336212 for discussion. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 571 bool setuid_sandbox_engaged = sandbox_flags & kSandboxLinuxSUID; | 597 bool setuid_sandbox_engaged = sandbox_flags & kSandboxLinuxSUID; |
| 572 CHECK_EQ(must_enable_setuid_sandbox, setuid_sandbox_engaged); | 598 CHECK_EQ(must_enable_setuid_sandbox, setuid_sandbox_engaged); |
| 573 | 599 |
| 574 Zygote zygote(sandbox_flags, fork_delegates.Pass(), extra_children, | 600 Zygote zygote(sandbox_flags, fork_delegates.Pass(), extra_children, |
| 575 extra_fds); | 601 extra_fds); |
| 576 // This function call can return multiple times, once per fork(). | 602 // This function call can return multiple times, once per fork(). |
| 577 return zygote.ProcessRequests(); | 603 return zygote.ProcessRequests(); |
| 578 } | 604 } |
| 579 | 605 |
| 580 } // namespace content | 606 } // namespace content |
| OLD | NEW |