Do not clear KN_INFLUX when not owning influx state.
authorkib <kib@FreeBSD.org>
Mon, 19 Dec 2016 22:18:36 +0000 (22:18 +0000)
committerkib <kib@FreeBSD.org>
Mon, 19 Dec 2016 22:18:36 +0000 (22:18 +0000)
commitfa7aa12d7b105770e53cdf0efff22feb14650630
tree95f25b0cf0bce9fcbaee2b4e84b220f1750e48bc
parent4bb8b1319be688cfcf14e0b7d5911c150ff2e5d4
Do not clear KN_INFLUX when not owning influx state.

For notes in KN_INFLUX|KN_SCAN state, the influx bit is set by a
parallel scan.  When knote() reports event for the vnode filters,
which require kqueue unlocked, it unconditionally sets and then clears
influx to keep note around kqueue unlock.  There, do not clear influx
flag if a scan set it, since we do not own it, instead we prevent scan
from executing by holding knlist lock.

The knote_fork() function has somewhat similar problem, it might set
KN_INFLUX for scanned note, drop kqueue and list locks, and then clear
the flag after relock.  A solution there would be different enough, as
well as the test program, so close the reported issue first.

Reported and test case provided by: yjh0502@gmail.com
PR: 214923
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
sys/kern/kern_event.c