Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 15 matching lines...) Expand all Loading... | |
| 26 #include "ipc/ipc_sync_message_filter.h" | 26 #include "ipc/ipc_sync_message_filter.h" |
| 27 #include "native_client/src/public/chrome_main.h" | 27 #include "native_client/src/public/chrome_main.h" |
| 28 #include "native_client/src/public/nacl_app.h" | 28 #include "native_client/src/public/nacl_app.h" |
| 29 #include "native_client/src/public/nacl_file_info.h" | 29 #include "native_client/src/public/nacl_file_info.h" |
| 30 | 30 |
| 31 #if defined(OS_POSIX) | 31 #if defined(OS_POSIX) |
| 32 #include "base/file_descriptor_posix.h" | 32 #include "base/file_descriptor_posix.h" |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 #if defined(OS_LINUX) | 35 #if defined(OS_LINUX) |
| 36 #include <fcntl.h> | |
| 37 | |
| 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 "ppapi/nacl_irt/plugin_startup.h" | 41 #include "ppapi/nacl_irt/plugin_startup.h" |
| 40 #endif | 42 #endif |
| 41 | 43 |
| 42 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
| 43 #include <fcntl.h> | 45 #include <fcntl.h> |
| 44 #include <io.h> | 46 #include <io.h> |
| 45 | 47 |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 | 443 |
| 442 // Send back to the client side IPC channel FD to the host. | 444 // Send back to the client side IPC channel FD to the host. |
| 443 browser_handle.socket = | 445 browser_handle.socket = |
| 444 base::FileDescriptor(browser_client_ppapi_fd, true); | 446 base::FileDescriptor(browser_client_ppapi_fd, true); |
| 445 ppapi_renderer_handle.socket = | 447 ppapi_renderer_handle.socket = |
| 446 base::FileDescriptor(renderer_client_ppapi_fd, true); | 448 base::FileDescriptor(renderer_client_ppapi_fd, true); |
| 447 manifest_service_handle.socket = | 449 manifest_service_handle.socket = |
| 448 base::FileDescriptor(manifest_service_client_fd, true); | 450 base::FileDescriptor(manifest_service_client_fd, true); |
| 449 } | 451 } |
| 450 | 452 |
| 453 CHECK(params.nexe_file != IPC::InvalidPlatformFileForTransit()); | |
| 454 NaClFileInfo nexe_file_info; | |
| 455 nexe_file_info.desc = | |
| 456 IPC::PlatformFileForTransitToPlatformFile(params.nexe_file); | |
| 457 nexe_file_info.file_token.lo = params.nexe_token_lo; | |
| 458 nexe_file_info.file_token.hi = params.nexe_token_hi; | |
| 459 | |
| 460 nacl::nonsfi::MainStart(NaClDescIoFromFileInfo(nexe_file_info, O_RDONLY)); | |
|
Mark Seaborn
2014/06/17 00:50:31
Why move this to occur earlier? It might reduce t
hidehiko
2014/06/18 08:43:32
Moved below.
| |
| 461 | |
| 451 // TODO(teravest): Do we plan on using this renderer handle for nexe loading | 462 // TODO(teravest): Do we plan on using this renderer handle for nexe loading |
| 452 // for non-SFI? Right now, passing an empty channel handle instead causes | 463 // for non-SFI? Right now, passing an empty channel handle instead causes |
| 453 // hangs, so we'll keep it. | 464 // hangs, so we'll keep it. |
| 454 IPC::ChannelHandle trusted_renderer_handle = CreateTrustedListener( | 465 IPC::ChannelHandle trusted_renderer_handle = CreateTrustedListener( |
| 455 io_thread_.message_loop_proxy(), &shutdown_event_); | 466 io_thread_.message_loop_proxy(), &shutdown_event_); |
| 456 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( | 467 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( |
| 457 browser_handle, ppapi_renderer_handle, | 468 browser_handle, ppapi_renderer_handle, |
| 458 trusted_renderer_handle, manifest_service_handle))) | 469 trusted_renderer_handle, manifest_service_handle))) |
| 459 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; | 470 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; |
| 460 | 471 |
| 461 // Ensure that the validation cache key (used as an extra input to the | 472 // Ensure that the validation cache key (used as an extra input to the |
| 462 // validation cache's hashing) isn't exposed accidentally. | 473 // validation cache's hashing) isn't exposed accidentally. |
| 463 CHECK(!params.validation_cache_enabled); | 474 CHECK(!params.validation_cache_enabled); |
| 464 CHECK(params.validation_cache_key.size() == 0); | 475 CHECK(params.validation_cache_key.size() == 0); |
| 465 CHECK(params.version.size() == 0); | 476 CHECK(params.version.size() == 0); |
| 466 // Ensure that a debug stub FD isn't passed through accidentally. | 477 // Ensure that a debug stub FD isn't passed through accidentally. |
| 467 CHECK(!params.enable_debug_stub); | 478 CHECK(!params.enable_debug_stub); |
| 468 CHECK(params.debug_stub_server_bound_socket.fd == -1); | 479 CHECK(params.debug_stub_server_bound_socket.fd == -1); |
| 469 | 480 |
| 470 CHECK(!params.uses_irt); | 481 CHECK(!params.uses_irt); |
| 482 // Currently imc bootstrap handle is still sent to the plugin. | |
| 483 // Get rid of this. | |
|
Mark Seaborn
2014/06/17 00:50:31
Nit: This comment should have a "TODO" in front of
hidehiko
2014/06/18 08:43:32
Done.
| |
| 471 CHECK(params.handles.size() == 1); | 484 CHECK(params.handles.size() == 1); |
| 472 int imc_bootstrap_handle = nacl::ToNativeHandle(params.handles[0]); | |
| 473 nacl::nonsfi::MainStart(imc_bootstrap_handle); | |
| 474 #endif // defined(OS_LINUX) | 485 #endif // defined(OS_LINUX) |
| 475 } | 486 } |
| 476 | 487 |
| 477 IPC::ChannelHandle NaClListener::CreateTrustedListener( | 488 IPC::ChannelHandle NaClListener::CreateTrustedListener( |
| 478 base::MessageLoopProxy* message_loop_proxy, | 489 base::MessageLoopProxy* message_loop_proxy, |
| 479 base::WaitableEvent* shutdown_event) { | 490 base::WaitableEvent* shutdown_event) { |
| 480 // The argument passed to GenerateVerifiedChannelID() here MUST be "nacl". | 491 // The argument passed to GenerateVerifiedChannelID() here MUST be "nacl". |
| 481 // Using an alternate channel name prevents the pipe from being created on | 492 // Using an alternate channel name prevents the pipe from being created on |
| 482 // Windows when the sandbox is enabled. | 493 // Windows when the sandbox is enabled. |
| 483 IPC::ChannelHandle trusted_renderer_handle = | 494 IPC::ChannelHandle trusted_renderer_handle = |
| 484 IPC::Channel::GenerateVerifiedChannelID("nacl"); | 495 IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| 485 trusted_listener_ = new NaClTrustedListener( | 496 trusted_listener_ = new NaClTrustedListener( |
| 486 trusted_renderer_handle, io_thread_.message_loop_proxy().get()); | 497 trusted_renderer_handle, io_thread_.message_loop_proxy().get()); |
| 487 #if defined(OS_POSIX) | 498 #if defined(OS_POSIX) |
| 488 trusted_renderer_handle.socket = base::FileDescriptor( | 499 trusted_renderer_handle.socket = base::FileDescriptor( |
| 489 trusted_listener_->TakeClientFileDescriptor(), true); | 500 trusted_listener_->TakeClientFileDescriptor(), true); |
| 490 #endif | 501 #endif |
| 491 return trusted_renderer_handle; | 502 return trusted_renderer_handle; |
| 492 } | 503 } |
| OLD | NEW |