#include <ipc/ipc_hash.h>
#include <ipc/ipc_table.h>
#include <ipc/ipc_right.h>
+
+#include <security/mac_mach_internal.h>
#endif
/*
if (space == IS_NULL)
return KERN_INVALID_TASK;
+#if !(DEVELOPMENT | DEBUG)
+ const boolean_t dbg_ok = (mac_task_check_expose_task(kernel_task) == 0);
+#else
+ const boolean_t dbg_ok = TRUE;
+#endif
+
/* start with in-line memory */
table_size = 0;
if (table_size != table_size_needed) {
if (table_size != 0)
kmem_free(ipc_kernel_map, table_addr, table_size);
- kr = kmem_alloc(ipc_kernel_map, &table_addr, table_size_needed);
+ kr = kmem_alloc(ipc_kernel_map, &table_addr, table_size_needed, VM_KERN_MEMORY_IPC);
if (kr != KERN_SUCCESS) {
return KERN_RESOURCE_SHORTAGE;
}
iin->iin_type = IE_BITS_TYPE(bits);
if ((entry->ie_bits & MACH_PORT_TYPE_PORT_RIGHTS) != MACH_PORT_TYPE_NONE &&
entry->ie_request != IE_REQ_NONE) {
- ipc_port_t port = (ipc_port_t) entry->ie_object;
+ __IGNORE_WCASTALIGN(ipc_port_t port = (ipc_port_t) entry->ie_object);
assert(IP_VALID(port));
ip_lock(port);
}
iin->iin_urefs = IE_BITS_UREFS(bits);
- iin->iin_object = (natural_t)VM_KERNEL_ADDRPERM((uintptr_t)entry->ie_object);
+ iin->iin_object = (dbg_ok) ? (natural_t)VM_KERNEL_ADDRPERM((uintptr_t)entry->ie_object) : 0;
iin->iin_next = entry->ie_next;
iin->iin_hash = entry->ie_index;
}
/* prepare the table out-of-line data for return */
if (table_size > 0) {
- if (table_size > infop->iis_table_size * sizeof(ipc_info_name_t))
+ vm_size_t used_table_size;
+
+ used_table_size = infop->iis_table_size * sizeof(ipc_info_name_t);
+ if (table_size > used_table_size)
bzero((char *)&table_info[infop->iis_table_size],
- table_size - infop->iis_table_size * sizeof(ipc_info_name_t));
+ table_size - used_table_size);
kr = vm_map_unwire(
ipc_kernel_map,
FALSE);
assert(kr == KERN_SUCCESS);
kr = vm_map_copyin(ipc_kernel_map, (vm_map_address_t)table_addr,
- (vm_map_size_t)table_size, TRUE, ©);
+ (vm_map_size_t)used_table_size, TRUE, ©);
assert(kr == KERN_SUCCESS);
*tablep = (ipc_info_name_t *)copy;
*tableCntp = infop->iis_table_size;
if (space == IS_NULL)
return KERN_INVALID_TASK;
+
is_read_lock(space);
if (!is_active(space)) {
is_read_unlock(space);
return KERN_INVALID_RIGHT;
}
- port = (ipc_port_t) entry->ie_object;
+ __IGNORE_WCASTALIGN(port = (ipc_port_t) entry->ie_object);
assert(port != IP_NULL);
ip_lock(port);
kaddr = (mach_vm_address_t)port->ip_kobject;
ip_unlock(port);
-#if !(DEVELOPMENT || DEBUG)
- /* disable this interface on release kernels */
- *addrp = 0;
-#else
+#if (DEVELOPMENT || DEBUG)
if (0 != kaddr && is_ipc_kobject(*typep))
*addrp = VM_KERNEL_UNSLIDE_OR_PERM(kaddr);
else
- *addrp = 0;
#endif
+ *addrp = 0;
return KERN_SUCCESS;
}
#endif /* MACH_IPC_DEBUG */
-
/*
* Routine: mach_port_kernel_object [Legacy kernel call]
* Purpose: