Chromium Code Reviews| Index: components/nacl/loader/nacl_helper_linux.cc |
| diff --git a/components/nacl/loader/nacl_helper_linux.cc b/components/nacl/loader/nacl_helper_linux.cc |
| index f81323ae49815b5110258505feb0393db7723df6..e6bef0cbdc6322418a8e7b22b91f83cc099b2858 100644 |
| --- a/components/nacl/loader/nacl_helper_linux.cc |
| +++ b/components/nacl/loader/nacl_helper_linux.cc |
| @@ -32,8 +32,6 @@ |
| #include "base/process/process_handle.h" |
| #include "base/rand_util.h" |
| #include "components/nacl/common/nacl_switches.h" |
| -#include "components/nacl/loader/nacl_listener.h" |
| -#include "components/nacl/loader/nonsfi/nonsfi_listener.h" |
| #include "components/nacl/loader/sandbox_linux/nacl_sandbox_linux.h" |
| #include "content/public/common/content_descriptors.h" |
| #include "content/public/common/send_zygote_child_ping_linux.h" |
| @@ -44,10 +42,11 @@ |
| #include "sandbox/linux/services/namespace_sandbox.h" |
| #if defined(OS_NACL_NONSFI) |
| +#include "components/nacl/loader/nonsfi/nonsfi_listener.h" |
| #include "native_client/src/public/nonsfi/irt_exception_handling.h" |
| #else |
| #include <link.h> |
| -#include "components/nacl/loader/nonsfi/irt_exception_handling.h" |
| +#include "components/nacl/loader/nacl_listener.h" |
| #endif |
| namespace { |
| @@ -57,6 +56,7 @@ struct NaClLoaderSystemInfo { |
| long number_of_cores; |
| }; |
| +#if defined(OS_NACL_NONSFI) |
| // Replace |file_descriptor| with the reading end of a closed pipe. |
| void ReplaceFDWithDummy(int file_descriptor) { |
| // Make sure that file_descriptor is an open descriptor. |
| @@ -67,6 +67,7 @@ void ReplaceFDWithDummy(int file_descriptor) { |
| PCHECK(0 == IGNORE_EINTR(close(pipefd[0]))); |
| PCHECK(0 == IGNORE_EINTR(close(pipefd[1]))); |
| } |
| +#endif |
| // The child must mimic the behavior of zygote_main_linux.cc on the child |
| // side of the fork. See zygote_main_linux.cc:HandleForkRequest from |
| @@ -79,27 +80,25 @@ void BecomeNaClLoader(base::ScopedFD browser_fd, |
| VLOG(1) << "NaCl loader: setting up IPC descriptor"; |
| // Close or shutdown IPC channels that we don't need anymore. |
| PCHECK(0 == IGNORE_EINTR(close(kNaClZygoteDescriptor))); |
| - // In Non-SFI mode, it's important to close any non-expected IPC channels. |
| - if (uses_nonsfi_mode) { |
| - // The low-level kSandboxIPCChannel is used by renderers and NaCl for |
| - // various operations. See the LinuxSandbox::METHOD_* methods. NaCl uses |
| - // LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT in SFI mode, so this |
| - // should only be closed in Non-SFI mode. |
| - // This file descriptor is insidiously used by a number of APIs. Closing it |
| - // could lead to difficult to debug issues. Instead of closing it, replace |
| - // it with a dummy. |
| - const int sandbox_ipc_channel = |
| - base::GlobalDescriptors::kBaseDescriptor + kSandboxIPCChannel; |
| - |
| - ReplaceFDWithDummy(sandbox_ipc_channel); |
| - |
| - // Install crash signal handlers before disallowing system calls. |
| + |
| #if defined(OS_NACL_NONSFI) |
| - nonsfi_initialize_signal_handler(); |
| -#else |
| - nacl::nonsfi::InitializeSignalHandler(); |
| + // In Non-SFI mode, it's important to close any non-expected IPC channels. |
| + CHECK(uses_nonsfi_mode); |
|
Mark Seaborn
2015/10/15 18:10:10
You could add:
#else
CHECK(!uses_nonsfi_mode);
o
hidehiko
2015/10/19 04:39:17
Done.
|
| + // The low-level kSandboxIPCChannel is used by renderers and NaCl for |
| + // various operations. See the LinuxSandbox::METHOD_* methods. NaCl uses |
| + // LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT in SFI mode, so this |
| + // should only be closed in Non-SFI mode. |
| + // This file descriptor is insidiously used by a number of APIs. Closing it |
| + // could lead to difficult to debug issues. Instead of closing it, replace |
| + // it with a dummy. |
| + const int sandbox_ipc_channel = |
| + base::GlobalDescriptors::kBaseDescriptor + kSandboxIPCChannel; |
| + |
| + ReplaceFDWithDummy(sandbox_ipc_channel); |
| + |
| + // Install crash signal handlers before disallowing system calls. |
| + nonsfi_initialize_signal_handler(); |
| #endif |
| - } |
| // Always ignore SIGPIPE, for consistency with other Chrome processes and |
| // because some IPC code, such as sync_socket_posix.cc, requires this. |