Kextd Method Exposed via MIG
If the client has UID 0 but passes an invalid client port this code will drop a UREF on client port then return KERN_FAILURE. Returning KERN_FAILURE in MIG means all resources will be released which will cause client to be passed to mach_port_deallocate again, even though only one UREF was taken. An attacker can drop an extra UREF on any send rights in kextd for which the attacker also has a send right; you could use this to cause a name for a privileged service to be deallocated then cause the name to be reused to name a port you control. Exploitation of this would be a privesc from unentitled root to root with com.apple.rootless.kext-management and com.apple.rootless.storage.KernelExtensionManagement entitlements, which at least last time I looked was equaivalent to root.