FreeBSD/src df20cc3 — tests/sys/kern ssl_sendfile.c

tests/ssl_sendfile: fix flakyness under load

When loopback TCP delivery is faster than our sending thread it may take
several writes to full buffer reliably.

PR:             299447
DeltaFile
+14-7tests/sys/kern/ssl_sendfile.c
+14-71 files

FreeBSD/src b5bff92 — usr.sbin/syslogd/tests syslogd_forwarded_format_test.sh syslogd_relayed_format_test.sh

syslogd/tests: wait for tcpdump before sending the message

The forwarded and relayed format tests could send the message before tcpdump
attached to lo0, so "tcpdump -c 1" never saw it and the test hung until the
300s timeout. Also make syslogd_stop_on_ports stop every port it is given.

Reviewed by:    markj
Approved by:    markj
Sponsored by:   Netflix
Differential Revision:  https://ron-dev.freebsd.org/FreeBSD/src/pulls/108
DeltaFile
+15-3usr.sbin/syslogd/tests/syslogd_format_test_common.sh
+4-3usr.sbin/syslogd/tests/syslogd_relayed_format_test.sh
+3-2usr.sbin/syslogd/tests/syslogd_forwarded_format_test.sh
+22-83 files

FreeBSD/src b496e15 — sys/dev/axgbe xgbe-sysctl.c

axgbe: return positive errno values from the sysctl handlers

Return positive errno values from the FreeBSD sysctl handlers so that
userland reports the proper error instead of "Unknown error: -22".

Convert the negative phy_config_aneg() result at the sysctl boundary,
matching axgbe_if_media_change(), and retain the PHY code's internal
error convention.

Differential Revision:  https://reviews.freebsd.org/D61400

(cherry picked from commit c89613ded9237811d35a42788e9728fe0404e26b)
DeltaFile
+20-20sys/dev/axgbe/xgbe-sysctl.c
+20-201 files

FreeBSD/src 8774185 — sys/dev/axgbe xgbe-sysctl.c

axgbe: bound the sysctl parser writes in get_val()

Reject tokens and option counts that exceed the fixed parser buffers,
and fix the terminating NUL offset. Have the sysctl handlers propagate
parser errors before applying settings.

Handle SYSL_U32 options and reject failed numeric conversions instead of
using an uninitialized value. Fix the duplex case falling through to an
error, and initialize the link-setting strings for unexpected speeds.

Differential Revision:  https://reviews.freebsd.org/D61339

(cherry picked from commit 5523a8ba6f618fa5c853450dd551d8a5f06715ca)
DeltaFile
+49-21sys/dev/axgbe/xgbe-sysctl.c
+49-211 files

FreeBSD/src cd2a0f8 — sys/netinet tcp_output.c

tcp: address PR295870

Fix accounting in the sequence space for a FIN bit potentially
piggy bagged during SACK loss recovery triggered transmissions.

Approved by:    re (cperciva)
Reviewed By: #transport, tuexen
Sponsored by: NetApp, Inc.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61312

(cherry picked from commit 0aa6428f463699c5f5e03715ea4ebe2309a23a2d)
(cherry picked from commit f5797fcb0d8d8b2a63a49c3fe27eb9d7c7c417a8)
DeltaFile
+10-1sys/netinet/tcp_output.c
+10-11 files

FreeBSD/src 3157501 — tests/sys/kern module_test.c

modstat: check errno before calling feature_present

feature_present will overwrite errno if COMPAT_FREEBSD13 is not present.

Approved by:    re (cperciva)
Reported by:    llm-postcr
Fixes:          ef726c645300 ("modstat: allow compat support to fail in tests")

(cherry picked from commit acd270c8c6542b45e404078b28e1a732106aa76c)
(cherry picked from commit ed8dc5e715fff0a0c9f60416362924315bb49381)
DeltaFile
+1-1tests/sys/kern/module_test.c
+1-11 files

FreeBSD/src 7675717 — tests/sys/kern module_test.c

modstat: allow compat support to fail in tests

v1 and v2 versions of stuct module_stat are now gated by COMPAT_ ifdefs
so allow the otherwise valid query to fail with EINVAL.

