NetBSD Problem Report #61008

From www@netbsd.org  Sat Nov 14 14:44:41 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.netbsd.org", Issuer "YR1" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 4FEA91A923C
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 14 Nov 2026 14:44:41 +0000 (UTC)
Message-Id: <20261114144440.4B3A51A9241@mollari.NetBSD.org>
Date: Sat, 14 Nov 2026 14:44:40 +0000 (UTC)
From: tuxifan@posteo.de
Reply-To: tuxifan@posteo.de
To: gnats-bugs@NetBSD.org
Subject: compat_linux: Calling EPOLL_CTL_ADD before calling listen() on the socket 
X-Send-Pr-Version: www-1.0
X-From4GNATS: "tuxifan@posteo.de via gnats" <gnats-admin@NetBSD.org>

>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:/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?

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.