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

Side by Side Diff: components/nacl/loader/nacl_listener.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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/loader/nacl_listener.h" 5 #include "components/nacl/loader/nacl_listener.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #if defined(OS_POSIX) 10 #if defined(OS_POSIX)
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 193 }
194 194
195 private: 195 private:
196 // The listener never dies, otherwise this might be a dangling reference. 196 // The listener never dies, otherwise this might be a dangling reference.
197 NaClListener* listener_; 197 NaClListener* listener_;
198 }; 198 };
199 199
200 200
201 NaClListener::NaClListener() : shutdown_event_(true, false), 201 NaClListener::NaClListener() : shutdown_event_(true, false),
202 io_thread_("NaCl_IOThread"), 202 io_thread_("NaCl_IOThread"),
203 uses_nonsfi_mode_(false),
203 #if defined(OS_LINUX) 204 #if defined(OS_LINUX)
204 prereserved_sandbox_size_(0), 205 prereserved_sandbox_size_(0),
205 #endif 206 #endif
206 #if defined(OS_POSIX) 207 #if defined(OS_POSIX)
207 number_of_cores_(-1), // unknown/error 208 number_of_cores_(-1), // unknown/error
208 #endif 209 #endif
209 main_loop_(NULL) { 210 main_loop_(NULL) {
210 io_thread_.StartWithOptions( 211 io_thread_.StartWithOptions(
211 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); 212 base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
212 #if defined(OS_WIN) 213 #if defined(OS_WIN)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 bool NaClListener::OnMessageReceived(const IPC::Message& msg) { 251 bool NaClListener::OnMessageReceived(const IPC::Message& msg) {
251 bool handled = true; 252 bool handled = true;
252 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg) 253 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg)
253 IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStart) 254 IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStart)
254 IPC_MESSAGE_UNHANDLED(handled = false) 255 IPC_MESSAGE_UNHANDLED(handled = false)
255 IPC_END_MESSAGE_MAP() 256 IPC_END_MESSAGE_MAP()
256 return handled; 257 return handled;
257 } 258 }
258 259
259 void NaClListener::OnStart(const nacl::NaClStartParams& params) { 260 void NaClListener::OnStart(const nacl::NaClStartParams& params) {
261 #if !defined(OS_LINUX)
262 CHECK(!uses_nonsfi_mode_) << "Non-SFI NaCl is only supported on Linux";
263 #endif
260 #if defined(OS_LINUX) || defined(OS_MACOSX) 264 #if defined(OS_LINUX) || defined(OS_MACOSX)
261 int urandom_fd = dup(base::GetUrandomFD()); 265 int urandom_fd = dup(base::GetUrandomFD());
262 if (urandom_fd < 0) { 266 if (urandom_fd < 0) {
263 LOG(ERROR) << "Failed to dup() the urandom FD"; 267 LOG(ERROR) << "Failed to dup() the urandom FD";
264 return; 268 return;
265 } 269 }
266 NaClChromeMainSetUrandomFd(urandom_fd); 270 NaClChromeMainSetUrandomFd(urandom_fd);
267 #endif 271 #endif
268 272
269 NaClChromeMainInit(); 273 NaClChromeMainInit();
(...skipping 10 matching lines...) Expand all
280 } 284 }
281 285
282 IPC::ChannelHandle browser_handle; 286 IPC::ChannelHandle browser_handle;
283 IPC::ChannelHandle ppapi_renderer_handle; 287 IPC::ChannelHandle ppapi_renderer_handle;
284 288
285 if (params.enable_ipc_proxy) { 289 if (params.enable_ipc_proxy) {
286 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); 290 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl");
287 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); 291 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl");
288 292
289 #if defined(OS_LINUX) 293 #if defined(OS_LINUX)
290 if (params.uses_nonsfi_mode) { 294 if (uses_nonsfi_mode_) {
291 // In non-SFI mode, we neither intercept nor rewrite the message using 295 // In non-SFI mode, we neither intercept nor rewrite the message using
292 // NaClIPCAdapter, and the channels are connected between the plugin and 296 // NaClIPCAdapter, and the channels are connected between the plugin and
293 // the hosts directly. So, the IPC::Channel instances will be created in 297 // the hosts directly. So, the IPC::Channel instances will be created in
294 // the plugin side, because the IPC::Listener needs to live on the 298 // the plugin side, because the IPC::Listener needs to live on the
295 // plugin's main thread. However, on initialization (i.e. before loading 299 // plugin's main thread. However, on initialization (i.e. before loading
296 // the plugin binary), the FD needs to be passed to the hosts. So, here 300 // the plugin binary), the FD needs to be passed to the hosts. So, here
297 // we create raw FD pairs, and pass the client side FDs to the hosts, 301 // we create raw FD pairs, and pass the client side FDs to the hosts,
298 // and the server side FDs to the plugin. 302 // and the server side FDs to the plugin.
299 int browser_server_ppapi_fd; 303 int browser_server_ppapi_fd;
300 int browser_client_ppapi_fd; 304 int browser_client_ppapi_fd;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 #endif 418 #endif
415 #if defined(OS_WIN) 419 #if defined(OS_WIN)
416 args->broker_duplicate_handle_func = BrokerDuplicateHandle; 420 args->broker_duplicate_handle_func = BrokerDuplicateHandle;
417 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; 421 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler;
418 #endif 422 #endif
419 #if defined(OS_LINUX) 423 #if defined(OS_LINUX)
420 args->prereserved_sandbox_size = prereserved_sandbox_size_; 424 args->prereserved_sandbox_size = prereserved_sandbox_size_;
421 #endif 425 #endif
422 426
423 #if defined(OS_LINUX) 427 #if defined(OS_LINUX)
424 if (params.uses_nonsfi_mode) { 428 if (uses_nonsfi_mode_) {
425 nacl::nonsfi::MainStart(args->imc_bootstrap_handle); 429 nacl::nonsfi::MainStart(args->imc_bootstrap_handle);
426 return; 430 return;
427 } 431 }
428 #endif 432 #endif
429 NaClChromeMainStartApp(nap, args); 433 NaClChromeMainStartApp(nap, args);
430 NOTREACHED(); 434 NOTREACHED();
431 } 435 }
OLDNEW
« no previous file with comments | « components/nacl/loader/nacl_listener.h ('k') | components/nacl/zygote/nacl_fork_delegate_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698