+#if CONFIG_MACF_MACH
+ /*
+ * We do the port send check here instead of in ipc_kmsg_send()
+ * because copying the header involves copying the port rights too
+ * and we need to do the send check before anything is actually copied.
+ */
+ entry = ipc_entry_lookup(space, dest_name);
+ if (entry != IE_NULL) {
+ int error = 0;
+ ipc_port_t port = (ipc_port_t) entry->ie_object;
+ if (port == IP_NULL)
+ goto invalid_dest;
+ ip_lock(port);
+ if (ip_active(port)) {
+ task_t self = current_task();
+ tasklabel_lock(self);
+ error = mac_port_check_send(&self->maclabel,
+ &port->ip_label);
+ tasklabel_unlock(self);
+ }
+ ip_unlock(port);
+ if (error != 0)
+ goto invalid_dest;
+ }
+#endif