From nobody Fri Oct 16 20:16:00 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4j5x5x6ZFLz6vg9P for ; Fri, 16 Oct 2026 20:16:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4j5x5x4khcz4sbX for ; Fri, 16 Oct 2026 20:16:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1792181765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=R5uqcFK1sug/Admm0k/Siv4ulf+8IEXP4yd1N1Oyp60=; b=hN2m3P0jcc2Yh3UJJ5h/J+5jxrWNfWNIZMk88oYkDzXCfS3XdHltsoV8fabDKBrkipwfTA 0iFG227tjE40calCOg1v2mWILjDN/c6pF0jis6kq78tTIQhBgRJX/Yvk/qA/7+lazaTQQT FlvnxtVSGcvevD80QtAneKmDa9lTkN70FnIhL2xiYa+ycdbuDD8layZ4Y5elupddXBNCXe Aoyw3zM3rifLYVPg1lCP4Po5/aNyQwJTIo8FFndVqbiIV89dMTWSOu7O6Ca7zRLnr1rveZ UHcCGUOSltyBZ2K7zvh78WCZlxGixEKdkm10H4J+tUMTHAwuTDuQC217V/pt1g== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1792181765; b=wjTsfj9kCtzdKxN4eTPWe5gzonA3kXD9dz/Uas5w+KebbqG3Z7VtfVEJ6KZ1uXRrSukeRm siRiXMzhCI/Ds0AZnBQG6IlWMZFUCc2WqNcrB6yrM26ISCG1Vhn8vlNr1H8POabsTfisYs lw6viLEusxjgXKmc4L8I54cse+WL6IAE7MLCZ39xzv7n8VDW8tIB3J+VyNOB99nCzrCaYT U09xgCuHhVSOSapIHRXK14GRYq+5Wiyv1gjy1W2NqS+O6ucNPOwaZUdURPdLQyngBvleBi V9NLg4Z0nsGmZEMkHQ89Qf7Uk5BdWfcYgJFdNS6MkYD0+cd1zAJSVz0mrB+eug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1792181765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=R5uqcFK1sug/Admm0k/Siv4ulf+8IEXP4yd1N1Oyp60=; b=BVaS22DCHKPQ5l+bu3Ki6LB/5dRI8kuemBsf4pKLGk+oLdlDBJlI6dVw3rO4bNyB4NeIIs l+4KxXHoMn6Zcp10imGQtXpuSuMqSjb8hxS9WfdISkUeGV1dtMf49Ejsd6bnDtooLULbsh urJKhkSNxQUmc90Dlvwm7eqdqJMg9T2Gs1xlIXBZpIiIR/lGgGtd3Ab1e+j1XyiJCNb14H pD+SN3Wsz7I2+Xt+9i7jKD1rXeluEAsnKl9xjgN2x9BojjLhbOMUmPxqSj/Om3KQtYhLoM aL+lFkLTQ9V6hRyglZFRfjL2xZzOfKJ+UQDSXT3fR/NO4OUTEo9PvZMxF+tuQQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4j5x5x4PQjzcJy for ; Fri, 16 Oct 2026 20:16:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 32565 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 16 Oct 2026 20:16:00 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Vladimir Grebenshchikov From: Konstantin Belousov Subject: git: b3836322a1e6 - main - linux: preserve epoll descriptors across fork using KQUEUE_CPONFORK List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: Commit messages for the main branch of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b3836322a1e6863734427ac9c01381ab25458126 Auto-Submitted: auto-generated Date: Fri, 16 Oct 2026 20:16:00 +0000 Message-Id: <6ad28600.32565.2b4932fa@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b3836322a1e6863734427ac9c01381ab25458126 commit b3836322a1e6863734427ac9c01381ab25458126 Author: Vladimir Grebenshchikov AuthorDate: 2026-10-12 18:40:23 +0000 Commit: Konstantin Belousov CommitDate: 2026-10-16 20:10:55 +0000 linux: preserve epoll descriptors across fork using KQUEUE_CPONFORK Linuxulator implements epoll instances using kqueues. Currently, epoll_create_common() creates the backing kqueue with copy-on-fork disabled. When fork() copies the descriptor table, the kqueue is omitted from the child's table. This differs from Linux, where an epoll descriptor survives fork(), including when it was created with EPOLL_CLOEXEC. That flag controls descriptor lifetime across exec(), not fork(). The missing descriptor breaks dbus-daemon daemonization. The daemon creates its epoll instance before forking and continues using the saved descriptor number in the child. F_GETFD initially fails with EBADF. Once another open reuses that number, subsequent epoll_ctl() calls fail with EINVAL because the descriptor no longer refers to an epoll instance. The daemon then exits, preventing applications that depend on the session bus from starting correctly. Enable KQUEUE_CPONFORK for epoll's backing kqueue. This preserves the descriptor number and copies supported event registrations into the child, allowing the daemonized process to continue using epoll. This is a partial compatibility improvement, not a complete implementation of Linux epoll inheritance. Linux parent and child reference the same epoll instance, whereas KQUEUE_CPONFORK creates independent queues. Consequently, registration changes and one-shot event consumption in one process are not reflected in the other. Applications relying on shared epoll state across fork still require further work. Validation: - A static Linux x86-64 C reproducer fails under the original Linuxulator and passes on a real Linux kernel under QEMU. - Before this change, the child loses its epoll descriptor with both EPOLL_CLOEXEC enabled and disabled, while ordinary pipe descriptors survive. - After this change, descriptor flags, inherited readiness and event data remain available in the child. epoll_ctl() also succeeds after allocating additional descriptors. - Both dbus-daemon --session --fork and dbus-launch start successfully and answer a ListNames request from a separate client. - Shared-state regression tests still fail for parent visibility of child ADD/MOD/DEL operations and EPOLLONESHOT consumption, documenting the remaining semantic differences. Reviewed by: kib MFC after: 1 week Differential revision: https://reviews.freebsd.org/D60783 --- sys/compat/linux/linux_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/compat/linux/linux_event.c b/sys/compat/linux/linux_event.c index de313aefff97..507ddf1cde6f 100644 --- a/sys/compat/linux/linux_event.c +++ b/sys/compat/linux/linux_event.c @@ -104,7 +104,7 @@ static int epoll_create_common(struct thread *td, int flags) { - return (kern_kqueue(td, flags, false, NULL)); + return (kern_kqueue(td, flags, true, NULL)); } #ifdef LINUX_LEGACY_SYSCALLS