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

Commit a94f129a authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

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
parent 2bf03060
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -20,6 +20,6 @@
using namespace android;
using namespace android;


int main(int argc, char** argv) {
int main(int argc, char** argv) {
    SurfaceFlinger::publishAndJoinThreadPool();
    SurfaceFlinger::publishAndJoinThreadPool(true);
    return 0;
    return 0;
}
}
+4 −4
Original line number Original line Diff line number Diff line
@@ -34,15 +34,15 @@ template<typename SERVICE>
class BinderService
class BinderService
{
{
public:
public:
    static status_t publish() {
    static status_t publish(bool allowIsolated = false) {
        sp<IServiceManager> sm(defaultServiceManager());
        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<ProcessState> proc(ProcessState::self());
        sp<IServiceManager> sm(defaultServiceManager());
        sp<IServiceManager> sm(defaultServiceManager());
        sm->addService(String16(SERVICE::getServiceName()), new SERVICE());
        sm->addService(String16(SERVICE::getServiceName()), new SERVICE(), allowIsolated);
        ProcessState::self()->startThreadPool();
        ProcessState::self()->startThreadPool();
        IPCThreadState::self()->joinThreadPool();
        IPCThreadState::self()->joinThreadPool();
    }
    }
+2 −1
Original line number Original line Diff line number Diff line
@@ -47,7 +47,8 @@ public:
     * Register a service.
     * Register a service.
     */
     */
    virtual status_t            addService( const String16& name,
    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.
     * Return list of all existing services.
+3 −1
Original line number Original line Diff line number Diff line
@@ -151,12 +151,14 @@ public:
        return reply.readStrongBinder();
        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;
        Parcel data, reply;
        data.writeInterfaceToken(IServiceManager::getInterfaceDescriptor());
        data.writeInterfaceToken(IServiceManager::getInterfaceDescriptor());
        data.writeString16(name);
        data.writeString16(name);
        data.writeStrongBinder(service);
        data.writeStrongBinder(service);
        data.writeInt32(allowIsolated ? 1 : 0);
        status_t err = remote()->transact(ADD_SERVICE_TRANSACTION, data, &reply);
        status_t err = remote()->transact(ADD_SERVICE_TRANSACTION, data, &reply);
        return err == NO_ERROR ? reply.readExceptionCode() : err;
        return err == NO_ERROR ? reply.readExceptionCode() : err;
    }
    }