Only allow access to the dexopt commands from root or shell.
To align with ART Service behaviour (cf.
commit 62e115d7682ee3ee277ab250499cb7afa8dffc50 in art/).
This also drops the intentionally allowed app use of the
`dump-profiles` command from
commit a877708286.
Test: adb shell pm dump-profiles com.android.egg
Bug: 251903639
Change-Id: Ib547600e98bb9fab938f09b90f25cf80a762c78e
This commit is contained in:
@@ -6675,15 +6675,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
|
||||
@Deprecated
|
||||
public void legacyDumpProfiles(String packageName, boolean dumpClassesAndMethods)
|
||||
throws LegacyDexoptDisabledException {
|
||||
/* Only the shell, root, or the app user should be able to dump profiles. */
|
||||
final int callingUid = Binder.getCallingUid();
|
||||
final Computer snapshot = snapshotComputer();
|
||||
final String[] callerPackageNames = snapshot.getPackagesForUid(callingUid);
|
||||
if (!PackageManagerServiceUtils.isRootOrShell(callingUid)
|
||||
&& !ArrayUtils.contains(callerPackageNames, packageName)) {
|
||||
throw new SecurityException("dumpProfiles");
|
||||
}
|
||||
|
||||
AndroidPackage pkg = snapshot.getPackage(packageName);
|
||||
if (pkg == null) {
|
||||
throw new IllegalArgumentException("Unknown package: " + packageName);
|
||||
|
||||
@@ -391,6 +391,11 @@ class PackageManagerShellCommand extends ShellCommand {
|
||||
private int runLegacyDexoptCommand(@NonNull String cmd)
|
||||
throws RemoteException, LegacyDexoptDisabledException {
|
||||
Installer.checkLegacyDexoptDisabled();
|
||||
|
||||
if (!PackageManagerServiceUtils.isRootOrShell(Binder.getCallingUid())) {
|
||||
throw new SecurityException("Dexopt shell commands need root or shell access");
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case "compile":
|
||||
return runCompile();
|
||||
|
||||
Reference in New Issue
Block a user