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

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

Issue 216603002: Tell nacl_helper to use non SFI mode in HandleForkRequest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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
« no previous file with comments | « chrome/app/chrome_main_delegate.cc ('k') | components/nacl/common/nacl_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 // We'll make sure this actually finished in StartWithLaunchedProcess, below. 422 // We'll make sure this actually finished in StartWithLaunchedProcess, below.
423 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 423 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
424 nacl_browser->EnsureAllResourcesAvailable(); 424 nacl_browser->EnsureAllResourcesAvailable();
425 if (!nacl_browser->IsOk()) { 425 if (!nacl_browser->IsOk()) {
426 SendErrorToRenderer("could not find all the resources needed" 426 SendErrorToRenderer("could not find all the resources needed"
427 " to launch the process"); 427 " to launch the process");
428 delete this; 428 delete this;
429 return; 429 return;
430 } 430 }
431 431
432 if (uses_nonsfi_mode_) {
433 #if defined(OS_LINUX)
434 const bool kNonSFIModeSupported = true;
435 #else
436 const bool kNonSFIModeSupported = false;
437 #endif
438 if (!kNonSFIModeSupported ||
439 !cmd->HasSwitch(switches::kEnableNaClNonSfiMode)) {
440 SendErrorToRenderer("NaCl non-SFI mode works only on Linux with"
441 " --enable-nacl-nonsfi-mode specified");
442 delete this;
443 return;
444 }
445 }
446
432 // Rather than creating a socket pair in the renderer, and passing 447 // Rather than creating a socket pair in the renderer, and passing
433 // one side through the browser to sel_ldr, socket pairs are created 448 // one side through the browser to sel_ldr, socket pairs are created
434 // in the browser and then passed to the renderer and sel_ldr. 449 // in the browser and then passed to the renderer and sel_ldr.
435 // 450 //
436 // This is mainly for the benefit of Windows, where sockets cannot 451 // This is mainly for the benefit of Windows, where sockets cannot
437 // be passed in messages, but are copied via DuplicateHandle(). 452 // be passed in messages, but are copied via DuplicateHandle().
438 // This means the sandboxed renderer cannot send handles to the 453 // This means the sandboxed renderer cannot send handles to the
439 // browser process. 454 // browser process.
440 455
441 NaClHandle pair[2]; 456 NaClHandle pair[2];
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 env->SetVar(kPath, new_path); 600 env->SetVar(kPath, new_path);
586 } 601 }
587 #endif // _DLL 602 #endif // _DLL
588 } 603 }
589 #endif 604 #endif
590 605
591 scoped_ptr<CommandLine> cmd_line(new CommandLine(exe_path)); 606 scoped_ptr<CommandLine> cmd_line(new CommandLine(exe_path));
592 CopyNaClCommandLineArguments(cmd_line.get()); 607 CopyNaClCommandLineArguments(cmd_line.get());
593 608
594 cmd_line->AppendSwitchASCII(switches::kProcessType, 609 cmd_line->AppendSwitchASCII(switches::kProcessType,
595 switches::kNaClLoaderProcess); 610 (uses_nonsfi_mode_ ?
611 switches::kNaClLoaderNonSfiProcess :
612 switches::kNaClLoaderProcess));
596 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); 613 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id);
597 if (NaClBrowser::GetDelegate()->DialogsAreSuppressed()) 614 if (NaClBrowser::GetDelegate()->DialogsAreSuppressed())
598 cmd_line->AppendSwitch(switches::kNoErrorDialogs); 615 cmd_line->AppendSwitch(switches::kNoErrorDialogs);
599 616
600 // On Windows we might need to start the broker process to launch a new loader 617 // On Windows we might need to start the broker process to launch a new loader
601 #if defined(OS_WIN) 618 #if defined(OS_WIN)
602 if (RunningOnWOW64()) { 619 if (RunningOnWOW64()) {
603 if (!NaClBrokerService::GetInstance()->LaunchLoader( 620 if (!NaClBrokerService::GetInstance()->LaunchLoader(
604 weak_factory_.GetWeakPtr(), channel_id)) { 621 weak_factory_.GetWeakPtr(), channel_id)) {
605 SendErrorToRenderer("broker service did not launch process"); 622 SendErrorToRenderer("broker service did not launch process");
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled(); 787 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled();
771 params.validation_cache_key = nacl_browser->GetValidationCacheKey(); 788 params.validation_cache_key = nacl_browser->GetValidationCacheKey();
772 params.version = NaClBrowser::GetDelegate()->GetVersionString(); 789 params.version = NaClBrowser::GetDelegate()->GetVersionString();
773 params.enable_exception_handling = enable_exception_handling_; 790 params.enable_exception_handling = enable_exception_handling_;
774 params.enable_debug_stub = enable_debug_stub_ && 791 params.enable_debug_stub = enable_debug_stub_ &&
775 NaClBrowser::GetDelegate()->URLMatchesDebugPatterns(manifest_url_); 792 NaClBrowser::GetDelegate()->URLMatchesDebugPatterns(manifest_url_);
776 // Enable PPAPI proxy channel creation only for renderer processes. 793 // Enable PPAPI proxy channel creation only for renderer processes.
777 params.enable_ipc_proxy = enable_ppapi_proxy(); 794 params.enable_ipc_proxy = enable_ppapi_proxy();
778 params.uses_irt = uses_irt_; 795 params.uses_irt = uses_irt_;
779 params.enable_dyncode_syscalls = enable_dyncode_syscalls_; 796 params.enable_dyncode_syscalls = enable_dyncode_syscalls_;
780 params.uses_nonsfi_mode = uses_nonsfi_mode_;
781 797
782 const ChildProcessData& data = process_->GetData(); 798 const ChildProcessData& data = process_->GetData();
783 if (!ShareHandleToSelLdr(data.handle, 799 if (!ShareHandleToSelLdr(data.handle,
784 internal_->socket_for_sel_ldr, true, 800 internal_->socket_for_sel_ldr, true,
785 &params.handles)) { 801 &params.handles)) {
786 return false; 802 return false;
787 } 803 }
788 804
789 if (params.uses_irt) { 805 if (params.uses_irt) {
790 base::PlatformFile irt_file = nacl_browser->IrtFile(); 806 base::PlatformFile irt_file = nacl_browser->IrtFile();
(...skipping 29 matching lines...) Expand all
820 #if defined(OS_POSIX) 836 #if defined(OS_POSIX)
821 if (params.enable_debug_stub) { 837 if (params.enable_debug_stub) {
822 net::SocketDescriptor server_bound_socket = GetDebugStubSocketHandle(); 838 net::SocketDescriptor server_bound_socket = GetDebugStubSocketHandle();
823 if (server_bound_socket != net::kInvalidSocket) { 839 if (server_bound_socket != net::kInvalidSocket) {
824 params.debug_stub_server_bound_socket = 840 params.debug_stub_server_bound_socket =
825 FileDescriptor(server_bound_socket, true); 841 FileDescriptor(server_bound_socket, true);
826 } 842 }
827 } 843 }
828 #endif 844 #endif
829 845
830 if (params.uses_nonsfi_mode) {
831 #if defined(OS_LINUX)
832 const bool kNonSFIModeSupported = true;
833 #else
834 const bool kNonSFIModeSupported = false;
835 #endif
836 if (!kNonSFIModeSupported ||
837 !CommandLine::ForCurrentProcess()->HasSwitch(
838 switches::kEnableNaClNonSfiMode)) {
839 return false;
840 }
841 }
842
843 process_->Send(new NaClProcessMsg_Start(params)); 846 process_->Send(new NaClProcessMsg_Start(params));
844 847
845 internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE; 848 internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE;
846 return true; 849 return true;
847 } 850 }
848 851
849 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is 852 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is
850 // received. 853 // received.
851 void NaClProcessHost::OnPpapiChannelsCreated( 854 void NaClProcessHost::OnPpapiChannelsCreated(
852 const IPC::ChannelHandle& browser_channel_handle, 855 const IPC::ChannelHandle& browser_channel_handle,
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 process_handle.Take(), info, 1084 process_handle.Take(), info,
1082 base::MessageLoopProxy::current(), 1085 base::MessageLoopProxy::current(),
1083 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 1086 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
1084 weak_factory_.GetWeakPtr())); 1087 weak_factory_.GetWeakPtr()));
1085 return true; 1088 return true;
1086 } 1089 }
1087 } 1090 }
1088 #endif 1091 #endif
1089 1092
1090 } // namespace nacl 1093 } // namespace nacl
OLDNEW
« no previous file with comments | « chrome/app/chrome_main_delegate.cc ('k') | components/nacl/common/nacl_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698