Revise the IllegalArgumentException check

Combining the two IllegalArgumentException check in getKeySetByAlias
to mitigate the potential information leakage.

Bug: 189858116
Test: atest PackageManagerTests
Test: manually using the PoC in the buganizer to ensure the symptom
      no longer exists.
Change-Id: Id407900e156555db1ec6b87cbcd233a9976f242e
This commit is contained in:
Jackal Guo
2021-06-15 13:01:25 +08:00
parent 96d2926fc7
commit 30611ae54d

View File

@@ -26421,16 +26421,12 @@ public class PackageManagerService extends IPackageManager.Stub
}
synchronized(mLock) {
final AndroidPackage pkg = mPackages.get(packageName);
if (pkg == null) {
if (pkg == null
|| shouldFilterApplicationLocked(getPackageSetting(pkg.getPackageName()),
Binder.getCallingUid(), UserHandle.getCallingUserId())) {
Slog.w(TAG, "KeySet requested for unknown package: " + packageName);
throw new IllegalArgumentException("Unknown package: " + packageName);
}
final PackageSetting ps = getPackageSetting(pkg.getPackageName());
if (shouldFilterApplicationLocked(
ps, Binder.getCallingUid(), UserHandle.getCallingUserId())) {
Slog.w(TAG, "KeySet requested for filtered package: " + packageName);
throw new IllegalArgumentException("Unknown package: " + packageName);
}
final KeySetManagerService ksms = mSettings.getKeySetManagerService();
return new KeySet(ksms.getKeySetByAliasAndPackageNameLPr(packageName, alias));
}