Skip to content

Commit 04ee44c

Browse files
pceballosgoogleandi34
authored andcommitted
DO NOT MERGE BQ: Add permission check to BufferQueueConsumer::dump
Bug 27046057 Change-Id: I387178708f460596433f75bb059854a26cc22e78 (cherry picked from commit 64e357d)
1 parent 371f043 commit 04ee44c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

libs/gui/BufferQueue.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
#include <utils/Trace.h>
3434
#include <utils/CallStack.h>
3535

36+
#include <binder/IPCThreadState.h>
37+
#include <binder/PermissionCache.h>
38+
#include <private/android_filesystem_config.h>
39+
3640
// Macros for including the BufferQueue name in log messages
3741
#define ST_LOGV(x, ...) ALOGV("[%s] "x, mConsumerName.string(), ##__VA_ARGS__)
3842
#define ST_LOGD(x, ...) ALOGD("[%s] "x, mConsumerName.string(), ##__VA_ARGS__)
@@ -769,6 +773,16 @@ status_t BufferQueue::disconnect(int api) {
769773
}
770774

771775
void BufferQueue::dump(String8& result, const char* prefix) const {
776+
const IPCThreadState* ipc = IPCThreadState::self();
777+
const pid_t pid = ipc->getCallingPid();
778+
const uid_t uid = ipc->getCallingUid();
779+
if ((uid != AID_SHELL)
780+
&& !PermissionCache::checkPermission(String16(
781+
"android.permission.DUMP"), pid, uid)) {
782+
result.appendFormat("Permission Denial: can't dump BufferQueueConsumer "
783+
"from pid=%d, uid=%d\n", pid, uid);
784+
return;
785+
}
772786
Mutex::Autolock _l(mMutex);
773787

774788
String8 fifo;

0 commit comments

Comments
 (0)