OSDN Git Service

ServiceManager: Restore basic uid check
authorArve Hjønnevåg <arve@android.com>
Mon, 1 Aug 2016 23:05:17 +0000 (16:05 -0700)
committergitbuildkicker <android-build@google.com>
Thu, 1 Sep 2016 03:55:49 +0000 (20:55 -0700)
Prevent apps from registering services without relying on selinux checks.

Bug: 29431260

Change-Id: I38c6e8bc7f7cba1cbd3568e8fed1ae7ac2054a9b
(cherry picked from commit 2b74d2c1d2a2c1bb6e9c420f7e9b339ba2a95179)

cmds/servicemanager/service_manager.c

index 21fdff0..8a8e688 100644 (file)
@@ -121,6 +121,11 @@ static bool check_mac_perms_from_lookup(pid_t spid, uid_t uid, const char *perm,
 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, uid, perm, str8(name, name_len)) ? 1 : 0;
 }