diff options
author | hidehiko <hidehiko@chromium.org> | 2015-02-02 23:24:34 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-03 07:25:21 +0000 |
commit | 763f8be26fd888e0ae7070a1a977238d2d65433b (patch) | |
tree | 86cc91fb45426f18c416e46b3bb7658eae88a550 /ipc | |
parent | c007c3a258816c2f6f6ccf7fc808887a03b0a26d (diff) | |
download | chromium_src-763f8be26fd888e0ae7070a1a977238d2d65433b.zip chromium_src-763f8be26fd888e0ae7070a1a977238d2d65433b.tar.gz chromium_src-763f8be26fd888e0ae7070a1a977238d2d65433b.tar.bz2 |
Non-SFI mode: Use dummy PID for NaCl's IPC channel for nacl_helper_nonsfi.
In nacl_helper_nonsfi, getpid() is prohibited to be called by seccomp-bpf
(will be implemented somehow soon). So, base::GetCurrentProcID() used in IPC
library, which uses getpid(), would cause a SIGSYS crashing.
As, in nacl_helper_nonsfi, PID is actually not used, so this CL replaces it
with -1 (dummy PID).
Note that the more generic CL crrev.com/695353005, which replaces PID with
dummy also on Linux platforms, was landed once, but reverted due to it was
still in use (crbug.com/441312). This CL extracts only Non-SFI related
part to avoid breakage.
TEST=Ran bots.
BUG=358465, 441312
CQ_EXTRA_TRYBOTS=tryserver.chromium.linux:linux_rel_precise32,linux_arm
Review URL: https://codereview.chromium.org/879303004
Cr-Commit-Position: refs/heads/master@{#314283}
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/ipc_channel.cc | 7 | ||||
-rw-r--r-- | ipc/ipc_channel_posix.cc | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/ipc/ipc_channel.cc b/ipc/ipc_channel.cc index 4a4e40d..ac09c5a 100644 --- a/ipc/ipc_channel.cc +++ b/ipc/ipc_channel.cc @@ -28,8 +28,13 @@ std::string Channel::GenerateUniqueRandomChannelID() { // the creator, an identifier for the child instance, and a strong random // component. The strong random component prevents other processes from // hijacking or squatting on predictable channel names. - +#if defined(OS_NACL_NONSFI) + // The seccomp sandbox disallows use of getpid(), so we provide a + // dummy PID. + int process_id = -1; +#else int process_id = base::GetCurrentProcId(); +#endif return base::StringPrintf("%d.%u.%d", process_id, g_last_id.GetNext(), diff --git a/ipc/ipc_channel_posix.cc b/ipc/ipc_channel_posix.cc index 6ba1f60..d853e4e 100644 --- a/ipc/ipc_channel_posix.cc +++ b/ipc/ipc_channel_posix.cc @@ -773,14 +773,20 @@ void ChannelPosix::ClosePipeOnError() { } int ChannelPosix::GetHelloMessageProcId() const { +#if defined(OS_NACL_NONSFI) + // In nacl_helper_nonsfi, getpid() invoked by GetCurrentProcId() is not + // allowed and would cause a SIGSYS crash because of the seccomp sandbox. + return -1; +#else int pid = base::GetCurrentProcId(); #if defined(OS_LINUX) // Our process may be in a sandbox with a separate PID namespace. if (global_pid_) { pid = global_pid_; } -#endif +#endif // defined(OS_LINUX) return pid; +#endif // defined(OS_NACL_NONSFI) } void ChannelPosix::QueueHelloMessage() { |