/*
- * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* 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-2006 SPARTA, Inc.
+ */
/*
*/
/*
#include <kern/kern_types.h>
#include <kern/misc_protos.h>
+#include <kern/ipc_kobject.h>
#include <ipc/ipc_types.h>
#include <ipc/port.h>
#include <ipc/ipc_right.h>
#include <ipc/ipc_notify.h>
#include <ipc/ipc_pset.h>
+#include <ipc/ipc_labelh.h>
+
+#include <security/mac_mach_internal.h>
zone_t ipc_object_zones[IOT_NUMBER];
ipc_port_t port = (ipc_port_t)object;
bzero((char *)port, sizeof(*port));
+#if CONFIG_MACF_MACH
+ mac_port_label_init(&port->ip_label);
+#endif
} else if (otype == IOT_PORT_SET) {
ipc_pset_t pset = (ipc_pset_t)object;
ipc_port_t port = (ipc_port_t)object;
bzero((char *)port, sizeof(*port));
+#if CONFIG_MACF_MACH
+ mac_port_label_init(&port->ip_label);
+#endif
} else if (otype == IOT_PORT_SET) {
ipc_pset_t pset = (ipc_pset_t)object;
return kr;
}
-#if MACH_ASSERT
+/*
+ * Get a label out of a port, to be used by a kernel call
+ * that takes a security label as a parameter. In this case, we want
+ * to use the label stored in the label handle and not the label on its
+ * port.
+ *
+ * The port should be locked for this call. The lock protecting
+ * label handle contents should not be necessary, as they can only
+ * be modified when a label handle with one reference is a task label.
+ * User allocated label handles can never be modified.
+ */
+#if CONFIG_MACF_MACH
+struct label *io_getlabel (ipc_object_t objp)
+{
+ ipc_port_t port = (ipc_port_t)objp;
+
+ assert(io_otype(objp) == IOT_PORT);
+
+ if (ip_kotype(port) == IKOT_LABELH)
+ return &((ipc_labelh_t) port->ip_kobject)->lh_label;
+ else
+ return &port->ip_label;
+}
+#endif
+#if MACH_ASSERT || CONFIG_MACF_MACH
/*
* Check whether the object is a port if so, free it. But
* keep track of that fact.
#if MACH_ASSERT
ipc_port_track_dealloc(port);
#endif /* MACH_ASSERT */
+
+#if CONFIG_MACF_MACH
+ /* Port label should have been initialized after creation. */
+ mac_port_label_destroy(&port->ip_label);
+#endif
}
zfree(ipc_object_zones[otype], object);
}
-#endif /* MACH_ASSERT */
+#endif /* MACH_ASSER || MAC */
#include <mach_kdb.h>
#if MACH_KDB
#include <ddb/db_output.h>
-#include <kern/ipc_kobject.h>
#define printf kdbprintf
"(IOKIT_OBJECT) ", /* 30 */
"(UPL) ",
"(MEM_OBJ_CONTROL) ",
+#if CONFIG_MACF_MACH
+ "(LABELH) ",
+#endif
/*
* Add new entries here.
* Please keep in sync with kern/ipc_kobject.h