| 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 "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 Loading... |
| 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 Loading... |
| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = |
| 246 setuid_sandbox_client->GetSandboxBinaryPath(); | 246 setuid_sandbox_host->GetSandboxBinaryPath(); |
| 247 argv_to_launch.insert(argv_to_launch.begin(), sandbox_path.value()); | 247 argv_to_launch.insert(argv_to_launch.begin(), sandbox_path.value()); |
| 248 setuid_sandbox_client->SetupLaunchOptions( | 248 setuid_sandbox_host->SetupLaunchOptions( |
| 249 &options, &fds_to_map, &dummy_fd); | 249 &options, &fds_to_map, &dummy_fd); |
| 250 setuid_sandbox_client->SetupLaunchEnvironment(); | 250 setuid_sandbox_host->SetupLaunchEnvironment(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 options.fds_to_remap = &fds_to_map; | 253 options.fds_to_remap = &fds_to_map; |
| 254 | 254 |
| 255 // The NaCl processes spawned may need to exceed the ambient soft limit | 255 // 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 | 256 // on RLIMIT_AS to allocate the untrusted address space and its guard |
| 257 // regions. The nacl_helper itself cannot just raise its own limit, | 257 // regions. The nacl_helper itself cannot just raise its own limit, |
| 258 // because the existing limit may prevent the initial exec of | 258 // because the existing limit may prevent the initial exec of |
| 259 // nacl_helper_bootstrap from succeeding, with its large address space | 259 // nacl_helper_bootstrap from succeeding, with its large address space |
| 260 // reservation. | 260 // reservation. |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 pass_through_vars.push_back(kNaClVerbosity); | 437 pass_through_vars.push_back(kNaClVerbosity); |
| 438 pass_through_vars.push_back(sandbox::kSandboxEnvironmentApiRequest); | 438 pass_through_vars.push_back(sandbox::kSandboxEnvironmentApiRequest); |
| 439 for (size_t i = 0; i < pass_through_vars.size(); ++i) { | 439 for (size_t i = 0; i < pass_through_vars.size(); ++i) { |
| 440 std::string temp; | 440 std::string temp; |
| 441 if (env->GetVar(pass_through_vars[i].c_str(), &temp)) | 441 if (env->GetVar(pass_through_vars[i].c_str(), &temp)) |
| 442 options->environ[pass_through_vars[i]] = temp; | 442 options->environ[pass_through_vars[i]] = temp; |
| 443 } | 443 } |
| 444 } | 444 } |
| 445 | 445 |
| 446 } // namespace nacl | 446 } // namespace nacl |
| OLD | NEW |