From nobody Tue Nov 17 17:04:14 2026 X-Original-To: dev-commits-src-all@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 4jTWKp5tZ0z71QnS for ; Tue, 17 Nov 2026 17:04:14 +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 4jTWKp3lxrz4FYk for ; Tue, 17 Nov 2026 17:04:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935054; 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=ukho9cdDT+EecpXSYFgQAqQ4bWD5oM4ZWLW+Q7mvo8w=; b=U988zR1Uu5dCONna1tN7Rl8vcn7KI+MtIIqSZcVhF8Cfn53Ufz6ndH+N8xHk6PWhnYXg6M yT2VhFiHAo3BWjlIPTTcN5VmdOvuc2cKQMOmVOAUIpJTIKeihcxDiN79YH0qxq5ztDjxnd j9ueTJ61Je8YGuT1ZT6D1N5h1+qO2DXmdXvNBkb1T7KJEY8ci+QYUCkia0V9Zm6RNSc34X 648VdCQohJkXTrBl81lJCyqWLHjZeijYzG9XFWZBnm9CQQKR1NBmOv/icrGvNDqPHfk+dB xDfj/J4HFN4ml/ae5/67S6pWgDH42wAyADLIy5GhE3ZjzH1qV62MkSEmTyNb9Q== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794935054; b=FVIUIrfbOA/tVgrD+KIrxU+HjgAjG6QuwYUAim9ROvkYFSRSPTbq848oN12bDFSpZhCqCq Atzx/3vau3k57oQv3hhySJPp6HahoURV+7WDFZJT6o/+3X+ExNvXHBJXLAVvPE3EcX1Yf9 lcxb0F4UwZ7ugwSkWm/re82MZ5St/NQtSkCAp+sYm9VS1SjJt/RzFqNA2YR5HrutMrk3LB hfatm8CZKRnxMnQRjCZRh5ci8uBOoAE9KElhjY+nIOxFxrJCJWGk93juxio7/Gjiccj41T coG/apDdo1wqldeU6vT/E1wwU+HXOvcgxFnmMuMI53tEpMFeolb1Sh6k2751rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935054; 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=ukho9cdDT+EecpXSYFgQAqQ4bWD5oM4ZWLW+Q7mvo8w=; b=T9uI7Qr5MtrhGCdx1gtkAz4fwYLCJOwGXocnJjgtqN/Q+2s1YU8mHmYyw243AdMqPDJAoQ dbdUqcoAU6zhV9FeTFbdkEpvzY6mzhO/0ZewYezXr4PUVcmQ49SMKwd0LobH82QEPJMPf5 FpSGsq8e6BREfYBBrx92Arih06jYJ2+9kZcBcWeTAmQNYhqDOFAJFwiWxxDjz21Itp7fX2 6GPTef/+2tKkxIYpgszdA9M+20vReoeB8xKpCHIATIcY+n4wyPDhcS8dvZLvRb9IdfhppI D1aZPhpP8nWZS0WITBiNgcGcx2TpuH1eHU29Iq+fSrEHlBjj5fzRSabHpBalLQ== 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 4jTWKp1rt1zrfc for ; Tue, 17 Nov 2026 17:04:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1f6a0 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 17:04:14 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 9823ecaea3c0 - releng/14.4 - kqueue: Fix a race when detaching a timer knote List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.4 X-Git-Reftype: branch X-Git-Commit: 9823ecaea3c0e9d0bdf0d847a4d8155dbbaac80c Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 17:04:14 +0000 Message-Id: <6afc890e.1f6a0.61c31a50@gitrepo.freebsd.org> The branch releng/14.4 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=9823ecaea3c0e9d0bdf0d847a4d8155dbbaac80c commit 9823ecaea3c0e9d0bdf0d847a4d8155dbbaac80c Author: Mark Johnston AuthorDate: 2026-11-12 19:16:53 +0000 Commit: Mark Johnston CommitDate: 2026-11-16 21:16:22 +0000 kqueue: Fix a race when detaching a timer knote We currently maintain a per-process list of stopped timer knotes, used when the owning process receives SIGSTOP. Upon receiving SIGCONT, queued timers are re-armed. When detaching a timer knote, we drain the callout and remove it from the queue, then check to see if the callout was re-armed by SIGCONT; if so, then we loop. However, the callout timer may fire before this check, and softclock_call_cc() clears the pending bit without the associated callout lock held, in which case filt_timerdetach() fails to observe that the callout is still running and doesn't drain. The callout handler then races with a free of the knote, and the resulting memory corruption can be exploited to obtain root privileges. Fix the problem by using an explicit flag that prevents re-arming a timer whose knote is in the process of being detached. Approved by: so Security: FreeBSD-SA-26:85.kqueue Security: CVE-2026-101320 Reported by: OpenAI Security Research Team Fixes: 2fd1ffefaa4d ("Stop arming kqueue timers on knote owner suspend or terminate") Sponsored by: The FreeBSD Foundation Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D61359 --- sys/kern/kern_event.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index c937505a7270..43ba760c7f2a 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -698,7 +698,8 @@ struct kq_timer_cb_data { sbintime_t to; /* precalculated timer period, 0 for abs */ }; -#define KQ_TIMER_CB_ENQUEUED 0x01 +#define KQ_TIMER_CB_ENQUEUED 0x01 /* in queue of stopped timers */ +#define KQ_TIMER_CB_DETACHING 0x02 /* detach started, don't requeue */ static void kqtimer_sched_callout(struct kq_timer_cb_data *kc) @@ -766,7 +767,8 @@ filt_timerexpire_l(struct knote *kn, bool proc_locked) if (!proc_locked) PROC_LOCK(p); if (P_SHOULDSTOP(p) || P_KILLED(p)) { - if ((kc->flags & KQ_TIMER_CB_ENQUEUED) == 0) { + if ((kc->flags & (KQ_TIMER_CB_ENQUEUED | + KQ_TIMER_CB_DETACHING)) == 0) { /* * Insert into head so that * kqtimer_proc_continue() does not @@ -879,24 +881,16 @@ filt_timerdetach(struct knote *kn) { struct kq_timer_cb_data *kc; unsigned int old __unused; - bool pending; kc = kn->kn_ptr.p_v; - do { - callout_drain(&kc->c); - - /* - * kqtimer_proc_continue() might have rescheduled this callout. - * Double-check, using the process mutex as an interlock. - */ - PROC_LOCK(kc->p); - if ((kc->flags & KQ_TIMER_CB_ENQUEUED) != 0) { - kc->flags &= ~KQ_TIMER_CB_ENQUEUED; - TAILQ_REMOVE(&kc->p->p_kqtim_stop, kc, link); - } - pending = callout_pending(&kc->c); - PROC_UNLOCK(kc->p); - } while (pending); + PROC_LOCK(kc->p); + kc->flags |= KQ_TIMER_CB_DETACHING; + if ((kc->flags & KQ_TIMER_CB_ENQUEUED) != 0) { + kc->flags &= ~KQ_TIMER_CB_ENQUEUED; + TAILQ_REMOVE(&kc->p->p_kqtim_stop, kc, link); + } + PROC_UNLOCK(kc->p); + callout_drain(&kc->c); free(kc, M_KQUEUE); old = atomic_fetchadd_int(&kq_ncallouts, -1); KASSERT(old > 0, ("Number of callouts cannot become negative"));