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

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

Issue 877153005: sandbox: extract SetuidSandboxHost code from SetuidSandboxClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to jln/hidehiko feedback; clang-format Created 5 years, 10 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 | « no previous file | content/browser/browser_main_loop.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>
(...skipping 17 matching lines...) Expand all
28 #include "base/process/launch.h" 28 #include "base/process/launch.h"
29 #include "base/strings/string_split.h" 29 #include "base/strings/string_split.h"
30 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 30 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
31 #include "build/build_config.h" 31 #include "build/build_config.h"
32 #include "components/nacl/common/nacl_nonsfi_util.h" 32 #include "components/nacl/common/nacl_nonsfi_util.h"
33 #include "components/nacl/common/nacl_paths.h" 33 #include "components/nacl/common/nacl_paths.h"
34 #include "components/nacl/common/nacl_switches.h" 34 #include "components/nacl/common/nacl_switches.h"
35 #include "components/nacl/loader/nacl_helper_linux.h" 35 #include "components/nacl/loader/nacl_helper_linux.h"
36 #include "content/public/common/content_descriptors.h" 36 #include "content/public/common/content_descriptors.h"
37 #include "content/public/common/content_switches.h" 37 #include "content/public/common/content_switches.h"
38 #include "sandbox/linux/suid/client/setuid_sandbox_client.h" 38 #include "sandbox/linux/suid/client/setuid_sandbox_host.h"
39 #include "sandbox/linux/suid/common/sandbox.h" 39 #include "sandbox/linux/suid/common/sandbox.h"
40 40
41 namespace { 41 namespace {
42 42
43 // Note these need to match up with their counterparts in nacl_helper_linux.c 43 // Note these need to match up with their counterparts in nacl_helper_linux.c
44 // and nacl_helper_bootstrap_linux.c. 44 // and nacl_helper_bootstrap_linux.c.
45 const char kNaClHelperReservedAtZero[] = 45 const char kNaClHelperReservedAtZero[] =
46 "--reserved_at_zero=0xXXXXXXXXXXXXXXXX"; 46 "--reserved_at_zero=0xXXXXXXXXXXXXXXXX";
47 const char kNaClHelperRDebug[] = "--r_debug=0xXXXXXXXXXXXXXXXX"; 47 const char kNaClHelperRDebug[] = "--r_debug=0xXXXXXXXXXXXXXXXX";
48 48
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 void NaClForkDelegate::Init(const int sandboxdesc, 140 void NaClForkDelegate::Init(const int sandboxdesc,
141 const bool enable_layer1_sandbox) { 141 const bool enable_layer1_sandbox) {
142 VLOG(1) << "NaClForkDelegate::Init()"; 142 VLOG(1) << "NaClForkDelegate::Init()";
143 143
144 // Only launch the non-SFI helper process if non-SFI mode is enabled. 144 // Only launch the non-SFI helper process if non-SFI mode is enabled.
145 if (nonsfi_mode_ && !IsNonSFIModeEnabled()) { 145 if (nonsfi_mode_ && !IsNonSFIModeEnabled()) {
146 return; 146 return;
147 } 147 }
148 148
149 scoped_ptr<sandbox::SetuidSandboxClient> setuid_sandbox_client( 149 scoped_ptr<sandbox::SetuidSandboxHost> setuid_sandbox_host(
150 sandbox::SetuidSandboxClient::Create()); 150 sandbox::SetuidSandboxHost::Create());
151 151
152 // For communications between the NaCl loader process and 152 // For communications between the NaCl loader process and
153 // the SUID sandbox. 153 // the SUID sandbox.
154 int nacl_sandbox_descriptor = 154 int nacl_sandbox_descriptor =
155 base::GlobalDescriptors::kBaseDescriptor + kSandboxIPCChannel; 155 base::GlobalDescriptors::kBaseDescriptor + kSandboxIPCChannel;
156 // Confirm a hard-wired assumption. 156 // Confirm a hard-wired assumption.
157 DCHECK_EQ(sandboxdesc, nacl_sandbox_descriptor); 157 DCHECK_EQ(sandboxdesc, nacl_sandbox_descriptor);
158 158
159 int fds[2]; 159 int fds[2];
160 PCHECK(0 == socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds)); 160 PCHECK(0 == socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 bootstrap_prepend.begin(), 235 bootstrap_prepend.begin(),
236 bootstrap_prepend.end()); 236 bootstrap_prepend.end());
237 } 237 }
238 238
239 base::LaunchOptions options; 239 base::LaunchOptions options;
240 240
241 base::ScopedFD dummy_fd; 241 base::ScopedFD dummy_fd;
242 if (enable_layer1_sandbox) { 242 if (enable_layer1_sandbox) {
243 // NaCl needs to keep tight control of the cmd_line, so prepend the 243 // NaCl needs to keep tight control of the cmd_line, so prepend the
244 // setuid sandbox wrapper manually. 244 // setuid sandbox wrapper manually.
245 base::FilePath sandbox_path = 245 base::FilePath sandbox_path = setuid_sandbox_host->GetSandboxBinaryPath();
246 setuid_sandbox_client->GetSandboxBinaryPath();
247 argv_to_launch.insert(argv_to_launch.begin(), sandbox_path.value()); 246 argv_to_launch.insert(argv_to_launch.begin(), sandbox_path.value());
248 setuid_sandbox_client->SetupLaunchOptions( 247 setuid_sandbox_host->SetupLaunchOptions(&options, &fds_to_map, &dummy_fd);
249 &options, &fds_to_map, &dummy_fd); 248 setuid_sandbox_host->SetupLaunchEnvironment();
250 setuid_sandbox_client->SetupLaunchEnvironment();
251 } 249 }
252 250
253 options.fds_to_remap = &fds_to_map; 251 options.fds_to_remap = &fds_to_map;
254 252
255 // The NaCl processes spawned may need to exceed the ambient soft limit 253 // The NaCl processes spawned may need to exceed the ambient soft limit
256 // on RLIMIT_AS to allocate the untrusted address space and its guard 254 // on RLIMIT_AS to allocate the untrusted address space and its guard
257 // regions. The nacl_helper itself cannot just raise its own limit, 255 // regions. The nacl_helper itself cannot just raise its own limit,
258 // because the existing limit may prevent the initial exec of 256 // because the existing limit may prevent the initial exec of
259 // nacl_helper_bootstrap from succeeding, with its large address space 257 // nacl_helper_bootstrap from succeeding, with its large address space
260 // reservation. 258 // reservation.
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 pass_through_vars.push_back(kNaClVerbosity); 435 pass_through_vars.push_back(kNaClVerbosity);
438 pass_through_vars.push_back(sandbox::kSandboxEnvironmentApiRequest); 436 pass_through_vars.push_back(sandbox::kSandboxEnvironmentApiRequest);
439 for (size_t i = 0; i < pass_through_vars.size(); ++i) { 437 for (size_t i = 0; i < pass_through_vars.size(); ++i) {
440 std::string temp; 438 std::string temp;
441 if (env->GetVar(pass_through_vars[i].c_str(), &temp)) 439 if (env->GetVar(pass_through_vars[i].c_str(), &temp))
442 options->environ[pass_through_vars[i]] = temp; 440 options->environ[pass_through_vars[i]] = temp;
443 } 441 }
444 } 442 }
445 443
446 } // namespace nacl 444 } // namespace nacl
OLDNEW
« no previous file with comments | « no previous file | content/browser/browser_main_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698