| 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" |
| 42 #include "content/public/browser/web_contents.h" |
| 41 #include "content/public/common/child_process_host.h" | 43 #include "content/public/common/child_process_host.h" |
| 42 #include "content/public/common/content_switches.h" | 44 #include "content/public/common/content_switches.h" |
| 43 #include "content/public/common/process_type.h" | 45 #include "content/public/common/process_type.h" |
| 44 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 46 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| 45 #include "ipc/ipc_channel.h" | 47 #include "ipc/ipc_channel.h" |
| 46 #include "ipc/ipc_switches.h" | 48 #include "ipc/ipc_switches.h" |
| 47 #include "native_client/src/shared/imc/nacl_imc_c.h" | 49 #include "native_client/src/shared/imc/nacl_imc_c.h" |
| 48 #include "net/base/net_util.h" | 50 #include "net/base/net_util.h" |
| 49 #include "net/socket/tcp_listen_socket.h" | 51 #include "net/socket/tcp_listen_socket.h" |
| 50 #include "ppapi/host/host_factory.h" | 52 #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)); | 223 reinterpret_cast<nacl::FileDescriptor>(channel)); |
| 222 #else | 224 #else |
| 223 nacl::FileDescriptor channel; | 225 nacl::FileDescriptor channel; |
| 224 channel.fd = sourceh; | 226 channel.fd = sourceh; |
| 225 channel.auto_close = close_source; | 227 channel.auto_close = close_source; |
| 226 handles_for_sel_ldr->push_back(channel); | 228 handles_for_sel_ldr->push_back(channel); |
| 227 #endif | 229 #endif |
| 228 return true; | 230 return true; |
| 229 } | 231 } |
| 230 | 232 |
| 231 ppapi::PpapiPermissions GetNaClPermissions(uint32 permission_bits) { | |
| 232 // 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 | |
| 234 // permissions which may expand the surface area of the sandbox. | |
| 235 uint32 masked_bits = permission_bits & ppapi::PERMISSION_DEV; | |
| 236 if (content::PluginService::GetInstance()->PpapiDevChannelSupported()) | |
| 237 masked_bits |= ppapi::PERMISSION_DEV_CHANNEL; | |
| 238 return ppapi::PpapiPermissions::GetForCommandLine(masked_bits); | |
| 239 } | |
| 240 | |
| 241 } // namespace | 233 } // namespace |
| 242 | 234 |
| 243 namespace nacl { | 235 namespace nacl { |
| 244 | 236 |
| 245 struct NaClProcessHost::NaClInternal { | 237 struct NaClProcessHost::NaClInternal { |
| 246 NaClHandle socket_for_renderer; | 238 NaClHandle socket_for_renderer; |
| 247 NaClHandle socket_for_sel_ldr; | 239 NaClHandle socket_for_sel_ldr; |
| 248 | 240 |
| 249 NaClInternal() | 241 NaClInternal() |
| 250 : socket_for_renderer(NACL_INVALID_HANDLE), | 242 : socket_for_renderer(NACL_INVALID_HANDLE), |
| 251 socket_for_sel_ldr(NACL_INVALID_HANDLE) { } | 243 socket_for_sel_ldr(NACL_INVALID_HANDLE) { } |
| 252 }; | 244 }; |
| 253 | 245 |
| 254 // ----------------------------------------------------------------------------- | 246 // ----------------------------------------------------------------------------- |
| 255 | 247 |
| 256 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ = | 248 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ = |
| 257 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds; | 249 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds; |
| 258 | 250 |
| 259 NaClProcessHost::NaClProcessHost(const GURL& manifest_url, | 251 NaClProcessHost::NaClProcessHost(const GURL& manifest_url, |
| 252 ppapi::PpapiPermissions permissions, |
| 260 int render_view_id, | 253 int render_view_id, |
| 261 uint32 permission_bits, | 254 uint32 permission_bits, |
| 262 bool uses_irt, | 255 bool uses_irt, |
| 263 bool uses_nonsfi_mode, | 256 bool uses_nonsfi_mode, |
| 264 bool enable_dyncode_syscalls, | 257 bool enable_dyncode_syscalls, |
| 265 bool enable_exception_handling, | 258 bool enable_exception_handling, |
| 266 bool enable_crash_throttling, | 259 bool enable_crash_throttling, |
| 267 bool off_the_record, | 260 bool off_the_record, |
| 268 const base::FilePath& profile_directory) | 261 const base::FilePath& profile_directory) |
| 269 : manifest_url_(manifest_url), | 262 : manifest_url_(manifest_url), |
| 270 permissions_(GetNaClPermissions(permission_bits)), | 263 permissions_(permissions), |
| 271 #if defined(OS_WIN) | 264 #if defined(OS_WIN) |
| 272 process_launched_by_broker_(false), | 265 process_launched_by_broker_(false), |
| 273 #endif | 266 #endif |
| 274 reply_msg_(NULL), | 267 reply_msg_(NULL), |
| 275 #if defined(OS_WIN) | 268 #if defined(OS_WIN) |
| 276 debug_exception_handler_requested_(false), | 269 debug_exception_handler_requested_(false), |
| 277 #endif | 270 #endif |
| 278 internal_(new NaClInternal()), | 271 internal_(new NaClInternal()), |
| 279 weak_factory_(this), | 272 weak_factory_(this), |
| 280 uses_irt_(uses_irt), | 273 uses_irt_(uses_irt), |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1131 process_handle.Take(), info, | 1124 process_handle.Take(), info, |
| 1132 base::MessageLoopProxy::current(), | 1125 base::MessageLoopProxy::current(), |
| 1133 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1126 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
| 1134 weak_factory_.GetWeakPtr())); | 1127 weak_factory_.GetWeakPtr())); |
| 1135 return true; | 1128 return true; |
| 1136 } | 1129 } |
| 1137 } | 1130 } |
| 1138 #endif | 1131 #endif |
| 1139 | 1132 |
| 1140 } // namespace nacl | 1133 } // namespace nacl |
| OLD | NEW |