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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "components/nacl/browser/nacl_host_message_filter.h" | 31 #include "components/nacl/browser/nacl_host_message_filter.h" |
32 #include "components/nacl/common/nacl_cmd_line.h" | 32 #include "components/nacl/common/nacl_cmd_line.h" |
33 #include "components/nacl/common/nacl_host_messages.h" | 33 #include "components/nacl/common/nacl_host_messages.h" |
34 #include "components/nacl/common/nacl_messages.h" | 34 #include "components/nacl/common/nacl_messages.h" |
35 #include "components/nacl/common/nacl_process_type.h" | 35 #include "components/nacl/common/nacl_process_type.h" |
36 #include "components/nacl/common/nacl_switches.h" | 36 #include "components/nacl/common/nacl_switches.h" |
37 #include "content/public/browser/browser_child_process_host.h" | 37 #include "content/public/browser/browser_child_process_host.h" |
38 #include "content/public/browser/browser_ppapi_host.h" | 38 #include "content/public/browser/browser_ppapi_host.h" |
39 #include "content/public/browser/child_process_data.h" | 39 #include "content/public/browser/child_process_data.h" |
40 #include "content/public/browser/plugin_service.h" | 40 #include "content/public/browser/plugin_service.h" |
| 41 #include "content/public/browser/render_process_host.h" |
41 #include "content/public/common/child_process_host.h" | 42 #include "content/public/common/child_process_host.h" |
42 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
43 #include "content/public/common/process_type.h" | 44 #include "content/public/common/process_type.h" |
44 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 45 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
45 #include "ipc/ipc_channel.h" | 46 #include "ipc/ipc_channel.h" |
46 #include "ipc/ipc_switches.h" | 47 #include "ipc/ipc_switches.h" |
47 #include "native_client/src/shared/imc/nacl_imc_c.h" | 48 #include "native_client/src/shared/imc/nacl_imc_c.h" |
48 #include "net/base/net_util.h" | 49 #include "net/base/net_util.h" |
49 #include "net/socket/tcp_listen_socket.h" | 50 #include "net/socket/tcp_listen_socket.h" |
50 #include "ppapi/host/host_factory.h" | 51 #include "ppapi/host/host_factory.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 reinterpret_cast<nacl::FileDescriptor>(channel)); | 222 reinterpret_cast<nacl::FileDescriptor>(channel)); |
222 #else | 223 #else |
223 nacl::FileDescriptor channel; | 224 nacl::FileDescriptor channel; |
224 channel.fd = sourceh; | 225 channel.fd = sourceh; |
225 channel.auto_close = close_source; | 226 channel.auto_close = close_source; |
226 handles_for_sel_ldr->push_back(channel); | 227 handles_for_sel_ldr->push_back(channel); |
227 #endif | 228 #endif |
228 return true; | 229 return true; |
229 } | 230 } |
230 | 231 |
231 ppapi::PpapiPermissions GetNaClPermissions(uint32 permission_bits) { | 232 ppapi::PpapiPermissions GetNaClPermissions( |
| 233 uint32 permission_bits, |
| 234 content::BrowserContext* browser_context, |
| 235 const GURL& document_url) { |
232 // Only allow NaCl plugins to request certain permissions. We don't want | 236 // Only allow NaCl plugins to request certain permissions. We don't want |
233 // a compromised renderer to be able to start a nacl plugin with e.g. Flash | 237 // a compromised renderer to be able to start a nacl plugin with e.g. Flash |
234 // permissions which may expand the surface area of the sandbox. | 238 // permissions which may expand the surface area of the sandbox. |
235 uint32 masked_bits = permission_bits & ppapi::PERMISSION_DEV; | 239 uint32 masked_bits = permission_bits & ppapi::PERMISSION_DEV; |
236 if (content::PluginService::GetInstance()->PpapiDevChannelSupported()) | 240 if (content::PluginService::GetInstance()->PpapiDevChannelSupported( |
| 241 browser_context, document_url)) |
237 masked_bits |= ppapi::PERMISSION_DEV_CHANNEL; | 242 masked_bits |= ppapi::PERMISSION_DEV_CHANNEL; |
238 return ppapi::PpapiPermissions::GetForCommandLine(masked_bits); | 243 return ppapi::PpapiPermissions::GetForCommandLine(masked_bits); |
239 } | 244 } |
240 | 245 |
241 } // namespace | 246 } // namespace |
242 | 247 |
243 namespace nacl { | 248 namespace nacl { |
244 | 249 |
245 struct NaClProcessHost::NaClInternal { | 250 struct NaClProcessHost::NaClInternal { |
246 NaClHandle socket_for_renderer; | 251 NaClHandle socket_for_renderer; |
247 NaClHandle socket_for_sel_ldr; | 252 NaClHandle socket_for_sel_ldr; |
248 | 253 |
249 NaClInternal() | 254 NaClInternal() |
250 : socket_for_renderer(NACL_INVALID_HANDLE), | 255 : socket_for_renderer(NACL_INVALID_HANDLE), |
251 socket_for_sel_ldr(NACL_INVALID_HANDLE) { } | 256 socket_for_sel_ldr(NACL_INVALID_HANDLE) { } |
252 }; | 257 }; |
253 | 258 |
254 // ----------------------------------------------------------------------------- | 259 // ----------------------------------------------------------------------------- |
255 | 260 |
256 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ = | 261 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ = |
257 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds; | 262 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds; |
258 | 263 |
259 NaClProcessHost::NaClProcessHost(const GURL& manifest_url, | 264 NaClProcessHost::NaClProcessHost(const GURL& document_url, |
| 265 const GURL& manifest_url, |
| 266 int render_process_id, |
260 int render_view_id, | 267 int render_view_id, |
261 uint32 permission_bits, | 268 uint32 permission_bits, |
262 bool uses_irt, | 269 bool uses_irt, |
263 bool uses_nonsfi_mode, | 270 bool uses_nonsfi_mode, |
264 bool enable_dyncode_syscalls, | 271 bool enable_dyncode_syscalls, |
265 bool enable_exception_handling, | 272 bool enable_exception_handling, |
266 bool enable_crash_throttling, | 273 bool enable_crash_throttling, |
267 bool off_the_record, | 274 bool off_the_record, |
268 const base::FilePath& profile_directory) | 275 const base::FilePath& profile_directory) |
269 : manifest_url_(manifest_url), | 276 : manifest_url_(manifest_url), |
270 permissions_(GetNaClPermissions(permission_bits)), | |
271 #if defined(OS_WIN) | 277 #if defined(OS_WIN) |
272 process_launched_by_broker_(false), | 278 process_launched_by_broker_(false), |
273 #endif | 279 #endif |
274 reply_msg_(NULL), | 280 reply_msg_(NULL), |
275 #if defined(OS_WIN) | 281 #if defined(OS_WIN) |
276 debug_exception_handler_requested_(false), | 282 debug_exception_handler_requested_(false), |
277 #endif | 283 #endif |
278 internal_(new NaClInternal()), | 284 internal_(new NaClInternal()), |
279 weak_factory_(this), | 285 weak_factory_(this), |
280 uses_irt_(uses_irt), | 286 uses_irt_(uses_irt), |
281 uses_nonsfi_mode_(uses_nonsfi_mode), | 287 uses_nonsfi_mode_(uses_nonsfi_mode), |
282 enable_debug_stub_(false), | 288 enable_debug_stub_(false), |
283 enable_dyncode_syscalls_(enable_dyncode_syscalls), | 289 enable_dyncode_syscalls_(enable_dyncode_syscalls), |
284 enable_exception_handling_(enable_exception_handling), | 290 enable_exception_handling_(enable_exception_handling), |
285 enable_crash_throttling_(enable_crash_throttling), | 291 enable_crash_throttling_(enable_crash_throttling), |
286 off_the_record_(off_the_record), | 292 off_the_record_(off_the_record), |
287 profile_directory_(profile_directory), | 293 profile_directory_(profile_directory), |
288 render_view_id_(render_view_id) { | 294 render_view_id_(render_view_id) { |
| 295 |
| 296 content::RenderProcessHost* host = |
| 297 content::RenderProcessHost::FromID(render_process_id); |
| 298 permissions_ = GetNaClPermissions(permission_bits, |
| 299 host->GetBrowserContext(), |
| 300 document_url); |
289 process_.reset(content::BrowserChildProcessHost::Create( | 301 process_.reset(content::BrowserChildProcessHost::Create( |
290 PROCESS_TYPE_NACL_LOADER, this)); | 302 PROCESS_TYPE_NACL_LOADER, this)); |
291 | 303 |
292 // Set the display name so the user knows what plugin the process is running. | 304 // Set the display name so the user knows what plugin the process is running. |
293 // We aren't on the UI thread so getting the pref locale for language | 305 // We aren't on the UI thread so getting the pref locale for language |
294 // formatting isn't possible, so IDN will be lost, but this is probably OK | 306 // formatting isn't possible, so IDN will be lost, but this is probably OK |
295 // for this use case. | 307 // for this use case. |
296 process_->SetName(net::FormatUrl(manifest_url_, std::string())); | 308 process_->SetName(net::FormatUrl(manifest_url_, std::string())); |
297 | 309 |
298 enable_debug_stub_ = CommandLine::ForCurrentProcess()->HasSwitch( | 310 enable_debug_stub_ = CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 process_handle.Take(), info, | 1143 process_handle.Take(), info, |
1132 base::MessageLoopProxy::current(), | 1144 base::MessageLoopProxy::current(), |
1133 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1145 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
1134 weak_factory_.GetWeakPtr())); | 1146 weak_factory_.GetWeakPtr())); |
1135 return true; | 1147 return true; |
1136 } | 1148 } |
1137 } | 1149 } |
1138 #endif | 1150 #endif |
1139 | 1151 |
1140 } // namespace nacl | 1152 } // namespace nacl |
OLD | NEW |