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

Side by Side Diff: components/nacl/zygote/nacl_fork_delegate_linux.cc

Issue 22911027: Pass StatsTable shared memory via global descriptors on Posix rather than using named shared memory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add empty line Created 7 years, 2 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 | « components/nacl/common/nacl_helper_linux.h ('k') | content/browser/child_process_launcher.cc » ('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 "components/nacl/zygote/nacl_fork_delegate_linux.h" 5 #include "components/nacl/zygote/nacl_fork_delegate_linux.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <sys/resource.h> 9 #include <sys/resource.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
11 11
12 #include <set> 12 #include <set>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/cpu.h" 16 #include "base/cpu.h"
17 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/path_service.h" 19 #include "base/path_service.h"
20 #include "base/pickle.h" 20 #include "base/pickle.h"
21 #include "base/posix/eintr_wrapper.h" 21 #include "base/posix/eintr_wrapper.h"
22 #include "base/posix/global_descriptors.h"
22 #include "base/posix/unix_domain_socket_linux.h" 23 #include "base/posix/unix_domain_socket_linux.h"
23 #include "base/process/kill.h" 24 #include "base/process/kill.h"
24 #include "base/process/launch.h" 25 #include "base/process/launch.h"
25 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 26 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
26 #include "components/nacl/common/nacl_helper_linux.h" 27 #include "components/nacl/common/nacl_helper_linux.h"
27 #include "components/nacl/common/nacl_paths.h" 28 #include "components/nacl/common/nacl_paths.h"
28 #include "components/nacl/common/nacl_switches.h" 29 #include "components/nacl/common/nacl_switches.h"
30 #include "content/public/common/content_descriptors.h"
29 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
30 32
31 namespace { 33 namespace {
32 34
33 // Note these need to match up with their counterparts in nacl_helper_linux.c 35 // Note these need to match up with their counterparts in nacl_helper_linux.c
34 // and nacl_helper_bootstrap_linux.c. 36 // and nacl_helper_bootstrap_linux.c.
35 const char kNaClHelperReservedAtZero[] = 37 const char kNaClHelperReservedAtZero[] =
36 "--reserved_at_zero=0xXXXXXXXXXXXXXXXX"; 38 "--reserved_at_zero=0xXXXXXXXXXXXXXXXX";
37 const char kNaClHelperRDebug[] = "--r_debug=0xXXXXXXXXXXXXXXXX"; 39 const char kNaClHelperRDebug[] = "--r_debug=0xXXXXXXXXXXXXXXXX";
38 40
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } // namespace. 105 } // namespace.
104 106
105 NaClForkDelegate::NaClForkDelegate() 107 NaClForkDelegate::NaClForkDelegate()
106 : status_(kNaClHelperUnused), 108 : status_(kNaClHelperUnused),
107 fd_(-1) {} 109 fd_(-1) {}
108 110
109 void NaClForkDelegate::Init(const int sandboxdesc) { 111 void NaClForkDelegate::Init(const int sandboxdesc) {
110 VLOG(1) << "NaClForkDelegate::Init()"; 112 VLOG(1) << "NaClForkDelegate::Init()";
111 int fds[2]; 113 int fds[2];
112 114
115 // For communications between the NaCl loader process and
116 // the SUID sandbox.
117 int nacl_sandbox_descriptor =
118 base::GlobalDescriptors::kBaseDescriptor + kSandboxIPCChannel;
113 // Confirm a hard-wired assumption. 119 // Confirm a hard-wired assumption.
114 // The NaCl constant is from chrome/nacl/nacl_linux_helper.h 120 DCHECK_EQ(sandboxdesc, nacl_sandbox_descriptor);
115 DCHECK(kNaClSandboxDescriptor == sandboxdesc);
116 121
117 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0); 122 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0);
118 base::FileHandleMappingVector fds_to_map; 123 base::FileHandleMappingVector fds_to_map;
119 fds_to_map.push_back(std::make_pair(fds[1], kNaClZygoteDescriptor)); 124 fds_to_map.push_back(std::make_pair(fds[1], kNaClZygoteDescriptor));
120 fds_to_map.push_back(std::make_pair(sandboxdesc, kNaClSandboxDescriptor)); 125 fds_to_map.push_back(std::make_pair(sandboxdesc, nacl_sandbox_descriptor));
121 126
122 // Using nacl_helper_bootstrap is not necessary on x86-64 because 127 // Using nacl_helper_bootstrap is not necessary on x86-64 because
123 // NaCl's x86-64 sandbox is not zero-address-based. Starting 128 // NaCl's x86-64 sandbox is not zero-address-based. Starting
124 // nacl_helper through nacl_helper_bootstrap works on x86-64, but it 129 // nacl_helper through nacl_helper_bootstrap works on x86-64, but it
125 // leaves nacl_helper_bootstrap mapped at a fixed address at the 130 // leaves nacl_helper_bootstrap mapped at a fixed address at the
126 // bottom of the address space, which is undesirable because it 131 // bottom of the address space, which is undesirable because it
127 // effectively defeats ASLR. 132 // effectively defeats ASLR.
128 #if defined(ARCH_CPU_X86_64) 133 #if defined(ARCH_CPU_X86_64)
129 bool kUseNaClBootstrap = false; 134 bool kUseNaClBootstrap = false;
130 #elif defined(ARCH_CPU_X86) 135 #elif defined(ARCH_CPU_X86)
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 int remote_exit_code; 337 int remote_exit_code;
333 if (!iter.ReadInt(&remote_exit_code)) { 338 if (!iter.ReadInt(&remote_exit_code)) {
334 LOG(ERROR) << "GetTerminationStatus: pickle failed"; 339 LOG(ERROR) << "GetTerminationStatus: pickle failed";
335 return false; 340 return false;
336 } 341 }
337 342
338 *status = static_cast<base::TerminationStatus>(termination_status); 343 *status = static_cast<base::TerminationStatus>(termination_status);
339 *exit_code = remote_exit_code; 344 *exit_code = remote_exit_code;
340 return true; 345 return true;
341 } 346 }
OLDNEW
« no previous file with comments | « components/nacl/common/nacl_helper_linux.h ('k') | content/browser/child_process_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698