Approved by:    re (cperciva)
Effort:         CHERI upstreaming
Reviewed by:    markj
Reported by:    llm-postcr
Sponsored by:   Innovate UK
Fixes:          1ebf46ecb627 ("modstat: don't copyout while holding a lock")
Differential Revision:  https://reviews.freebsd.org/D61460

(cherry picked from commit ef726c645300870b6bdf3573079b1f89f3b45c74)
(cherry picked from commit 4a9770b9256c7119da287b15a6e7900298e6d514)
DeltaFile
+16-8tests/sys/kern/module_test.c
+16-81 files

FreeBSD/src e1d96bb — sys/kern kern_module.c

modstat: don't copyout while holding a lock

If a user arranges for a page fault to never be filled (e.g., via a
FUSE file system), this can hold the shared lock forever.

To make this all work, refactor kern_modstat and freebsd32_modstat to
malloc a temporary buffer and fill it before copying it out rather
than doing a bunch of copies.

Add COMPAT_* ifdefs around compat code.  The module_stat_v1 code is
really for a.out binaries in practice and thus a bit questionable.

Approved by:    re (cperciva)
Reviewed by:    markj
Reported by:    llm-postcr
Sponsored by:   Innovate UK
Fixes:          7f8c2056db1e ("modstat: avoid copying from freed memory")
Differential Revision:  https://reviews.freebsd.org/D61432


    [2 lines not shown]
DeltaFile
+153-108sys/kern/kern_module.c
+153-1081 files

FreeBSD/src 0ca2438 — sys/kern kern_module.c

modstat: avoid copying from freed memory

If a module is unloaded after the module is looked up in kern_modstat,
but before one of the copyout's occurs, then the memory being copied
might be freed and reused leading to an information disclosure.

The LLM was particularly concerned about a TOCTOU issue in the length
of the name, but it seems likely that there are issues with all the
copyout's.  As such, hold the shared lock throughout.

Approved by:    re (cperciva)
Reviewed by:    markj
Reported by:    llm-postcr
MFC after:      3 days
Sponsored by:   Innovate UK
Fixes:          9b3851e9e3b1 ("- Lock down the ``module'' structure...")
Differential Revision:  https://reviews.freebsd.org/D61398

(cherry picked from commit 7f8c2056db1e39e44c3eda15aa4e53f7fc971cd8)
(cherry picked from commit 80fed5b6b5bdf712603b90a236796e35ed7e604c)
DeltaFile
+32-26sys/kern/kern_module.c
+32-261 files

FreeBSD/src 300d7db — sys/kern kern_module.c, sys/sys syscallsubr.h

kern_module.c: add kern_ implementations

In the case of modstat(2) use a cast to access the name member of the
old struct version so the compiler see the right array size.  This
addresses a sub-object bounds bug.

Approved by:    re (cperciva)
Effort:         CHERI upstreaming
Sponsored by:   DARPA, AFRL, Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284

(cherry picked from commit b96dc2c04fb4f504ad0c752c5d4b074c5bfbf7e0)
(cherry picked from commit 5c7d799c53ccb2f0a886566750f8226ea0c7f02f)
DeltaFile
+22-7sys/kern/kern_module.c
+3-0sys/sys/syscallsubr.h
+25-72 files

FreeBSD/src 33101b0 — sys/kern vfs_extattr.c

extattr_list*: avoid panic with absurd buffer lengths

Apply a layered defence:
 - Reject nbytes > IOSIZE_MAX in user_extattr_list_fd and
   user_extattr_list_path.
 - In extattr_list_vp require auiop->uio_resid to be non-negative.

Approved by:    re (cperciva)
Effort:         CHERI upstreaming
Reviewed by:    markj
Reported by:    llm-postcr
MFC after:      3 days
Sponsored by:   Innovate UK
Fixes:          6453d4240f6b ("vfs: Export exattr methods to reuse by Linuxulator")
Differential Revision:  https://reviews.freebsd.org/D61461

(cherry picked from commit 118067f51c111390dbc54760d781cd14a10c499e)
(cherry picked from commit 0967b36fe7837e4b1727ec1230ef1ee28ea6db8c)
DeltaFile
+7-1sys/kern/vfs_extattr.c
+7-11 files

FreeBSD/src f7cbc4d — sys/powerpc/aim mmu_radix.c

powerpc/pmap: Use dcbz to zero pages in the radix pmap

