summaryrefslogtreecommitdiff
path: root/opengl/libagl/Tokenizer.cpp
diff options
context:
space:
mode:
author Valerie Hau <vhau@google.com> 2019-08-28 14:08:17 -0700
committer Valerie Hau <vhau@google.com> 2019-09-02 19:29:24 +0000
commitc38310ff547909bd8fa2edc562186aa26227e572 (patch)
tree551781f6b38d9c703603ff58d0d09dffae12a2c5 /opengl/libagl/Tokenizer.cpp
parent32615136ae12dfbbb47366522fc2320a0bbdafd5 (diff)
Restrict Automerge: Fix reinterpret_cast security bug
This patch fixes a security bug in SurfaceFlinger. Bug is due to a reinterpret_cast used when obtaining a sp<Layer> from an sp<IBinder> passed from a client. Without a checking mechanism, client could pass a malicious data packet. This is a modified cherry-pick of a patch by Rob Carr that utilizes a map to identify the appropriate layer based on the incoming IBinder token. Original patch commit: "Author: Robert Carr <racarr@google.com> Date: Thu Apr 11 13:18:21 2019 -0700 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: 137284057 Test: build, boot, manual, SurfaceFlinger_test Change-Id: I9b5f298db2da9cd974c423eb52f261a90f0d17dc
Diffstat (limited to 'opengl/libagl/Tokenizer.cpp')
0 files changed, 0 insertions, 0 deletions