diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-19 18:05:11 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-19 18:05:11 +0000 |
commit | 29c5d23eeb86edb8a1ca8a97fb56b0a2e698b759 (patch) | |
tree | bf9fe5f567e6fe59eeb8ee980b39dbb258e106ce /ipc/ipc_channel_proxy.cc | |
parent | 1c0e5732ac1faa5bf69dcd2cae5e91ac52b3fbf0 (diff) | |
download | chromium_src-29c5d23eeb86edb8a1ca8a97fb56b0a2e698b759.zip chromium_src-29c5d23eeb86edb8a1ca8a97fb56b0a2e698b759.tar.gz chromium_src-29c5d23eeb86edb8a1ca8a97fb56b0a2e698b759.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/7661004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97481 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_channel_proxy.cc')
-rw-r--r-- | ipc/ipc_channel_proxy.cc | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc index dc990c2..db801fd 100644 --- a/ipc/ipc_channel_proxy.cc +++ b/ipc/ipc_channel_proxy.cc @@ -71,10 +71,15 @@ ChannelProxy::Context::~Context() { } void ChannelProxy::Context::CreateChannel(const IPC::ChannelHandle& handle, - const Channel::Mode& mode) { + const Channel::Mode& mode, + bool needs_override_peer_pid) { DCHECK(channel_.get() == NULL); channel_id_ = handle.name; channel_.reset(new Channel(handle, mode, this)); +#if defined(OS_LINUX) + if (needs_override_peer_pid) + channel_->SetNeedsOverridePeerPid(); +#endif } bool ChannelProxy::Context::TryFilters(const Message& message) { @@ -226,6 +231,14 @@ void ChannelProxy::Context::OnRemoveFilter(MessageFilter* filter) { NOTREACHED() << "filter to be removed not found"; } +#if defined(OS_LINUX) +// Called on the IPC::Channel thread +void ChannelProxy::Context::OnOverridePeerPid(int32 peer_pid) { + if (channel_.get()) + channel_->OverridePeerPid(peer_pid); +} +#endif // defined(OS_LINUX) + // Called on the listener's thread void ChannelProxy::Context::AddFilter(MessageFilter* filter) { base::AutoLock auto_lock(pending_filters_lock_); @@ -282,20 +295,23 @@ void ChannelProxy::Context::OnDispatchError() { ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, Channel::Listener* listener, - base::MessageLoopProxy* ipc_thread) + base::MessageLoopProxy* ipc_thread, + bool needs_override_peer_pid) : context_(new Context(listener, ipc_thread)), outgoing_message_filter_(NULL) { - Init(channel_handle, mode, ipc_thread, true); + Init(channel_handle, mode, ipc_thread, true, needs_override_peer_pid); } ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, base::MessageLoopProxy* ipc_thread, + bool needs_override_peer_pid, Context* context, bool create_pipe_now) : context_(context), outgoing_message_filter_(NULL) { - Init(channel_handle, mode, ipc_thread, create_pipe_now); + Init(channel_handle, mode, ipc_thread, create_pipe_now, + needs_override_peer_pid); } ChannelProxy::~ChannelProxy() { @@ -305,7 +321,8 @@ ChannelProxy::~ChannelProxy() { void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, base::MessageLoopProxy* ipc_thread_loop, - bool create_pipe_now) { + bool create_pipe_now, + bool needs_override_peer_pid) { #if defined(OS_POSIX) // When we are creating a server on POSIX, we need its file descriptor // to be created immediately so that it can be accessed and passed @@ -321,10 +338,11 @@ void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, // low-level pipe so that the client can connect. Without creating // the pipe immediately, it is possible for a listener to attempt // to connect and get an error since the pipe doesn't exist yet. - context_->CreateChannel(channel_handle, mode); + context_->CreateChannel(channel_handle, mode, needs_override_peer_pid); } else { context_->ipc_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( - context_.get(), &Context::CreateChannel, channel_handle, mode)); + context_.get(), &Context::CreateChannel, channel_handle, mode, + needs_override_peer_pid)); } // complete initialization on the background thread @@ -392,6 +410,13 @@ bool ChannelProxy::GetClientEuid(uid_t* client_euid) const { } #endif +#if defined(OS_LINUX) +void ChannelProxy::OverridePeerPid(int32 peer_pid) { + context_->ipc_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( + context_.get(), &Context::OnOverridePeerPid, peer_pid)); +} +#endif // defined(OS_LINUX) + //----------------------------------------------------------------------------- } // namespace IPC |