+/*
+ * 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