From ca0653a424f9d0f64ad15236c882af2b8ed2fe00 Mon Sep 17 00:00:00 2001 From: Craig Mautner Date: Tue, 17 Feb 2015 10:17:21 -0800 Subject: Do not make ActivityContainer available to apps. DO NOT MERGE A security leak was discovered whereby a malicious app could get the IActivityContainer object from one app and use it to inject events into another app. This fix removes the availability of the IActivityContainer and replaces its one use with a method for returning the information the IActivityContainer was used for. Fixes bug 19394591. Change-Id: Ib3cec25b25130cd8e098892c057742cfd575cfdd --- core/java/android/app/ActivityManagerNative.java | 29 ++++++++---------------- core/java/android/app/ActivityThread.java | 5 +--- core/java/android/app/IActivityManager.java | 5 ++-- 3 files changed, 12 insertions(+), 27 deletions(-) (limited to 'core') diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index e8d08b8..8c57169 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -17,7 +17,6 @@ package android.app; import android.app.ActivityManager.StackInfo; -import android.app.ProfilerInfo; import android.content.ComponentName; import android.content.IIntentReceiver; import android.content.IIntentSender; @@ -2209,17 +2208,12 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM return true; } - case GET_ACTIVITY_CONTAINER_TRANSACTION: { + case GET_ACTIVITY_DISPLAY_ID_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); IBinder activityToken = data.readStrongBinder(); - IActivityContainer activityContainer = getEnclosingActivityContainer(activityToken); + int displayId = getActivityDisplayId(activityToken); reply.writeNoException(); - if (activityContainer != null) { - reply.writeInt(1); - reply.writeStrongBinder(activityContainer.asBinder()); - } else { - reply.writeInt(0); - } + reply.writeInt(displayId); return true; } @@ -5238,26 +5232,21 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } - public IActivityContainer getEnclosingActivityContainer(IBinder activityToken) - throws RemoteException { + @Override + public int getActivityDisplayId(IBinder activityToken) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeStrongBinder(activityToken); - mRemote.transact(GET_ACTIVITY_CONTAINER_TRANSACTION, data, reply, 0); + mRemote.transact(GET_ACTIVITY_DISPLAY_ID_TRANSACTION, data, reply, 0); reply.readException(); - final int result = reply.readInt(); - final IActivityContainer res; - if (result == 1) { - res = IActivityContainer.Stub.asInterface(reply.readStrongBinder()); - } else { - res = null; - } + final int displayId = reply.readInt(); data.recycle(); reply.recycle(); - return res; + return displayId; } + @Override public IBinder getHomeActivityToken() throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index f2be45c..8353d54 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -2339,10 +2339,7 @@ public final class ActivityThread { final DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance(); try { - IActivityContainer container = - ActivityManagerNative.getDefault().getEnclosingActivityContainer(r.token); - final int displayId = - container == null ? Display.DEFAULT_DISPLAY : container.getDisplayId(); + final int displayId = ActivityManagerNative.getDefault().getActivityDisplayId(r.token); if (displayId > Display.DEFAULT_DISPLAY) { Display display = dm.getRealDisplay(displayId, r.token); baseContext = appContext.createDisplayContext(display); diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java index e505d69..dd3a38b 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -438,8 +438,7 @@ public interface IActivityManager extends IInterface { public void deleteActivityContainer(IActivityContainer container) throws RemoteException; - public IActivityContainer getEnclosingActivityContainer(IBinder activityToken) - throws RemoteException; + public int getActivityDisplayId(IBinder activityToken) throws RemoteException; public IBinder getHomeActivityToken() throws RemoteException; @@ -754,7 +753,7 @@ public interface IActivityManager extends IInterface { int GET_PERSISTED_URI_PERMISSIONS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+181; int APP_NOT_RESPONDING_VIA_PROVIDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+182; int GET_HOME_ACTIVITY_TOKEN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+183; - int GET_ACTIVITY_CONTAINER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+184; + int GET_ACTIVITY_DISPLAY_ID_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+184; int DELETE_ACTIVITY_CONTAINER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+185; -- cgit v1.1