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

Side by Side Diff: chrome/browser/nacl_host/nacl_process_host.cc

Issue 14750007: NaCl: enable meta-based validation for shared libraries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More edits Created 7 years, 7 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 "chrome/browser/nacl_host/nacl_process_host.h" 5 #include "chrome/browser/nacl_host/nacl_process_host.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 return true; 616 return true;
617 } 617 }
618 618
619 bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { 619 bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) {
620 bool handled = true; 620 bool handled = true;
621 IPC_BEGIN_MESSAGE_MAP(NaClProcessHost, msg) 621 IPC_BEGIN_MESSAGE_MAP(NaClProcessHost, msg)
622 IPC_MESSAGE_HANDLER(NaClProcessMsg_QueryKnownToValidate, 622 IPC_MESSAGE_HANDLER(NaClProcessMsg_QueryKnownToValidate,
623 OnQueryKnownToValidate) 623 OnQueryKnownToValidate)
624 IPC_MESSAGE_HANDLER(NaClProcessMsg_SetKnownToValidate, 624 IPC_MESSAGE_HANDLER(NaClProcessMsg_SetKnownToValidate,
625 OnSetKnownToValidate) 625 OnSetKnownToValidate)
626 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClProcessMsg_ResolveFileNonce,
627 OnResolveFileNonce)
626 #if defined(OS_WIN) 628 #if defined(OS_WIN)
627 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClProcessMsg_AttachDebugExceptionHandler, 629 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClProcessMsg_AttachDebugExceptionHandler,
628 OnAttachDebugExceptionHandler) 630 OnAttachDebugExceptionHandler)
629 #endif 631 #endif
630 IPC_MESSAGE_HANDLER(NaClProcessHostMsg_PpapiChannelCreated, 632 IPC_MESSAGE_HANDLER(NaClProcessHostMsg_PpapiChannelCreated,
631 OnPpapiChannelCreated) 633 OnPpapiChannelCreated)
632 IPC_MESSAGE_UNHANDLED(handled = false) 634 IPC_MESSAGE_UNHANDLED(handled = false)
633 IPC_END_MESSAGE_MAP() 635 IPC_END_MESSAGE_MAP()
634 return handled; 636 return handled;
635 } 637 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 const ChildProcessData& data = process_->GetData(); 756 const ChildProcessData& data = process_->GetData();
755 if (!ShareHandleToSelLdr(data.handle, 757 if (!ShareHandleToSelLdr(data.handle,
756 internal_->socket_for_sel_ldr, true, 758 internal_->socket_for_sel_ldr, true,
757 &params.handles)) { 759 &params.handles)) {
758 return false; 760 return false;
759 } 761 }
760 762
761 if (params.uses_irt) { 763 if (params.uses_irt) {
762 base::PlatformFile irt_file = nacl_browser->IrtFile(); 764 base::PlatformFile irt_file = nacl_browser->IrtFile();
763 CHECK_NE(irt_file, base::kInvalidPlatformFileValue); 765 CHECK_NE(irt_file, base::kInvalidPlatformFileValue);
764
765 // Send over the IRT file handle. We don't close our own copy! 766 // Send over the IRT file handle. We don't close our own copy!
766 if (!ShareHandleToSelLdr(data.handle, irt_file, false, &params.handles)) 767 if (!ShareHandleToSelLdr(data.handle, irt_file, false, &params.handles))
767 return false; 768 return false;
768 } 769 }
769 770
770 #if defined(OS_MACOSX) 771 #if defined(OS_MACOSX)
771 // For dynamic loading support, NaCl requires a file descriptor that 772 // For dynamic loading support, NaCl requires a file descriptor that
772 // was created in /tmp, since those created with shm_open() are not 773 // was created in /tmp, since those created with shm_open() are not
773 // mappable with PROT_EXEC. Rather than requiring an extra IPC 774 // mappable with PROT_EXEC. Rather than requiring an extra IPC
774 // round trip out of the sandbox, we create an FD here. 775 // round trip out of the sandbox, we create an FD here.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 void NaClProcessHost::OnQueryKnownToValidate(const std::string& signature, 924 void NaClProcessHost::OnQueryKnownToValidate(const std::string& signature,
924 bool* result) { 925 bool* result) {
925 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 926 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
926 *result = nacl_browser->QueryKnownToValidate(signature, off_the_record_); 927 *result = nacl_browser->QueryKnownToValidate(signature, off_the_record_);
927 } 928 }
928 929
929 void NaClProcessHost::OnSetKnownToValidate(const std::string& signature) { 930 void NaClProcessHost::OnSetKnownToValidate(const std::string& signature) {
930 NaClBrowser::GetInstance()->SetKnownToValidate(signature, off_the_record_); 931 NaClBrowser::GetInstance()->SetKnownToValidate(signature, off_the_record_);
931 } 932 }
932 933
934 void NaClProcessHost::FileResolved(
935 base::PlatformFile* file,
936 const base::FilePath& file_path,
937 IPC::Message* reply_msg) {
938
Mark Seaborn 2013/05/16 23:01:47 Remove empty line at function start
Nick Bray (chromium) 2013/05/21 20:09:06 Done.
939 if (*file != base::kInvalidPlatformFileValue) {
940 IPC::PlatformFileForTransit handle = IPC::GetFileHandleForProcess(
941 *file,
942 process_->GetData().handle,
943 true /* close_source */);
944 NaClProcessMsg_ResolveFileNonce::WriteReplyParams(
945 reply_msg,
946 handle,
947 file_path);
948 } else {
949 NaClProcessMsg_ResolveFileNonce::WriteReplyParams(
950 reply_msg,
951 IPC::InvalidPlatformFileForTransit(),
952 base::FilePath(FILE_PATH_LITERAL("")));
953 }
954 Send(reply_msg);
955 }
956
957 void NaClProcessHost::OnResolveFileNonce(uint64 nonce,
958 IPC::Message* reply_msg) {
959 // Was the file registered?
960 // Note that the file path cache is of bounded size, and old entries can get
961 // evicted. If a large number of NaCl modules are being launched at once,
962 // resolving the nonce may fail because the path cache was thrashed while the
Mark Seaborn 2013/05/16 23:01:47 As I said in the other comment, this is bad, so yo
Nick Bray (chromium) 2013/05/21 20:09:06 The cache is big enough this shouldn't happen in p
963 // nonce was in flight. In this case the query fails, and we need to fall
964 // back to the slower path.
965 base::FilePath file_path;
966 if (!NaClBrowser::GetInstance()->GetFilePath(nonce, &file_path)){
Mark Seaborn 2013/05/16 23:01:47 Add space: ") {"
Nick Bray (chromium) 2013/05/21 20:09:06 Done.
967 NaClProcessMsg_ResolveFileNonce::WriteReplyParams(
Mark Seaborn 2013/05/16 23:01:47 Wrong indentation here (it's using 2+3 instead of
Nick Bray (chromium) 2013/05/21 20:09:06 Done.
968 reply_msg,
969 IPC::InvalidPlatformFileForTransit(),
970 base::FilePath(FILE_PATH_LITERAL("")));
971 Send(reply_msg);
972 return;
973 }
974
975 // Scratch space to share between the callbacks.
976 base::PlatformFile* data = new base::PlatformFile();
977
978 // Open the file.
979 if (!content::BrowserThread::PostBlockingPoolTaskAndReply(
980 FROM_HERE,
Mark Seaborn 2013/05/16 23:01:47 Indent the function's arguments
Nick Bray (chromium) 2013/05/21 20:09:06 They are. Four space indent. Which is ambiguous
981 base::Bind(nacl::OpenNaClExecutableImpl,
982 file_path, data),
983 base::Bind(&NaClProcessHost::FileResolved,
984 weak_factory_.GetWeakPtr(),
985 base::Owned(data),
986 file_path,
987 reply_msg))) {
988 NaClProcessMsg_ResolveFileNonce::WriteReplyParams(
989 reply_msg,
990 IPC::InvalidPlatformFileForTransit(),
991 base::FilePath(FILE_PATH_LITERAL("")));
992 Send(reply_msg);
993 }
994 }
995
933 #if defined(OS_WIN) 996 #if defined(OS_WIN)
934 void NaClProcessHost::OnAttachDebugExceptionHandler(const std::string& info, 997 void NaClProcessHost::OnAttachDebugExceptionHandler(const std::string& info,
935 IPC::Message* reply_msg) { 998 IPC::Message* reply_msg) {
936 if (!AttachDebugExceptionHandler(info, reply_msg)) { 999 if (!AttachDebugExceptionHandler(info, reply_msg)) {
937 // Send failure message. 1000 // Send failure message.
938 NaClProcessMsg_AttachDebugExceptionHandler::WriteReplyParams(reply_msg, 1001 NaClProcessMsg_AttachDebugExceptionHandler::WriteReplyParams(reply_msg,
939 false); 1002 false);
940 Send(reply_msg); 1003 Send(reply_msg);
941 } 1004 }
942 } 1005 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 } else { 1054 } else {
992 NaClStartDebugExceptionHandlerThread( 1055 NaClStartDebugExceptionHandlerThread(
993 process_handle.Take(), info, 1056 process_handle.Take(), info,
994 base::MessageLoopProxy::current(), 1057 base::MessageLoopProxy::current(),
995 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 1058 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
996 weak_factory_.GetWeakPtr())); 1059 weak_factory_.GetWeakPtr()));
997 return true; 1060 return true;
998 } 1061 }
999 } 1062 }
1000 #endif 1063 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698