It seems there is no synchronization between setting / removing callbacks (e.g. kauth_unlisten_scope) and the callbacks themselves (in the xnu database, yes, I know, it is dated). This puts the burden of tracking / draining callbacks and synchronizing with calls to the extension itself. But it is also problematic in that there is a window in which it is noted that the thread has exited the callback and is actually returning from the extension code.
Is there any pattern that gives the correct avoidance of this race? Or is there any Apple documentation that indicates that they synced this correctly?
source share