/*
* Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * 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.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 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 OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * 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_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.
+ */
/*
*/
/*
* of the message.
*/
+struct ipc_labelh;
struct ipc_kmsg {
struct ipc_kmsg *ikm_next;
struct ipc_kmsg *ikm_prev;
ipc_port_t ikm_prealloc; /* port we were preallocated from */
mach_msg_size_t ikm_size;
+ struct ipc_labelh *ikm_sender;
mach_msg_header_t *ikm_header;
};
+#if defined(__i386__) || defined(__arm__)
+#define IKM_SUPPORT_LEGACY 1
+#else
+#define IKM_SUPPORT_LEGACY 0
+#endif
#define IKM_OVERHEAD (sizeof(struct ipc_kmsg))
ip_release(port); \
MACRO_END
-
#define ikm_init(kmsg, size) \
MACRO_BEGIN \
(kmsg)->ikm_size = (size); \
(kmsg)->ikm_prealloc = IP_NULL; \
+ (kmsg)->ikm_sender = NULL; \
assert((kmsg)->ikm_prev = (kmsg)->ikm_next = IKM_BOGUS); \
MACRO_END
assert((kmsg)->ikm_next == IKM_BOGUS); \
MACRO_END
+#define ikm_set_header(kmsg, mtsize) \
+MACRO_BEGIN \
+ (kmsg)->ikm_header = (mach_msg_header_t *) \
+ ((vm_offset_t)((kmsg) + 1) + (kmsg)->ikm_size - (mtsize)); \
+MACRO_END
+
struct ipc_kmsg_queue {
struct ipc_kmsg *ikmq_base;
};
/*
* extern void
* ipc_kmsg_send_always(ipc_kmsg_t);
- *
- * Unfortunately, to avoid warnings/lint about unused variables
- * when assertions are turned off, we need two versions of this.
*/
-#if MACH_ASSERT
-
-#define ipc_kmsg_send_always(kmsg) \
-MACRO_BEGIN \
- mach_msg_return_t mr2; \
- \
- mr2 = ipc_kmsg_send((kmsg), MACH_SEND_ALWAYS, \
- MACH_MSG_TIMEOUT_NONE); \
- assert(mr == MACH_MSG_SUCCESS); \
-MACRO_END
-
-#else /* MACH_ASSERT */
-
#define ipc_kmsg_send_always(kmsg) \
-MACRO_BEGIN \
- (void) ipc_kmsg_send((kmsg), MACH_SEND_ALWAYS, \
- MACH_MSG_TIMEOUT_NONE); \
-MACRO_END
-
-#endif /* MACH_ASSERT */
+ ipc_kmsg_send((kmsg), MACH_SEND_ALWAYS, MACH_MSG_TIMEOUT_NONE)
/* Allocate a kernel message */
extern void ipc_kmsg_destroy_dest(
ipc_kmsg_t kmsg);
-
/* Preallocate a kernel message buffer */
+extern ipc_kmsg_t ipc_kmsg_prealloc(
+ mach_msg_size_t size);
+
+/* bind a preallocated message buffer to a port */
extern void ipc_kmsg_set_prealloc(
ipc_kmsg_t kmsg,
ipc_port_t port);
-/* Clear a kernel message buffer */
+/* Clear preallocated message buffer binding */
extern void ipc_kmsg_clear_prealloc(
ipc_kmsg_t kmsg,
ipc_port_t port);
extern void ipc_kmsg_copyin_from_kernel(
ipc_kmsg_t kmsg);
+#if IKM_SUPPORT_LEGACY
+extern void ipc_kmsg_copyin_from_kernel_legacy(
+ ipc_kmsg_t kmsg);
+#endif
+
/* Copyout port rights in the header of a message */
extern mach_msg_return_t ipc_kmsg_copyout_header(
mach_msg_header_t *msg,
ipc_kmsg_t kmsg,
ipc_space_t space);
+#if IKM_SUPPORT_LEGACY
+extern void ipc_kmsg_copyout_to_kernel_legacy(
+ ipc_kmsg_t kmsg,
+ ipc_space_t space);
+#endif
+
/* get a scatter list and check consistency */
extern mach_msg_body_t *ipc_kmsg_get_scatter(
mach_vm_address_t msg_addr,
mach_msg_size_t slist_size);
#endif /* _IPC_IPC_KMSG_H_ */
+