Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1524)

Side by Side Diff: components/nacl/browser/nacl_process_host.cc

Issue 332463003: Pepper: Remove LOAD_MODULE SRPC call in SFI mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes for mseaborn Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 socket_for_sel_ldr(NACL_INVALID_HANDLE) { } 243 socket_for_sel_ldr(NACL_INVALID_HANDLE) { }
244 }; 244 };
245 245
246 // ----------------------------------------------------------------------------- 246 // -----------------------------------------------------------------------------
247 247
248 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ = 248 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ =
249 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds; 249 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds;
250 250
251 NaClProcessHost::NaClProcessHost(const GURL& manifest_url, 251 NaClProcessHost::NaClProcessHost(const GURL& manifest_url,
252 base::File nexe_file, 252 base::File nexe_file,
253 NaClFileToken nexe_token,
253 ppapi::PpapiPermissions permissions, 254 ppapi::PpapiPermissions permissions,
254 int render_view_id, 255 int render_view_id,
255 uint32 permission_bits, 256 uint32 permission_bits,
256 bool uses_irt, 257 bool uses_irt,
257 bool uses_nonsfi_mode, 258 bool uses_nonsfi_mode,
258 bool enable_dyncode_syscalls, 259 bool enable_dyncode_syscalls,
259 bool enable_exception_handling, 260 bool enable_exception_handling,
260 bool enable_crash_throttling, 261 bool enable_crash_throttling,
261 bool off_the_record, 262 bool off_the_record,
262 const base::FilePath& profile_directory) 263 const base::FilePath& profile_directory)
263 : manifest_url_(manifest_url), 264 : manifest_url_(manifest_url),
264 nexe_file_(nexe_file.Pass()), 265 nexe_file_(nexe_file.Pass()),
266 nexe_token_(nexe_token),
265 permissions_(permissions), 267 permissions_(permissions),
266 #if defined(OS_WIN) 268 #if defined(OS_WIN)
267 process_launched_by_broker_(false), 269 process_launched_by_broker_(false),
268 #endif 270 #endif
269 reply_msg_(NULL), 271 reply_msg_(NULL),
270 #if defined(OS_WIN) 272 #if defined(OS_WIN)
271 debug_exception_handler_requested_(false), 273 debug_exception_handler_requested_(false),
272 #endif 274 #endif
273 internal_(new NaClInternal()), 275 internal_(new NaClInternal()),
274 weak_factory_(this), 276 weak_factory_(this),
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 } 812 }
811 #endif 813 #endif
812 814
813 bool NaClProcessHost::StartNaClExecution() { 815 bool NaClProcessHost::StartNaClExecution() {
814 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 816 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
815 817
816 NaClStartParams params; 818 NaClStartParams params;
817 819
818 // Enable PPAPI proxy channel creation only for renderer processes. 820 // Enable PPAPI proxy channel creation only for renderer processes.
819 params.enable_ipc_proxy = enable_ppapi_proxy(); 821 params.enable_ipc_proxy = enable_ppapi_proxy();
822 // nexe_file_ still keeps the ownership at this moment, because |params|
823 // may just be destroyed before sending IPC is properly processed.
824 // Note that although we set auto_close=true for FileDescriptor's
825 // constructor, it is not automatically handled in its destructor as RAII.
826 #if defined(OS_POSIX)
827 params.nexe_file =
828 base::FileDescriptor(nexe_file_.TakePlatformFile(), false);
Mark Seaborn 2014/07/08 18:46:00 This leaks the FD. You should either do: // take
teravest 2014/07/08 19:03:45 Yes, you're right. I wanted GetPlatformFile() here
829 #elif defined(OS_WIN)
830 params.nexe_file = IPC::GetFileHandleForProcess(nexe_file_.TakePlatformFile(),
Mark Seaborn 2014/07/08 18:46:00 This has a similar leak.
teravest 2014/07/08 19:03:45 Done.
831 process_->GetData().handle,
832 false);
833 #else
834 #error Unsupported target platform.
835 #endif
836
820 if (uses_nonsfi_mode_) { 837 if (uses_nonsfi_mode_) {
821 // Currently, non-SFI mode is supported only on Linux. 838 // Currently, non-SFI mode is supported only on Linux.
822 #if defined(OS_LINUX) 839 #if defined(OS_LINUX)
823 // nexe_file_ still keeps the ownership at this moment, because |params|
824 // may just be destroyed before sending IPC is properly processed.
825 // Note that although we set auto_close=true for FileDescriptor's
826 // constructor, it is not automatically handled in its destructor as RAII.
827 params.nexe_file =
828 base::FileDescriptor(nexe_file_.GetPlatformFile(), true);
829 // In non-SFI mode, we do not use SRPC. Make sure that the socketpair is 840 // In non-SFI mode, we do not use SRPC. Make sure that the socketpair is
830 // not created. 841 // not created.
831 DCHECK_EQ(internal_->socket_for_sel_ldr, NACL_INVALID_HANDLE); 842 DCHECK_EQ(internal_->socket_for_sel_ldr, NACL_INVALID_HANDLE);
832 #endif 843 #endif
833 } else { 844 } else {
834 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled(); 845 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled();
835 params.validation_cache_key = nacl_browser->GetValidationCacheKey(); 846 params.validation_cache_key = nacl_browser->GetValidationCacheKey();
836 params.version = NaClBrowser::GetDelegate()->GetVersionString(); 847 params.version = NaClBrowser::GetDelegate()->GetVersionString();
837 params.enable_exception_handling = enable_exception_handling_; 848 params.enable_exception_handling = enable_exception_handling_;
838 params.enable_debug_stub = enable_debug_stub_ && 849 params.enable_debug_stub = enable_debug_stub_ &&
839 NaClBrowser::GetDelegate()->URLMatchesDebugPatterns(manifest_url_); 850 NaClBrowser::GetDelegate()->URLMatchesDebugPatterns(manifest_url_);
840 params.uses_irt = uses_irt_; 851 params.uses_irt = uses_irt_;
841 params.enable_dyncode_syscalls = enable_dyncode_syscalls_; 852 params.enable_dyncode_syscalls = enable_dyncode_syscalls_;
842 853
854 // TODO(teravest): Resolve the file tokens right now instead of making the
855 // loader send IPC to resolve them later.
856 params.nexe_token_lo = nexe_token_.lo;
857 params.nexe_token_hi = nexe_token_.hi;
858
843 const ChildProcessData& data = process_->GetData(); 859 const ChildProcessData& data = process_->GetData();
844 if (!ShareHandleToSelLdr(data.handle, 860 if (!ShareHandleToSelLdr(data.handle,
845 internal_->socket_for_sel_ldr, true, 861 internal_->socket_for_sel_ldr, true,
846 &params.handles)) { 862 &params.handles)) {
847 return false; 863 return false;
848 } 864 }
849 865
850 if (params.uses_irt) { 866 if (params.uses_irt) {
851 const base::File& irt_file = nacl_browser->IrtFile(); 867 const base::File& irt_file = nacl_browser->IrtFile();
852 CHECK(irt_file.IsValid()); 868 CHECK(irt_file.IsValid());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 if (params.enable_debug_stub) { 900 if (params.enable_debug_stub) {
885 net::SocketDescriptor server_bound_socket = GetDebugStubSocketHandle(); 901 net::SocketDescriptor server_bound_socket = GetDebugStubSocketHandle();
886 if (server_bound_socket != net::kInvalidSocket) { 902 if (server_bound_socket != net::kInvalidSocket) {
887 params.debug_stub_server_bound_socket = 903 params.debug_stub_server_bound_socket =
888 FileDescriptor(server_bound_socket, true); 904 FileDescriptor(server_bound_socket, true);
889 } 905 }
890 } 906 }
891 #endif 907 #endif
892 } 908 }
893 909
894 // Here we are about to send the IPC, so release file descriptors to delegate 910 // Here we are about to send the IPC, so close the file descriptor in
895 // the ownership to the message. 911 // nexe_file_.
896 if (uses_nonsfi_mode_) { 912 nexe_file_.Close();
Mark Seaborn 2014/07/08 18:46:00 This has no effect, because the code did TakePlatf
teravest 2014/07/08 19:03:45 Done.
897 nexe_file_.TakePlatformFile(); 913 if (!uses_nonsfi_mode_) {
898 } else {
899 internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE; 914 internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE;
900 } 915 }
901 916
902 process_->Send(new NaClProcessMsg_Start(params)); 917 process_->Send(new NaClProcessMsg_Start(params));
903 return true; 918 return true;
904 } 919 }
905 920
906 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is 921 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is
907 // received. 922 // received.
908 void NaClProcessHost::OnPpapiChannelsCreated( 923 void NaClProcessHost::OnPpapiChannelsCreated(
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 process_handle.Take(), info, 1161 process_handle.Take(), info,
1147 base::MessageLoopProxy::current(), 1162 base::MessageLoopProxy::current(),
1148 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 1163 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
1149 weak_factory_.GetWeakPtr())); 1164 weak_factory_.GetWeakPtr()));
1150 return true; 1165 return true;
1151 } 1166 }
1152 } 1167 }
1153 #endif 1168 #endif
1154 1169
1155 } // namespace nacl 1170 } // namespace nacl
OLDNEW
« no previous file with comments | « components/nacl/browser/nacl_process_host.h ('k') | components/nacl/common/nacl_host_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698