DO NOT MERGE ServiceManager: Restore basic uid check
Prevent apps from registering services without relying on selinux checks. Bug: 29431260 Change-Id: I38c6e8bc7f7cba1cbd3568e8fed1ae7ac2054a9b (cherry picked from commit f03ba2c0d878071603d73b7f8e9a4a468364ac27)
This commit is contained in:
parent
07cd4cdf21
commit
dbee7f4650
@ -107,9 +107,14 @@ static bool check_mac_perms_from_lookup(pid_t spid, const char *perm, const char
|
|||||||
return allowed;
|
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";
|
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;
|
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))
|
if (!handle || (len == 0) || (len > 127))
|
||||||
return -1;
|
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",
|
ALOGE("add_service('%s',%x) uid=%d - PERMISSION DENIED\n",
|
||||||
str8(s, len), handle, uid);
|
str8(s, len), handle, uid);
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user