FreeBSD/src ea390ec — tests/sys/netinet ip_reass_test.c

tests/netinet/ip_reass: skip when IP reassembly is disabled
DeltaFile
+17-0tests/sys/netinet/ip_reass_test.c
+17-01 files

FreeBSD/src 002594c — lib/libpmc pmc.soft.3

pmc.soft(3): fixup table formatting

The default indent did not serve well. No content change.

MFC after:      3 days
DeltaFile
+1-1lib/libpmc/pmc.soft.3
+1-11 files

FreeBSD/src bf7bb73 — sys/compat/linux linux_fork.c, sys/kern kern_kthread.c

hwpmc: call the thread-create hook for Linux and kernel threads

linux_clone_thread() and kthread_add() did not call the
PMC_FN_THR_CREATE hook.  Their new threads had no hwpmc thread
descriptor.  If the process had a sampling PMC, the first switch-in
of such a thread hit KASSERT(pt != NULL) in pmc_process_csw_in().
An unprivileged user could panic an INVARIANTS kernel with
"pmcstat -P" on a threaded Linux program.

Call the hook in both functions, as thread_create() does.

kern_kthread.c did not include opt_hwpmc_hooks.h, so its hwpmc code
never compiled.  Include it, and use newtd in kthread_add1().
Remove the exit log call from kthread_exit(), because thread_exit()
already logs the exit.

Reported by:    llm-postcr
Reviewed by:    kib, mhorne
Fixes:          6161b98c9935 ("hwpmc: Implement per-thread counters for PMC sampling")
Differential Revision:  https://reviews.freebsd.org/D61524
DeltaFile
+9-6sys/kern/kern_kthread.c
+11-0sys/compat/linux/linux_fork.c
+20-62 files

FreeBSD/src 125b88f — sys/amd64/vmm/io vrtc.c

vmm: release the lock when vrtc_snapshot() fails

The error path of the SNAPSHOT_*_OR_LEAVE() macros jumped past
VRTC_UNLOCK() and returned with the vrtc lock held.

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

Reviewed by:    bnovkov, markj, jhb
Sponsored by:   keelos.dev
Differential Revision:  https://reviews.freebsd.org/D60232
DeltaFile
+1-2sys/amd64/vmm/io/vrtc.c
+1-21 files

FreeBSD/src 018bd70 — sys/amd64/vmm/io vrtc.c

vmm: do not let the RTC's periodic interrupt drift

The callout of the periodic interrupt was rearmed from its handler with
a timeout of one period from the time the handler ran.  Each period was
longer than programmed by the latency of the callout, so the interrupt
came at a lower rate than the guest asked for.  A guest that counts
these interrupts to keep its time runs slow.

Give the callout absolute deadlines one period apart, as vatpit does.
If a deadline has already passed when it is computed, for instance
after the VM was paused, start again from the current time.

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

Reviewed by:    jhb
Sponsored by:   keelos.dev
Differential Revision:  https://reviews.freebsd.org/D60233
DeltaFile
+21-7sys/amd64/vmm/io/vrtc.c
+21-71 files

FreeBSD/src 611046b — sbin/ipfw nat.c, tests/sys/netpfil/ipfw Makefile nat.sh

ipfw: print the log, not the config, for "nat <name> show log"

Add a test too.

Reviewed by:    ae
Fixes:          d6164b77f8b7 ("Make ipfw_nat module use IP_FW3 codes.")
Found with:     Claude Opus 4.8
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D61588
DeltaFile
+66-0tests/sys/netpfil/ipfw/nat.sh
+4-1sbin/ipfw/nat.c
+1-0tests/sys/netpfil/ipfw/Makefile
+71-13 files

FreeBSD/src 1c8725c — sys/netpfil/ipfw ip_fw_nat.c, tests/sys/netpfil/ipfw Makefile nat_getlog.c

ipfw_nat: fix the buffer length check in IP_FW_NAT44_XGETLOG

nat44_get_log() compared the user buffer length against the request
header plus another ipfw_obj_header instead of the request header plus
the log buffer.  A buffer that passed this check but was shorter than
the full reply left too little room in the sockopt window, so
ipfw_get_sopt_space() returned NULL and the following memcpy() of the
log wrote through a NULL pointer, panicking the kernel.

The handler was cloned from nat44_get_cfg() in the commit below, under
the convention of that time where ucfg->size held the payload only and
the ipfw_obj_header was added back in the length check.  9f925e8a920e
("Fix IP_FW_NAT44_LIST_NAT size calculation.") later switched
nat44_get_cfg() to count the header in ucfg->size and reduced its check
to "valsize < size", but nat44_get_log() was not updated.  It kept the
stale idiom, whose check counts the header twice, and by coincidence of
the struct sizes that never leaves room for the log.

