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

Commit 101c6789 authored by Arve Hjnnevg's avatar Arve Hjnnevg Committed by android-build-merger
Browse files

DO NOT MERGE ServiceManager: Restore basic uid check am: 247ae463

am: 171ab279

Change-Id: I3cfc70e8fb1dd393a92ace283d36ee2b35585ea4
parents b990d753 171ab279
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -107,9 +107,14 @@ static bool check_mac_perms_from_lookup(pid_t spid, const char *perm, const char
    return allowed;
}

static int svc_can_register(const uint16_t *name, size_t name_len, pid_t spid)
static int svc_can_register(const uint16_t *name, size_t name_len, pid_t spid, uid_t uid)
{
    const char *perm = "add";

    if (uid >= AID_APP) {
        return 0; /* Don't allow apps to register services */
    }

    return check_mac_perms_from_lookup(spid, perm, str8(name, name_len)) ? 1 : 0;
}

@@ -204,7 +209,7 @@ int do_add_service(struct binder_state *bs,
    if (!handle || (len == 0) || (len > 127))
        return -1;

    if (!svc_can_register(s, len, spid)) {
    if (!svc_can_register(s, len, spid, uid)) {
        ALOGE("add_service('%s',%x) uid=%d - PERMISSION DENIED\n",
             str8(s, len), handle, uid);
        return -1;