summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRiddle Hsu <riddlehsu@google.com>2020-03-03 14:36:21 +0800
committersyphyr <syphyr@gmail.com>2020-05-07 00:52:54 +0200
commit0cd8f1867b55ad7e526a9da66e6d1c8dc99a12c9 (patch)
tree38cc976ff7745814cea93883b5ca4b13b027512b
parentdb8d9ce65e236bcfb420b28dc0ad505da1c990d5 (diff)
downloadandroid_frameworks_base-0cd8f1867b55ad7e526a9da66e6d1c8dc99a12c9.tar.gz
android_frameworks_base-0cd8f1867b55ad7e526a9da66e6d1c8dc99a12c9.tar.bz2
android_frameworks_base-0cd8f1867b55ad7e526a9da66e6d1c8dc99a12c9.zip
RESTRICT AUTOMERGE Use consistent calling uid and package in navigateUpTo
Originally, if the caller of navigateUpTo is alive, even the calling uid is set to the caller who launched the existing destination activity, the uid from caller process has higher priority to replace the given calling uid. So this change doesn't modify the existing behavior if the caller process is valid. Besides, the case of delivering new intent uses the source record as calling identity too, so the case of starting new activity should be consistent. Also forbid attaching null application thread to avoid unexpected state in process record. Bug: 144285917 Test: bit FrameworksServicesTests:ActivityStackTests Test: bit CtsSecurityTestCases:ActivityManagerTest# \ testActivityManager_attachNullApplication Merged-In: I60732f430256d37cb926d08d093581f051c4afed Change-Id: I60732f430256d37cb926d08d093581f051c4afed (cherry picked from commit 1c9bf5cc54d0b32d8f3046c452e710b017c477c0)
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java5
-rw-r--r--services/core/java/com/android/server/am/ActivityStack.java5
2 files changed, 9 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index bcf3cc256fb..72f2c94a795 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -6639,7 +6639,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
- private final boolean attachApplicationLocked(IApplicationThread thread,
+ private boolean attachApplicationLocked(@NonNull IApplicationThread thread,
int pid) {
// Find the application record that is being attached... either via
@@ -6887,6 +6887,9 @@ public final class ActivityManagerService extends ActivityManagerNative
@Override
public final void attachApplication(IApplicationThread thread) {
+ if (thread == null) {
+ throw new SecurityException("Invalid application interface");
+ }
synchronized (this) {
int callingPid = Binder.getCallingPid();
final long origId = Binder.clearCallingIdentity();
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index fdf8d95d7c7..7376fa869ab 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -3738,6 +3738,11 @@ final class ActivityStack {
final boolean navigateUpToLocked(ActivityRecord srec, Intent destIntent, int resultCode,
Intent resultData) {
+ if (srec.app == null || srec.app.thread == null) {
+ // Nothing to do if the caller is not attached, because this method should be called
+ // from an alive activity.
+ return false;
+ }
final TaskRecord task = srec.task;
final ArrayList<ActivityRecord> activities = task.mActivities;
final int start = activities.indexOf(srec);