git: kernel - Fix long-standing bug in kqueue backend for *poll*()
Matthew Dillon
dillon at crater.dragonflybsd.org
Tue Jan 23 22:13:52 PST 2024
commit 0d47c594fde0de2008b2f26db9ab7a6a22eaf64f
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date: Tue Jan 23 13:00:54 2024 -0800
kernel - Fix long-standing bug in kqueue backend for *poll*()
* The poll() family of system calls passes an fds[] array with a
series of descriptors and event requests. Our kernel implementation
uses kqueue but a long standing bug breaks situations where
more than one fds[] entry for the poll corresponds to the same
{ ident, filter } for kqueue, causing only the last such entry
to be registered with kqueue and breaking poll().
* Added feature to kqueue to supply further distinctions between
knotes beyond the nominal { kq, filter, ident } tuple, allowing
us to fix poll().
* Added a FreeBSD feature where poll() implements an implied POLLHUP
when events = 0. This is used by X11 and (perhaps mistakenly) also
by sshd. Our poll previous ignored fds[] entries with events = 0.
* Note that sshd can generate poll fds[] arrays with both an events = 0
and an events = POLLIN for the same descriptor, which broke sshd
when I initially added the events = 0 support due to the first bug.
Now with that fixed, sshd works properly. However it is unclear whether
the authors of sshd intended events = 0 to detect POLLHUP or not.
Reported-by: servik (missing events = 0 poll feature)
Testing: servik, dillon
Summary of changes:
sys/kern/kern_event.c | 36 +++++++++++++++++++++++++++------
sys/kern/sys_generic.c | 54 +++++++++++++++++++++++++++++++++++++++++---------
sys/sys/event.h | 5 ++++-
3 files changed, 79 insertions(+), 16 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/0d47c594fde0de2008b2f26db9ab7a6a22eaf64f
--
DragonFly BSD source repository
More information about the Commits
mailing list