Enforce permission checks in getting app exit reasons Bug: 165595677 Test: atest CtsSecurityTestCases:ActivityManagerTest Change-Id: Ia758d32bce6b2ac4c7145a96eccf68a962f0748b (cherry picked from commit e9b1dd415fed5415bc21abbd8e2f653fda5cf30c)
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 3b85180..091c77e 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -10459,12 +10459,10 @@ } finally { Binder.restoreCallingIdentity(identity); } - if (uid == Process.INVALID_UID) { - return Process.INVALID_UID; - } + // If the uid is Process.INVALID_UID, the below 'if' check will be always true if (UserHandle.getAppId(uid) != UserHandle.getAppId(callingUid)) { // Requires the DUMP permission if the target package doesn't belong - // to the caller. + // to the caller or it doesn't exist. enforceCallingPermission(android.Manifest.permission.DUMP, function); } return uid;