linux: Handle OOB accesses in bsd_to_linux_errno()
Such accesses can be triggered via ptrace(PT_SET_SC_RET).
Approved by: re (cperciva)
Reported by: Dennys Kaluzny Pereira <dennyskaluzny at gmail.com>
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 8f024e97cabf7497dc047538db9c6be9067752a1)
(cherry picked from commit c48a331e54794310fe05dddcb0719cdba1f5b1c3)
fget_remote(9): recheck remote process fdp after holding the file
kern_pddupfd() grants access to the process named by a process
descriptor with p_candebug(), then calls fget_remote() to duplicate a
descriptor from that process's current filedesc. The check remains
stable against an execve() by that one process, but the implementation
does not keep the held filedesc semantically bound to that process.
If the authorized process P shares its descriptor table with another
process Q, P can detach from the table with rfork(RFCFDG) after
fget_remote() has held the old table but before it acquires the table
lock. After P detaches, Q is the sole process-reference owner of the
old table; fget_remote() retains only a separate lifetime hold. When
Q executes a setuid program, the normal fdunshare() call observes
fd_refcnt == 1 and does not copy the table. Privileged descriptors are
therefore installed in the held old table. The waiting pddupfd() call
accepts that table because its process reference count is nonzero and
can return a descriptor opened by Q even though the security check was
performed against P.
[11 lines not shown]
fget_remote(9): recheck remote process fdp after holding the file
kern_pddupfd() grants access to the process named by a process
descriptor with p_candebug(), then calls fget_remote() to duplicate a
descriptor from that process's current filedesc. The check remains
stable against an execve() by that one process, but the implementation
does not keep the held filedesc semantically bound to that process.
If the authorized process P shares its descriptor table with another
process Q, P can detach from the table with rfork(RFCFDG) after
fget_remote() has held the old table but before it acquires the table
lock. After P detaches, Q is the sole process-reference owner of the
old table; fget_remote() retains only a separate lifetime hold. When
Q executes a setuid program, the normal fdunshare() call observes
fd_refcnt == 1 and does not copy the table. Privileged descriptors are
therefore installed in the held old table. The waiting pddupfd() call
accepts that table because its process reference count is nonzero and
can return a descriptor opened by Q even though the security check was
performed against P.
[9 lines not shown]
linux: Handle OOB accesses in bsd_to_linux_errno()
Such accesses can be triggered via ptrace(PT_SET_SC_RET).
Reported by: Dennys Kaluzny Pereira <dennyskaluzny at gmail.com>
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 8f024e97cabf7497dc047538db9c6be9067752a1)
vfs: Check access for O_CREAT directory opens
O_CREAT with O_DIRECTORY takes LOOKUP without creating a vnode.
Clear O_CREAT there so vn_open_vnode checks read or search access.
Add an unprivileged regression test for denied and permitted opens.
Approved by: so
Security: FreeBSD-SA-26:92.vfs
Security: CVE-2026-127746
Reviewed by: kib
Fixes: 9e18c9eb27cd
bsnmp: do not act on an SNMPv3 discovery message that carries bindings
An SNMPv3 message with an empty engine id and empty user name is handled
as snmpEngineID discovery: snmp_pdu_auth_user() sets SNMP_MSG_AUTODISCOVER
and returns without a USM user, and snmp_pdu_auth_access() then grants the
message access. A genuine discovery request carries no variable bindings
and only elicits a Report, but a discovery PDU that did carry bindings was
executed anyway -- so a GET or SET ran with no authentication and without
the VACM access check.
This affects two cases. With an empty user name the message is wholly
unauthenticated, so anyone able to reach the agent could issue a SET. It
also affects a configured noAuthNoPriv user: such a user has no digest to
verify, so it too can set the AUTODISCOVER flag (an authenticated request
before time synchronisation) and have a bindings-carrying PDU bypass VACM
and operate outside its views.
Refuse any AUTODISCOVER message that arrives with variable bindings
instead of acting on it. Empty-binding discovery, the authenticated
[23 lines not shown]
fdescfs: add VOP_ACCESS() implementation
kern_truncate() checks VWRITE only through VOP_ACCESS() on the fdescfs
vnode, which always succeeded until now. So a file opened read-only
could be truncated, even if the caller has no write permission for it.
Note that reopen on mounts without nodup already performs the permission
checks in dupfdopen(). For nodup mounts, the VOP_ACCESS() implementation
of the real filesystem is used.
Approved by: so
Security: FreeBSD-SA-26:91.fdescfs
Security: CVE-2026-127745
Reported by: Kevin Day <kevin at your.org>
Sponsored by: The FreeBSD Foundation
kqueue: Fix a race between kqueue_fork_copy_list() and kqueue_expand()
While kqueue_fork_copy_list() is iterating over the knote lists, the
backing array may change while the kqueue lock is dropped. Since each
list is a singly-linked list, kqueue_fork_copy_list() must start
iterating from the list head in order to remove the marker, but that
list head pointer is invalid after kqueue_expand() runs.
Add a bit of indirection to re-compute the correct list head each time
the kqueue lock is dropped.
Avoid changing the layout of struct knote since I want to backport this
to releng branches.
Approved by: so
Security: FreeBSD-SA-26:85.kqueue
Security: CVE-2026-127750
Reported by: Dennys Kaluzny Pereira <dennyskaluzny at gmail.com>
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D61608
bsnmp: let an SNMPv3 discovery message elicit only a Report
An SNMPv3 message with no variable bindings is treated as RFC 3414
engineID (or time-window) discovery: snmp_input_start() appends a
single usmStats counter to the request, and snmp_pdu_auth_access()
skips the VACM check because the AUTODISCOVER flag is set. The
request's verb was then still dispatched by type. A genuine discovery
is a GET and simply reads that counter back -- the intended Report --
but a zero-binding GETNEXT or GETBULK instead walks forward from the
appended OID, and with VACM skipped it returns the next registered
object(s): an unauthenticated read of the agent's USM and VACM
configuration (objects at or after 1.3.6.1.6.3.15).
Force the verb of a discovery message to GET, so the appended counter
is read as-is and no walk (or SET) can run under the skipped-VACM
state. Genuine discovery, which already uses GET, is unaffected.
This complements the earlier change that rejects an AUTODISCOVER
message carrying its own bindings; that guard is never reached on this
[7 lines not shown]
tmpfs: Clear setgid on creation by nonmembers
New tmpfs nodes inherit their parent directory group. Clear S_ISGID when
the creator is not a member of that group and lacks PRIV_VFS_SETGID,
matching UFS and tmpfs chmod behavior.
Approved by: so
Security: FreeBSD-SA-26:94.tmpfs
Security: CVE-2026-127749
Reviewed by: kib
freebsd32: Avoid modifying a shared control message
freebsd32_copy_msg_out() copies out received control messages. The
cmsg ABI differs between the 32-bit and native ABIs in that the 32-bit
ABI requires only 4-byte alignment for message bodies, see CMSG_ALIGN.
When the control message is read from the socket buffer with MSG_PEEK,
short messages which fit into an mbuf are copied into private storage,
but larger messages are returned by acquiring a counted reference on the
underlying mbuf cluster still attached to the socket buffer.
When the underlying storage is shared, the non-atomic, temporary
modification of the control message header in freebsd32_copy_msg_out()
can be abused to corrupt the message queue; this can be leveraged to
escalate privileges.
Approved by: so
Security: FreeBSD-SA-26:86.freebsd32
Security: CVE-2026-101321
[4 lines not shown]
so_splice: Serialize teardowns of splices
A socket splice can be configured with a timeout; once the timeout
expires, the splice is automatically undone. The implementation of an
unsplice operation detaches each socket from the splice structure, and
then drains the timeout task. The timeout task takes the splice
structure as an argument, and passes the source socket to so_unsplice().
It is possible for two threads to race with the task thread: one removes
the source socket from the splice associated with currently running
task, and the other thread splices that socket again, creating a new
splice structure. The timeout thread may then unsplice the source
socket even though it doesn't own that socket's current splice. The
resulting use-after-free can be exploited by a local user to escalate
privileges.
Fix the problem by serializing teardowns of splices: make so_unsplice()
callers specify the cause of the teardown, and ensure that threads can't
race to destroy a splice after an error occurs.
[8 lines not shown]
tests: Add test for fdescfs truncation bug
Add a test case that verifies that it is not possible to truncate a
file opened read-only through fdescfs in default mode, and another that
verifies that it is possible when fdescfs was mounted in nodup mode.
Approved by: so
Security: FreeBSD-SA-26:91.fdescfs
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D61236
vm_map: Fix handling of largepage mappings
vm_map_pmap_enter() is not aware of largepage objects and enters their
constituent 4KB pages into the pmap. This permits mapping a constituent
page after the corresponding largepage object is freed, which can be
abused to escalate privileges. Simply don't pass largepage mappings to
it.
Modify vm_fault_copy_entry() to handle largepage mappings for the case
where mprotect() needs to eagerly upgrade protections on a wired
largepage mapping.
Approved by: so
Security: FreeBSD-SA-26:90.vm
Security: CVE-2026-127744
Reviewed by: alc, kib
Reported by: OpenAI Security Research Team
Reported by: Albert at Vexera AI
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61363
bsnmp: reject an oversized vacmViewTreeFamilyMask
The SET handler for vacmViewTreeFamilyMask compared the value length
against the 16-byte view->mask, but the check had no statement of its
own: it guarded the following malloc() instead of rejecting the
request. A value longer than 16 bytes was therefore copied into
view->mask with memcpy(), overflowing struct vacm_view. Add the
missing return so an over-long value is refused with wrongValue.
Approved by: so
Security: FreeBSD-SA-26:89.bsnmp
Security: CVE-2026-127743
Reviewed by: harti
Fixes: 135f7de5ddb6
bsnmp: mask reserved SNMPv3 msgFlags bits on input
snmp_pdu_decode_header() reads the msgFlags octet straight into
pdu->flags and never sanitises it. Only bits 0..2 are defined on the
wire (authFlag, privFlag, reportableFlag). Bit 7 (0x80) is bsnmp's
internal SNMP_MSG_AUTODISCOVER marker: it shares the same field and is
tested later as "this is discovery, skip USM and VACM".
Because the byte is taken verbatim from an unauthenticated peer, a
client that sets bit 7 of msgFlags has (pdu->flags &
SNMP_MSG_AUTODISCOVER) read true straight after header decode, forging
the discovery state. A noAuthNoPriv user -- which has no digest to
verify -- can thus mark an ordinary request as discovery and have it
bypass the VACM access check, operating outside its configured views.
Keep only the three defined wire bits when decoding msgFlags, so the
internal marker can never be set from the network.
Approved by: so
[3 lines not shown]
fdescfs: check the target file for FWRITE access when truncating
Truncation is done by calling fdesc_setattr(), and fdesc_setattr() looks
up fd N again, so a concurrent dup2() can swap the file between the
access check and the truncate.
Correct the rights checked for the setattr().
Unlock the fdescfs vnode around fdrop() of the underlying file.
Approved by: so
Security: FreeBSD-SA-26:91.fdescfs
Sponsored by: The FreeBSD Foundation
tcp: Handle read-only mbufs in tcp_pulloutofband()
tcp_pulloutofband() is used to implement the urgent flag: it pulls a
byte out of the data stream, to be returned to the recevier when MSG_OOB
is specified. That function extracts the byte assuming that the mbuf is
safe to modify, which may not be the case, e.g., when transmitting file
data with sendfile(). This flaw can be exploited by a local user to
obtain root privileges.
Generalize this subroutine so that it handles read-only mbufs as well.
Add some regression tests.
Approved by: so
Security: FreeBSD-SA-26:93.tcp
Security: CVE-2026-127748
Reported by: OpenAI Security Research Team
Reviewed by: tuexen
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61411
sound: Improve interlocking in chn_resizebuf()
chn_resizebuf() fails if the channel's software buffer is mapped, but
does not take into account the fact that channel I/O drops the channel
lock when copying from or to user memory. During the window where the
lock is dropped, a resize may free the old buffer, causing userspace to
access freed kernel memory. This can be exploited to escalate
privileges.
Fix this by disallowing resizing when I/O is in progress.
Approved by: so
Security: FreeBSD-SA-26:88.sound
Security: CVE-2026-127741
Reviewed by: christos, kib
Reported by: OpenAI Security Research Team
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61446
nfsserver: initialize ni_rbeneath_dpp in nfsvno_namei()
Approved by: so
Security: FreeBSD-SA-26:81.vfs
Reported by: markj
Sponsored by: The FreeBSD Foundation
lookup_cap_dotdot test: check symlink escape below a union mount root
Let mount_tmpfs() add the union option, and leave creating the mount
point to the callers, so that the covered directory can be populated
before the mount.
Approved by: so
Security: FreeBSD-SA-26:81.vfs
Sponsored by: The FreeBSD Foundation
inotify: Make the oneshot watch lookup stricter
inotify_log_one() needs to handle one-shot watches, which are removed
from the inotify descriptor after the first event. To handle races with
a close of the inotify descriptor, which frees all watches, it re-looks
up the watch in the descriptor's watch tree, which is keyed by the watch
descriptor number.
inotify_log_one() assumed that presence of the watch descriptor in the
tree meant that the watch on which it is operating is also present in
the tree. However, watch descriptors are 32 bits wide and malicious
userspace can trigger descriptor reuse such that this assumption is
false, and inotify_log_one() ends up freeing the wrong watch, resulting
in an exploitable use-after-free.
Approved by: so
Security: FreeBSD-SA-26:80.vfs
Security: CVE-2026-101316
Fixes: f1f230439fa4 ("vfs: Initial revision of inotify")
[2 lines not shown]
amd64/vmm: Reject TSC_AUX writes with reserved bits set
On Intel CPUs, bits 63:32 of IA32_TSC_AUX are reserved. Guest writes to
the MSR are trapped and the value is stored in the vCPU's MSR array.
vmx_msr_guest_enter_tsc_aux() later writes the value to the physical MSR,
so reserved bits must be rejected before the value reaches the host MSR.
Inject #GP into the guest instead, as the hardware would.
Approved by: so
Security: FreeBSD-SA-26:84.vmm
Security: CVE-2026-101319
Fixes: f5f5f1e7d6de ("Support guest rdtscp and rdpid instructions on Intel VT-x")
Sponsored by: Alchemilla Ventures Private Limited
unix: Fix a race between shutdown and listen
In uipc_shutdown(), the SOLISTENING() check is stale as soon as the
socket lock is dropped. Acquire the unpcb lock earlier and use that to
interlock with other work that touches the socket buffers which are
invalid for a listening socket. Fix unp_dispose() to handle errors when
acquiring the I/O lock; contrary to the assertions, such races are
possible.
Approved by: so
Security: FreeBSD-SA-26:83.unix
Security: CVE-2026-127751
Reported by: OpenAI Security Research Team
Sponsored by: The FreeBSD Foundation
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.
[8 lines not shown]
gssd: Fix unix credential squashing when accepting a context
gssd_accept_sec_context_lucid_v1_1_svc() handles context acceptance when
MIT Kerberos is in use. Its last operation is to map the Kerberos
principal to a local credential subsequently used by the NFS server for
the authenticated session.
If it fails to resolve the principal to a local user, it is supposed to
squash the client's credentials. However, it failed to set the UID
field, which will end up set to zero, corresponding to the root user on
the server. As a result, an authenticated principal that doesn't map to
a local user ends up being treated as UID 0.
Fix this. Use names for the nobody user and group.
Approved by: so
Security: FreeBSD-SA-26:78.gssd
Security: CVE-2026-101315
Reported by: Erik Power
[4 lines not shown]