diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-20 07:05:23 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-20 07:05:23 +0000 |
commit | 4da8a2e32bc164d2402c29ade52c2babcfff0d39 (patch) | |
tree | cfd73d77e42cb9c49af61d2aef873ffc4ea16afd /chrome/plugin/plugin_channel_base.h | |
parent | ca4a992e75a7466f9c0f50544af0883d9ef9a90b (diff) | |
download | chromium_src-4da8a2e32bc164d2402c29ade52c2babcfff0d39.zip chromium_src-4da8a2e32bc164d2402c29ade52c2babcfff0d39.tar.gz chromium_src-4da8a2e32bc164d2402c29ade52c2babcfff0d39.tar.bz2 |
The renderer and plugin processes can send over raw NPObjects valid in the other side's address
space. Basically the way this works is if an NPObject is marshaled over to the other side, an
NPObjectStub is created in the caller address space and a NPObjectProxy is created on the other side.
The NPObjectProxy is passed the raw NPObject pointer which is used as a cookie.
If the original NPObject needs to be passed back we pass the underlying NPObject saved in the NPObjectProxy.
The receiver does not validate whether this NPObject is valid before invoking on it.
While this is mostly fine, in the case of a compromised renderer invalid addresses could be passed back
to the plugin which would invoke on these addresses and crash.
Fix is to never pass raw object pointers across and just pass the corresponding routing id of the NPObjectStub.
The receiver validates this object by invoking a new method GetNPObjectListenerForRoute on the PluginChannelBase.
This method returns the corresponding NPObject listener for the routing id. We then retrieve the underlying NPObject
from the listener and use it.
The map of NPObjectListeners which is maintained by PluginChannelBase has been changed to hold NPObjectBase
pointers instead. NPObjectStub and NPObjectProxy implement the new NPObjectBase interface which provides
methods to return the underlying NPObject and the IPC::Channel::Listener pointer.
Fixes bug http://code.google.com/p/chromium/issues/detail?id=31880
I verified with the steps outlined in the bug that this fix does address the underlying crash.
Bug=31880
Test=We need a framework to test PluginChannel and NPObjectProxy/Stub. Will add a test case for this
once we have this in place.
Review URL: http://codereview.chromium.org/548046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36618 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin/plugin_channel_base.h')
-rw-r--r-- | chrome/plugin/plugin_channel_base.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/chrome/plugin/plugin_channel_base.h b/chrome/plugin/plugin_channel_base.h index f4aab85..455ca12 100644 --- a/chrome/plugin/plugin_channel_base.h +++ b/chrome/plugin/plugin_channel_base.h @@ -14,6 +14,7 @@ #include "base/ref_counted.h" #include "base/scoped_ptr.h" #include "chrome/common/message_router.h" +#include "chrome/plugin/npobject_base.h" #include "ipc/ipc_sync_channel.h" // Encapsulates an IPC channel between a renderer and a plugin process. @@ -28,7 +29,8 @@ class PluginChannelBase : public IPC::Channel::Listener, // lifetime of this object (by passing true for npobject) because we don't // want a leak of an NPObject in a plugin to keep the channel around longer // than necessary. - void AddRoute(int route_id, IPC::Channel::Listener* listener, bool npobject); + void AddRoute(int route_id, IPC::Channel::Listener* listener, + NPObjectBase* npobject); void RemoveRoute(int route_id); // IPC::Message::Sender implementation: @@ -55,6 +57,10 @@ class PluginChannelBase : public IPC::Channel::Listener, static void CleanupChannels(); + // Returns the NPObjectBase object for the route id passed in. + // Returns NULL on failure. + NPObjectBase* GetNPObjectListenerForRoute(int route_id); + protected: typedef PluginChannelBase* (*PluginChannelFactory)(); @@ -107,7 +113,7 @@ class PluginChannelBase : public IPC::Channel::Listener, // Keep track of all the registered NPObjects proxies/stubs so that when the // channel is closed we can inform them. - typedef base::hash_map<int, IPC::Channel::Listener*> ListenerMap; + typedef base::hash_map<int, NPObjectBase*> ListenerMap; ListenerMap npobject_listeners_; // Used to implement message routing functionality to WebPlugin[Delegate] |