]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/ipc/ipc_port.h
xnu-1504.3.12.tar.gz
[apple/xnu.git] / osfmk / ipc / ipc_port.h
index 5df916d98f813a2d269fefa7816af960a4fd3ccd..4998a84bc6e860b3186daaae68767f3ad3d8de42 100644 (file)
@@ -1,31 +1,29 @@
 /*
- * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2008 Apple Computer, 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.
+ */
 /*
  */
 /*
@@ -68,6 +72,8 @@
 #ifndef        _IPC_IPC_PORT_H_
 #define _IPC_IPC_PORT_H_
 
+#if MACH_KERNEL_PRIVATE
+
 #include <norma_vm.h>
 #include <mach_rt.h>
 #include <mach_assert.h>
@@ -85,6 +91,8 @@
 #include <ipc/ipc_mqueue.h>
 #include <ipc/ipc_space.h>
 
+#include <security/_label.h>
+
 /*
  *  A receive right (port) can be in four states:
  *     1) dead (not active, ip_timestamp has death time)
@@ -105,10 +113,12 @@ typedef unsigned int ipc_port_timestamp_t;
 struct ipc_port {
 
        /*
-        * Initial sub-structure in common with ipc_pset and rpc_port
-        * First element is an ipc_object
+        * Initial sub-structure in common with ipc_pset
+        * First element is an ipc_object second is a
+        * message queue
         */
        struct ipc_object ip_object;
+       struct ipc_mqueue ip_messages;
 
        union {
                struct ipc_space *receiver;
@@ -126,8 +136,8 @@ struct ipc_port {
        struct ipc_port_request *ip_dnrequests;
 
        unsigned int ip_pset_count;
-       struct ipc_mqueue ip_messages;
        struct ipc_kmsg *ip_premsg;
+       mach_vm_address_t ip_context;
 
 #if    NORMA_VM
        /*
@@ -140,26 +150,31 @@ struct ipc_port {
 #endif
 
 #if    MACH_ASSERT
-#define        IP_NSPARES              10
-#define        IP_CALLSTACK_MAX        10
+#define        IP_NSPARES              4
+#define        IP_CALLSTACK_MAX        16
        queue_chain_t   ip_port_links;  /* all allocated ports */
        thread_t        ip_thread;      /* who made me?  thread context */
        unsigned long   ip_timetrack;   /* give an idea of "when" created */
        natural_t       ip_callstack[IP_CALLSTACK_MAX]; /* stack trace */
        unsigned long   ip_spares[IP_NSPARES]; /* for debugging */
 #endif /* MACH_ASSERT */
-       int             alias;
+       uintptr_t               alias;
+
+#if CONFIG_MACF_MACH
+        struct label    ip_label;
+#endif
 };
 
 
 #define ip_references          ip_object.io_references
 #define ip_bits                        ip_object.io_bits
-#define ip_receiver_name       ip_object.io_receiver_name
 
 #define        ip_receiver             data.receiver
 #define        ip_destination          data.destination
 #define        ip_timestamp            data.timestamp
 
+#define ip_receiver_name       ip_messages.imq_receiver_name
+
 #define IP_NULL                        IPC_PORT_NULL
 #define IP_DEAD                        IPC_PORT_DEAD
 #define        IP_VALID(port)          IPC_PORT_VALID(port)
@@ -219,22 +234,26 @@ struct ipc_port_request {
 #define        ipr_soright             notify.port
 #define        ipr_name                name.name
 
+extern lck_grp_t       ipc_lck_grp;
+extern lck_attr_t      ipc_lck_attr;
+
 /*
  *     Taking the ipc_port_multiple lock grants the privilege
  *     to lock multiple ports at once.  No ports must locked
  *     when it is taken.
  */
 
-decl_mutex_data(extern,ipc_port_multiple_lock_data)
+decl_lck_mtx_data(extern,ipc_port_multiple_lock_data)
+extern lck_mtx_ext_t   ipc_port_multiple_lock_data_ext;
 
 #define        ipc_port_multiple_lock_init()                                   \
-               mutex_init(&ipc_port_multiple_lock_data, 0)
+               lck_mtx_init_ext(&ipc_port_multiple_lock_data, &ipc_port_multiple_lock_data_ext, &ipc_lck_grp, &ipc_lck_attr)
 
 #define        ipc_port_multiple_lock()                                        \
-               mutex_lock(&ipc_port_multiple_lock_data)
+               lck_mtx_lock(&ipc_port_multiple_lock_data)
 
 #define        ipc_port_multiple_unlock()                                      \
-               mutex_unlock(&ipc_port_multiple_lock_data)
+               lck_mtx_unlock(&ipc_port_multiple_lock_data)
 
 /*
  *     The port timestamp facility provides timestamps
@@ -242,17 +261,19 @@ decl_mutex_data(extern,ipc_port_multiple_lock_data)
  *     mach_port_names with port death.
  */
 
-decl_mutex_data(extern,ipc_port_timestamp_lock_data)
+decl_lck_mtx_data(extern,ipc_port_timestamp_lock_data)
+extern lck_mtx_ext_t   ipc_port_timestamp_lock_data_ext;
+
 extern ipc_port_timestamp_t ipc_port_timestamp_data;
 
 #define        ipc_port_timestamp_lock_init()                                  \
-               mutex_init(&ipc_port_timestamp_lock_data, 0)
+               lck_mtx_init_ext(&ipc_port_timestamp_lock_data, &ipc_port_timestamp_lock_data_ext, &ipc_lck_grp, &ipc_lck_attr)
 
 #define        ipc_port_timestamp_lock()                                       \
-               mutex_lock(&ipc_port_timestamp_lock_data)
+               lck_mtx_lock(&ipc_port_timestamp_lock_data)
 
 #define        ipc_port_timestamp_unlock()                                     \
-               mutex_unlock(&ipc_port_timestamp_lock_data)
+               lck_mtx_unlock(&ipc_port_timestamp_lock_data)
 
 /* Retrieve a port timestamp value */
 extern ipc_port_timestamp_t ipc_port_timestamp(void);
@@ -390,10 +411,18 @@ extern mach_port_name_t ipc_port_copyout_send(
        ipc_port_t      sright,
        ipc_space_t     space);
 
+#endif /* MACH_KERNEL_PRIVATE */
+
+#if KERNEL_PRIVATE
+
 /* Release a (valid) naked send right */
 extern void ipc_port_release_send(
        ipc_port_t      port);
 
+#endif /* KERNEL_PRIVATE */
+
+#if MACH_KERNEL_PRIVATE
+
 /* Make a naked send-once right from a receive right */
 extern ipc_port_t ipc_port_make_sonce(
        ipc_port_t      port);
@@ -440,4 +469,6 @@ extern void ipc_port_debug_init(void);
 #define        ipc_port_release(port)          \
                ipc_object_release(&(port)->ip_object)
 
+#endif /* MACH_KERNEL_PRIVATE */
+
 #endif /* _IPC_IPC_PORT_H_ */