+ } else if (replyp->ip_receiver == ipc_space_kernel) {
+ /*
+ * Don't send replies to kobject kernel ports
+ */
+#if DEVELOPMENT || DEBUG
+ printf("%s: refusing to send reply to kobject %d port (id:%d)\n",
+ __func__, ip_kotype(replyp),
+ request->ikm_header->msgh_id);
+#endif /* DEVELOPMENT || DEBUG */
+ ipc_kmsg_destroy(reply);
+ return IKM_NULL;
+ }
+
+ /* Fail the MIG call if the task exec token changed during the call */
+ if (kr == KERN_SUCCESS && exec_token_changed) {
+ /*
+ * Create a new reply msg with error and destroy the old reply msg.
+ */
+ ipc_kmsg_t new_reply = ipc_kmsg_alloc(reply_size);
+
+ if (new_reply == IKM_NULL) {
+ printf("ipc_kobject_server: dropping request\n");
+ ipc_kmsg_destroy(reply);
+ return IKM_NULL;
+ }
+ /*
+ * Initialize the new reply message.
+ */
+ {
+#define OutP_new ((mig_reply_error_t *) new_reply->ikm_header)
+#define OutP_old ((mig_reply_error_t *) reply->ikm_header)
+
+ bzero((void *)OutP_new, reply_size);
+
+ OutP_new->NDR = OutP_old->NDR;
+ OutP_new->Head.msgh_size = sizeof(mig_reply_error_t);
+ OutP_new->Head.msgh_bits = OutP_old->Head.msgh_bits & ~MACH_MSGH_BITS_COMPLEX;
+ OutP_new->Head.msgh_remote_port = OutP_old->Head.msgh_remote_port;
+ OutP_new->Head.msgh_local_port = MACH_PORT_NULL;
+ OutP_new->Head.msgh_voucher_port = MACH_PORT_NULL;
+ OutP_new->Head.msgh_id = OutP_old->Head.msgh_id;
+
+ /* Set the error as KERN_INVALID_TASK */
+ OutP_new->RetCode = KERN_INVALID_TASK;
+
+#undef OutP_new
+#undef OutP_old
+ }
+
+ /*
+ * Destroy everything in reply except the reply port right,
+ * which is needed in the new reply message.
+ */
+ reply->ikm_header->msgh_remote_port = MACH_PORT_NULL;
+ ipc_kmsg_destroy(reply);
+
+ reply = new_reply;