pagezero() was a plain store loop (bzero), which under the kernel build
flags (-mno-vsx -msoft-float) compiles to byte stores.  dcbz
establishes a zeroed cache line directly in the cache without a
read-for-ownership fetch from memory, roughly halving the memory
transactions of page zeroing.

Measured on POWER9 (Raptor Blackbird, DD2.3, bare metal), zeroing a
cold 256 MB buffer with 128-byte scalar loops:

  byte stores (current libkern memset)     8.6 GB/s
  doubleword (std) stores                  26.8 GB/s
  dcbz                                     34.6 GB/s

dcbz raises an alignment interrupt on caching-inhibited mappings, and
the kernel does not emulate it, so mmu_radix_zero_page() falls back to
bzero() for any page whose memattr is not the write-back default.  The
internal pagezero() callers only touch freshly allocated page-table

    [13 lines not shown]
DeltaFile
+16-3sys/powerpc/aim/mmu_radix.c
+16-31 files

FreeBSD/src 66e24d4 — sys/compat/linux linux_xattr.c

linux: do not truncate the listxattr() size

listxattr() sized its buffer with min(), which truncates the 64-bit
size to 32 bits, so a size of 2^32 + k allocated k bytes while the
copy-out guard used the full size.  The walk then read record lengths
past the buffer and copied kernel heap out to the caller, and could
panic the kernel.  Any user can reach it through a user.* attribute on
a file it owns.

Use MIN(), and fail with EIO if a record runs past the data returned.

Approved by:    re (cperciva)
Reviewed by:    adrian, markj
Approved by:    adrian (mentor)
Differential Revision:  https://reviews.freebsd.org/D61006
Signed-off-by: Nick Price <nprice at FreeBSD.org>
(cherry picked from commit fbe4835e6b1eec36103a5ce97efbab11b3b5fc72)
(cherry picked from commit a46d6ae4c0b6f6e8eb74b13da6f607d2ead74be7)
DeltaFile
+9-1sys/compat/linux/linux_xattr.c
+9-11 files

FreeBSD/src af04e99 — sys/kern uipc_socket.c, tests/sys/kern ktls_test.c

ktls: Check the record type message holds its byte

sosend_generic() read the TLS record type past a TLS_SET_RECORD_TYPE
control message holding only a cmsghdr, and sent that stale byte.

Approved by:    re (cperciva)
Approved by:    markj
Fixes:          b2e60773c6b0 ("Add kernel-side support for in-kernel TLS.")
Sponsored by:   Netflix

(cherry picked from commit bd4975e5fb051c2b2e8d5218940b7e8ef87b5bdf)
(cherry picked from commit 42e7802e24fefd1cef6913ab162cda2c7bdc477f)
DeltaFile
+43-0tests/sys/kern/ktls_test.c
+1-1sys/kern/uipc_socket.c
+44-12 files

FreeBSD/src 12c79b3 — lib/libc/tests/db db_hash_tamper_test.c

libc/db: Correct a typo in the the hash tampering test

Fixes the gcc build.

Fixes:  7f5f07b139a5
(cherry picked from commit b774fbdb0077571dd34ca55ecb87199895ff47d3)
DeltaFile
+1-1lib/libc/tests/db/db_hash_tamper_test.c
+1-11 files

FreeBSD/src e3483db — sys/netinet tcp_input.c tcp_var.h, sys/netinet/tcp_stacks rack.c bbr.c

tcp: improve consistency

Use an inline function tcp_adapt_iss_check() to perform the check
consistently instead of replicating the code multiple times. These
checks already became inconsistent.
A fix for PR 298560 requires more calls to tcp_adapt_iss_check().

Reviewed by:            Peter Lei
Fixes:                  fa2ad70a4511 ("tcp: make ghost ACK handling more conformant")
MFC after:              3 days
MFC to:                 stable/14
MFC to:                 stable/15
Sponsored by:           Netflix, Inc.
Differential Revision:  https://reviews.freebsd.org/D61685
DeltaFile
+10-0sys/netinet/tcp_var.h
+1-4sys/netinet/tcp_stacks/rack.c
+1-4sys/netinet/tcp_stacks/bbr.c
+1-4sys/netinet/tcp_input.c
+13-124 files

FreeBSD/src 5b2f5e9 — usr.sbin/bhyve bhyverun.h bhyverun.c, usr.sbin/bhyve/aarch64 vmexit.c

