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

Side by Side Diff: components/nacl/loader/nacl_listener.cc

Issue 332463003: Pepper: Remove LOAD_MODULE SRPC call in SFI mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes for jvoung and hidehiko Created 6 years, 5 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 <fcntl.h>
8 #include <stdlib.h> 9 #include <stdlib.h>
9 10
10 #if defined(OS_POSIX) 11 #if defined(OS_POSIX)
11 #include <unistd.h> 12 #include <unistd.h>
12 #endif 13 #endif
13 14
14 #include "base/command_line.h" 15 #include "base/command_line.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
18 #include "base/rand_util.h" 19 #include "base/rand_util.h"
19 #include "components/nacl/common/nacl_messages.h" 20 #include "components/nacl/common/nacl_messages.h"
20 #include "components/nacl/loader/nacl_ipc_adapter.h" 21 #include "components/nacl/loader/nacl_ipc_adapter.h"
21 #include "components/nacl/loader/nacl_validation_db.h" 22 #include "components/nacl/loader/nacl_validation_db.h"
22 #include "components/nacl/loader/nacl_validation_query.h" 23 #include "components/nacl/loader/nacl_validation_query.h"
23 #include "ipc/ipc_channel_handle.h" 24 #include "ipc/ipc_channel_handle.h"
24 #include "ipc/ipc_switches.h" 25 #include "ipc/ipc_switches.h"
25 #include "ipc/ipc_sync_channel.h" 26 #include "ipc/ipc_sync_channel.h"
26 #include "ipc/ipc_sync_message_filter.h" 27 #include "ipc/ipc_sync_message_filter.h"
27 #include "native_client/src/public/chrome_main.h" 28 #include "native_client/src/public/chrome_main.h"
28 #include "native_client/src/public/nacl_app.h" 29 #include "native_client/src/public/nacl_app.h"
29 #include "native_client/src/public/nacl_file_info.h" 30 #include "native_client/src/public/nacl_file_info.h"
31 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h"
30 32
31 #if defined(OS_POSIX) 33 #if defined(OS_POSIX)
32 #include "base/file_descriptor_posix.h" 34 #include "base/file_descriptor_posix.h"
33 #endif 35 #endif
34 36
35 #if defined(OS_LINUX) 37 #if defined(OS_LINUX)
36 #include "components/nacl/loader/nonsfi/irt_random.h" 38 #include "components/nacl/loader/nonsfi/irt_random.h"
37 #include "components/nacl/loader/nonsfi/nonsfi_main.h" 39 #include "components/nacl/loader/nonsfi/nonsfi_main.h"
38 #include "content/public/common/child_process_sandbox_support_linux.h" 40 #include "content/public/common/child_process_sandbox_support_linux.h"
39 #include "native_client/src/trusted/desc/nacl_desc_io.h" 41 #include "native_client/src/trusted/desc/nacl_desc_io.h"
40 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h"
41 #include "ppapi/nacl_irt/plugin_startup.h" 42 #include "ppapi/nacl_irt/plugin_startup.h"
42 #endif 43 #endif
43 44
44 #if defined(OS_WIN) 45 #if defined(OS_WIN)
45 #include <fcntl.h> 46 #include <fcntl.h>
46 #include <io.h> 47 #include <io.h>
47 48
48 #include "content/public/common/sandbox_init.h" 49 #include "content/public/common/sandbox_init.h"
49 #endif 50 #endif
50 51
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 #if defined(OS_WIN) 384 #if defined(OS_WIN)
384 args->broker_duplicate_handle_func = BrokerDuplicateHandle; 385 args->broker_duplicate_handle_func = BrokerDuplicateHandle;
385 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; 386 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler;
386 args->debug_stub_server_port_selected_handler_func = 387 args->debug_stub_server_port_selected_handler_func =
387 DebugStubPortSelectedHandler; 388 DebugStubPortSelectedHandler;
388 #endif 389 #endif
389 #if defined(OS_LINUX) 390 #if defined(OS_LINUX)
390 args->prereserved_sandbox_size = prereserved_sandbox_size_; 391 args->prereserved_sandbox_size = prereserved_sandbox_size_;
391 #endif 392 #endif
392 393
394 NaClFileInfo nexe_file_info;
395 base::PlatformFile nexe_file = IPC::PlatformFileForTransitToPlatformFile(
396 params.nexe_file);
397 #if defined(OS_WIN)
398 nexe_file_info.desc =
399 _open_osfhandle(reinterpret_cast<intptr_t>(nexe_file),
400 _O_RDONLY | _O_BINARY);
401 #elif defined(OS_POSIX)
402 nexe_file_info.desc = nexe_file;
403 #else
404 #error Unsupported target platform.
405 #endif
406 // TODO(teravest): Resolve the file tokens right now in the browser process
Mark Seaborn 2014/07/02 23:48:36 Nit: "right now in the browser process" is out of
teravest 2014/07/07 22:48:48 Done.
407 // instead of making the loader send IPC to resolve them later.
408 nexe_file_info.file_token.lo = params.nexe_token_lo;
409 nexe_file_info.file_token.hi = params.nexe_token_hi;
410 args->nexe_desc = NaClDescIoFromFileInfo(nexe_file_info, NACL_ABI_O_RDONLY);
411
393 NaClChromeMainStartApp(nap, args); 412 NaClChromeMainStartApp(nap, args);
Mark Seaborn 2014/07/01 20:32:48 Since you're not switching to using NaClChromeMain
394 NOTREACHED(); 413 NOTREACHED();
395 } 414 }
396 415
397 void NaClListener::StartNonSfi(const nacl::NaClStartParams& params) { 416 void NaClListener::StartNonSfi(const nacl::NaClStartParams& params) {
398 #if !defined(OS_LINUX) 417 #if !defined(OS_LINUX)
399 NOTREACHED() << "Non-SFI NaCl is only supported on Linux"; 418 NOTREACHED() << "Non-SFI NaCl is only supported on Linux";
400 #else 419 #else
401 // Random number source initialization. 420 // Random number source initialization.
402 nacl::nonsfi::SetUrandomFd(base::GetUrandomFD()); 421 nacl::nonsfi::SetUrandomFd(base::GetUrandomFD());
403 422
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 CHECK(params.validation_cache_key.size() == 0); 485 CHECK(params.validation_cache_key.size() == 0);
467 CHECK(params.version.size() == 0); 486 CHECK(params.version.size() == 0);
468 // Ensure that a debug stub FD isn't passed through accidentally. 487 // Ensure that a debug stub FD isn't passed through accidentally.
469 CHECK(!params.enable_debug_stub); 488 CHECK(!params.enable_debug_stub);
470 CHECK(params.debug_stub_server_bound_socket.fd == -1); 489 CHECK(params.debug_stub_server_bound_socket.fd == -1);
471 490
472 CHECK(!params.uses_irt); 491 CHECK(!params.uses_irt);
473 CHECK(params.handles.empty()); 492 CHECK(params.handles.empty());
474 493
475 CHECK(params.nexe_file != IPC::InvalidPlatformFileForTransit()); 494 CHECK(params.nexe_file != IPC::InvalidPlatformFileForTransit());
495 CHECK(params.nexe_token_lo == 0);
496 CHECK(params.nexe_token_hi == 0);
476 nacl::nonsfi::MainStart( 497 nacl::nonsfi::MainStart(
477 NaClDescIoDescFromDescAllocCtor( 498 NaClDescIoDescFromDescAllocCtor(
478 IPC::PlatformFileForTransitToPlatformFile(params.nexe_file), 499 IPC::PlatformFileForTransitToPlatformFile(params.nexe_file),
479 NACL_ABI_O_RDONLY)); 500 NACL_ABI_O_RDONLY));
480 #endif // defined(OS_LINUX) 501 #endif // defined(OS_LINUX)
481 } 502 }
482 503
483 IPC::ChannelHandle NaClListener::CreateTrustedListener( 504 IPC::ChannelHandle NaClListener::CreateTrustedListener(
484 base::MessageLoopProxy* message_loop_proxy, 505 base::MessageLoopProxy* message_loop_proxy,
485 base::WaitableEvent* shutdown_event) { 506 base::WaitableEvent* shutdown_event) {
486 // The argument passed to GenerateVerifiedChannelID() here MUST be "nacl". 507 // The argument passed to GenerateVerifiedChannelID() here MUST be "nacl".
487 // Using an alternate channel name prevents the pipe from being created on 508 // Using an alternate channel name prevents the pipe from being created on
488 // Windows when the sandbox is enabled. 509 // Windows when the sandbox is enabled.
489 IPC::ChannelHandle trusted_renderer_handle = 510 IPC::ChannelHandle trusted_renderer_handle =
490 IPC::Channel::GenerateVerifiedChannelID("nacl"); 511 IPC::Channel::GenerateVerifiedChannelID("nacl");
491 trusted_listener_ = new NaClTrustedListener( 512 trusted_listener_ = new NaClTrustedListener(
492 trusted_renderer_handle, io_thread_.message_loop_proxy().get()); 513 trusted_renderer_handle, io_thread_.message_loop_proxy().get());
493 #if defined(OS_POSIX) 514 #if defined(OS_POSIX)
494 trusted_renderer_handle.socket = base::FileDescriptor( 515 trusted_renderer_handle.socket = base::FileDescriptor(
495 trusted_listener_->TakeClientFileDescriptor(), true); 516 trusted_listener_->TakeClientFileDescriptor(), true);
496 #endif 517 #endif
497 return trusted_renderer_handle; 518 return trusted_renderer_handle;
498 } 519 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698