FreeBSD/src 78bbe9fusr.sbin/pmc cmd_pmc_record.cc

pmc: Use distinct names for arguments to the pmc_config constructor

This pacifies shadow warnings from GCC:

usr.sbin/pmc/cmd_pmc_record.cc: In constructor 'pmc_config::pmc_config(const std::__1::string&, uint64_t, cpuset_t)':
usr.sbin/pmc/cmd_pmc_record.cc:96:71: error: declaration of 'cpumask' shadows a member of 'pmc_config' [-Werror=shadow]
   96 |         pmc_config(const std::string &event, uint64_t count, cpuset_t cpumask)
      |                                                              ~~~~~~~~~^~~~~~~
usr.sbin/pmc/cmd_pmc_record.cc:90:25: note: shadowed declaration is here
   90 |         cpuset_t        cpumask;
      |                         ^~~~~~~
usr.sbin/pmc/cmd_pmc_record.cc:96:55: error: declaration of 'count' shadows a member of 'pmc_config' [-Werror=shadow]
   96 |         pmc_config(const std::string &event, uint64_t count, cpuset_t cpumask)
      |                                              ~~~~~~~~~^~~~~
usr.sbin/pmc/cmd_pmc_record.cc:89:25: note: shadowed declaration is here
   89 |         uint64_t        count;
      |                         ^~~~~
usr.sbin/pmc/cmd_pmc_record.cc:96:39: error: declaration of 'event' shadows a member of 'pmc_config' [-Werror=shadow]
   96 |         pmc_config(const std::string &event, uint64_t count, cpuset_t cpumask)

    [7 lines not shown]
DeltaFile
+4-3usr.sbin/pmc/cmd_pmc_record.cc
+4-31 files

FreeBSD/src 8502036sys/dev/thunderbolt nhi.c

thunderbolt: Fix v2.0 reset to reliably wait for the reset to finish

The `reg` value was never initialized, so the loop could potentially
abort without a single read of the register.  This was found by the
following warning from GCC:

