summaryrefslogtreecommitdiffstats
path: root/chrome/plugin/npobject_proxy.h
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-20 07:05:23 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-20 07:05:23 +0000
commit4da8a2e32bc164d2402c29ade52c2babcfff0d39 (patch)
treecfd73d77e42cb9c49af61d2aef873ffc4ea16afd /chrome/plugin/npobject_proxy.h
parentca4a992e75a7466f9c0f50544af0883d9ef9a90b (diff)
downloadchromium_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/npobject_proxy.h')
-rw-r--r--chrome/plugin/npobject_proxy.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/chrome/plugin/npobject_proxy.h b/chrome/plugin/npobject_proxy.h
index c5f3e597..f372a52 100644
--- a/chrome/plugin/npobject_proxy.h
+++ b/chrome/plugin/npobject_proxy.h
@@ -10,6 +10,7 @@
#include "app/gfx/native_widget_types.h"
#include "base/ref_counted.h"
+#include "chrome/plugin/npobject_base.h"
#include "googleurl/src/gurl.h"
#include "ipc/ipc_channel.h"
#include "third_party/npapi/bindings/npruntime.h"
@@ -26,13 +27,13 @@ struct NPObject;
// side translates the IPC messages into calls to the actual NPObject, and
// returns the marshalled result.
class NPObjectProxy : public IPC::Channel::Listener,
- public IPC::Message::Sender {
+ public IPC::Message::Sender,
+ public NPObjectBase {
public:
~NPObjectProxy();
static NPObject* Create(PluginChannelBase* channel,
int route_id,
- intptr_t npobject_ptr,
gfx::NativeViewId containing_window,
const GURL& page_url);
@@ -41,10 +42,6 @@ class NPObjectProxy : public IPC::Channel::Listener,
int route_id() { return route_id_; }
PluginChannelBase* channel() { return channel_; }
- // Returns the real NPObject's pointer (obviously only valid in the other
- // process).
- intptr_t npobject_ptr() { return npobject_ptr_; }
-
// The next 9 functions are called on NPObjects from the plugin and browser.
static bool NPHasMethod(NPObject *obj,
NPIdentifier name);
@@ -92,10 +89,18 @@ class NPObjectProxy : public IPC::Channel::Listener,
static NPObjectProxy* GetProxy(NPObject* object);
static const NPClass* npclass() { return &npclass_proxy_; }
+ // NPObjectBase implementation.
+ virtual NPObject* GetUnderlyingNPObject() {
+ return NULL;
+ }
+
+ IPC::Channel::Listener* GetChannelListener() {
+ return static_cast<IPC::Channel::Listener*>(this);
+ }
+
private:
NPObjectProxy(PluginChannelBase* channel,
int route_id,
- intptr_t npobject_ptr,
gfx::NativeViewId containing_window,
const GURL& page_url);
@@ -112,7 +117,6 @@ class NPObjectProxy : public IPC::Channel::Listener,
scoped_refptr<PluginChannelBase> channel_;
int route_id_;
- intptr_t npobject_ptr_;
gfx::NativeViewId containing_window_;
// The url of the main frame hosting the plugin.