summaryrefslogtreecommitdiffstats
path: root/libs/gui/include
diff options
context:
space:
mode:
authorRobert Carr <racarr@google.com>2019-04-11 13:18:21 -0700
committerRobert Carr <racarr@google.com>2019-04-15 14:30:19 -0700
commitc0df312c34d92161e955fd1057afaa1337b7a56d (patch)
treea7fffbb585f25f1a377f78a97f80c423593dc666 /libs/gui/include
parent27e6f2b579ebca586411ced6106c48b014730160 (diff)
downloadandroid_frameworks_native-c0df312c34d92161e955fd1057afaa1337b7a56d.tar.gz
android_frameworks_native-c0df312c34d92161e955fd1057afaa1337b7a56d.tar.bz2
android_frameworks_native-c0df312c34d92161e955fd1057afaa1337b7a56d.zip
SurfaceFlinger: Validate layers before casting.
Reinterpret casting random IBinder = no-fun. I first attempted to use inheritance of "getInterfaceDescriptor" in Layer::Handle but departing from "standard-layout" (e.g. using virtual methods) means that downcasting with static/reinterpret_cast is no longer valid. Instead I opted for the pattern the system-server uses of maintaing a map. Now that we look up the handle in a map rather than casting IBinder to Layer::Handle we need to make sure we have unique instances of the handle. In general this is true but we weren't doing this in the createWithSurfaceParent where we had an extra call to getHandle. Here we both refactor createWithSurfaceParent so it works with the new changes and also add protection for getHandle. We also fix an error where the handle map was populated outside of lock. Bug: 129768960 Test: InvalidHandles_test.cpp ASurfaceControlTest SurfaceControlTest Change-Id: I869bf6164c8d8203af7486ed1b12a763d5a56662
Diffstat (limited to 'libs/gui/include')
-rw-r--r--libs/gui/include/gui/SurfaceControl.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/libs/gui/include/gui/SurfaceControl.h b/libs/gui/include/gui/SurfaceControl.h
index 55efcbfb3..23bfc0256 100644
--- a/libs/gui/include/gui/SurfaceControl.h
+++ b/libs/gui/include/gui/SurfaceControl.h
@@ -84,6 +84,9 @@ public:
explicit SurfaceControl(const sp<SurfaceControl>& other);
+ SurfaceControl(const sp<SurfaceComposerClient>& client, const sp<IBinder>& handle,
+ const sp<IGraphicBufferProducer>& gbp, bool owned);
+
private:
// can't be copied
SurfaceControl& operator = (SurfaceControl& rhs);
@@ -92,12 +95,6 @@ private:
friend class SurfaceComposerClient;
friend class Surface;
- SurfaceControl(
- const sp<SurfaceComposerClient>& client,
- const sp<IBinder>& handle,
- const sp<IGraphicBufferProducer>& gbp,
- bool owned);
-
~SurfaceControl();
sp<Surface> generateSurfaceLocked() const;