OS X/iOS kernel UAF racing getProperty on IOHDIXController and testNetBootMethod on IOHDIXControllerUserClient
This is a Use-After-Free vulnerability in the OS X/iOS kernel. The vulnerability is caused by a race condition between the copyProperty macro used by is_io_registry_entry_get_property_bin and the testNetBootMethod external method. The copyProperty macro takes the entry's properties lock before reading and taking a reference on the property, while the testNetBootMethod external method directly calls the overriden setProperty without taking that same lock. This can lead to a Use-After-Free condition if the ::release call happens before the ::retain in copyProperty. This PoC will crash as a UaF but with more care, it is possible to get the OSSerialize to serialize an invalid object leading to a kernel memory disclosure.