-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

=============================================================================
FreeBSD-SA-26:50.kqueue                                     Security Advisory
                                                          The FreeBSD Project

Topic:          Use-after-free in kqueue copy-on-fork

Category:       core
Module:         kqueue
Announced:      2026-07-29
Credits:        Hazley Samsudin of GovTech CSG
Affects:        FreeBSD 15.1
Corrected:      2026-07-29 17:48:38 UTC (stable/15, 15.1-STABLE)
                2026-07-29 17:50:29 UTC (releng/15.1, 15.1-RELEASE-p2)
CVE Name:       CVE-2026-58083

For general information regarding FreeBSD Security Advisories, including
descriptions of the fields above, security branches, and the following
sections, please visit <URL:https://security.FreeBSD.org/>.

I.   Background

The kqueue(2) event notification facility supports a copy-on-fork mode
(KQUEUE_CPONFORK) in which registered event filters (knotes) are duplicated
into the child process during fork(2).

II.  Problem Description

While the kernel was copying knotes during fork, a knote with a timer-based
filter could fire and be enqueued on the kqueue's active list before the copy
was complete.  The copy routine did not account for this and could enqueue
the new knote a second time, corrupting the active list.  In addition, the
copy routine did not hold the appropriate locks while reading knote state,
allowing further races.

III. Impact

An unprivileged local user can trigger a use-after-free in the kernel,
potentially leading to privilege escalation.

IV.  Workaround

No workaround is available.

V.   Solution

Upgrade your vulnerable system to a supported FreeBSD stable or
release / security branch (releng) dated after the correction date,
and reboot the system.

Perform one of the following:

1) To update your vulnerable system installed from base system packages:

Systems running a 15.0-RELEASE or later version of FreeBSD on the amd64 or
arm64 platforms, which were installed using base system packages, can be
updated via the pkg(8) utility:

# pkg upgrade -r FreeBSD-base
# shutdown -r +10min "Rebooting for a security update"

2) To update your vulnerable system installed from binary distribution sets:

Systems running a RELEASE version of FreeBSD on the amd64 or arm64 platforms
which were not installed using base system packages can be updated via the
freebsd-update(8) utility:

# freebsd-update fetch
# freebsd-update install
# shutdown -r +10min "Rebooting for a security update"

3) To update your vulnerable system via a source code patch:

The following patches have been verified to apply to the applicable
FreeBSD release branches.

a) Download the relevant patch from the location below, and verify the
detached PGP signature using your PGP utility.

# fetch https://security.FreeBSD.org/patches/SA-26:50/kqueue.patch
# fetch https://security.FreeBSD.org/patches/SA-26:50/kqueue.patch.asc
# gpg --verify kqueue.patch.asc

b) Apply the patch.  Execute the following commands as root:

# cd /usr/src
# patch -E -p0 < /path/to/patch

c) Recompile your kernel as described in
<URL:https://www.FreeBSD.org/handbook/kernelconfig.html> and reboot the
system.

VI.  Correction details

This issue is corrected as of the corresponding Git commit hash in the
following stable and release branches:

Branch/path                             Hash                     Revision
- -------------------------------------------------------------------------
stable/15/                              cb7cb40ae47b    stable/15-n284642
releng/15.1/                            5a4222a1b225  releng/15.1-n283588
- -------------------------------------------------------------------------

Run the following command to see which files were modified by a
particular commit:

# git show --stat <commit hash>

Or visit the following URL, replacing NNNNNN with the hash:

<URL:https://cgit.freebsd.org/src/commit/?id=NNNNNN>

To determine the commit count in a working tree (for comparison against
nNNNNNN in the table above), run:

# git rev-list --count --first-parent HEAD

VII. References

<URL:https://www.cve.org/CVERecord?id=CVE-2026-58083>

The latest revision of this advisory is available at
<URL:https://security.FreeBSD.org/advisories/FreeBSD-SA-26:50.kqueue.asc>
-----BEGIN PGP SIGNATURE-----

iQJPBAEBCgA5FiEEthUnfoEIffdcgYM7bljekB8AGu8FAmpqbkQbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMCwzAAoJEG5Y3pAfABrv0LsP/jNvCmjgjFj/yoF6f2VC
bHKymftfRZXrMj7xhO95IISFEwth5KwmrwS9e6nNwHBygRiH9AvAbrMREAhju8LK
jtPkh0kAyMuAVIIDCcpMtFrMHoCS2FyuHLifA0LWhD8ouxPleJ/AkrjBDo9QRx3U
REdng9J3nvq5N8rzon9yTqosv0qoPQD7y/QJPduzhFA6aPVK6MCHEmOtCjyUMUTS
8Lze1WFzlqMt1tRl+iVsLsZa9uameOb4D/GQMkT3OagYQQ8rDLtw0r3hyzmWEw9x
ckx3DgKNQygLY5nOvw7iHUbFdl3ovSAIjDbxRY0TV+UNVfcGhROL7GLkfg4YMVIf
o5+61XFUaavzYH03xgAVaSKhdNAEv/ybatA/F4HDGeqNVY1V9lqUMX9E+z/n7rfs
Y4theutEgwhO0ZJ3kB4WtkREEIovKOWDlPX+wbwxc2KUiEg6opkm0Ehjqt0p26+t
ReWevNgO2qXIFr7ch0JiHJpmI8/yoKwS4VJTizaT5FgYO0fLlOBhJX/YXSGqeOPG
V+Lb3MnLCGTSkRF4RckDq2ITWbRdQn0IEwYi2v1D6w5NYBd3weJdUioJUuUnXur/
XweEflFDkNvcA4tOhn8ivMgKkT0xE4FEhBTa7ARlbsaE3/CTiu6Q4688lnKhxIzi
IXAWlS8Xup6fxlIakdBALCr0
=BGt9
-----END PGP SIGNATURE-----