Compare against the full reply length and check the result of

    [18 lines not shown]
DeltaFile
+226-0tests/sys/netpfil/ipfw/nat_getlog.c
+6-2sys/netpfil/ipfw/ip_fw_nat.c
+2-0tests/sys/netpfil/ipfw/Makefile
+234-23 files

FreeBSD/src 596a470 — usr.sbin/bhyve pci_e82545.c

bhyve: e82545: deassert the interrupt when its last cause is masked

A write to IMC only cleared the bits in the mask.  If the device was
asserting INTx for a cause that the write masked, the line stayed up
until the guest cleared the cause in ICR.  The hardware deasserts INTx
as soon as no unmasked cause is left, and a guest may rely on that:
Windows masks all causes and unloads its driver when it shuts down, and
then spends its time in the handlers of whatever shares the interrupt.

Do what the comment in the code asked for.

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

Reviewed by:    jhb
Sponsored by:   keelos.dev
Differential Revision:  https://reviews.freebsd.org/D60230
DeltaFile
+3-2usr.sbin/bhyve/pci_e82545.c
+3-21 files

FreeBSD/src b9e45c2 — sys/netipsec ipsec.h xform_ipcomp.c

netipsec: Clear the crypto error before dispatching a request again

When a crypto driver unregisters, a request on one of its sessions
completes with EAGAIN.  The ESP, AH and IPComp callbacks then move the
SA to the new session and pass the same request to crypto_dispatch()
again, with crp_etype still set to EAGAIN.

crypto_dispatch() requires a request without an error.  A kernel with
INVARIANTS panics there with "incoming crp with error".  The other
consumers that dispatch a request again after EAGAIN clear the field
first.

The six callbacks prepare the request for the retry with the same
code.  Move that code to a new function, ipsec_crypto_retry(), and
clear the error there.  ipsec_updateid() has no other callers and
becomes static.  The callbacks still dispatch the request themselves,
because the input callbacks have to release the sahtree lock first.

Reviewed by:            markj, kib

    [4 lines not shown]
DeltaFile
+18-1sys/netipsec/ipsec.c
+2-12sys/netipsec/xform_ipcomp.c
+2-12sys/netipsec/xform_esp.c
+2-12sys/netipsec/xform_ah.c
+4-1sys/netipsec/ipsec.h
+28-385 files

FreeBSD/src c27f0ee — sys/security/mac mac_syscalls.h mac_syscalls.c

mac: Fix a couple of bugs in prison label handling

In mac_get_prison(), mac.m_string points to a user address; the
string is copied in by mac_label_copyin_string().  If an error occurs
before that copyin, we end up freeing a user-controlled pointer.

In mac_set_prison_prepare(), the string is leaked.

Fix both problems.  While here, make free_copied_label() a bit more
robust to bugs in callers.

Fixes:          bd55cbb50c58 ("kern: add a mac.label jail parameter")
Reviewed by:    olce, kevans
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D61596
DeltaFile
+18-7sys/security/mac/mac_syscalls.c
+1-1sys/security/mac/mac_syscalls.h
+19-82 files

FreeBSD/src d174085 — sys/netinet tcp_output.c

tcp: improve sender side SWS avoidance

When checking for a full sized segment, take all TCP options that will
be included into account. This fixes a bug which can trigger the
"sent too much" KASSERT related to limited transmit.

Reported by:            olivier
Reviewed by:            rscheff, Peter Lei
MFC after:              3 days
MFC to:                 stable/15
MFC to:                 stable/14
Sponsored by:           Netflix, Inc.
Differential Revision:  https://reviews.freebsd.org/D61605
DeltaFile
+1-13sys/netinet/tcp_output.c
+1-131 files

FreeBSD/src 766061e — tests/sys/kern module_test.c

modstat: check errno before calling feature_present

feature_present will overwrite errno if COMPAT_FREEBSD13 is not present.

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

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

FreeBSD/src 9d6b8de — 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.

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)
DeltaFile
+16-8tests/sys/kern/module_test.c
+16-81 files

FreeBSD/src 3b321d5 — 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.

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

(cherry picked from commit 1ebf46ecb6278e31d7ae029b0f8af3d64e7bc1f9)
DeltaFile
+153-108sys/kern/kern_module.c
+153-1081 files

FreeBSD/src 776493a — 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.

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)
DeltaFile
+32-26sys/kern/kern_module.c
+32-261 files

FreeBSD/src ec213d1 — 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.

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

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

FreeBSD/src a04f2d4 — 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.

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)
DeltaFile
+7-1sys/kern/vfs_extattr.c
+7-11 files

FreeBSD/src 698d942 — sys/netipsec ipsec_output.c

netipsec: Release the SA and SP when mb_unmapped_to_ext() fails