bhyve: Do not abort when the VM is destroyed during an exit

When a VM is destroyed (bhyvectl --destroy) while a vCPU thread is
handling an exit in bhyve, every call on the VM fails.  vm_loop()
handles that for vm_run() and ends bhyve with BHYVE_EXIT_ERROR, but a
vCPU in the middle of an exit hits one of the assert(error == 0) after
a register update or an exception injection (emulate_inout(),
vmexit_rdmsr(), vm_inject_fault()), or reports "Failed to emulate
instruction" and returns VMEXIT_ABORT: bhyve dies of SIGABRT and
leaves a core.  With a guest doing a lot of port I/O or MSR accesses
that bhyve emulates, a forced stop hits this regularly.

Add vm_check_destroyed(), which exits with BHYVE_EXIT_ERROR, as
vm_loop() does, if the VM is gone.  Call it before those asserts and
on the instruction emulation failure paths on amd64, arm64 and
riscv.  A failure on a VM that still exists asserts or aborts as
before.

Signed-off-by:  Wanpeng Qian <wanpengqian at gmail.com>

    [4 lines not shown]
DeltaFile
+18-0usr.sbin/bhyve/bhyverun.c
+8-0usr.sbin/bhyve/amd64/vmexit.c
+8-0usr.sbin/bhyve/amd64/inout.c
+1-0usr.sbin/bhyve/riscv/vmexit.c
+1-0usr.sbin/bhyve/bhyverun.h
+1-0usr.sbin/bhyve/aarch64/vmexit.c
+37-06 files

FreeBSD/src 1c44c38 — contrib/blocklist/bin blacklistd.8

blocklist: blacklist: Chase recent upstream changes

MFC after:      3 days

(cherry picked from commit e00339214db27eccf3d1574516960ba4b8869369)
DeltaFile
+19-11contrib/blocklist/bin/blacklistd.8
+19-111 files

FreeBSD/src edb5996 — contrib/blocklist/bin blocklistd.8, contrib/blocklist/diff named.diff

MFV: Import blocklist 2026-11-12 (590e95e)

Merge commit 'b0788c28c7bc6631129bc366bad491cf5698b2dc'

Changes:

https://github.com/zoulasc/blocklist/compare/10a907f...590e95e

MFC after:      3 days

(cherry picked from commit ea9a38e03249e25e1be8bd8f3c64028f9ac1102f)
DeltaFile
+140-195contrib/blocklist/diff/named.diff
+19-11contrib/blocklist/bin/blocklistd.8
+1-1contrib/blocklist/etc/blocklistd.conf
+160-2073 files

FreeBSD/src 4fae50e — sys/amd64/pt pt.c

amd64/pt.c: Clear ToPa PMI status for stray interrupts

An inactive tracing session might encounter stray ToPA PMI
interrupts, in which case the interrupt handler skips processing
the interrupt but fails to reset the ToPA status bit.
DeltaFile
+1-0sys/amd64/pt/pt.c
+1-01 files

FreeBSD/src c8fc545 — sys/amd64/pt pt.c

amd64/pt.c: Plug a 'pt_backend_alloc_thread' error path memory leak

The thread-mode allocation method failed to release the previously
allocate `pt_ctx` structure on error.

Fixes:  310162ea218a
DeltaFile
+3-1sys/amd64/pt/pt.c
+3-11 files

FreeBSD/src aa17908 — sys/amd64/pt pt.c

amd64/pt.c: Align ToPA table to page size

The Intel SDM states that the ToPA table must by 4k-aligned, and any
alignment issues will cause an operational error and disable tracing.

The default buffer size prevented this from happening, but a smaller
buffer size could hit this issue. Fix this by explicitly allocating
the ToPA table with malloc_aligned.

Fixes:  310162ea218a
DeltaFile
+1-1sys/amd64/pt/pt.c
+1-11 files

FreeBSD/src 8f926f2 — share/man/man4 unix.4, sys/kern uipc_usrreq.c

unix: Do not copy out internalized SCM_RIGHTS on MSG_PEEK

recvmsg(2) with MSG_PEEK on a queued SCM_RIGHTS message copied the
control data out in its internalized form, an in-kernel struct file
pointer per descriptor, instead of as file descriptors.  The
stream/seqpacket receive method noted this in an XXXGL comment; the
datagram peek path behaved the same way.