sys/dev/thunderbolt/nhi.c: In function 'nhi_reset_v2':
sys/dev/thunderbolt/nhi.c:272:35: error: 'reg' is used uninitialized [-Werror=uninitialized]
  272 |         for (size_t i = 0; i < 10 && reg; i++) {
      |                                   ^~
sys/dev/thunderbolt/nhi.c:257:18: note: 'reg' was declared here
  257 |         uint32_t reg;
      |                  ^~~

Reported by:    GCC 15
Fixes:          efdb82413963 ("thunderbolt: Reset controllers")
DeltaFile
+1-0sys/dev/thunderbolt/nhi.c
+1-01 files

FreeBSD/src 01c0ddflib/libc/gen uexterr_format.c

exterr: Fix build with GCC on 32-bit architectures

Use an intermediate uintptr_t cast to avoid casting a uint64_t value
directly to void * on 32-bit platforms (including lib32 builds).

lib/libc/gen/uexterr_format.c: In function 'uexterr_format_msg':
lib/libc/gen/uexterr_format.c:248:35: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
  248 |                         PFMT(fmt, (void *)ARG(nextarg));
      |                                   ^
lib/libc/gen/uexterr_format.c:144:47: note: in definition of macro 'PFMT'
  144 |                 psz = snprintf(buf, bufsz, f, a);                       \
      |                                               ^

Reported by:    GCC 15
Fixes:          2f024a7cfddd ("exterr: relax format restrictions")
DeltaFile
+1-1lib/libc/gen/uexterr_format.c
+1-11 files

FreeBSD/src bdfae0fsys/kern subr_epoch.c

epoch: Fix epoch_drain_callbacks()

This function is supposed to wait until all pending callbacks have been
executed.  This is useful in some contexts where we tear down some
context (like a VNET jail and its associated UMA zones) synchronously,
and we want to make sure that all pending asynchronous callbacks (which
may free objects to said UMA zones) have run first.

The implementation schedules a callback on each CPU and waits for them
all to run.  This assumes that, on a given CPU, callbacks are executed
in the order that they are pushed.  This assumption depends on the
implementation of epoch_call_task() and ck_epoch_poll_deferred(), and it
is not true in general.

Callbacks are pushed onto a per-CPU stack in LIFO order.
ck_epoch_poll_deferred() first pulls out the callbacks from epoch - 2,
which are always safe to execute, and in so doing reorders them such
that the oldest callback as at the top of the stack, so in this case,
epoch_call_task() will execute them in order.  However,

    [26 lines not shown]
DeltaFile
+30-20sys/kern/subr_epoch.c
+30-201 files

FreeBSD/src eddae79share/man/man4 ctl.4

ctl.4: Document the assumption that CTL HA runs only on trusted networks

The CTL High Availablity clustering feature allows a pair of hosts to
implement transparent failover.  The implementation uses a TCP
connection to exchange messages.  There is no authentication mechanism
and the protocol itself embeds kernel pointers in the messages exchanged
between HA hosts.  This property (of CTL_MSG_DATAMOVE messages
specifically), as well as insufficient validation of inbound messages,
mean that anyone able to access a CTL HA port is able to remotely
execute code on that host.

Provide a warning to this effect in the CTL man page.

Approved by:    re (cperciva)
Reported by:    Ryan of Calif.io
Reviewed by:    ziaee, ken, mav
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D58622

    [3 lines not shown]
DeltaFile
+6-1share/man/man4/ctl.4
+6-11 files

FreeBSD/src 10dd09cusr.sbin/ppp lcp.c

ppp: Reject invalid endpoint discriminator options

Per RFC1717 section 5.1.3, the option length must be at least three.
Processing an undersized option would trigger a large out-of-bounds
write.

Approved by:    re (cperciva)
PR:             271910
Reported by:    Robert Morris
Reported by:    Décio Brandão (0xDBJ)
Reviewed by:    emaste
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D58554

(cherry picked from commit b9d07a4308226b683b64827e0aaed1180e0da996)
(cherry picked from commit 30b4bdd451ad4ec2470f9a378bd62e948a85ef81)
DeltaFile
+6-0usr.sbin/ppp/lcp.c
+6-01 files

FreeBSD/src 281fb7dusr.sbin/ppp mp.c

ppp: Avoid overflow when formatting endpoint discriminator options

Each byte of the address is represented by a pair of characters, so we
should be multiplying len by 2 when figuring out how much buffer space
we have.  Previously, a sufficiently large option could cause an
overflow of the global "result" buffer.

Approved by:    re (cperciva)
Reported by:    Joshua Rogers <joshua at joshua.hu>
Tested by:      Décio Brandão (0xDBJ)
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D58555

(cherry picked from commit e004ff15f87e6aa8f2aa13cd5600ae13457b95f1)
(cherry picked from commit 607c41d8f869243db275a6b1bd6cc66bf58d0f36)
DeltaFile
+6-6usr.sbin/ppp/mp.c
+6-61 files

FreeBSD/src 43bbea2sys/kern kern_fork.c

proc: Copy the p_reapsubtree field explicitly during fork

p_reapsubtree lives in the p_startcopy/p_endcopy block of struct proc,
which is copied during fork without any synchronization.  However, the
field is not stable except when the proctree lock is held, and indeed
may change if p1's reaper exits or explicitly releases its reaper
status.  This state change can race with fork() and leave the child with
an incorrect p_reapsubtree field.

Close the race: explicitly copy the field under the proctree lock during
fork.

Approved by:    re (cperciva)
Reported by:    syzkaller
Reviewed by:    kib
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D58482


    [2 lines not shown]
DeltaFile
+7-0sys/kern/kern_fork.c
+7-01 files

FreeBSD/src dde5572sys/netinet6 raw_ip6.c

rawip: Fix handling of checksums in rip6_input()

A v6 raw socket may ask the kernel to validate the checksum of an
inbound packet.  If it does, and the validation fails, we discard the
packet, but this isn't really right: other raw sockets may wish to
receive a copy of the packet anyway.

Rework checksum handling to address this problem, and use a flag to
avoid computing the checksum more than once for a given packet.

Approved by:    re (cperciva)
Fixes:          de2d47842e880281 ("SMR protection for inpcbs")
Reviewed by:    pouria, glebius
Reported by:    Yunzhi Ke
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D58559

(cherry picked from commit 196874ce2e97e3e6425493b1d501e716b356bc36)
(cherry picked from commit 1fe3a2897b4ad7a9b9128efd6ec0c24b371bf5bd)
DeltaFile
+15-11sys/netinet6/raw_ip6.c
+15-111 files

FreeBSD/src 9c5f813sys/netinet in_mcast.c, sys/netinet6 in6_mcast.c

in_mcast: Fix uninitialized variable usage in inm_merge()

When the first loop in inm_merge() hits an error, generally because it
hit some limit on the number of source filters for a multicast group,
inm_merge() tries to atomically roll back changes to the group source
filter list.

To roll back, it iterates over the global source filter list for the
multicast group, starting at the last entry that we updated ("nims").
But, if we have not yet updated any entries, this variable is
uninitialized.  Initialize it to NULL, so that RB_FOREACH_REVERSE_FROM
doesn't visit any source filters in this case.

All of the above applies to the v6 case.

Approved by:    re (cperciva)
Reported by:    Daniel Birtwhistle
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation

    [3 lines not shown]
DeltaFile
+1-0sys/netinet6/in6_mcast.c
+1-0sys/netinet/in_mcast.c
+2-02 files

FreeBSD/src c4bca1fshare/examples/jails jail.xxx.conf jng

New version of jng (9.2)

Use jail.conf(5) $name in the jail.conf examples so the jail name
need only be set on the stanza. Keep host.hostname as xxx.yyy;
a jail name is not a DNS label. Leave the rc.conf excerpt as xxx.

Suggested by:   jlduran
MFC after:      1 week
Reviewed by:    kfv, jlduran
Differential Revision:  https://reviews.freebsd.org/D59032
DeltaFile
+14-14share/examples/jails/jng
+10-10share/examples/jails/jail.xxx.conf
+24-242 files

FreeBSD/src 0011cd9sys/dev/ice ice_lib.h ice_strings.c

ice(4): Support Total Port Shutdown on E830 devices

When 'Permit Total Port Shutdown' feature in BIOS is enabled then Port
Disable bit is set in the Link Default Override Mask TLV PFA module
in the NVM. In this mode, the driver acts as if the link_active_on_if_down
flag is always disabled and disallow any change to that flag.
This feature applies for E830 and E835 NIC series.

Signed-off-by: Pawel Sobczyk <pawel.sobczyk at intel.com>

Tested by:      Mateusz Moga <mateusz.moga at intel.com>
MFC after:      2 weeks
Sponsored by:   Intel Corporation
Differential Revision:  https://reviews.freebsd.org/D58149
DeltaFile
+10-5sys/dev/ice/ice_lib.c
+9-0sys/dev/ice/if_ice_iflib.c
+2-0sys/dev/ice/ice_strings.c
+1-0sys/dev/ice/ice_lib.h
+22-54 files

FreeBSD/src 81a67bfsys/dev/usb/wlan if_rsu.c

rsu: add a runtime TX buffer bound check for a kernel buffer overflow

The rsu driver currently relies on a `KASSERT` to prove that the mbuf payload
plus TX descriptor fits in the per-transfer USB TX buffer. On production
kernels without `INVARIANTS`, an oversized raw 802.11 frame can reach
`m_copydata()` and overwrite past that buffer, causing local kernel memory
corruption.

This suggested patch replaces the assertion-only guard with a runtime size
check before the copy. Oversized frames return `EMSGSIZE`, leaving the existing
caller cleanup paths responsible for freeing `m0`, `ni`, and the unused
transfer buffer.

Reachable via root / bpf access

Reviewed by:    bz, adrian
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D58898
DeltaFile
+3-1sys/dev/usb/wlan/if_rsu.c
+3-11 files

FreeBSD/src 7e9e72bsys/dev/usb/wlan if_mtwvar.h

mtw: fix zero-length queue array that can corrupt struct mtw_softc

The mtw softc declares sc_epq with MTW_BULK_RX even though MTW_BULK_RX is enum
value 0, while initialization and queue handling index up to MTW_EP_QUEUES;
attaching a matching USB WLAN device can drive writes past the absent array and
corrupt adjacent softc fields.

This suggested patch sizes sc_epq with MTW_EP_QUEUES so the softc contains the
endpoint queues the driver initializes and uses.

Fixes:          c14b01624261 ("mt7601U: Importing if_mtw from OpenBSD")
Reviewed by:    bz
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D58897
DeltaFile
+1-1sys/dev/usb/wlan/if_mtwvar.h
+1-11 files

FreeBSD/src f236685sys/sys sched.h

kern/sched: Hide scheduler selection from C++

The scheduler selection interface uses names that are reserved words in
C++, causing problems for downstream projects that use C++ in the
kernel.  Work around this by hiding the interface from C++ compilers
until we can come up with a better solution.

Fixes:          ce38acee8d0b ("Add kern/sched_shim.c")
MFC after:      1 week
Sponsored by:   Klara, Inc.
Sponsored by:   NetApp, Inc.
Reviewed by:    siderop1_netapp.com, imp, kib
Differential Revision:  https://reviews.freebsd.org/D58991
DeltaFile
+12-2sys/sys/sched.h
+12-21 files

FreeBSD/src 2ff0ca5lib/libc/gen Makefile.inc

uexterror(3): install the right manpage

Reported by:    Herbert J. Skuhra
DeltaFile
+1-1lib/libc/gen/Makefile.inc
+1-11 files

FreeBSD/src 94f86eftests/sys/kern exterr_test.c

uexterror_gettext: add tests for invalid formats

Verify that unsupported, unterminated, and overly long formats output
expected messages.

Reviewed by:    kib
Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Differential Revision:  https://reviews.freebsd.org/D58413
DeltaFile
+66-0tests/sys/kern/exterr_test.c
+66-01 files

FreeBSD/src ddf6065tests/sys/kern exterr_test.c

exterr(9): add a few tests of new message formats

This is enough to show that the idea works (and to exercise
uexterr_set()), but isn't complete by any means.

Reviewed by:    kib
Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Differential Revision:  https://reviews.freebsd.org/D58060
DeltaFile
+34-0tests/sys/kern/exterr_test.c
+34-01 files

FreeBSD/src 95e3309include uexterror.h, lib/libc/gen uexterr_gettext.c uexterr_init.c

runtime: add the ability to set exterrors in userspace

The UEXTERROR(3) macro is a partial analog to EXTERROR(9) that sets
the current user exterror state and errno.  The main difference is
that it returns no value and sets errno directly since that's the
typical pattern in libraries.

While here move the storage and constructor for single-threaded
program's uexterr to its own file.

Reviewed by:    kib
Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Differential Revision:  https://reviews.freebsd.org/D58059
DeltaFile
+135-0lib/libc/gen/uexterror.3
+65-0include/uexterror.h
+50-0lib/libc/gen/uexterr_set.c
+26-0lib/libc/gen/uexterr_init.c
+0-18lib/libc/gen/uexterr_gettext.c
+13-0lib/libthr/thread/thr_syscalls.c
+289-186 files not shown
+304-1912 files

FreeBSD/src 2f024a7lib/libc/gen uexterr_format.c, share/man/man9 exterror.9

exterr: relax format restrictions

Rather than passing the format string to printf and forcing the
arguments to be (u)intmax_t, partially parse format strings and cast
p1 and p2 to the correct type before running the individual format
though printf.  This restructure has a couple motivatations:
 - We can skip formats that make no sense (floating point, %n, etc.).
 - It is possible to special case the printing of pointers in the
   CHERI case.

The first case is motivated by a suggestion from the audiance at
one of Kirk's BSDCan talks on exterr to allow userspace to set exterr
status.  Allowing arbitrary format strings including %n creates a
write-what-where gadget so we need to not do that.

The second case is motivated by our experinces with CHERI and debugging
mmap issues using a different textual error reporting framework.  With
CHERI, pointers are more than integer addresses and it's useful to
include more details.  Doing so will follow in a future commit.

    [8 lines not shown]
DeltaFile
+165-2lib/libc/gen/uexterr_format.c
+10-7share/man/man9/exterror.9
+175-92 files

FreeBSD/src d58ca84tools/test/stress2/misc socketpair3.sh

Fix zombie leak in test using pdfork()
DeltaFile
+1-1tools/test/stress2/misc/socketpair3.sh
+1-11 files

FreeBSD/src 8eb77a5tools/test/stress2/misc all.exclude

stress2: Enable two hwpmc tests that now run as expected
DeltaFile
+0-2tools/test/stress2/misc/all.exclude
+0-21 files

FreeBSD/src 2296f35sys/fs/nullfs null_vnops.c

nullfs(4): Fix a typo in a source code comment

- s/modifing/modifying/

(cherry picked from commit 27c70deb3d260b48bee8f3c4c975fd2de64264fb)
DeltaFile
+1-1sys/fs/nullfs/null_vnops.c
+1-11 files

FreeBSD/src 10e3185sys/dev/ichwd i6300esbwd.c

ichwd(4): Fix a typo in a source code comment

- s/modifing/modifying/

(cherry picked from commit 8362aecdeb2548813942a7e604543c71f5a10271)
DeltaFile
+1-1sys/dev/ichwd/i6300esbwd.c
+1-11 files

FreeBSD/src 8402cf6sys/dev/fxp rcvbundl.h

fxp(4): Fix a typo in a source code comment

- s/modifing/modifying/

(cherry picked from commit c47b430c6ea3aa8d133af0af426d018bae3b7018)
DeltaFile
+1-1sys/dev/fxp/rcvbundl.h
+1-11 files

FreeBSD/src 05f4908sys/netpfil/ipfw dn_sched_fq_pie.c

ipfw(4): Fix a typo in a source code comment

- s/varaiables/variables/

(cherry picked from commit 251e6ef40203a6f911d7f4daacf3075de7f870c0)
DeltaFile
+1-1sys/netpfil/ipfw/dn_sched_fq_pie.c
+1-11 files

FreeBSD/src 06c3e7clib/msun/src catrig.c

msun: Fix a typo in a source code comment

- s/uneccessarily/unnecessarily/

Obtained from:  NetBSD

(cherry picked from commit cd4aae2fa9d35015248c445752e23800e75e8517)
DeltaFile
+1-1lib/msun/src/catrig.c
+1-11 files

FreeBSD/src 259c45dsys/vm swap_pager.c

swap_pager: Fix a typo in a source code comment

- s/errornous/erroneous/

(cherry picked from commit 88293bdd1eefb4bf518e1764d370b4a2321afdd1)
DeltaFile
+1-1sys/vm/swap_pager.c
+1-11 files

FreeBSD/src 1c4f2a6sys/dev/ppbus ppb_msq.h

ppbus(4): Fix a typo in a source code comment

- s/predifined/predefined/

(cherry picked from commit 709bd45a1b3a5ca21e05995c0c01f0ee8e7e8c38)
DeltaFile
+1-1sys/dev/ppbus/ppb_msq.h
+1-11 files

FreeBSD/src aeec956sys/fs/nullfs null_vnops.c

nullfs(4): Fix a typo in a source code comment

- s/modifing/modifying/

(cherry picked from commit 27c70deb3d260b48bee8f3c4c975fd2de64264fb)
DeltaFile
+1-1sys/fs/nullfs/null_vnops.c
+1-11 files