Merge commit '219b580fed7916ed4e02dd634e003073f91c6b93' into manual_merge_219b580fe

am: 84548cfbfb

Change-Id: If48564795bbe12183be06d60bdfa757819b418c8
This commit is contained in:
Yifan Hong 2017-08-03 20:34:22 +00:00 committed by android-build-merger
commit 5cd3d789b8
2 changed files with 13 additions and 6 deletions

View file

@ -8,10 +8,9 @@
#include <stdlib.h>
#include <string.h>
#include <cutils/android_filesystem_config.h>
#include <cutils/multiuser.h>
#include <private/android_filesystem_config.h>
#include <selinux/android.h>
#include <selinux/avc.h>

View file

@ -15,6 +15,8 @@
*/
#include <inttypes.h>
#include <pwd.h>
#include <sys/types.h>
#define LOG_TAG "BufferQueueConsumer"
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
@ -34,7 +36,6 @@
#include <binder/IPCThreadState.h>
#include <binder/PermissionCache.h>
#include <private/android_filesystem_config.h>
namespace android {
@ -745,12 +746,19 @@ status_t BufferQueueConsumer::discardFreeBuffers() {
}
status_t BufferQueueConsumer::dumpState(const String8& prefix, String8* outResult) const {
struct passwd* pwd = getpwnam("shell");
uid_t shellUid = pwd ? pwd->pw_uid : 0;
if (!shellUid) {
int savedErrno = errno;
BQ_LOGE("Cannot get AID_SHELL");
return savedErrno ? -savedErrno : UNKNOWN_ERROR;
}
const IPCThreadState* ipc = IPCThreadState::self();
const pid_t pid = ipc->getCallingPid();
const uid_t uid = ipc->getCallingUid();
if ((uid != AID_SHELL)
&& !PermissionCache::checkPermission(String16(
"android.permission.DUMP"), pid, uid)) {
if ((uid != shellUid) &&
!PermissionCache::checkPermission(String16("android.permission.DUMP"), pid, uid)) {
outResult->appendFormat("Permission Denial: can't dump BufferQueueConsumer "
"from pid=%d, uid=%d\n", pid, uid);
android_errorWriteWithInfoLog(0x534e4554, "27046057",