ipsec4_perform_request() maps unmapped (M_EXTPG) mbufs before the
software transforms run.  mb_unmapped_to_ext() frees the chain when it
fails, and the error return then kept both the SA reference taken by
ipsec4_allocsa() and the SP reference that this function must release.
The SA, its crypto session and the SP were never freed after they were
deleted.

The conversion fails with ENOMEM when an mbuf allocation fails, for
example for sendfile(2) data sent through a software IPv4 SA, and with
EINVAL for every packet of a NIC kTLS connection that matches an IPsec
policy.  Take the common error path instead; it skips m_freem() when
the mbuf pointer is NULL.

IPv6 is not affected: ipsec6_perform_request() does not call
mb_unmapped_to_ext().

Reported by:    llm-postcr

    [3 lines not shown]
DeltaFile
+3-1sys/netipsec/ipsec_output.c
+3-11 files

FreeBSD/src d939014 — libexec/tftpd tftp-options.h tftp-options.c

tftpd: Keep proper track of option length

When parsing options, keep track of the length of the unparsed portion
and pass that to get_field() instead of the length of the entire header.

While here, switch both make_options() and parse_options() to using
size_t for sizes and lengths.

MFC after:      1 week
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D61048

(cherry picked from commit 35cd70490f4b7ec1921db980ae3992192e4cbfbb)
DeltaFile
+14-15libexec/tftpd/tftp-options.c
+3-3libexec/tftpd/tftp-options.h
+17-182 files

FreeBSD/src 6d18a70 — usr.bin/login login.c, usr.bin/su su.c

su, login: fix heap over-read in environment export filter

ok_to_export() (su.c) and export() (login.c) read s[n] before
strncmp(s, *pp, n) confirms s is at least n bytes long, where n is
the length of the blocked variable name. A PAM environment entry
shorter than that name over-reads past its heap allocation.

Check strncmp() first; it stops at s's NUL terminator and never
reads past the boundary that guarded the s[n] access.

MFC after:      1 week
Sponsored by:   Advanced Micro Devices, Inc.
Signed-off-by:  Osvaldo Janeri Filho <ojanerif at amd.com>
Reviewed by:    des, markj
Differential Revision:  https://reviews.freebsd.org/D61420

(cherry picked from commit e1b5e1f9ddac43ed669a44cfdbba1b394d144c6b)
DeltaFile
+1-1usr.bin/su/su.c
+1-1usr.bin/login/login.c
+2-22 files

FreeBSD/src e30c4d4 — libexec/tftpd tftp-utils.c

tftpd: Fix off-by-one in get_field()

Due to a logic error, get_field() would behave as if the passed-in size
was one greater than it actually is.  Fix it so it always fails if no
terminating NUL is found within the buffer, instead of succeeding if the
first byte past the end is a NUL.

MFC after:      1 week
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D61032

(cherry picked from commit 14541ca2bf3766e659a22c5ea9ed3dc2d5f11fa5)
DeltaFile
+7-8libexec/tftpd/tftp-utils.c
+7-81 files

FreeBSD/src 5d0e1ae — libexec/tftpd tftpd.c

tftpd: Keep proper track of header length

When parsing a header, keep track of the length of the unparsed portion
and pass that to get_field() instead of the length of the entire header.

Reported by:    n0ps1ed
MFC after:      1 week
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D60902

(cherry picked from commit 579e428a551a11b43e341297dd0ef9d38c4fcda7)
DeltaFile
+7-6libexec/tftpd/tftpd.c
+7-61 files

FreeBSD/src 7e3a60f — libexec/tftpd tftpd.c

tftpd: Keep proper track of header length

When parsing a header, keep track of the length of the unparsed portion
and pass that to get_field() instead of the length of the entire header.

Reported by:    n0ps1ed
MFC after:      1 week
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D60902

(cherry picked from commit 579e428a551a11b43e341297dd0ef9d38c4fcda7)
DeltaFile
+7-6libexec/tftpd/tftpd.c
+7-61 files

FreeBSD/src a74f742 — libexec/tftpd tftp-utils.c

tftpd: Fix off-by-one in get_field()

Due to a logic error, get_field() would behave as if the passed-in size
was one greater than it actually is.  Fix it so it always fails if no
terminating NUL is found within the buffer, instead of succeeding if the
first byte past the end is a NUL.

MFC after:      1 week
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D61032

(cherry picked from commit 14541ca2bf3766e659a22c5ea9ed3dc2d5f11fa5)
DeltaFile
+7-8libexec/tftpd/tftp-utils.c
+7-81 files

FreeBSD/src 0d8a925 — usr.bin/login login.c, usr.bin/su su.c

su, login: fix heap over-read in environment export filter

