summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-02-09 16:12:18 -0800
committerDianne Hackborn <hackbod@google.com>2012-02-09 18:06:01 -0800
commita94f129a7bbaa8ea45c50e49ba3e6127ca2a15ec (patch)
treecc601c2c420c5235b4e1526d29509c568f4eb13e
parent2bf030602f54cd4594a64f19fe84661660d18952 (diff)
downloadframeworks_native-a94f129a7bbaa8ea45c50e49ba3e6127ca2a15ec.zip
frameworks_native-a94f129a7bbaa8ea45c50e49ba3e6127ca2a15ec.tar.gz
frameworks_native-a94f129a7bbaa8ea45c50e49ba3e6127ca2a15ec.tar.bz2
Some hardening of isolated processes by restricting access to services.
Services now must explicitly opt in to being accessed by isolated processes. Currently only the activity manager and surface flinger allow this. Activity manager is needed so that we can actually bring up the process; SurfaceFlinger is needed to be able to get the display information for creating the Configuration. The SurfaceFlinger should be safe because the app doesn't have access to the window manager so can't actually get a surface to do anything with. The activity manager now protects most of its entry points against isolated processes. Change-Id: I0dad8cb2c873575c4c7659c3c2a7eda8e98f46b0
-rw-r--r--cmds/surfaceflinger/main_surfaceflinger.cpp2
-rw-r--r--include/binder/BinderService.h8
-rw-r--r--include/binder/IServiceManager.h3
-rw-r--r--libs/binder/IServiceManager.cpp4
4 files changed, 10 insertions, 7 deletions
diff --git a/cmds/surfaceflinger/main_surfaceflinger.cpp b/cmds/surfaceflinger/main_surfaceflinger.cpp
index 78b1007..6dbcf5c 100644
--- a/cmds/surfaceflinger/main_surfaceflinger.cpp
+++ b/cmds/surfaceflinger/main_surfaceflinger.cpp
@@ -20,6 +20,6 @@
using namespace android;
int main(int argc, char** argv) {
- SurfaceFlinger::publishAndJoinThreadPool();
+ SurfaceFlinger::publishAndJoinThreadPool(true);
return 0;
}
diff --git a/include/binder/BinderService.h b/include/binder/BinderService.h
index 2316fef..ca594d3 100644
--- a/include/binder/BinderService.h
+++ b/include/binder/BinderService.h
@@ -34,15 +34,15 @@ template<typename SERVICE>
class BinderService
{
public:
- static status_t publish() {
+ static status_t publish(bool allowIsolated = false) {
sp<IServiceManager> sm(defaultServiceManager());
- return sm->addService(String16(SERVICE::getServiceName()), new SERVICE());
+ return sm->addService(String16(SERVICE::getServiceName()), new SERVICE(), allowIsolated);
}
- static void publishAndJoinThreadPool() {
+ static void publishAndJoinThreadPool(bool allowIsolated = false) {
sp<ProcessState> proc(ProcessState::self());
sp<IServiceManager> sm(defaultServiceManager());
- sm->addService(String16(SERVICE::getServiceName()), new SERVICE());
+ sm->addService(String16(SERVICE::getServiceName()), new SERVICE(), allowIsolated);
ProcessState::self()->startThreadPool();
IPCThreadState::self()->joinThreadPool();
}
diff --git a/include/binder/IServiceManager.h b/include/binder/IServiceManager.h
index 24e9e99..2c297d6 100644
--- a/include/binder/IServiceManager.h
+++ b/include/binder/IServiceManager.h
@@ -47,7 +47,8 @@ public:
* Register a service.
*/
virtual status_t addService( const String16& name,
- const sp<IBinder>& service) = 0;
+ const sp<IBinder>& service,
+ bool allowIsolated = false) = 0;
/**
* Return list of all existing services.
diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp
index 33b305d..1750640 100644
--- a/libs/binder/IServiceManager.cpp
+++ b/libs/binder/IServiceManager.cpp
@@ -151,12 +151,14 @@ public:
return reply.readStrongBinder();
}
- virtual status_t addService(const String16& name, const sp<IBinder>& service)
+ virtual status_t addService(const String16& name, const sp<IBinder>& service,
+ bool allowIsolated)
{
Parcel data, reply;
data.writeInterfaceToken(IServiceManager::getInterfaceDescriptor());
data.writeString16(name);
data.writeStrongBinder(service);
+ data.writeInt32(allowIsolated ? 1 : 0);
status_t err = remote()->transact(ADD_SERVICE_TRANSACTION, data, &reply);
return err == NO_ERROR ? reply.readExceptionCode() : err;
}