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

Unified Diff: ppapi/native_client/src/trusted/plugin/plugin.cc

Issue 177113009: Support non-SFI mode in NaCl manifest file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/native_client/src/trusted/plugin/plugin.cc
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc
index 894337b01fc03a2518174077c81c5cf0aafadab6..1164c2fa57e164e22903561fd27080f075c0566d 100644
--- a/ppapi/native_client/src/trusted/plugin/plugin.cc
+++ b/ppapi/native_client/src/trusted/plugin/plugin.cc
@@ -283,7 +283,7 @@ bool Plugin::LoadNaClModuleFromBackgroundThread(
const SelLdrStartParams& params) {
CHECK(!pp::Module::Get()->core()->IsMainThread());
ServiceRuntime* service_runtime =
- new ServiceRuntime(this, manifest, false,
+ new ServiceRuntime(this, manifest, false, nonsfi_enabled(),
pp::BlockUntilComplete(), pp::BlockUntilComplete());
subprocess->set_service_runtime(service_runtime);
PLUGIN_PRINTF(("Plugin::LoadNaClModuleFromBackgroundThread "
@@ -342,6 +342,7 @@ void Plugin::LoadNaClModule(nacl::DescWrapper* wrapper,
bool enable_dyncode_syscalls,
bool enable_exception_handling,
bool enable_crash_throttling,
+ bool enable_nonsfi,
const pp::CompletionCallback& init_done_cb,
const pp::CompletionCallback& crash_cb) {
nacl::scoped_ptr<nacl::DescWrapper> scoped_wrapper(wrapper);
@@ -357,10 +358,12 @@ void Plugin::LoadNaClModule(nacl::DescWrapper* wrapper,
enable_dev_interfaces_,
enable_dyncode_syscalls,
enable_exception_handling,
- enable_crash_throttling);
+ enable_crash_throttling,
+ enable_nonsfi);
ErrorInfo error_info;
ServiceRuntime* service_runtime =
- new ServiceRuntime(this, manifest_.get(), true, init_done_cb, crash_cb);
+ new ServiceRuntime(this, manifest_.get(), true, nonsfi_enabled(),
+ init_done_cb, crash_cb);
main_subprocess_.set_service_runtime(service_runtime);
PLUGIN_PRINTF(("Plugin::LoadNaClModule (service_runtime=%p)\n",
static_cast<void*>(service_runtime)));
@@ -398,16 +401,18 @@ void Plugin::LoadNexeAndStart(int32_t pp_error,
}
bool Plugin::LoadNaClModuleContinuationIntern(ErrorInfo* error_info) {
- if (!main_subprocess_.StartSrpcServices()) {
- // The NaCl process probably crashed. On Linux, a crash causes this error,
- // while on other platforms, the error is detected below, when we attempt to
- // start the proxy. Report a module initialization error here, to make it
- // less confusing for developers.
- NaClLog(LOG_ERROR, "LoadNaClModuleContinuationIntern: "
- "StartSrpcServices failed\n");
- error_info->SetReport(PP_NACL_ERROR_START_PROXY_MODULE,
- "could not initialize module.");
- return false;
+ if (!nonsfi_enabled()) {
+ if (!main_subprocess_.StartSrpcServices()) {
+ // The NaCl process probably crashed. On Linux, a crash causes this
+ // error, while on other platforms, the error is detected below, when we
+ // attempt to start the proxy. Report a module initialization error here,
+ // to make it less confusing for developers.
+ NaClLog(LOG_ERROR, "LoadNaClModuleContinuationIntern: "
+ "StartSrpcServices failed\n");
+ error_info->SetReport(PP_NACL_ERROR_START_PROXY_MODULE,
+ "could not initialize module.");
+ return false;
+ }
}
PP_ExternalPluginResult ipc_result =
nacl_interface_->StartPpapiProxy(pp_instance());
@@ -458,7 +463,8 @@ NaClSubprocess* Plugin::LoadHelperNaClModule(nacl::DescWrapper* wrapper,
enable_dev_interfaces_,
false /* enable_dyncode_syscalls */,
false /* enable_exception_handling */,
- true /* enable_crash_throttling */);
+ true /* enable_crash_throttling */,
+ false /* enable_nonsfi */);
if (!LoadNaClModuleFromBackgroundThread(wrapper, nacl_subprocess.get(),
manifest, params)) {
return NULL;
@@ -763,6 +769,7 @@ void Plugin::NexeFileDidOpen(int32_t pp_error) {
true, /* enable_dyncode_syscalls */
true, /* enable_exception_handling */
false, /* enable_crash_throttling */
+ nonsfi_enabled(),
callback_factory_.NewCallback(&Plugin::NexeFileDidOpenContinuation),
callback_factory_.NewCallback(&Plugin::NexeDidCrash));
}
@@ -880,6 +887,7 @@ void Plugin::BitcodeDidTranslate(int32_t pp_error) {
false, /* enable_dyncode_syscalls */
false, /* enable_exception_handling */
true, /* enable_crash_throttling */
+ false, /* enable_nonsfi */
callback_factory_.NewCallback(&Plugin::BitcodeDidTranslateContinuation),
callback_factory_.NewCallback(&Plugin::NexeDidCrash));
}
@@ -1034,16 +1042,19 @@ void Plugin::NaClManifestFileDidOpen(int32_t pp_error) {
void Plugin::ProcessNaClManifest(const nacl::string& manifest_json) {
HistogramSizeKB("NaCl.Perf.Size.Manifest",
static_cast<int32_t>(manifest_json.length() / 1024));
- nacl::string program_url;
- PnaclOptions pnacl_options;
ErrorInfo error_info;
if (!SetManifestObject(manifest_json, &error_info)) {
ReportLoadError(error_info);
return;
}
- if (manifest_->GetProgramURL(&program_url, &pnacl_options, &error_info)) {
+ nacl::string program_url;
+ PnaclOptions pnacl_options;
+ bool nonsfi_enabled;
+ if (manifest_->GetProgramURL(
+ &program_url, &pnacl_options, &nonsfi_enabled, &error_info)) {
is_installed_ = GetUrlScheme(program_url) == SCHEME_CHROME_EXTENSION;
+ set_nonsfi_enabled(nonsfi_enabled);
set_nacl_ready_state(LOADING);
// Inform JavaScript that we found a nexe URL to load.
EnqueueProgressEvent(PP_NACL_EVENT_PROGRESS);
@@ -1137,10 +1148,12 @@ bool Plugin::SetManifestObject(const nacl::string& manifest_json,
// Determine whether lookups should use portable (i.e., pnacl versions)
// rather than platform-specific files.
bool is_pnacl = (mime_type() == kPnaclMIMEType);
+ bool nonsfi_enabled = PP_ToBool(nacl_interface_->IsNonSFIEnabled());
nacl::scoped_ptr<JsonManifest> json_manifest(
new JsonManifest(url_util_,
manifest_base_url(),
- (is_pnacl ? kPortableISA : GetSandboxISA())));
+ (is_pnacl ? kPortableISA : GetSandboxISA()),
+ nonsfi_enabled));
if (!json_manifest->Init(manifest_json, error_info)) {
return false;
}

Powered by Google App Engine
This is Rietveld 408576698