Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52ba8f1a authored by Kunal Malhotra's avatar Kunal Malhotra Committed by Android Build Coastguard Worker
Browse files

Adding in verification of calling UID in onShellCommand

Test: manual testing on device
Bug: b/261709193
(cherry picked from commit b651d295)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:3ef3f18ba3094c4cc4f954ba23d1da421f9ca8b0)
Merged-In: I68903ebd6d3d85f4bc820b745e3233a448b62273
Change-Id: I68903ebd6d3d85f4bc820b745e3233a448b62273
parent 57cd7d2a
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -8704,6 +8704,13 @@ public class ActivityManagerService extends IActivityManager.Stub
    public void onShellCommand(FileDescriptor in, FileDescriptor out,
            FileDescriptor err, String[] args, ShellCallback callback,
            ResultReceiver resultReceiver) {
        final int callingUid = Binder.getCallingUid();
        if (callingUid != ROOT_UID && callingUid != Process.SHELL_UID) {
            if (resultReceiver != null) {
                resultReceiver.send(-1, null);
            }
            throw new SecurityException("Shell commands are only callable by root or shell");
        }
        (new ActivityManagerShellCommand(this, false)).exec(
                this, in, out, err, args, callback, resultReceiver);
    }