]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Avoid unsynchronized updates to kn_status.
authorMark Johnston <markj@FreeBSD.org>
Wed, 21 Nov 2018 17:32:09 +0000 (17:32 +0000)
committerMark Johnston <markj@FreeBSD.org>
Wed, 21 Nov 2018 17:32:09 +0000 (17:32 +0000)
commitd5e494fee4daf42e505af339677642ca507c9839
tree361ec7a25400d0c99f33415810ce0fccc6f574cf
parent45aecd0422ae83e9de44e9412208e3fdf3474aab
Avoid unsynchronized updates to kn_status.

kn_status is protected by the kqueue's lock, but we were updating it
without the kqueue lock held.  For EVFILT_TIMER knotes, there is no
knlist lock, so the knote activation could occur during the kn_status
update and result in KN_QUEUED being lost, in which case we'd enqueue
an already-enqueued knote, corrupting the queue.

Fix the problem by setting or clearing KN_DISABLED before dropping the
kqueue lock to call into the filter.  KN_DISABLED is used only by the
core kevent code, so there is no side effect from setting it earlier.

Reported and tested by: Sylvain GALLIANO <sg@efficientip.com>
Reviewed by: kib
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18060
sys/kern/kern_event.c