On a peek, return the SCM_RIGHTS message with -1 in place of each
descriptor.  A descriptor is a non-negative integer, so -1 tells the
caller that descriptors are queued without installing any; they are
delivered by the next non-peek receive.  Other control messages (e.g.
SCM_CREDS) are still returned.  Document this in unix(4).

Reviewed by:    glebius, markj
Suggested by:   glebius
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2469
Signed-off-by:  Patrick Crandol <patrick at crandol.com>
DeltaFile
+63-18sys/kern/uipc_usrreq.c
+12-1share/man/man4/unix.4
+75-192 files

FreeBSD/src f5c2169 — tests/sys/kern unix_passfd_test.c

tests: unix: Check that MSG_PEEK returns -1 for SCM_RIGHTS

Add a regression test that a MSG_PEEK receive of a queued SCM_RIGHTS
message returns -1 in place of the descriptor, while other control
messages, here SCM_CREDS, are still returned, and that the following
receive still delivers the descriptor.

Signed-off-by: Patrick Crandol <patrick at crandol.com>
DeltaFile
+59-0tests/sys/kern/unix_passfd_test.c
+59-01 files

FreeBSD/src c1914b1 — sys/netipsec xform_ah.c

ipsec: Reject an AH IPv4 option that runs past the header

ah_massage_headers() zeroed each mutable IPv4 option before checking its
length fit the header, so an option length byte could write up to 255 zero
bytes past the IP header (and the mbuf) when ip_dooptions() had not
validated the options (process_options=0).

With the check done up front, the post-switch off > skip test is dead;
remove it.

Reviewed by:    markj, rcm
Approved by:    markj, rcm
Sponsored by:   Netflix
Fixes:  b12a7532e390 ("Merge revision 1.35 from NetBSD: fix pointer/offset mistakes in handling of IPv4 options")
Differential Revision:  https://ron-dev.freebsd.org/FreeBSD/src/pulls/94
DeltaFile
+9-9sys/netipsec/xform_ah.c
+9-91 files

FreeBSD/src bd29b7b — sys/compat/linux linux_errno.c

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)
DeltaFile
+4-5sys/compat/linux/linux_errno.c
+4-51 files

FreeBSD/src 1089333 — sys/compat/freebsd32 freebsd32_misc.c, sys/kern sys_process.c

ptrace: Call ptrace_check_allowed() from the compat32 layer

Otherwise the checks there aren't applied to freebsd32 ptrace calls.

Approved by:    re (cperciva)
Fixes:  7006cb7bd22d ("pdptrace(2): allow debugging in capability mode")
Reviewed by:    kib
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D61597

(cherry picked from commit 44ae34814f689bf640c03b7f26f4f540a5f92d54)
(cherry picked from commit c1b0ea1f72d7c7ad21c969191d1bb85aac08d18f)
DeltaFile
+4-1sys/compat/freebsd32/freebsd32_misc.c
+1-1sys/kern/sys_process.c
+2-0sys/sys/ptrace.h
+7-23 files

FreeBSD/src c350c69 — sys/kern kern_descrip.c

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]
DeltaFile
+16-5sys/kern/kern_descrip.c
+16-51 files

FreeBSD/src 6b1e53a — sys/kern subr_sglist.c, sys/sys sglist.h

sglist: use u_int instead of u_short to store sizes

sglist_alloc accepts an int argument to specify the number of segments
in the sglist. The sglist struct however stores this value in a u_short,
which may wrap in the case of larger sglists. This happens when the
NVIDIA driver performs large allocations, as reported by a user.

This changes updates the use of u_short to a u_int to match the arg
passed into sglist_alloc. The sglist init and save locations are also
updated to no longer use shorts to represent nseg.

Approved by:    khng (mentor)
PR:             299611
Sponsored by:   NVIDIA
Differential Revision:  https://reviews.freebsd.org/D61197
DeltaFile
+3-3sys/sys/sglist.h
+1-1sys/kern/subr_sglist.c
+4-42 files

FreeBSD/src cfd6ff1 — sys/kern kern_descrip.c

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]
DeltaFile
+16-5sys/kern/kern_descrip.c
+16-51 files