From nobody Tue Sep 29 15:55:43 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 4hvN7N42Vkz6tkml for ; Tue, 29 Sep 2026 15:55:44 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hvN7N30N6z4TBj for ; Tue, 29 Sep 2026 15:55:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790697344; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+qpYzb8icd99XwT7RyyUyEFLTI4Ujc3Lq693AVkDB5k=; b=eCisewbLvrUivoavXvxHHbQgwhU/miir4R0a43DCCHekHiS7QKO88rkCIr6CmdGs3Sz4eD oO16uibyjVj2XA7Wx2tT9oNGsPYOxyJ2JxKFTK96vPs9GuC9AO6PGkrHYSOZ4gLgkO07/1 r4Ac89Ftaz5TI4Bm4NGU/ZspJWrjjyZ9YaIjytEbXZZIg/vAZHuF9jkg8WnTjGftXA7v/I VD+9On1i0QNg2w84RYCoRH5yFVrAGytIupSnjdEcb65KS8VopvNRV/Kf1s9BTwGp9jYfow F4FSqK4pSwSq0P9KAjG18pp94DHVd/73NoVvunZopWbjKuC/S0JHKL3z+Lye7A== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1790697344; b=j7PMhYIOfuGDbpLpMADd/YnvIqyDVSXnQopWkSCKzkfWbDFhPLUAbHXp2UN0qeEvzamcQk 45dfauPlQScLzkoL4RWQ0TfCakBoul/21uWFekN70oUwwESH+7g+2m4Lr5wWdpilCijzOI 8z0XY3wXGTPB87xzIXnrDkz7gT6FQYzfArCSVo4QZZMfrIHCPbLogHmPQ3H6B4Ij9Lp3PP KDQf38H3rhbjIXM9YzhbqzKVSTL8+t0KP6SMEYSDd2xeLwTmo2hyKlKjaZyPOjjgb4rI1H 0rOyn566PMMZQ6Gu3GaCVQ2LOZ9+I9fFX+32ibUEvC7QG5x9Vnc3H/BQtJTMeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790697344; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+qpYzb8icd99XwT7RyyUyEFLTI4Ujc3Lq693AVkDB5k=; b=nizQEP7t5P0/3G1Bx5VcuOis0b920g2c9nCe8rBecISfg0fiFrQRt4H0Gnd5K0h9QUoim8 TWonLJncUgptisG8eU+apKNGGuY/XOF3JmyqDkBHfuSrHgr2S7guXRgJoyW8tqEvKTttE6 /tZhL8Ye3MmGVyZsRmDJQCN3HTHpxzk/YBlK8Ek+qxmDvyk4i7ftQXvK6yCuQArDAhZueT YiiiPcnwfBDGrLegRZGscXkWi8vqoNI0QKYyrEAUM3X0Al9nJ7C0Vx08cPcJ6srZ8vuXua E3i3yyzHakbq45WiNhiDY+e9mV2MIOhXzH8Si+hLhXQyV8jU0XD/99INONKQcQ== 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 4hvN7M4ljkz1JZf for ; Tue, 29 Sep 2026 15:55:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 24a55 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 29 Sep 2026 15:55:43 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 4ba0c0c4887d - main - kqueue: Fix handling of marker knotes during fork List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4ba0c0c4887d0e648b3b6d4002e96c6630e72137 Auto-Submitted: auto-generated Date: Tue, 29 Sep 2026 15:55:43 +0000 Message-Id: <6abbdf7f.24a55.4973367d@gitrepo.freebsd.org> The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4ba0c0c4887d0e648b3b6d4002e96c6630e72137 commit 4ba0c0c4887d0e648b3b6d4002e96c6630e72137 Author: Mark Johnston AuthorDate: 2026-09-28 13:40:45 +0000 Commit: Mark Johnston CommitDate: 2026-09-29 15:54:15 +0000 kqueue: Fix handling of marker knotes during fork Commit d8bdcb08d0eb fixed a problem in kqueue_fork_copy_knote() where we did not skip over marker knotes when copying. However, that fix was not sufficient: we bump the influx counter and check for a marker after dropping the kqueue lock. So, if multiple threads in a process are forking concurrently, kqueue_fork_copy_list() may mark a marker as in-flux and drop the lock; if the marker owner then frees the marker, the first thread will decrement the in-flux counter of a freed knotes. This use-after-free can be exploited, at least prior to commit d8bdcb08d0eb, which makes exploitation more challenging. Approved by: so Security: FreeBSD-SA-26:65.kqueue Security: CVE-2026-58099 Reported by: Reo Shiseki Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D59522 --- sys/kern/kern_event.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 734f8a408f4d..9fa7f50dc625 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -3096,9 +3096,9 @@ kqueue_fork_copy_knote(struct kqueue *kq, struct kqueue *kq1, struct knote *kn, ("%s: knote %p not in flux", __func__, kn)); KASSERT((kn->kn_status & KN_DETACHED) == 0, ("%s: knote %p not detached", __func__, kn)); + KASSERT((kn->kn_status & KN_MARKER) == 0, + ("%s: knote %p not detached", __func__, kn)); - if ((kn->kn_status & KN_MARKER) != 0) - return; if ((kn->kn_status & KN_KQUEUE) != 0) { /* * We cannot hold references to a kqueue outside of the process @@ -3164,7 +3164,7 @@ kqueue_fork_copy_list(struct klist *knlist, struct knote *marker, kn = SLIST_FIRST(knlist); while (kn != NULL) { MPASS(kn->kn_kq == kq); - if ((kn->kn_status & KN_DETACHED) != 0 || + if ((kn->kn_status & (KN_DETACHED | KN_MARKER)) != 0 || (kn_in_flux(kn) && (kn->kn_status & KN_SCAN) == 0)) { kn = SLIST_NEXT(kn, kn_link); continue;