summaryrefslogtreecommitdiffstats
path: root/ipc/ipc_channel_posix.cc
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-31 21:11:04 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-31 21:11:04 +0000
commite1d67a8826a4a19e370b8f9f18b45bff4d4de163 (patch)
tree986b2ec88dc7a312435bb307e648daeac401a648 /ipc/ipc_channel_posix.cc
parent943b86100cc75e6fbccdf82aeca23cce9aa66508 (diff)
downloadchromium_src-e1d67a8826a4a19e370b8f9f18b45bff4d4de163.zip
chromium_src-e1d67a8826a4a19e370b8f9f18b45bff4d4de163.tar.gz
chromium_src-e1d67a8826a4a19e370b8f9f18b45bff4d4de163.tar.bz2
Fix IPC OnChannelConnected() to send correct PID on Linux/CrOS
Sandboxed renderers on Linux/CrOS are in a PID namespace, so they don't know their own global PID. Thus the PID sent in the IPC channel Hello message contains an unexpected value, which is used in the OnChannelConnected() callback into chrome. This causes problems like the Task Manager not showing any data for FPS, JavaScript memory and image cache memory. The task manager is attempting to use the PID/process handle from BrowserMessageFilter, which got it from IPC::Channel::Listener::OnChannelConnected(), and it doesn't match the global PID of each renderer. BUG=70179 TEST=manual, open a few tabs, then open task manager, right-click to turn on JavaScript memory and image memory. Verify there are non-zero values for FPS, JavaScript memory, image cache memory Review URL: http://codereview.chromium.org/7778031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99040 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_channel_posix.cc')
-rw-r--r--ipc/ipc_channel_posix.cc32
1 files changed, 30 insertions, 2 deletions
diff --git a/ipc/ipc_channel_posix.cc b/ipc/ipc_channel_posix.cc
index 8cda88b..df927d0 100644
--- a/ipc/ipc_channel_posix.cc
+++ b/ipc/ipc_channel_posix.cc
@@ -293,6 +293,10 @@ bool SocketWriteErrorIsRecoverable() {
} // namespace
//------------------------------------------------------------------------------
+#if defined(OS_LINUX)
+int Channel::ChannelImpl::global_pid_ = 0;
+#endif // OS_LINUX
+
Channel::ChannelImpl::ChannelImpl(const IPC::ChannelHandle& channel_handle,
Mode mode, Listener* listener)
: mode_(mode),
@@ -997,6 +1001,13 @@ bool Channel::ChannelImpl::IsNamedServerInitialized(
return file_util::PathExists(FilePath(channel_id));
}
+#if defined(OS_LINUX)
+// static
+void Channel::ChannelImpl::SetGlobalPid(int pid) {
+ global_pid_ = pid;
+}
+#endif // OS_LINUX
+
// Called by libevent when we can read from the pipe without blocking.
void Channel::ChannelImpl::OnFileCanReadWithoutBlocking(int fd) {
bool send_server_hello_msg = false;
@@ -1109,13 +1120,23 @@ void Channel::ChannelImpl::ClosePipeOnError() {
}
}
+int Channel::ChannelImpl::GetHelloMessageProcId() {
+ 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
+ return pid;
+}
+
void Channel::ChannelImpl::QueueHelloMessage() {
// Create the Hello message
scoped_ptr<Message> msg(new Message(MSG_ROUTING_NONE,
HELLO_MESSAGE_TYPE,
IPC::Message::PRIORITY_NORMAL));
-
- if (!msg->WriteInt(base::GetCurrentProcId())) {
+ if (!msg->WriteInt(GetHelloMessageProcId())) {
NOTREACHED() << "Unable to pickle hello message proc id";
}
#if defined(IPC_USES_READWRITE)
@@ -1211,4 +1232,11 @@ bool Channel::IsNamedServerInitialized(const std::string& channel_id) {
return ChannelImpl::IsNamedServerInitialized(channel_id);
}
+#if defined(OS_LINUX)
+// static
+void Channel::SetGlobalPid(int pid) {
+ ChannelImpl::SetGlobalPid(pid);
+}
+#endif // OS_LINUX
+
} // namespace IPC