summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author kholoud mohamed <kholoudm@google.com> 2020-01-16 17:34:06 +0000
committer Kholoud Mohamed <kholoudm@google.com> 2020-01-22 13:01:13 +0000
commit971e7cc56463f871ded3c257d337730d9ace04d5 (patch)
tree7eac52ab8493c92a8e470cbcf2c1f7e5bdb13e63
parenta263d01c447f4bf5d946dfb4361ad78a5ecce7b1 (diff)
Restrict bindServiceAsUser to same package with _ACROSS_PROFILES
Only allow bindServiceAsUser to bind to a service with the same calling package if caller has _ACROSS_PROFILES permission. BUG: 136249261 Test: atest ContextCrossProfileHostTest Change-Id: I0754258e58cab9acba1109088a22ad403bc74f2f
-rw-r--r--services/core/java/com/android/server/am/ActiveServices.java18
1 files changed, 15 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index 3ffa5dea4d89..ac85bf57e9b0 100644
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -31,6 +31,7 @@ import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_SERVICE_E
import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
+import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
import android.app.ActivityThread;
@@ -2068,9 +2069,9 @@ public final class ActiveServices {
if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "retrieveServiceLocked: " + service
+ " type=" + resolvedType + " callingUid=" + callingUid);
- userId = mAm.mUserController.handleIncomingUser(callingPid, callingUid, userId, false,
- ActivityManagerInternal.ALLOW_ALL_PROFILE_PERMISSIONS_IN_PROFILE, "service",
- callingPackage);
+ userId = mAm.mUserController.handleIncomingUser(callingPid, callingUid, userId,
+ /* allowAll= */false, getAllowMode(service, callingPackage),
+ /* name= */ "service", callingPackage);
ServiceMap smap = getServiceMapLocked(userId);
final ComponentName comp;
@@ -2260,6 +2261,17 @@ public final class ActiveServices {
return null;
}
+ private int getAllowMode(Intent service, @Nullable String callingPackage) {
+ if (callingPackage == null || service.getComponent() == null) {
+ return ActivityManagerInternal.ALLOW_NON_FULL_IN_PROFILE;
+ }
+ if (callingPackage.equals(service.getComponent().getPackageName())) {
+ return ActivityManagerInternal.ALLOW_ALL_PROFILE_PERMISSIONS_IN_PROFILE;
+ } else {
+ return ActivityManagerInternal.ALLOW_NON_FULL_IN_PROFILE;
+ }
+ }
+
private final void bumpServiceExecutingLocked(ServiceRecord r, boolean fg, String why) {
if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, ">>> EXECUTING "
+ why + " of " + r + " in app " + r.app);