knotes with a non-trivial f_copy implementation may be activated before
kqueue_fork_copy_knote() is finished. In particular, it may be enqueued
at the time that kqueue_fork_copy_knote() calls knote_enqueue(). Guard
against this and add a test case which triggers the race. Note, the race
can be exploited to obtain root privileges.
Also make sure that the new knote does not inherit the KN_SCAN flag.