]> Zhao Yanbai Git Server - minix.git/commitdiff
RS: fix IPC privilege computation bug
authorDavid van Moolenbroek <david@minix3.org>
Wed, 8 Dec 2010 14:54:08 +0000 (14:54 +0000)
committerDavid van Moolenbroek <david@minix3.org>
Wed, 8 Dec 2010 14:54:08 +0000 (14:54 +0000)
Take into account the ALL and ALL_SYS cases when constructing proper
symmetrical IPC send masks. Fix system.conf accordingly, to keep
userland processes from sending to several non-interface servers and
drivers. Also fix IS's F4 formatting.

etc/system.conf
servers/is/dmp_kernel.c
servers/rs/manager.c

index 8671583d8098d107600fa285a8ac6931bb010e0a..d7a1a405b81de064b7e8804e4279730d39f7ac5e 100644 (file)
@@ -23,7 +23,7 @@ service rs
 service ds
 {
        uid     0;
-       ipc     ALL;            # ALL ipc targets allowed
+       ipc     ALL_SYS;        # All system ipc targets allowed
        system  ALL;            # ALL kernel calls allowed
        vm      BASIC;          # Only basic VM calls allowed
        io      NONE;           # No I/O range allowed
@@ -76,7 +76,7 @@ service pm
 service sched
 {
        uid     0;
-       ipc     ALL;            # ALL ipc targets allowed
+       ipc     ALL_SYS;        # All system ipc targets allowed
        system  ALL;            # ALL kernel calls allowed
        vm      BASIC;          # Only basic VM calls allowed
        io      NONE;           # No I/O range allowed
@@ -108,7 +108,7 @@ service vfs
 service mfs
 {
        uid     0;
-       ipc     ALL;            # ALL ipc targets allowed
+       ipc     ALL_SYS;        # All system ipc targets allowed
        system  BASIC;          # Only basic kernel calls allowed
        vm      BASIC;          # Only basic VM calls allowed
        io      NONE;           # No I/O range allowed
@@ -121,7 +121,7 @@ service mfs
 
 service ext2
 {
-       ipc     ALL;            # ALL ipc targets allowed
+       ipc     ALL_SYS;        # All system ipc targets allowed
        system  BASIC;          # Only basic kernel calls allowed
        vm      BASIC;          # Only basic VM calls allowed
        io      NONE;           # No I/O range allowed
@@ -135,7 +135,7 @@ service ext2
 service pfs
 {
        uid     0;
-       ipc     ALL;            # ALL ipc targets allowed
+       ipc     ALL_SYS;        # All system ipc targets allowed
        system  BASIC;          # Only basic kernel calls allowed
        vm      BASIC;          # Only basic VM calls allowed
        io      NONE;           # No I/O range allowed
@@ -149,7 +149,7 @@ service pfs
 service tty
 {
        uid     0;
-       ipc     ALL;            # ALL ipc targets allowed
+       ipc     ALL_SYS;        # All system ipc targets allowed
        system                  # Extra kernel calls allowed:
                KILL            # 06
                SEGCTL          # 12
@@ -177,7 +177,7 @@ service tty
 service memory
 {
        uid     0;
-       ipc     ALL;            # ALL ipc targets allowed
+       ipc     ALL_SYS;        # All system ipc targets allowed
        system                  # Extra kernel calls allowed:
                SEGCTL          # 12
                UMAP            # 14
@@ -202,7 +202,7 @@ service memory
 service log
 {
        uid     0;
-       ipc     ALL;            # ALL ipc targets allowed
+       ipc     ALL_SYS;        # All system ipc targets allowed
        system                  # Extra kernel calls allowed:
                SEGCTL          # 12
                UMAP            # 14
index a69f1161d4c277cf2636cadd3aeb12e71e66d130..3b92ffde7ed11f37b432bee6dcf36ba8dd6a3cff 100644 (file)
@@ -326,7 +326,8 @@ PUBLIC void privileges_dmp()
       return;
   }
 
-  printf("-nr- -id- -name-- -flags-    traps  grants -ipc_to--  -kernel calls-\n");
+  printf("-nr- -id- -name-- -flags- traps grants -ipc_to--"
+    "            -kernel calls-\n");
 
   PROCLOOP(rp, oldrp)
         r = -1;
@@ -335,7 +336,7 @@ PUBLIC void privileges_dmp()
         if (r == -1 && !isemptyp(rp)) {
            sp = &priv[USER_PRIV_ID];
         }
-       printf("(%02u) %-7.7s %s    %s %7d",
+       printf("(%02u) %-7.7s %s %s %6d",
               sp->s_id, rp->p_name,
               s_flags_str(sp->s_flags), s_traps_str(sp->s_trap_mask),
                sp->s_grant_entries);
index 110dfaea09090cf287dc93f5e7c338de3f12d8c7..969969f8dd6649a661daa6b3ff077bdaa2b0dff6 100644 (file)
@@ -1957,7 +1957,7 @@ struct priv *privp;
        struct rproc *rrp;
        struct rprocpub *rrpub;
        char *proc_name;
-       int priv_id;
+       int priv_id, is_ipc_all, is_ipc_all_sys;
 
        proc_name = rp->r_pub->proc_name;
 
@@ -1965,25 +1965,45 @@ struct priv *privp;
                if (!(rrp->r_flags & RS_IN_USE))
                        continue;
 
-               /* If an IPC target list was provided for the process being
-                * checked here, make sure that the name of the new process
+               if (!rrp->r_ipc_list[0])
+                       continue;
+
+               /* If the process being checked is set to allow IPC to all
+                * other processes, or for all other system processes and the
+                * target process is a system process, add a permission bit.
+                */
+               rrpub = rrp->r_pub;
+
+               is_ipc_all = !strcmp(rrp->r_ipc_list, RSS_IPC_ALL);
+               is_ipc_all_sys = !strcmp(rrp->r_ipc_list, RSS_IPC_ALL_SYS);
+
+               if (is_ipc_all ||
+                       (is_ipc_all_sys && (privp->s_flags & SYS_PROC))) {
+#if PRIV_DEBUG
+                       printf("  RS: add_backward_ipc: setting sendto bit "
+                               "for %d...\n", rrpub->endpoint);
+#endif
+                       priv_id= rrp->r_priv.s_id;
+                       set_sys_bit(privp->s_ipc_to, priv_id);
+
+                       continue;
+               }
+
+               /* An IPC target list was provided for the process being
+                * checked here. Make sure that the name of the new process
                 * is in that process's list. There may be multiple matches.
                 */
-               if (rrp->r_ipc_list[0]) {
-                       rrpub = rrp->r_pub;
-                       p = rrp->r_ipc_list;
+               p = rrp->r_ipc_list;
 
-                       while ((p = get_next_name(p, name,
-                               rrpub->label)) != NULL) {
-                               if (!strcmp(proc_name, name)) {
+               while ((p = get_next_name(p, name, rrpub->label)) != NULL) {
+                       if (!strcmp(proc_name, name)) {
 #if PRIV_DEBUG
-                                       printf("  RS: add_backward_ipc: setting"
-                                               " sendto bit for %d...\n",
-                                               rrpub->endpoint);
+                               printf("  RS: add_backward_ipc: setting sendto"
+                                       " bit for %d...\n",
+                                       rrpub->endpoint);
 #endif
-                                       priv_id= rrp->r_priv.s_id;
-                                       set_sys_bit(privp->s_ipc_to, priv_id);
-                               }
+                               priv_id= rrp->r_priv.s_id;
+                               set_sys_bit(privp->s_ipc_to, priv_id);
                        }
                }
        }