summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2020-07-06 16:10:49 -0700
committerAnis Assi <anisassi@google.com>2020-08-07 09:56:59 -0700
commitad31dbbdcd76091d7d2d1fc6c863ee17c3bfe87d (patch)
treedc7ba3bac05828e8a374c7f5650c5f17ca362888
parentde42bc39cc5603d82998de00c7bf234bc40b0305 (diff)
downloadbase-android-9.0.0_r61.tar.gz
Add missing isShellUser checkandroid-9.0.0_r61
Bug: 160390416 Test: verified command still works from shell Change-Id: I23bb06e00f1623e4f27c02d7eb2c0d273b40771b (cherry picked from commit 03542611973e4ce3ddca522ee12bcc85e59ce901) Merged-In: I23bb06e00f1623e4f27c02d7eb2c0d273b40771b (cherry picked from commit 5e2931c6569aa8084be9d0690a1ca30534f49c46) (cherry picked from commit 4a31000e6072c14608ec1c59321481c8aa330313)
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index a2ea8e0dac29..a6d103136c8a 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -4818,9 +4818,18 @@ public class ActivityManagerService extends IActivityManager.Stub
return procState;
}
+ private boolean isCallerShell() {
+ final int callingUid = Binder.getCallingUid();
+ return callingUid == SHELL_UID || callingUid == ROOT_UID;
+ }
+
@Override
public boolean setProcessMemoryTrimLevel(String process, int userId, int level)
throws RemoteException {
+ if (!isCallerShell()) {
+ EventLog.writeEvent(0x534e4554, 160390416, Binder.getCallingUid(), "");
+ throw new SecurityException("Only shell can call it");
+ }
synchronized (this) {
final ProcessRecord app = findProcessLocked(process, userId, "setProcessMemoryTrimLevel");
if (app == null) {