| 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/browser/nacl_process_host.h" | 5 #include "components/nacl/browser/nacl_process_host.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 namespace { | 158 namespace { |
| 159 | 159 |
| 160 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 160 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 161 content::ZygoteHandle g_nacl_zygote; | 161 content::ZygoteHandle g_nacl_zygote; |
| 162 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) | 162 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
| 163 | 163 |
| 164 // NOTE: changes to this class need to be reviewed by the security team. | 164 // NOTE: changes to this class need to be reviewed by the security team. |
| 165 class NaClSandboxedProcessLauncherDelegate | 165 class NaClSandboxedProcessLauncherDelegate |
| 166 : public content::SandboxedProcessLauncherDelegate { | 166 : public content::SandboxedProcessLauncherDelegate { |
| 167 public: | 167 public: |
| 168 NaClSandboxedProcessLauncherDelegate(ChildProcessHost* host) | 168 NaClSandboxedProcessLauncherDelegate(ChildProcessHost* host) {} |
| 169 #if defined(OS_POSIX) | |
| 170 : ipc_fd_(host->TakeClientFileDescriptor()) | |
| 171 #endif | |
| 172 {} | |
| 173 | 169 |
| 174 ~NaClSandboxedProcessLauncherDelegate() override {} | 170 ~NaClSandboxedProcessLauncherDelegate() override {} |
| 175 | 171 |
| 176 #if defined(OS_WIN) | 172 #if defined(OS_WIN) |
| 177 void PostSpawnTarget(base::ProcessHandle process) override { | 173 void PostSpawnTarget(base::ProcessHandle process) override { |
| 178 // For Native Client sel_ldr processes on 32-bit Windows, reserve 1 GB of | 174 // For Native Client sel_ldr processes on 32-bit Windows, reserve 1 GB of |
| 179 // address space to prevent later failure due to address space fragmentation | 175 // address space to prevent later failure due to address space fragmentation |
| 180 // from .dll loading. The NaCl process will attempt to locate this space by | 176 // from .dll loading. The NaCl process will attempt to locate this space by |
| 181 // scanning the address space using VirtualQuery. | 177 // scanning the address space using VirtualQuery. |
| 182 // TODO(bbudge) Handle the --no-sandbox case. | 178 // TODO(bbudge) Handle the --no-sandbox case. |
| 183 // http://code.google.com/p/nativeclient/issues/detail?id=2131 | 179 // http://code.google.com/p/nativeclient/issues/detail?id=2131 |
| 184 const SIZE_T kNaClSandboxSize = 1 << 30; | 180 const SIZE_T kNaClSandboxSize = 1 << 30; |
| 185 if (!nacl::AllocateAddressSpaceASLR(process, kNaClSandboxSize)) { | 181 if (!nacl::AllocateAddressSpaceASLR(process, kNaClSandboxSize)) { |
| 186 DLOG(WARNING) << "Failed to reserve address space for Native Client"; | 182 DLOG(WARNING) << "Failed to reserve address space for Native Client"; |
| 187 } | 183 } |
| 188 } | 184 } |
| 189 #elif defined(OS_POSIX) | 185 #elif defined(OS_POSIX) |
| 190 #if !defined(OS_MACOSX) | 186 #if !defined(OS_MACOSX) |
| 191 content::ZygoteHandle* GetZygote() override { | 187 content::ZygoteHandle* GetZygote() override { |
| 192 return content::GetGenericZygote(); | 188 return content::GetGenericZygote(); |
| 193 } | 189 } |
| 194 #endif // !defined(OS_MACOSX) | 190 #endif // !defined(OS_MACOSX) |
| 195 | |
| 196 base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } | |
| 197 #endif // OS_WIN | 191 #endif // OS_WIN |
| 198 | |
| 199 private: | |
| 200 #if defined(OS_POSIX) | |
| 201 base::ScopedFD ipc_fd_; | |
| 202 #endif // OS_POSIX | |
| 203 }; | 192 }; |
| 204 | 193 |
| 205 void CloseFile(base::File file) { | 194 void CloseFile(base::File file) { |
| 206 // The base::File destructor will close the file for us. | 195 // The base::File destructor will close the file for us. |
| 207 } | 196 } |
| 208 | 197 |
| 209 } // namespace | 198 } // namespace |
| 210 | 199 |
| 211 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ = | 200 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ = |
| 212 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds; | 201 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds; |
| (...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1300 NaClStartDebugExceptionHandlerThread( | 1289 NaClStartDebugExceptionHandlerThread( |
| 1301 std::move(process), info, base::ThreadTaskRunnerHandle::Get(), | 1290 std::move(process), info, base::ThreadTaskRunnerHandle::Get(), |
| 1302 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1291 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
| 1303 weak_factory_.GetWeakPtr())); | 1292 weak_factory_.GetWeakPtr())); |
| 1304 return true; | 1293 return true; |
| 1305 } | 1294 } |
| 1306 } | 1295 } |
| 1307 #endif | 1296 #endif |
| 1308 | 1297 |
| 1309 } // namespace nacl | 1298 } // namespace nacl |
| OLD | NEW |