From b77d8b60857be5f5724b080ca42d2dfb2755e0fb Mon Sep 17 00:00:00 2001 From: Simranjit Singh Kohli Date: Fri, 7 Aug 2015 17:07:23 -0700 Subject: [PATCH] [Fix getAccounts MANAGE_USERS permission] Make code having potential to call userInfo inside clearIdentity. Bug: 22917218 Change-Id: If95fb7c0ec36a2f5c737f04bc7d8af95b44fea22 --- .../server/accounts/AccountManagerService.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java index 83e8db06d6f14..aab6374cff83b 100644 --- a/services/core/java/com/android/server/accounts/AccountManagerService.java +++ b/services/core/java/com/android/server/accounts/AccountManagerService.java @@ -2604,7 +2604,8 @@ public class AccountManagerService // Prune the list down to just the requested type. visibleAccountTypes = new ArrayList<>(); visibleAccountTypes.add(type); - } // else aggregate all the visible accounts (it won't matter if the list is empty). + } // else aggregate all the visible accounts (it won't matter if the + // list is empty). long identityToken = clearCallingIdentity(); try { @@ -3788,8 +3789,15 @@ public class AccountManagerService private List getTypesForCaller( int callingUid, int userId, boolean isOtherwisePermitted) { List managedAccountTypes = new ArrayList<>(); + long identityToken = Binder.clearCallingIdentity(); + Collection> serviceInfos; + try { + serviceInfos = mAuthenticatorCache.getAllServices(userId); + } finally { + Binder.restoreCallingIdentity(identityToken); + } for (RegisteredServicesCache.ServiceInfo serviceInfo : - mAuthenticatorCache.getAllServices(userId)) { + serviceInfos) { final int sigChk = mPackageManager.checkSignatures(serviceInfo.uid, callingUid); if (isOtherwisePermitted || sigChk == PackageManager.SIGNATURE_MATCH) { managedAccountTypes.add(serviceInfo.type.type);