From 6e8d0f67ad12a2819c0bd5f39f28e484aa3c92a2 Mon Sep 17 00:00:00 2001 From: Rhed Jao Date: Tue, 31 May 2022 19:40:57 +0800 Subject: [PATCH 1/2] Fix cross user package visibility leakage for hasSigningCertificate - To fix cross user package visibility leakage for the API #hasSigningCertificate, this CL returns false if the target package does not install in the calling user. Bug: 229684723 Test: atest CrossUserPackageVisibilityTests Change-Id: Id82ed5d2d4678acf185ea3561787c0213d4c0224 --- .../core/java/com/android/server/pm/ComputerEngine.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/pm/ComputerEngine.java b/services/core/java/com/android/server/pm/ComputerEngine.java index 5bdc9d821e7c4..b19ed167244ba 100644 --- a/services/core/java/com/android/server/pm/ComputerEngine.java +++ b/services/core/java/com/android/server/pm/ComputerEngine.java @@ -4453,13 +4453,11 @@ public class ComputerEngine implements Computer { if (p == null) { return false; } - final PackageStateInternal ps = getPackageStateInternal(p.getPackageName()); - if (ps == null) { - return false; - } final int callingUid = Binder.getCallingUid(); final int callingUserId = UserHandle.getUserId(callingUid); - if (shouldFilterApplication(ps, callingUid, callingUserId)) { + final PackageStateInternal ps = getPackageStateInternal(p.getPackageName()); + if (ps == null + || shouldFilterApplicationIncludingUninstalled(ps, callingUid, callingUserId)) { return false; } switch (type) { From 44edc937602b575d2077e34ddc7c1fec2b92fe9e Mon Sep 17 00:00:00 2001 From: Rhed Jao Date: Wed, 1 Jun 2022 17:38:33 +0800 Subject: [PATCH 2/2] Fix cross user package visibility leakage for canPackageQuery API Returns false if the target packages are not installed under the calling user. Bug: 229684723 Test: atest CrossUserPackageVisibilityTests Change-Id: Ie76f85bef808c3fef366d334978d007691f43991 --- .../core/java/com/android/server/pm/ComputerEngine.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/pm/ComputerEngine.java b/services/core/java/com/android/server/pm/ComputerEngine.java index b19ed167244ba..dce609fe3148f 100644 --- a/services/core/java/com/android/server/pm/ComputerEngine.java +++ b/services/core/java/com/android/server/pm/ComputerEngine.java @@ -5547,7 +5547,7 @@ public class ComputerEngine implements Computer { final PackageStateInternal packageState = getPackageStateInternal(component.getPackageName()); return packageState != null && !shouldFilterApplication(packageState, callingUid, - component, TYPE_UNKNOWN, userId); + component, TYPE_UNKNOWN, userId, true /* filterUninstall */); } @Override @@ -5591,9 +5591,9 @@ public class ComputerEngine implements Computer { boolean throwException = sourceSetting == null || targetSetting == null; if (!throwException) { final boolean filterSource = - shouldFilterApplication(sourceSetting, callingUid, userId); + shouldFilterApplicationIncludingUninstalled(sourceSetting, callingUid, userId); final boolean filterTarget = - shouldFilterApplication(targetSetting, callingUid, userId); + shouldFilterApplicationIncludingUninstalled(targetSetting, callingUid, userId); // The caller must have visibility of the both packages throwException = filterSource || filterTarget; }