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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 | 228 |
229 void CloseFile(base::File file) { | 229 void CloseFile(base::File file) { |
230 // The base::File destructor will close the file for us. | 230 // The base::File destructor will close the file for us. |
231 } | 231 } |
232 | 232 |
233 } // namespace | 233 } // namespace |
234 | 234 |
235 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ = | 235 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ = |
236 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds; | 236 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds; |
237 | 237 |
238 NaClProcessHost::NaClProcessHost(const GURL& manifest_url, | 238 NaClProcessHost::NaClProcessHost( |
239 base::File nexe_file, | 239 const GURL& manifest_url, |
240 const NaClFileToken& nexe_token, | 240 base::File nexe_file, |
241 ppapi::PpapiPermissions permissions, | 241 const NaClFileToken& nexe_token, |
242 int render_view_id, | 242 const std::vector< |
243 uint32 permission_bits, | 243 nacl::NaClResourceFileInfo>& prefetched_resource_files_info, |
244 bool uses_nonsfi_mode, | 244 ppapi::PpapiPermissions permissions, |
245 bool off_the_record, | 245 int render_view_id, |
246 NaClAppProcessType process_type, | 246 uint32 permission_bits, |
247 const base::FilePath& profile_directory) | 247 bool uses_nonsfi_mode, |
248 bool off_the_record, | |
249 NaClAppProcessType process_type, | |
250 const base::FilePath& profile_directory) | |
248 : manifest_url_(manifest_url), | 251 : manifest_url_(manifest_url), |
249 nexe_file_(nexe_file.Pass()), | 252 nexe_file_(nexe_file.Pass()), |
250 nexe_token_(nexe_token), | 253 nexe_token_(nexe_token), |
254 prefetched_resource_files_info_(prefetched_resource_files_info), | |
251 permissions_(permissions), | 255 permissions_(permissions), |
252 #if defined(OS_WIN) | 256 #if defined(OS_WIN) |
253 process_launched_by_broker_(false), | 257 process_launched_by_broker_(false), |
254 #endif | 258 #endif |
255 reply_msg_(NULL), | 259 reply_msg_(NULL), |
256 #if defined(OS_WIN) | 260 #if defined(OS_WIN) |
257 debug_exception_handler_requested_(false), | 261 debug_exception_handler_requested_(false), |
258 #endif | 262 #endif |
259 uses_nonsfi_mode_(uses_nonsfi_mode), | 263 uses_nonsfi_mode_(uses_nonsfi_mode), |
260 enable_debug_stub_(false), | 264 enable_debug_stub_(false), |
(...skipping 27 matching lines...) Expand all Loading... | |
288 base::StringPrintf("NaCl process exited with status %i (0x%x)", | 292 base::StringPrintf("NaCl process exited with status %i (0x%x)", |
289 exit_code, exit_code); | 293 exit_code, exit_code); |
290 if (exit_code == 0) { | 294 if (exit_code == 0) { |
291 VLOG(1) << message; | 295 VLOG(1) << message; |
292 } else { | 296 } else { |
293 LOG(ERROR) << message; | 297 LOG(ERROR) << message; |
294 } | 298 } |
295 NaClBrowser::GetInstance()->OnProcessEnd(process_->GetData().id); | 299 NaClBrowser::GetInstance()->OnProcessEnd(process_->GetData().id); |
296 } | 300 } |
297 | 301 |
302 for (size_t i = 0; i < prefetched_resource_files_info_.size(); ++i) { | |
303 // The process failed to launch for some reason. Close resource file | |
304 // handles. | |
305 base::File file(IPC::PlatformFileForTransitToFile( | |
306 prefetched_resource_files_info_[i].file)); | |
307 content::BrowserThread::GetBlockingPool()->PostTask( | |
308 FROM_HERE, | |
309 base::Bind(&CloseFile, base::Passed(file.Pass()))); | |
310 } | |
311 | |
298 if (reply_msg_) { | 312 if (reply_msg_) { |
299 // The process failed to launch for some reason. | 313 // The process failed to launch for some reason. |
300 // Don't keep the renderer hanging. | 314 // Don't keep the renderer hanging. |
301 reply_msg_->set_reply_error(); | 315 reply_msg_->set_reply_error(); |
302 nacl_host_message_filter_->Send(reply_msg_); | 316 nacl_host_message_filter_->Send(reply_msg_); |
303 } | 317 } |
304 #if defined(OS_WIN) | 318 #if defined(OS_WIN) |
305 if (process_launched_by_broker_) { | 319 if (process_launched_by_broker_) { |
306 NaClBrokerService::GetInstance()->OnLoaderDied(); | 320 NaClBrokerService::GetInstance()->OnLoaderDied(); |
307 } | 321 } |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
879 #endif | 893 #endif |
880 } | 894 } |
881 | 895 |
882 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle, | 896 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle, |
883 ¶ms.crash_info_shmem_handle)) { | 897 ¶ms.crash_info_shmem_handle)) { |
884 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer"; | 898 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer"; |
885 return false; | 899 return false; |
886 } | 900 } |
887 | 901 |
888 base::FilePath file_path; | 902 base::FilePath file_path; |
889 // Don't retrieve the file path when using nonsfi mode; there's no validation | 903 if (uses_nonsfi_mode_) { |
Mark Seaborn
2015/02/25 20:01:23
See comment below. If you gate the handling of pr
Yusuke Sato
2015/03/01 06:59:37
Done.
| |
890 // caching in that case, so it's unnecessary work, and would expose the file | 904 // Don't retrieve the file path when using nonsfi mode; there's no |
891 // path to the plugin. | 905 // validation caching in that case, so it's unnecessary work, and would |
892 if (!uses_nonsfi_mode_ && | 906 // expose the file path to the plugin. |
893 NaClBrowser::GetInstance()->GetFilePath(nexe_token_.lo, | 907 |
894 nexe_token_.hi, | 908 // Pass the pre-opened resource files to the loader. For the same reason |
895 &file_path)) { | 909 // as above, use an empty base::FilePath. |
896 // We have to reopen the file in the browser process; we don't want a | 910 for (size_t i = 0; i < prefetched_resource_files_info_.size(); ++i) { |
897 // compromised renderer to pass an arbitrary fd that could get loaded | 911 params.prefetched_resource_files.push_back( |
898 // into the plugin process. | 912 NaClResourceFileInfo(prefetched_resource_files_info_[i].file, |
899 if (base::PostTaskAndReplyWithResult( | 913 base::FilePath(), |
900 content::BrowserThread::GetBlockingPool(), | 914 prefetched_resource_files_info_[i].file_key)); |
901 FROM_HERE, | |
902 base::Bind(OpenNaClReadExecImpl, | |
903 file_path, | |
904 true /* is_executable */), | |
905 base::Bind(&NaClProcessHost::StartNaClFileResolved, | |
906 weak_factory_.GetWeakPtr(), | |
907 params, | |
908 file_path))) { | |
909 return true; | |
910 } | 915 } |
916 prefetched_resource_files_info_.clear(); | |
917 } else { | |
918 if (NaClBrowser::GetInstance()->GetFilePath(nexe_token_.lo, | |
919 nexe_token_.hi, | |
920 &file_path)) { | |
921 // We have to reopen the file in the browser process; we don't want a | |
922 // compromised renderer to pass an arbitrary fd that could get loaded | |
923 // into the plugin process. | |
924 if (base::PostTaskAndReplyWithResult( | |
925 content::BrowserThread::GetBlockingPool(), | |
926 FROM_HERE, | |
927 base::Bind(OpenNaClReadExecImpl, | |
928 file_path, | |
929 true /* is_executable */), | |
930 base::Bind(&NaClProcessHost::StartNaClFileResolved, | |
931 weak_factory_.GetWeakPtr(), | |
932 params, | |
933 file_path))) { | |
934 return true; | |
935 } | |
936 } | |
937 // TODO(yusukes): Handle |prefetched_resource_files_info_| for SFI-NaCl. | |
938 CHECK(prefetched_resource_files_info_.empty()); | |
Mark Seaborn
2015/02/25 20:01:23
It's not clear whether this would allow the render
Yusuke Sato
2015/03/01 06:59:37
Done.
| |
911 } | 939 } |
912 | 940 |
913 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(), | 941 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(), |
914 process_->GetData().handle); | 942 process_->GetData().handle); |
915 process_->Send(new NaClProcessMsg_Start(params)); | 943 process_->Send(new NaClProcessMsg_Start(params)); |
916 return true; | 944 return true; |
917 } | 945 } |
918 | 946 |
919 void NaClProcessHost::StartNaClFileResolved( | 947 void NaClProcessHost::StartNaClFileResolved( |
920 NaClStartParams params, | 948 NaClStartParams params, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1180 process.Pass(), info, | 1208 process.Pass(), info, |
1181 base::MessageLoopProxy::current(), | 1209 base::MessageLoopProxy::current(), |
1182 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1210 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
1183 weak_factory_.GetWeakPtr())); | 1211 weak_factory_.GetWeakPtr())); |
1184 return true; | 1212 return true; |
1185 } | 1213 } |
1186 } | 1214 } |
1187 #endif | 1215 #endif |
1188 | 1216 |
1189 } // namespace nacl | 1217 } // namespace nacl |
OLD | NEW |