Skip to content
Mach trap#-18

svc · mach trap -18

_kernelrpc_mach_port_deallocate_trap

Trap-level entry point that backs mach_port_deallocate — drops one user reference on a send or send-once right.

Prototype

kern_return_t _kernelrpc_mach_port_deallocate_trap(/* 2 args */);

Returns: kern_return_t

Version history

XNU tagmacOS#
xnu-2050.18.24macOS 10.8 Mountain Lion-18
xnu-2422.115.4macOS 10.9 Mavericks-18
xnu-2782.40.9macOS 10.10 Yosemite-18
xnu-3247.1.106macOS 10.11 El Capitan-18
xnu-3789.1.32macOS 10.12 Sierra-18
xnu-4570.1.46macOS 10.13 High Sierra-18
xnu-4903.221.2macOS 10.14 Mojave-18
xnu-6153.11.26macOS 10.15 Catalina-18
xnu-7195.50.7.100.1macOS 11.0 Big Sur-18
xnu-8019.41.5macOS 12.0 Monterey-18
xnu-8792.41.9macOS 13.0 Ventura-18
xnu-10002.1.13macOS 14.0 Sonoma-18
xnu-11215.1.10macOS 15.0 Sequoia-18
xnu-11417.101.15macOS 15.4 Sequoia-18
xnu-12377.1.9macOS 26.0 Tahoe-18
xnu-10002.41.9—-18
xnu-10002.61.3—-18
xnu-10002.81.5—-18
xnu-10063.101.15—-18
xnu-10063.121.3—-18
xnu-10063.141.1—-18
xnu-11215.41.3—-18
xnu-11215.61.5—-18
xnu-11215.81.4—-18
xnu-11417.121.6—-18
xnu-11417.140.69—-18
xnu-12377.101.15—-18
xnu-12377.41.6—-18
xnu-12377.61.12—-18
xnu-12377.81.4—-18
xnu-2050.22.13—-18
xnu-2050.24.15—-18
xnu-2050.48.11—-18
xnu-2050.7.9—-18
xnu-2050.9.2—-18
xnu-2422.1.72—-18
xnu-2422.100.13—-18
xnu-2422.110.17—-18
xnu-2422.90.20—-18
xnu-2782.1.97—-18
xnu-2782.10.72—-18
xnu-2782.20.48—-18
xnu-2782.30.5—-18
xnu-3247.10.11—-18
xnu-3248.20.55—-18
xnu-3248.30.4—-18
xnu-3248.40.184—-18
xnu-3248.50.21—-18
xnu-3248.60.10—-18
xnu-3789.21.4—-18
xnu-3789.31.2—-18
xnu-3789.41.3—-18
xnu-3789.51.2—-18
xnu-3789.60.24—-18
xnu-3789.70.16—-18
xnu-4570.20.62—-18
xnu-4570.31.3—-18
xnu-4570.41.2—-18
xnu-4570.51.1—-18
xnu-4570.61.1—-18
xnu-4570.71.2—-18
xnu-4903.231.4—-18
xnu-4903.241.1—-18
xnu-4903.270.47—-18
xnu-6153.101.6—-18
xnu-6153.121.1—-18
xnu-6153.141.1—-18
xnu-6153.41.3—-18
xnu-6153.61.1—-18
xnu-6153.81.5—-18
xnu-7195.101.1—-18
xnu-7195.121.3—-18
xnu-7195.141.2—-18
xnu-7195.60.75—-18
xnu-7195.81.3—-18
xnu-8019.61.5—-18
xnu-8019.80.24—-18
xnu-8020.101.4—-18
xnu-8020.121.3—-18
xnu-8020.140.41—-18
xnu-8792.61.2—-18
xnu-8792.81.2—-18
xnu-8796.101.5—-18
xnu-8796.121.2—-18
xnu-8796.141.3—-18

Notes

Deallocating a right decrements its userspace refcount; when the refcount hits zero the name is removed from the IPC space and, if the right was the last send right on the port, a no-senders notification fires for any subscriber. The trap is the workhorse of every libsyscall and MIG cleanup path — every successful mach_thread_self(), mach_msg receive with MOVE_SEND, and task_for_pid call pairs with a corresponding deallocate. Calling deallocate on a pinned port (mach_task_self, mach_thread_self on hardened-runtime processes) raises EXC_GUARD with kGUARD_EXC_MOD_REFS.

Detection

Not visible to Endpoint Security. DTrace observation point is mach_trap::_kernelrpc_mach_port_deallocate_trap:entry. Crashes from over-deallocating pinned ports show up as EXC_GUARD in ReportCrash with subtype kGUARD_EXC_MOD_REFS.

Related APIs

_kernelrpc_mach_port_destroy_trap_kernelrpc_mach_port_mod_refs_trap_kernelrpc_mach_port_destruct_trapmach_port_deallocate