summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/nacl/browser/nacl_host_message_filter.cc2
-rw-r--r--components/nacl/browser/nacl_process_host.cc27
-rw-r--r--components/nacl/browser/nacl_process_host.h4
-rw-r--r--components/nacl/common/nacl_host_messages.h1
-rw-r--r--components/nacl/common/nacl_messages.h1
-rw-r--r--components/nacl/common/nacl_types.cc44
-rw-r--r--components/nacl/common/nacl_types.h9
-rw-r--r--components/nacl/loader/nacl_listener.cc12
-rw-r--r--components/nacl/loader/nonsfi/nonsfi_main.cc122
-rw-r--r--components/nacl/loader/nonsfi/nonsfi_main.h7
-rw-r--r--components/nacl/renderer/ppb_nacl_private_impl.cc24
-rw-r--r--ppapi/api/private/ppb_nacl_private.idl4
-rw-r--r--ppapi/c/private/ppb_nacl_private.h6
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.cc28
-rw-r--r--ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc2
-rw-r--r--ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h1
-rw-r--r--ppapi/native_client/src/trusted/plugin/service_runtime.cc12
-rw-r--r--ppapi/native_client/src/trusted/plugin/service_runtime.h3
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c6
19 files changed, 154 insertions, 161 deletions
diff --git a/components/nacl/browser/nacl_host_message_filter.cc b/components/nacl/browser/nacl_host_message_filter.cc
index 16f55929..d98ac71 100644
--- a/components/nacl/browser/nacl_host_message_filter.cc
+++ b/components/nacl/browser/nacl_host_message_filter.cc
@@ -143,6 +143,8 @@ void NaClHostMessageFilter::LaunchNaClContinuation(
ppapi::PpapiPermissions permissions) {
NaClProcessHost* host = new NaClProcessHost(
GURL(launch_params.manifest_url),
+ base::File(
+ IPC::PlatformFileForTransitToPlatformFile(launch_params.nexe_file)),
permissions,
launch_params.render_view_id,
launch_params.permission_bits,
diff --git a/components/nacl/browser/nacl_process_host.cc b/components/nacl/browser/nacl_process_host.cc
index 6a4af07..728fff6 100644
--- a/components/nacl/browser/nacl_process_host.cc
+++ b/components/nacl/browser/nacl_process_host.cc
@@ -249,6 +249,7 @@ unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ =
ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds;
NaClProcessHost::NaClProcessHost(const GURL& manifest_url,
+ base::File nexe_file,
ppapi::PpapiPermissions permissions,
int render_view_id,
uint32 permission_bits,
@@ -260,6 +261,7 @@ NaClProcessHost::NaClProcessHost(const GURL& manifest_url,
bool off_the_record,
const base::FilePath& profile_directory)
: manifest_url_(manifest_url),
+ nexe_file_(nexe_file.Pass()),
permissions_(permissions),
#if defined(OS_WIN)
process_launched_by_broker_(false),
@@ -448,6 +450,9 @@ void NaClProcessHost::Launch(
}
}
+ // TODO(hidehiko): We no longer use imc socket channel for non-SFI mode.
+ // Do not create it.
+
// Rather than creating a socket pair in the renderer, and passing
// one side through the browser to sel_ldr, socket pairs are created
// in the browser and then passed to the renderer and sel_ldr.
@@ -812,9 +817,20 @@ bool NaClProcessHost::StartNaClExecution() {
NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
NaClStartParams params;
+
// Enable PPAPI proxy channel creation only for renderer processes.
params.enable_ipc_proxy = enable_ppapi_proxy();
- if (!uses_nonsfi_mode_) {
+ if (uses_nonsfi_mode_) {
+ // Currently, non-SFI mode is supported only on Linux.
+#if defined(OS_LINUX)
+ // nexe_file_ still keeps the ownership at this moment, because |params|
+ // may just be destroyed before sending IPC is properly processed.
+ // Note that although we set auto_close=true for FileDescriptor's
+ // constructor, it is not automatically handled in its destructor as RAII.
+ params.nexe_file =
+ base::FileDescriptor(nexe_file_.GetPlatformFile(), true);
+#endif
+ } else {
params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled();
params.validation_cache_key = nacl_browser->GetValidationCacheKey();
params.version = NaClBrowser::GetDelegate()->GetVersionString();
@@ -875,9 +891,14 @@ bool NaClProcessHost::StartNaClExecution() {
}
#endif
- process_->Send(new NaClProcessMsg_Start(params));
-
+ // Here we are about to send the IPC, so release file descriptors to delegate
+ // the ownership to the message.
+ if (uses_nonsfi_mode_) {
+ nexe_file_.TakePlatformFile();
+ }
internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE;
+
+ process_->Send(new NaClProcessMsg_Start(params));
return true;
}
diff --git a/components/nacl/browser/nacl_process_host.h b/components/nacl/browser/nacl_process_host.h
index a02d772..a5e3e52 100644
--- a/components/nacl/browser/nacl_process_host.h
+++ b/components/nacl/browser/nacl_process_host.h
@@ -7,6 +7,7 @@
#include "build/build_config.h"
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/file_util_proxy.h"
#include "base/memory/ref_counted.h"
@@ -61,6 +62,7 @@ class NaClProcessHost : public content::BrowserChildProcessHostDelegate {
// off_the_record: was the process launched from an incognito renderer?
// profile_directory: is the path of current profile directory.
NaClProcessHost(const GURL& manifest_url,
+ base::File nexe_file,
ppapi::PpapiPermissions permissions,
int render_view_id,
uint32 permission_bits,
@@ -186,6 +188,8 @@ class NaClProcessHost : public content::BrowserChildProcessHostDelegate {
const IPC::ChannelHandle& manifest_service_channel_handle);
GURL manifest_url_;
+ base::File nexe_file_;
+
ppapi::PpapiPermissions permissions_;
#if defined(OS_WIN)
diff --git a/components/nacl/common/nacl_host_messages.h b/components/nacl/common/nacl_host_messages.h
index 88237da..5525454 100644
--- a/components/nacl/common/nacl_host_messages.h
+++ b/components/nacl/common/nacl_host_messages.h
@@ -21,6 +21,7 @@
IPC_STRUCT_TRAITS_BEGIN(nacl::NaClLaunchParams)
IPC_STRUCT_TRAITS_MEMBER(manifest_url)
+ IPC_STRUCT_TRAITS_MEMBER(nexe_file)
IPC_STRUCT_TRAITS_MEMBER(render_view_id)
IPC_STRUCT_TRAITS_MEMBER(permission_bits)
IPC_STRUCT_TRAITS_MEMBER(uses_irt)
diff --git a/components/nacl/common/nacl_messages.h b/components/nacl/common/nacl_messages.h
index bb58f9e..a3b89e2 100644
--- a/components/nacl/common/nacl_messages.h
+++ b/components/nacl/common/nacl_messages.h
@@ -14,6 +14,7 @@
#define IPC_MESSAGE_START NaClMsgStart
IPC_STRUCT_TRAITS_BEGIN(nacl::NaClStartParams)
+ IPC_STRUCT_TRAITS_MEMBER(nexe_file)
IPC_STRUCT_TRAITS_MEMBER(handles)
IPC_STRUCT_TRAITS_MEMBER(debug_stub_server_bound_socket)
IPC_STRUCT_TRAITS_MEMBER(validation_cache_enabled)
diff --git a/components/nacl/common/nacl_types.cc b/components/nacl/common/nacl_types.cc
index cc339b9..0b096a65 100644
--- a/components/nacl/common/nacl_types.cc
+++ b/components/nacl/common/nacl_types.cc
@@ -8,7 +8,8 @@
namespace nacl {
NaClStartParams::NaClStartParams()
- : validation_cache_enabled(false),
+ : nexe_file(IPC::InvalidPlatformFileForTransit()),
+ validation_cache_enabled(false),
enable_exception_handling(false),
enable_debug_stub(false),
enable_ipc_proxy(false),
@@ -20,7 +21,8 @@ NaClStartParams::~NaClStartParams() {
}
NaClLaunchParams::NaClLaunchParams()
- : render_view_id(0),
+ : nexe_file(IPC::InvalidPlatformFileForTransit()),
+ render_view_id(0),
permission_bits(0),
uses_irt(false),
enable_dyncode_syscalls(false),
@@ -28,15 +30,18 @@ NaClLaunchParams::NaClLaunchParams()
enable_crash_throttling(false) {
}
-NaClLaunchParams::NaClLaunchParams(const std::string& manifest_url,
- int render_view_id,
- uint32 permission_bits,
- bool uses_irt,
- bool uses_nonsfi_mode,
- bool enable_dyncode_syscalls,
- bool enable_exception_handling,
- bool enable_crash_throttling)
+NaClLaunchParams::NaClLaunchParams(
+ const std::string& manifest_url,
+ const IPC::PlatformFileForTransit& nexe_file,
+ int render_view_id,
+ uint32 permission_bits,
+ bool uses_irt,
+ bool uses_nonsfi_mode,
+ bool enable_dyncode_syscalls,
+ bool enable_exception_handling,
+ bool enable_crash_throttling)
: manifest_url(manifest_url),
+ nexe_file(nexe_file),
render_view_id(render_view_id),
permission_bits(permission_bits),
uses_irt(uses_irt),
@@ -46,15 +51,16 @@ NaClLaunchParams::NaClLaunchParams(const std::string& manifest_url,
enable_crash_throttling(enable_crash_throttling) {
}
-NaClLaunchParams::NaClLaunchParams(const NaClLaunchParams& l) {
- manifest_url = l.manifest_url;
- render_view_id = l.render_view_id;
- permission_bits = l.permission_bits;
- uses_irt = l.uses_irt;
- uses_nonsfi_mode = l.uses_nonsfi_mode;
- enable_dyncode_syscalls = l.enable_dyncode_syscalls;
- enable_exception_handling = l.enable_exception_handling;
- enable_crash_throttling = l.enable_crash_throttling;
+NaClLaunchParams::NaClLaunchParams(const NaClLaunchParams& l)
+ : manifest_url(l.manifest_url),
+ nexe_file(l.nexe_file),
+ render_view_id(l.render_view_id),
+ permission_bits(l.permission_bits),
+ uses_irt(l.uses_irt),
+ uses_nonsfi_mode(l.uses_nonsfi_mode),
+ enable_dyncode_syscalls(l.enable_dyncode_syscalls),
+ enable_exception_handling(l.enable_exception_handling),
+ enable_crash_throttling(l.enable_crash_throttling) {
}
NaClLaunchParams::~NaClLaunchParams() {
diff --git a/components/nacl/common/nacl_types.h b/components/nacl/common/nacl_types.h
index a4759b1..e2c7793 100644
--- a/components/nacl/common/nacl_types.h
+++ b/components/nacl/common/nacl_types.h
@@ -12,6 +12,7 @@
#include "base/process/process_handle.h"
#include "build/build_config.h"
#include "ipc/ipc_channel.h"
+#include "ipc/ipc_platform_file.h"
#if defined(OS_POSIX)
#include "base/file_descriptor_posix.h"
@@ -42,6 +43,8 @@ struct NaClStartParams {
NaClStartParams();
~NaClStartParams();
+ IPC::PlatformFileForTransit nexe_file;
+
std::vector<FileDescriptor> handles;
FileDescriptor debug_stub_server_bound_socket;
@@ -68,7 +71,10 @@ struct NaClStartParams {
// nacl_host_messages.h.
struct NaClLaunchParams {
NaClLaunchParams();
- NaClLaunchParams(const std::string& u, int r, uint32 p,
+ NaClLaunchParams(const std::string& manifest_url,
+ const IPC::PlatformFileForTransit& nexe_file,
+ int render_view_id,
+ uint32 permission_bits,
bool uses_irt,
bool uses_nonsfi_mode,
bool enable_dyncode_syscalls,
@@ -78,6 +84,7 @@ struct NaClLaunchParams {
~NaClLaunchParams();
std::string manifest_url;
+ IPC::PlatformFileForTransit nexe_file;
int render_view_id;
uint32 permission_bits;
bool uses_irt;
diff --git a/components/nacl/loader/nacl_listener.cc b/components/nacl/loader/nacl_listener.cc
index f5c282a..9658ab5 100644
--- a/components/nacl/loader/nacl_listener.cc
+++ b/components/nacl/loader/nacl_listener.cc
@@ -36,6 +36,8 @@
#include "components/nacl/loader/nonsfi/irt_random.h"
#include "components/nacl/loader/nonsfi/nonsfi_main.h"
#include "content/public/common/child_process_sandbox_support_linux.h"
+#include "native_client/src/trusted/desc/nacl_desc_io.h"
+#include "native_client/src/trusted/service_runtime/include/sys/fcntl.h"
#include "ppapi/nacl_irt/plugin_startup.h"
#endif
@@ -468,9 +470,15 @@ void NaClListener::StartNonSfi(const nacl::NaClStartParams& params) {
CHECK(params.debug_stub_server_bound_socket.fd == -1);
CHECK(!params.uses_irt);
+ // TODO(hidehiko): Currently imc bootstrap handle is still sent to the
+ // plugin. Get rid of this.
CHECK(params.handles.size() == 1);
- int imc_bootstrap_handle = nacl::ToNativeHandle(params.handles[0]);
- nacl::nonsfi::MainStart(imc_bootstrap_handle);
+
+ CHECK(params.nexe_file != IPC::InvalidPlatformFileForTransit());
+ nacl::nonsfi::MainStart(
+ NaClDescIoDescFromDescAllocCtor(
+ IPC::PlatformFileForTransitToPlatformFile(params.nexe_file),
+ NACL_ABI_O_RDONLY));
#endif // defined(OS_LINUX)
}
diff --git a/components/nacl/loader/nonsfi/nonsfi_main.cc b/components/nacl/loader/nonsfi/nonsfi_main.cc
index bc420a0..96c6cb2 100644
--- a/components/nacl/loader/nonsfi/nonsfi_main.cc
+++ b/components/nacl/loader/nonsfi/nonsfi_main.cc
@@ -4,7 +4,6 @@
#include "components/nacl/loader/nonsfi/nonsfi_main.h"
-#include "base/debug/leak_annotations.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/platform_thread.h"
@@ -13,14 +12,7 @@
#include "components/nacl/loader/nonsfi/irt_interfaces.h"
#include "native_client/src/include/elf_auxv.h"
#include "native_client/src/include/nacl_macros.h"
-#include "native_client/src/public/secure_service.h"
-#include "native_client/src/shared/srpc/nacl_srpc.h"
#include "native_client/src/trusted/desc/nacl_desc_base.h"
-#include "native_client/src/trusted/desc/nacl_desc_imc.h"
-#include "native_client/src/trusted/desc/nrd_all_modules.h"
-#include "native_client/src/trusted/desc/nrd_xfer.h"
-#include "native_client/src/trusted/service_runtime/nacl_error_code.h"
-#include "ppapi/nacl_irt/plugin_startup.h"
namespace nacl {
namespace nonsfi {
@@ -70,13 +62,10 @@ struct NaClDescUnrefer {
}
};
-void LoadModuleRpc(struct NaClSrpcRpc* rpc,
- struct NaClSrpcArg** in_args,
- struct NaClSrpcArg** out_args,
- struct NaClSrpcClosure* done_cls) {
- rpc->result = NACL_SRPC_RESULT_INTERNAL;
+} // namespace
- ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> desc(in_args[0]->u.hval);
+void MainStart(NaClDesc* nexe_file) {
+ ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> desc(nexe_file);
ElfImage image;
if (image.Read(desc.get()) != LOAD_OK) {
LOG(ERROR) << "LoadModuleRpc: Failed to read binary.";
@@ -95,111 +84,6 @@ void LoadModuleRpc(struct NaClSrpcRpc* rpc,
LOG(ERROR) << "LoadModuleRpc: Failed to create plugin main thread.";
return;
}
-
- rpc->result = NACL_SRPC_RESULT_OK;
- (*done_cls->Run)(done_cls);
-}
-
-const static struct NaClSrpcHandlerDesc kNonSfiServiceHandlers[] = {
- { NACL_SECURE_SERVICE_LOAD_MODULE, LoadModuleRpc, },
- { static_cast<const char*>(NULL), static_cast<NaClSrpcMethod>(NULL), },
-};
-
-// Creates two socketpairs to communicate with the host process.
-void CreateSecureSocketPair(struct NaClDesc* secure_pair[2],
- struct NaClDesc* pair[2]) {
- // Set up a secure pair.
- if (NaClCommonDescMakeBoundSock(secure_pair)) {
- LOG(FATAL) << "Cound not create secure service socket\n";
- }
-
- // Set up a service pair.
- if (NaClCommonDescMakeBoundSock(pair)) {
- LOG(FATAL) << "Could not create service socket";
- }
-}
-
-// Wraps handle by NaClDesc, and sends secure_service_address and
-// service_address via the created descriptor.
-struct NaClDesc* SetUpBootstrapChannel(NaClHandle handle,
- struct NaClDesc* secure_service_address,
- struct NaClDesc* service_address) {
- if (secure_service_address == NULL) {
- LOG(FATAL) << "SetUpBootstrapChannel: secure_service_address is not set";
- }
-
- if (service_address == NULL) {
- LOG(FATAL) << "SetUpBootstrapChannel: secure_service_address is not set";
- }
-
- struct NaClDescImcDesc* channel =
- static_cast<struct NaClDescImcDesc*>(malloc(sizeof *channel));
- if (channel == NULL) {
- LOG(FATAL) << "SetUpBootstrapChannel: no memory";
- }
-
- if (!NaClDescImcDescCtor(channel, handle)) {
- LOG(FATAL) << "SetUpBootstrapChannel: cannot construct IMC descriptor "
- << "object for inherited descriptor: " << handle;
- }
-
- // Send the descriptors to the host.
- struct NaClDesc* descs[2] = {
- secure_service_address,
- service_address,
- };
-
- struct NaClImcTypedMsgHdr hdr;
- hdr.iov = static_cast<struct NaClImcMsgIoVec*>(NULL);
- hdr.iov_length = 0;
- hdr.ndescv = descs;
- hdr.ndesc_length = NACL_ARRAY_SIZE(descs);
- hdr.flags = 0;
-
- ssize_t error = (*NACL_VTBL(NaClDesc, channel)->SendMsg)(
- reinterpret_cast<struct NaClDesc*>(channel), &hdr, 0);
- if (error) {
- LOG(FATAL) << "SetUpBootstrapChannel: SendMsg failed, error = " << error;
- }
- return reinterpret_cast<struct NaClDesc*>(channel);
-}
-
-// Starts to listen to the port and runs the server loop.
-void ServiceAccept(struct NaClDesc* port) {
- struct NaClDesc* connected_desc = NULL;
- int status = (*NACL_VTBL(NaClDesc, port)->AcceptConn)(port, &connected_desc);
- if (status) {
- LOG(ERROR) << "ServiceAccept: Failed to accept " << status;
- return;
- }
-
- NaClSrpcServerLoop(connected_desc, kNonSfiServiceHandlers, NULL);
-}
-
-} // namespace
-
-void MainStart(NaClHandle imc_bootstrap_handle) {
- NaClSrpcModuleInit();
-
- struct NaClDesc* secure_pair[2] = { NULL, NULL };
- struct NaClDesc* pair[2] = { NULL, NULL };
- CreateSecureSocketPair(secure_pair, pair);
- ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> secure_port(secure_pair[0]);
- ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> secure_address(
- secure_pair[1]);
- ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> service_port(pair[0]);
- ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> service_address(pair[1]);
-
- ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> channel(
- SetUpBootstrapChannel(imc_bootstrap_handle,
- secure_address.get(), service_address.get()));
- if (!channel) {
- LOG(ERROR) << "MainStart: Failed to set up bootstrap channel.";
- return;
- }
-
- // Start the SRPC server loop.
- ServiceAccept(secure_port.get());
}
} // namespace nonsfi
diff --git a/components/nacl/loader/nonsfi/nonsfi_main.h b/components/nacl/loader/nonsfi/nonsfi_main.h
index 6c674ce..5098ab0 100644
--- a/components/nacl/loader/nonsfi/nonsfi_main.h
+++ b/components/nacl/loader/nonsfi/nonsfi_main.h
@@ -5,14 +5,13 @@
#ifndef COMPONENTS_NACL_LOADER_NONSFI_NONSFI_MAIN_H_
#define COMPONENTS_NACL_LOADER_NONSFI_NONSFI_MAIN_H_
-#include "native_client/src/include/portability.h"
-#include "native_client/src/public/imc_types.h"
+struct NaClDesc;
namespace nacl {
namespace nonsfi {
-// Launch NaCl with Non SFI mode.
-void MainStart(NaClHandle imc_bootstrap_handle);
+// Launch NaCl with Non SFI mode. This takes the ownership of |nexe_file|.
+void MainStart(NaClDesc* nexe_file);
} // namespace nonsfi
} // namespace nacl
diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc
index 0393b09..a2b0c43 100644
--- a/components/nacl/renderer/ppb_nacl_private_impl.cc
+++ b/components/nacl/renderer/ppb_nacl_private_impl.cc
@@ -296,6 +296,7 @@ int32_t FileDownloaderToPepperError(FileDownloader::Status status) {
void LaunchSelLdr(PP_Instance instance,
PP_Bool main_service_runtime,
const char* alleged_url,
+ const PP_NaClFileInfo* nexe_file_info,
PP_Bool uses_irt,
PP_Bool uses_ppapi,
PP_Bool uses_nonsfi_mode,
@@ -330,6 +331,9 @@ void LaunchSelLdr(PP_Instance instance,
if (uses_ppapi) {
routing_id = GetRoutingID(instance);
if (!routing_id) {
+ if (nexe_file_info->handle != PP_kInvalidFileHandle) {
+ base::ClosePlatformFile(nexe_file_info->handle);
+ }
ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
FROM_HERE,
base::Bind(callback.func, callback.user_data,
@@ -352,15 +356,19 @@ void LaunchSelLdr(PP_Instance instance,
std::string error_message_string;
NaClLaunchResult launch_result;
+ content::RendererPpapiHost* host =
+ content::RendererPpapiHost::GetForPPInstance(instance);
if (!sender->Send(new NaClHostMsg_LaunchNaCl(
- NaClLaunchParams(instance_info.url.spec(),
- routing_id,
- perm_bits,
- PP_ToBool(uses_irt),
- PP_ToBool(uses_nonsfi_mode),
- PP_ToBool(enable_dyncode_syscalls),
- PP_ToBool(enable_exception_handling),
- PP_ToBool(enable_crash_throttling)),
+ NaClLaunchParams(
+ instance_info.url.spec(),
+ host->ShareHandleWithRemote(nexe_file_info->handle, true),
+ routing_id,
+ perm_bits,
+ PP_ToBool(uses_irt),
+ PP_ToBool(uses_nonsfi_mode),
+ PP_ToBool(enable_dyncode_syscalls),
+ PP_ToBool(enable_exception_handling),
+ PP_ToBool(enable_crash_throttling)),
&launch_result,
&error_message_string))) {
ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
diff --git a/ppapi/api/private/ppb_nacl_private.idl b/ppapi/api/private/ppb_nacl_private.idl
index f57b7f6..882f08a 100644
--- a/ppapi/api/private/ppb_nacl_private.idl
+++ b/ppapi/api/private/ppb_nacl_private.idl
@@ -177,6 +177,9 @@ interface PPB_NaCl_Private {
* indicates that the nexe run by sel_ldr will use the PPAPI APIs.
* This implies that LaunchSelLdr is run from the main thread. If a nexe
* does not need PPAPI, then it can run off the main thread.
+ * The |nexe_file_info| is currently used only in non-SFI mode. It is the
+ * file handle for the main nexe file, which should be initially loaded.
+ * LaunchSelLdr takes the ownership of the file handle.
* The |uses_irt| flag indicates whether the IRT should be loaded in this
* NaCl process. This is true for ABI stable nexes.
* The |uses_nonsfi_mode| flag indicates whether or not nonsfi-mode should
@@ -192,6 +195,7 @@ interface PPB_NaCl_Private {
void LaunchSelLdr([in] PP_Instance instance,
[in] PP_Bool main_service_runtime,
[in] str_t alleged_url,
+ [in] PP_NaClFileInfo nexe_file_info,
[in] PP_Bool uses_irt,
[in] PP_Bool uses_ppapi,
[in] PP_Bool uses_nonsfi_mode,
diff --git a/ppapi/c/private/ppb_nacl_private.h b/ppapi/c/private/ppb_nacl_private.h
index 3b23e19..8a045c1 100644
--- a/ppapi/c/private/ppb_nacl_private.h
+++ b/ppapi/c/private/ppb_nacl_private.h
@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
-/* From private/ppb_nacl_private.idl modified Wed Jun 18 19:15:01 2014. */
+/* From private/ppb_nacl_private.idl modified Mon Jun 23 12:23:23 2014. */
#ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
#define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
@@ -230,6 +230,9 @@ struct PPB_NaCl_Private_1_0 {
* indicates that the nexe run by sel_ldr will use the PPAPI APIs.
* This implies that LaunchSelLdr is run from the main thread. If a nexe
* does not need PPAPI, then it can run off the main thread.
+ * The |nexe_file_info| is currently used only in non-SFI mode. It is the
+ * file handle for the main nexe file, which should be initially loaded.
+ * LaunchSelLdr takes the ownership of the file handle.
* The |uses_irt| flag indicates whether the IRT should be loaded in this
* NaCl process. This is true for ABI stable nexes.
* The |uses_nonsfi_mode| flag indicates whether or not nonsfi-mode should
@@ -246,6 +249,7 @@ struct PPB_NaCl_Private_1_0 {
PP_Instance instance,
PP_Bool main_service_runtime,
const char* alleged_url,
+ const struct PP_NaClFileInfo* nexe_file_info,
PP_Bool uses_irt,
PP_Bool uses_ppapi,
PP_Bool uses_nonsfi_mode,
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc
index 7bb9cf8..a9969ce 100644
--- a/ppapi/native_client/src/trusted/plugin/plugin.cc
+++ b/ppapi/native_client/src/trusted/plugin/plugin.cc
@@ -41,6 +41,12 @@ const int64_t kTimeSmallMin = 1; // in ms
const int64_t kTimeSmallMax = 20000; // in ms
const uint32_t kTimeSmallBuckets = 100;
+const PP_NaClFileInfo kInvalidNaClFileInfo = {
+ PP_kInvalidFileHandle,
+ 0, // token_lo
+ 0, // token_hi
+};
+
} // namespace
void Plugin::ShutDownSubprocesses() {
@@ -167,7 +173,20 @@ void Plugin::LoadNaClModule(PP_NaClFileInfo file_info,
pp::Var manifest_base_url =
pp::Var(pp::PASS_REF, nacl_interface_->GetManifestBaseURL(pp_instance()));
std::string manifest_base_url_str = manifest_base_url.AsString();
+
+ PP_NaClFileInfo file_info_for_srpc = kInvalidNaClFileInfo;
+ PP_NaClFileInfo file_info_for_ipc = kInvalidNaClFileInfo;
+ if (uses_nonsfi_mode) {
+ // In non-SFI mode, LaunchSelLdr is used to pass the nexe file's descriptor
+ // to the NaCl loader process.
+ file_info_for_ipc = file_info;
+ } else {
+ // Otherwise (i.e. in SFI-mode), LoadModule SRPC is still being used.
+ file_info_for_srpc = file_info;
+ }
+
SelLdrStartParams params(manifest_base_url_str,
+ file_info_for_ipc,
true /* uses_irt */,
true /* uses_ppapi */,
enable_dyncode_syscalls,
@@ -191,7 +210,7 @@ void Plugin::LoadNaClModule(PP_NaClFileInfo file_info,
// callback here for |callback|.
pp::CompletionCallback callback = callback_factory_.NewCallback(
&Plugin::LoadNexeAndStart,
- service_runtime, file_info, pp::CompletionCallback());
+ service_runtime, file_info_for_srpc, pp::CompletionCallback());
StartSelLdrOnMainThread(
static_cast<int32_t>(PP_OK), service_runtime, params, callback);
}
@@ -246,7 +265,14 @@ NaClSubprocess* Plugin::LoadHelperNaClModule(const nacl::string& helper_url,
// TODO(sehr): define new UMA stats for translator related nexe events.
// NOTE: The PNaCl translator nexes are not built to use the IRT. This is
// done to save on address space and swap space.
+ //
+ // Currently, this works only in SFI-mode. So, LoadModule SRPC is still used.
+ // So, pass kInvalidNaClFileInfo here, and instead |file_handle| is passed
+ // to LoadNaClModuleFromBackgroundThread() below.
+ // TODO(teravest, hidehiko): Pass file_handle to params, so that LaunchSelLdr
+ // will look at the info.
SelLdrStartParams params(helper_url,
+ kInvalidNaClFileInfo,
false /* uses_irt */,
false /* uses_ppapi */,
false /* enable_dyncode_syscalls */,
diff --git a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc
index 46d6367..4508fb9 100644
--- a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc
+++ b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc
@@ -19,6 +19,7 @@ void SelLdrLauncherChrome::Start(
PP_Instance instance,
bool main_service_runtime,
const char* url,
+ const PP_NaClFileInfo* file_info,
bool uses_irt,
bool uses_ppapi,
bool uses_nonsfi_mode,
@@ -37,6 +38,7 @@ void SelLdrLauncherChrome::Start(
instance,
PP_FromBool(main_service_runtime),
url,
+ file_info,
PP_FromBool(uses_irt),
PP_FromBool(uses_ppapi),
PP_FromBool(uses_nonsfi_mode),
diff --git a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h
index 72b3eee..f435098 100644
--- a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h
+++ b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h
@@ -18,6 +18,7 @@ class SelLdrLauncherChrome : public nacl::SelLdrLauncherBase {
virtual void Start(PP_Instance instance,
bool main_service_runtime,
const char* url,
+ const PP_NaClFileInfo* file_info,
bool uses_irt,
bool uses_ppapi,
bool uses_nonsfi_mode,
diff --git a/ppapi/native_client/src/trusted/plugin/service_runtime.cc b/ppapi/native_client/src/trusted/plugin/service_runtime.cc
index e03f3dc..f2d0230 100644
--- a/ppapi/native_client/src/trusted/plugin/service_runtime.cc
+++ b/ppapi/native_client/src/trusted/plugin/service_runtime.cc
@@ -437,6 +437,11 @@ bool ServiceRuntime::SetupCommandChannel() {
NaClLog(4, "ServiceRuntime::SetupCommand (this=%p, subprocess=%p)\n",
static_cast<void*>(this),
static_cast<void*>(subprocess_.get()));
+ if (uses_nonsfi_mode_) {
+ // In non-SFI mode, no SRPC is used. Just skips and returns success.
+ return true;
+ }
+
if (!subprocess_->SetupCommand(&command_channel_)) {
if (main_service_runtime_) {
ErrorInfo error_info;
@@ -451,6 +456,12 @@ bool ServiceRuntime::SetupCommandChannel() {
void ServiceRuntime::LoadModule(PP_NaClFileInfo file_info,
pp::CompletionCallback callback) {
+ if (uses_nonsfi_mode_) {
+ // In non-SFI mode, loading is done a part of LaunchSelLdr.
+ DidLoadModule(callback, PP_OK);
+ return;
+ }
+
NaClFileInfo nacl_file_info;
nacl_file_info.desc = ConvertFileDescriptor(file_info.handle, true);
nacl_file_info.file_token.lo = file_info.token_lo;
@@ -610,6 +621,7 @@ void ServiceRuntime::StartSelLdr(const SelLdrStartParams& params,
tmp_subprocess->Start(plugin_->pp_instance(),
main_service_runtime_,
params.url.c_str(),
+ &params.file_info,
params.uses_irt,
params.uses_ppapi,
uses_nonsfi_mode_,
diff --git a/ppapi/native_client/src/trusted/plugin/service_runtime.h b/ppapi/native_client/src/trusted/plugin/service_runtime.h
index d53d612..3c5e436 100644
--- a/ppapi/native_client/src/trusted/plugin/service_runtime.h
+++ b/ppapi/native_client/src/trusted/plugin/service_runtime.h
@@ -42,12 +42,14 @@ class ServiceRuntime;
// creation templates aren't overwhelmed with too many parameters.
struct SelLdrStartParams {
SelLdrStartParams(const nacl::string& url,
+ const PP_NaClFileInfo& file_info,
bool uses_irt,
bool uses_ppapi,
bool enable_dyncode_syscalls,
bool enable_exception_handling,
bool enable_crash_throttling)
: url(url),
+ file_info(file_info),
uses_irt(uses_irt),
uses_ppapi(uses_ppapi),
enable_dyncode_syscalls(enable_dyncode_syscalls),
@@ -55,6 +57,7 @@ struct SelLdrStartParams {
enable_crash_throttling(enable_crash_throttling) {
}
nacl::string url;
+ PP_NaClFileInfo file_info;
bool uses_irt;
bool uses_ppapi;
bool enable_dev_interfaces;
diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
index 1753ee0..7143236 100644
--- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
+++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
@@ -3279,9 +3279,9 @@ static int32_t Pnacl_M33_PPB_IsolatedFileSystem_Private_Open(PP_Instance instanc
/* Begin wrapper methods for PPB_NaCl_Private_1_0 */
-static void Pnacl_M25_PPB_NaCl_Private_LaunchSelLdr(PP_Instance instance, PP_Bool main_service_runtime, const char* alleged_url, PP_Bool uses_irt, PP_Bool uses_ppapi, PP_Bool uses_nonsfi_mode, PP_Bool enable_ppapi_dev, PP_Bool enable_dyncode_syscalls, PP_Bool enable_exception_handling, PP_Bool enable_crash_throttling, const struct PPP_ManifestService_1_0* manifest_service_interface, void* manifest_service_user_data, void* imc_handle, struct PP_CompletionCallback* callback) {
+static void Pnacl_M25_PPB_NaCl_Private_LaunchSelLdr(PP_Instance instance, PP_Bool main_service_runtime, const char* alleged_url, const struct PP_NaClFileInfo* nexe_file_info, PP_Bool uses_irt, PP_Bool uses_ppapi, PP_Bool uses_nonsfi_mode, PP_Bool enable_ppapi_dev, PP_Bool enable_dyncode_syscalls, PP_Bool enable_exception_handling, PP_Bool enable_crash_throttling, const struct PPP_ManifestService_1_0* manifest_service_interface, void* manifest_service_user_data, void* imc_handle, struct PP_CompletionCallback* callback) {
const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface;
- iface->LaunchSelLdr(instance, main_service_runtime, alleged_url, uses_irt, uses_ppapi, uses_nonsfi_mode, enable_ppapi_dev, enable_dyncode_syscalls, enable_exception_handling, enable_crash_throttling, manifest_service_interface, manifest_service_user_data, imc_handle, *callback);
+ iface->LaunchSelLdr(instance, main_service_runtime, alleged_url, nexe_file_info, uses_irt, uses_ppapi, uses_nonsfi_mode, enable_ppapi_dev, enable_dyncode_syscalls, enable_exception_handling, enable_crash_throttling, manifest_service_interface, manifest_service_user_data, imc_handle, *callback);
}
static PP_Bool Pnacl_M25_PPB_NaCl_Private_StartPpapiProxy(PP_Instance instance) {
@@ -5223,7 +5223,7 @@ static const struct PPB_IsolatedFileSystem_Private_0_2 Pnacl_Wrappers_PPB_Isolat
/* Not generating wrapper interface for PPP_ManifestService_1_0 */
static const struct PPB_NaCl_Private_1_0 Pnacl_Wrappers_PPB_NaCl_Private_1_0 = {
- .LaunchSelLdr = (void (*)(PP_Instance instance, PP_Bool main_service_runtime, const char* alleged_url, PP_Bool uses_irt, PP_Bool uses_ppapi, PP_Bool uses_nonsfi_mode, PP_Bool enable_ppapi_dev, PP_Bool enable_dyncode_syscalls, PP_Bool enable_exception_handling, PP_Bool enable_crash_throttling, const struct PPP_ManifestService_1_0* manifest_service_interface, void* manifest_service_user_data, void* imc_handle, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_LaunchSelLdr,
+ .LaunchSelLdr = (void (*)(PP_Instance instance, PP_Bool main_service_runtime, const char* alleged_url, const struct PP_NaClFileInfo* nexe_file_info, PP_Bool uses_irt, PP_Bool uses_ppapi, PP_Bool uses_nonsfi_mode, PP_Bool enable_ppapi_dev, PP_Bool enable_dyncode_syscalls, PP_Bool enable_exception_handling, PP_Bool enable_crash_throttling, const struct PPP_ManifestService_1_0* manifest_service_interface, void* manifest_service_user_data, void* imc_handle, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_LaunchSelLdr,
.StartPpapiProxy = (PP_Bool (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_StartPpapiProxy,
.UrandomFD = (int32_t (*)(void))&Pnacl_M25_PPB_NaCl_Private_UrandomFD,
.Are3DInterfacesDisabled = (PP_Bool (*)(void))&Pnacl_M25_PPB_NaCl_Private_Are3DInterfacesDisabled,