NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/61008: compat_linux: Calling EPOLL_CTL_ADD before calling listen() on the socket



>Number:         61008
>Category:       kern
>Synopsis:       compat_linux: Calling EPOLL_CTL_ADD before calling listen() on the socket
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Nov 14 14:45:00 +0000 2026
>Originator:     tuxi
>Release:        11.1
>Organization:
>Environment:
NetBSD gb-backup 11.1 NetBSD 11.1 (GENERIC) #0: Mon Nov  2 16:34:32 UTC 2026  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64

>Description:
Calling EPOLL_CTL_ADD before calling listen() on a socket under compat_linux causes epoll to never receive any events for the socket.

 12357  12357 luxon_server.mus CALL  socket(2,1,0)
 12357  12357 luxon_server.mus RET   socket 4
 12357  12357 luxon_server.mus CALL  epoll_ctl(3,1,4,0x7f7fffffc454)  <-- Added to epoll (1 = EPOLL_CTL_ADD)
 12357  12357 luxon_server.mus RET   epoll_ctl 0
 12357  12357 luxon_server.mus CALL  setsockopt(4,IPPROTO_ICMP,2,0x7f7fffffc55c,4)
 12357  12357 luxon_server.mus RET   setsockopt 0
 12357  12357 luxon_server.mus CALL  fcntl(4,F_GETFL,0)
 12357  12357 luxon_server.mus RET   fcntl 2
 12357  12357 luxon_server.mus CALL  fcntl(4,F_SETFL,0x8802)
 12357  12357 luxon_server.mus RET   fcntl 0
 12357  12357 luxon_server.mus CALL  bind(4,0x7f7fffffc5b0,0x10)      <-- Bound to 0.0.0.0
 12357  12357 luxon_server.mus MISC  mbsoname: [0.0.0.0]
 12357  12357 luxon_server.mus RET   bind 0
 12357  12357 luxon_server.mus CALL  listen(4,5)                      <-- Finally set to listen
 12357  12357 luxon_server.mus RET   listen 0

>How-To-Repeat:
The Linux binaries in the current release of LuxonServer: https://github.com/niansa/LuxonServer/releases/tag/v1.5 trigger this issue on the HTTP server (copy in the example config for testing: https://github.com/niansa/LuxonServer/blob/master/config.example.yml).
The server won't respond to HTTP requests since it is never notified by epoll about incoming data.
This commit: https://github.com/niansa/LuxonServer/commit/640e44cca2cd863447afe46bb6a0cf5009f2b43a fixes the issue.
The relevant epoll calls are here: https://github.com/niansa/LuxonServer/blob/master/src/sock_selector.cpp

This works fine under Linux, only fails under NetBSD with compat_linux.
>Fix:
I am no kernel dev so I have no idea. I assume listen() needs to internally readd the FD to epoll somehow?




Home | Main Index | Thread Index | Old Index