ok_to_export() (su.c) and export() (login.c) read s[n] before
strncmp(s, *pp, n) confirms s is at least n bytes long, where n is
the length of the blocked variable name. A PAM environment entry
shorter than that name over-reads past its heap allocation.

Check strncmp() first; it stops at s's NUL terminator and never
reads past the boundary that guarded the s[n] access.

MFC after:      1 week
Sponsored by:   Advanced Micro Devices, Inc.
Signed-off-by:  Osvaldo Janeri Filho <ojanerif at amd.com>
Reviewed by:    des, markj
Differential Revision:  https://reviews.freebsd.org/D61420

(cherry picked from commit e1b5e1f9ddac43ed669a44cfdbba1b394d144c6b)
DeltaFile
+1-1usr.bin/su/su.c
+1-1usr.bin/login/login.c
+2-22 files

FreeBSD/src 9a44e17 — libexec/tftpd tftp-options.h tftp-options.c

tftpd: Keep proper track of option length

When parsing options, keep track of the length of the unparsed portion
and pass that to get_field() instead of the length of the entire header.

While here, switch both make_options() and parse_options() to using
size_t for sizes and lengths.

MFC after:      1 week
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D61048

(cherry picked from commit 35cd70490f4b7ec1921db980ae3992192e4cbfbb)
DeltaFile
+14-15libexec/tftpd/tftp-options.c
+3-3libexec/tftpd/tftp-options.h
+17-182 files

FreeBSD/src 471d0cb — bin/pax extern.h ar_io.c

pax: Use copy_file_range

Use copy_file_range(2) instead of our own inefficient and unreliable
attempt at detecting holes.  If copy_file_range(2) is not available,
which in theory should be never, we fall back to a simple read(2) /
write(2) loop which makes no attempt to copy holes.  This should
speed up pax copy mode and cpio passthrough mode significantly.

This includes refactoring much of the existing I/O code to use the
size_t and ssize_t instead of int where appropriate.

MFC after:      1 week
Sponsored by:   Klara, Inc.
Reviewed by:    obiwac
Differential Revision:  https://reviews.freebsd.org/D58470
DeltaFile
+92-75bin/pax/buf_subs.c
+18-17bin/pax/ar_io.c
+6-6bin/pax/extern.h
+116-983 files

FreeBSD/src fb79a94 — bin/pax/tests Makefile pax_test.sh

pax: Add tests

Add tests exercising pax copy mode, cpio passthrough mode, the ability
to extract pax, cpio, and tar archives, and the ability to parse pax,
cpio, and tar command lines.

MFC after:      1 week
Sponsored by:   Klara, Inc.
Reviewed by:    obiwac
Differential Revision:  https://reviews.freebsd.org/D58469
DeltaFile
+109-0bin/pax/tests/pax_test.sh
+1-2bin/pax/tests/Makefile
+110-22 files

FreeBSD/src 37d71d6 — share/mk bsd.sys.mk

bsd.sys.mk: suppress some clang warnings for C++ for >= 19

I just tried building with system clang on one of my Linux systems which
happens to be version 19, and these warning suppressions are needed for
that version too: same errors as in the original commit.

Reviewed by:    imp
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D56874

(cherry picked from commit 004b5935a6e643033526cab623c6005b69ab11aa)
DeltaFile
+0-2share/mk/bsd.sys.mk
+0-21 files

FreeBSD/src 1b9a8e1 — share/man/man4 ipsec.4, sys/netipsec key.c ipsec.c

netipsec: Select outbound transmit queues by SA instead of inner flow

Outbound IPsec packets retain the flow ID of the inner traffic. Multi-queue
interfaces use this ID to select a transmit queue (iflib's QIDX()) or a member
port (lagg(4) with use_flowid). Consequently, packets belonging to the same
security association (SA) can be distributed across independently draining
queues.

ESP and AH sequence numbers are assigned before encryption, but the packets
can be transmitted out of order when different queues drain at different
rates. This can cause legitimate packets to fall outside the receiver's
anti-replay window and be dropped as possible replays. RFC 4303, Section
3.4.3, makes 32 packets the smallest window a receiver must support, and
strongSwan installs that minimum by default.

Assign each SA a flow ID derived from a Jenkins hash of its SPI, computed once
when the SA is created, from the SPI in host byte order so that the value is
the same on every architecture. Set this ID on outbound packets in
ipsec{4,6}_perform_request(), with M_HASHTYPE_OPAQUE_HASH, once the SA is

    [32 lines not shown]
DeltaFile
+165-0tests/sys/netipsec/tunnel/sa_flowid.sh
+23-1share/man/man4/ipsec.4
+18-0sys/netipsec/ipsec_output.c
+5-0sys/netipsec/ipsec.c
+4-0sys/netipsec/key.c
+2-1tests/sys/netipsec/tunnel/Makefile
+217-22 files not shown
+220-28 files