]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/ipc_kobject.c
xnu-1228.15.4.tar.gz
[apple/xnu.git] / osfmk / kern / ipc_kobject.c
index 41edf5e953a55e0f26009fe5c9c42d2b38819a84..646788daa56a39ef44bc479b711bb0c9181ca65f 100644 (file)
@@ -1,31 +1,29 @@
 /*
- * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
  *
- * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
- * This file contains Original Code and/or Modifications of Original Code 
- * as defined in and that are subject to the Apple Public Source License 
- * Version 2.0 (the 'License'). You may not use this file except in 
- * compliance with the License.  The rights granted to you under the 
- * License may not be used to create, or enable the creation or 
- * redistribution of, unlawful or unlicensed copies of an Apple operating 
- * system, or to circumvent, violate, or enable the circumvention or 
- * violation of, any terms of an Apple operating system software license 
- * agreement.
- *
- * Please obtain a copy of the License at 
- * http://www.opensource.apple.com/apsl/ and read it before using this 
- * file.
- *
- * The Original Code and all software distributed under the License are 
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
- * Please see the License for the specific language governing rights and 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ * 
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
  * limitations under the License.
- *
- * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
+ * 
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 /*
  * @OSF_COPYRIGHT@
  * any improvements or extensions that they make and grant Carnegie Mellon
  * the rights to redistribute these changes.
  */
+/*
+ * NOTICE: This file was modified by McAfee Research in 2004 to introduce
+ * support for mandatory and extensible security protections.  This notice
+ * is included in support of clause 2.2 (b) of the Apple Public License,
+ * Version 2.0.
+ * Copyright (c) 2005 SPARTA, Inc.
+ */
 /*
  */
 /*
 #include <kern/misc_protos.h>
 #include <ipc/ipc_kmsg.h>
 #include <ipc/ipc_port.h>
+#include <ipc/ipc_labelh.h>
 #include <kern/counters.h>
 
-#include <vm/vm_shared_memory_server.h>
 #include <vm/vm_protos.h>
 
+#include <security/mac_mach_internal.h>
+
 /*
  *     Routine:        ipc_kobject_notify
  *     Purpose:
@@ -156,6 +163,9 @@ mig_hash_t mig_buckets[MAX_MIG_ENTRIES];
 int mig_table_max_displ;
 mach_msg_size_t mig_reply_size;
 
+#if CONFIG_MACF
+#include <mach/security_server.h>
+#endif
 
 
 
@@ -189,6 +199,10 @@ const struct mig_subsystem *mig_e[] = {
 #if     MCMSG && iPSC860
        (const struct mig_subsystem *)&mcmsg_info_subsystem,
 #endif  /* MCMSG && iPSC860 */
+
+#if CONFIG_MACF
+       (const struct mig_subsystem *)&security_subsystem,
+#endif
 };
 
 void
@@ -210,7 +224,7 @@ mig_init(void)
            nentry = j + mig_e[i]->start;       
            for (pos = MIG_HASH(nentry) % MAX_MIG_ENTRIES, howmany = 1;
                 mig_buckets[pos].num;
-                pos = ++pos % MAX_MIG_ENTRIES, howmany++) {
+                pos++, pos = pos % MAX_MIG_ENTRIES, howmany++) {
                 if (mig_buckets[pos].num == nentry) {
                        printf("message id = %d\n", nentry);
                        panic("multiple entries with the same msgh_id");
@@ -435,6 +449,11 @@ ipc_kobject_set(
 {
        ip_lock(port);
        ipc_kobject_set_atomically(port, kobject, type);
+
+#if CONFIG_MACF_MACH
+       mac_port_label_update_kobject (&port->ip_label, type);
+#endif
+
        ip_unlock(port);
 }
 
@@ -484,6 +503,12 @@ ipc_kobject_destroy(
                host_notify_port_destroy(port);
                break;
 
+#if CONFIG_MACF_MACH
+       case IKOT_LABELH:
+               labelh_destroy(port);
+               break;
+#endif
+
        default:
                break;
        }
@@ -518,8 +543,7 @@ ipc_kobject_notify(
                                (mach_port_mscount_t) 
                                ((mach_no_senders_notification_t *) 
                                 request_header)->not_count);
-                          (ipc_port_t)reply_header->msgh_remote_port
-                                  = MACH_PORT_NULL;
+                          reply_header->msgh_remote_port = MACH_PORT_NULL;
                           return TRUE;
                   }
                                
@@ -593,7 +617,7 @@ kobjserver_stats(void)
            nentry = j + mig_e[i]->start;       
            for (pos = MIG_HASH(nentry) % MAX_MIG_ENTRIES, howmany = 1;
                 mig_buckets[pos].num;
-                pos = ++pos % MAX_MIG_ENTRIES, howmany++) {
+                pos++, pos = pos % MAX_MIG_ENTRIES, howmany++) {
                    if (mig_buckets[pos].num == nentry)
                        bucket_stats_print(&mig_buckets[pos]);
            }