Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: content/zygote/zygote_main_linux.cc

Issue 1041163003: Revert of Start all children in their own PID namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/zygote/zygote_linux.cc ('k') | sandbox/linux/services/credentials.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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"
44 #include "sandbox/linux/services/init_process_reaper.h" 43 #include "sandbox/linux/services/init_process_reaper.h"
45 #include "sandbox/linux/services/libc_urandom_override.h" 44 #include "sandbox/linux/services/libc_urandom_override.h"
46 #include "sandbox/linux/services/namespace_sandbox.h" 45 #include "sandbox/linux/services/namespace_sandbox.h"
47 #include "sandbox/linux/services/thread_helpers.h" 46 #include "sandbox/linux/services/thread_helpers.h"
48 #include "sandbox/linux/suid/client/setuid_sandbox_client.h" 47 #include "sandbox/linux/suid/client/setuid_sandbox_client.h"
49 #include "third_party/icu/source/i18n/unicode/timezone.h" 48 #include "third_party/icu/source/i18n/unicode/timezone.h"
50 #include "third_party/skia/include/ports/SkFontConfigInterface.h" 49 #include "third_party/skia/include/ports/SkFontConfigInterface.h"
51 50
52 #if defined(OS_LINUX) 51 #if defined(OS_LINUX)
53 #include <sys/prctl.h> 52 #include <sys/prctl.h>
(...skipping 20 matching lines...) Expand all
74 namespace content { 73 namespace content {
75 74
76 namespace { 75 namespace {
77 76
78 void CloseFds(const std::vector<int>& fds) { 77 void CloseFds(const std::vector<int>& fds) {
79 for (const auto& it : fds) { 78 for (const auto& it : fds) {
80 PCHECK(0 == IGNORE_EINTR(close(it))); 79 PCHECK(0 == IGNORE_EINTR(close(it)));
81 } 80 }
82 } 81 }
83 82
84 void RunTwoClosures(const base::Closure* first, const base::Closure* second) {
85 first->Run();
86 second->Run();
87 }
88
89 } // namespace 83 } // namespace
90 84
91 // See http://code.google.com/p/chromium/wiki/LinuxZygote 85 // See http://code.google.com/p/chromium/wiki/LinuxZygote
92 86
93 static void ProxyLocaltimeCallToBrowser(time_t input, struct tm* output, 87 static void ProxyLocaltimeCallToBrowser(time_t input, struct tm* output,
94 char* timezone_out, 88 char* timezone_out,
95 size_t timezone_out_len) { 89 size_t timezone_out_len) {
96 Pickle request; 90 Pickle request;
97 request.WriteInt(LinuxSandbox::METHOD_LOCALTIME); 91 request.WriteInt(LinuxSandbox::METHOD_LOCALTIME);
98 request.WriteString( 92 request.WriteString(
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 if (getpid() == 1) { 400 if (getpid() == 1) {
407 // 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
408 // to assume the role of init. 402 // to assume the role of init.
409 CHECK(CreateInitProcessReaper(post_fork_parent_callback)); 403 CHECK(CreateInitProcessReaper(post_fork_parent_callback));
410 } 404 }
411 405
412 CHECK(SandboxDebugHandling::SetDumpableStatusAndHandlers()); 406 CHECK(SandboxDebugHandling::SetDumpableStatusAndHandlers());
413 return true; 407 return true;
414 } 408 }
415 409
416 static void DropAllCapabilities(int proc_fd) {
417 CHECK(sandbox::Credentials::DropAllCapabilities(proc_fd));
418 }
419
420 static void EnterNamespaceSandbox(LinuxSandbox* linux_sandbox, 410 static void EnterNamespaceSandbox(LinuxSandbox* linux_sandbox,
421 base::Closure* post_fork_parent_callback) { 411 base::Closure* post_fork_parent_callback) {
422 linux_sandbox->EngageNamespaceSandbox(); 412 linux_sandbox->EngageNamespaceSandbox();
423 413
424 if (getpid() == 1) { 414 if (getpid() == 1) {
425 base::Closure drop_all_caps_callback = 415 CHECK(CreateInitProcessReaper(post_fork_parent_callback));
426 base::Bind(&DropAllCapabilities, linux_sandbox->proc_fd());
427 base::Closure callback = base::Bind(
428 &RunTwoClosures, &drop_all_caps_callback, post_fork_parent_callback);
429 CHECK(CreateInitProcessReaper(&callback));
430 } 416 }
431 } 417 }
432 418
433 #if defined(SANITIZER_COVERAGE) 419 #if defined(SANITIZER_COVERAGE)
434 const size_t kSanitizerMaxMessageLength = 1 * 1024 * 1024; 420 const size_t kSanitizerMaxMessageLength = 1 * 1024 * 1024;
435 421
436 // A helper process which collects code coverage data from the renderers over a 422 // A helper process which collects code coverage data from the renderers over a
437 // socket and dumps it to a file. See http://crbug.com/336212 for discussion. 423 // socket and dumps it to a file. See http://crbug.com/336212 for discussion.
438 static void SanitizerCoverageHelper(int socket_fd, int file_fd) { 424 static void SanitizerCoverageHelper(int socket_fd, int file_fd) {
439 scoped_ptr<char[]> buffer(new char[kSanitizerMaxMessageLength]); 425 scoped_ptr<char[]> buffer(new char[kSanitizerMaxMessageLength]);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS; 596 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS;
611 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged); 597 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged);
612 598
613 Zygote zygote(sandbox_flags, fork_delegates.Pass(), extra_children, 599 Zygote zygote(sandbox_flags, fork_delegates.Pass(), extra_children,
614 extra_fds); 600 extra_fds);
615 // This function call can return multiple times, once per fork(). 601 // This function call can return multiple times, once per fork().
616 return zygote.ProcessRequests(); 602 return zygote.ProcessRequests();
617 } 603 }
618 604
619 } // namespace content 605 } // namespace content
OLDNEW
« no previous file with comments | « content/zygote/zygote_linux.cc ('k') | sandbox/linux/services/credentials.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698