HardenedBSD/src c18015e — share/man/man4 mgb.4, sys/dev/nvme nvme_qpair.c

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/pledge
DeltaFile
+159-0sys/dev/rge/if_rge.c
+26-9sys/kern/subr_sglist.c
+20-11sys/dev/nvme/nvme_qpair.c
+4-2tests/sys/netpfil/pf/pfsync_upd_c.py
+3-1share/man/man4/mgb.4
+4-0sys/dev/rge/if_rge_sysctl.c
+216-235 files not shown
+225-2311 files

HardenedBSD/src 8575212 — share/man/man4 mgb.4, sys/dev/nvme nvme_qpair.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+159-0sys/dev/rge/if_rge.c
+26-9sys/kern/subr_sglist.c
+20-11sys/dev/nvme/nvme_qpair.c
+4-2tests/sys/netpfil/pf/pfsync_upd_c.py
+3-1share/man/man4/mgb.4
+4-0sys/dev/rge/if_rge_sysctl.c
+216-235 files not shown
+225-2311 files

HardenedBSD/src a9067a5 — sys/dev/rge if_rge.c

rge: Make the TX watchdog reset the chip

If the cable is pulled, and re-inserted, the driver does not
re-establish any connections, inet nor inet6. rge_init_locked() returns
too early when IFF_DRV_RUNNING is set, so the watchdog's reset doesn't
help, only a full ifconfig rge0 down/up is sufficient.

Clearing the flag & calling rge_init_locked() addresses this, but it
takes around 5 seconds to completely recover.

Reviewed by:    adrian
Differential Revision:  https://reviews.freebsd.org/D62221
DeltaFile
+6-0sys/dev/rge/if_rge.c
+6-01 files

HardenedBSD/src e3ded94 — sys/dev/rge if_rgevar.h if_rgereg.h

rge(4): Implement RTL8125 UDP hardware workaround

Directly quoting Kevin Lo <kevlo at openbsd.org>
"The RTL8125/RTL8125B parses short udp frames for ptp messages.
If a frame shorter than 175 bytes reads port 319 or 320 where the chip
expects the udp destination port and fewer than 47 bytes of udp data follow,
the transmitter stops for good."

Separately, the hw doesn't checksum frames shorter than 60 bytes
properly.

We get around both by padding and computing the checksums for these frames.

Both OpenBSD and Linux have implemented a similar workaround [1][2].

[1] https://marc.info/?l=openbsd-tech&m=179358733449818&w=2
[2] https://github.com/torvalds/linux/commit/8d520b4de3edca4f4fb242b5ddc659b6a9b9e65e

Signed-off-by: Aaron Espinoza <acesp25 at freebsd.org>

    [3 lines not shown]
DeltaFile
+153-0sys/dev/rge/if_rge.c
+4-0sys/dev/rge/if_rge_sysctl.c
+2-0sys/dev/rge/if_rgereg.h
+1-0sys/dev/rge/if_rgevar.h
+160-04 files

HardenedBSD/src 3719269 — sys/kern subr_sglist.c

sglist: Cosmetic cleanups to sglist_join

- Don't create an out-of-bounds pointer in flast.  Instead, use NULL
  for the case that first is empty for a more deterministic failure.

- Use a helper variable to de-duplicate an expression

Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D62005
DeltaFile
+8-3sys/kern/subr_sglist.c
+8-31 files

HardenedBSD/src 7b8f10e — sys/kern subr_sglist.c

sglist: Correct order of operands to bcopy in sglist_join

This was trashing the second list with uninitialized garbage from the
first list.

Reviewed by:    markj
Fixes:          b36cfff75df4 ("Add a simple API to manage scatter/gather...")
Differential Revision:  https://reviews.freebsd.org/D62004
DeltaFile
+1-1sys/kern/subr_sglist.c
+1-11 files

HardenedBSD/src a4ccfb2 — sys/kern subr_sglist.c

sglist: Avoid an out-of-bounds access in sglist_append_sglist

If the destination sglist is empty, then the first matching segment
from the source sglist should be added as the first segment in the
destination list.  This happened to work by accident when sg_nseg was
a u_short as ss pointed to the sglist header which never had a
matching paddr so _sglist_append_range fell through to appending a new
range, but that was still buggy.  After sg_nseg changed to an unsigned
int, the initial ss now points way out of range on 64-bit platforms
resulting in reading from a random (possibly unmapped) kernel address.

Reported by:    llm-postcr
Reviewed by:    markj
Fixes:          00f6cd3f5682 ("Add sglist_append_sglist().")
Differential Revision:  https://reviews.freebsd.org/D62003
DeltaFile
+17-5sys/kern/subr_sglist.c
+17-51 files

HardenedBSD/src efda129 — tests/sys/netpfil/pf pfsync_upd_c.py

tests/pfsync_upd_c: only import necessary scapy modules

This test currently fails in Jenkins CI[0] because the runner
does not have an /etc/resolv.conf file while scapy expects one[1].

Instead, avoid the full scapy.all import path (which calls
read_nameservers(...)) and only import the modules we need.

[0] https://ci.freebsd.org/job/FreeBSD-main-amd64-test/30046/testReport/sys.netpfil.pf/pfsync/stale_upd_c/
[1] https://github.com/secdev/scapy/blob/123e241/scapy/arch/common.py#L176

Fixes:          4a97b40891f0 ("pfsync: don't apply a stale dst peer...")
MFC after:      3 days
Reviewed by:    ngie
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D62141
DeltaFile
+4-2tests/sys/netpfil/pf/pfsync_upd_c.py
+4-21 files

HardenedBSD/src 0b2cc30 — share/man/man4 mgb.4, sys/dev/mgb if_mgb.h if_mgb.c

mgb: Add PCI11010 support

The Microchip PCI11010 is a PCIe switch with embedded multi-Gigabit
Ethernet controller.  Only a new PCI ID is needed, as commit
da8a529bc01f ("mgb: support for PCI11414.") added required new
functionality.

Reviewed by:    br
Sponsored by:   The FreeBSD Foundation
Sponsored by:   Microchip (hardware)
Differential Revision: https://reviews.freebsd.org/D62208
DeltaFile
+3-1share/man/man4/mgb.4
+3-0sys/dev/mgb/if_mgb.c
+1-0sys/dev/mgb/if_mgb.h
+7-13 files

HardenedBSD/src cd6143b — sys/dev/nvme nvme_private.h nvme_qpair.c

nvme: do not submit Abort commands with the qpair lock held

The Abort for a timed-out admin command is submitted to the queue
whose lock the watchdog holds. For an I/O command, a failed admin
queue completes the Abort during submission, and nvme_abort_complete()
takes the I/O takes the I/O qpair lock again.
Either way the thread recurses on a non-recursive mutex.

Abort command: NVM Express Base Specification 2.4, section 5.2.1.

Fixes:  2a6b7055a980 ("nvme: Timeout expired transactions")

Reviewed by:    rz_fabmicro.ru, ngie
Differential Revision:  https://reviews.freebsd.org/D61625
DeltaFile
+20-11sys/dev/nvme/nvme_qpair.c
+2-0sys/dev/nvme/nvme_private.h
+22-112 files

HardenedBSD/src 3a0b944 — sys/dev/cpufreq cpufreq_dt.c, sys/kern subr_unit.c

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/pledge
DeltaFile
+73-0tests/sys/netpfil/pf/ioctl/validation.c
+55-8sys/kern/subr_unit.c
+23-5sys/dev/cpufreq/cpufreq_dt.c
+9-8sys/netpfil/pf/if_pfsync.c
+8-4sys/netpfil/pf/pf_ioctl.c
+3-3sys/netpfil/ipfw/ip_dn_io.c
+171-286 files

HardenedBSD/src 5308e2a — sys/dev/cpufreq cpufreq_dt.c, sys/kern subr_unit.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+73-0tests/sys/netpfil/pf/ioctl/validation.c
+55-8sys/kern/subr_unit.c
+23-5sys/dev/cpufreq/cpufreq_dt.c
+9-8sys/netpfil/pf/if_pfsync.c
+8-4sys/netpfil/pf/pf_ioctl.c
+3-3sys/netpfil/ipfw/ip_dn_io.c
+171-286 files

HardenedBSD/src 3d35051 — sys/kern subr_unit.c

unr(9): fix iterator with trivial unit allocations

Hoist the check that we've scanned all the unrs to the top of the
loop since none might have been allocated e.g., if we've only used
allocated units in order with alloc_unr() and never freed any.

Add a test of the trivial case.

Reviewed by:    kib, markj
Sponsored by:   Innovate UK
Fixes:          a014e0a3987a ("unr(9): add iterator interface")
Differential Revision:  https://reviews.freebsd.org/D62139
DeltaFile
+55-8sys/kern/subr_unit.c
+55-81 files

HardenedBSD/src cec3503 — sys/netpfil/ipfw ip_dn_io.c

dummynet: mark sysctls as CTLFLAG_VNET

sysctl_hash_size() and sysctl_limits() read and write V_dn_cfg, the current
VNET's dummynet configuration, but their sysctls lack CTLFLAG_VNET, so a VNET
jail reads its own values (100 slots, 64 buckets) and cannot set them: a queue
longer than 100 packets cannot be configured in a jail, and the host's setting

Reviewed by:    kp
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+3-3sys/netpfil/ipfw/ip_dn_io.c
+3-31 files

HardenedBSD/src b65057a — sys/netpfil/pf pf_ioctl.c, tests/sys/netpfil/pf/ioctl validation.c

pf: fix error handling in pf_ioctl_addrule()

If we bail out of pf_ioctl_addrule() before the pf_addr_setup() calls
the subsequent pf_free_rule() will end up dereferencing a NULL pointer.

Check for NULL before freeing dynaddr or tables.

PR:             301184
Submitted by:   laamalif at proton.me
Reviewed by:    kp
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+73-0tests/sys/netpfil/pf/ioctl/validation.c
+8-4sys/netpfil/pf/pf_ioctl.c
+81-42 files

HardenedBSD/src f3cb62f — sys/netpfil/pf if_pfsync.c

pfsync: account for second tickover in bulk updates

When one peer requests a bulk update it keeps track of when it sent this
request. The exporting peer includes 'endtime', indicating how long it
took to send the entire update along with its final message.

That allows the receiving peer to verify that the entire update was done
in response to its most recent request. However, due to different second
tickovers this calculation might be off by one.

Use milliseconds internally. This does not change the wire protocol,
'endtime' is still expressed in seconds. When the exporting peer
computes this value it will implicitly round down.

PR:             300824
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+9-8sys/netpfil/pf/if_pfsync.c
+9-81 files

HardenedBSD/src 34b0e01 — sys/dev/cpufreq cpufreq_dt.c

cpufreq_dt: Do not use an uninitialised OPP when restoring the state

cpufreq_dt_set() only looks up the current OPP (copp) when the voltage
cannot be read from the regulator.  When it can, which is the usual
case, copp is never set but the two error paths that restore the
previous state still use it: a failure to set the clock reads the
voltage limits of copp and a failure to lower the voltage reads its
frequency.

Restore the frequency with the one that was read from the clock before
the change, and look up the current OPP when the voltage has to be
restored, skipping it if there is none.

Fixes:  a701764e9c50 ("Improve cpufreq_dt.")
Reported by:    llm-postcr
DeltaFile
+9-3sys/dev/cpufreq/cpufreq_dt.c
+9-31 files

HardenedBSD/src c54c8a5 — sys/dev/cpufreq cpufreq_dt.c

cpufreq_dt: Use all the OPPs when the hardware version is unknown

An OPP with opp-supported-hw is only used if the hardware version, given
by the vendor specific code, matches it.  When no vendor class handles
the OPP table, for example the ones of the TI and i.MX SoCs, the version
is unknown, so every OPP that has the property was dropped and the table
ended up empty.  The driver still attached and cpufreq_dt_find_opp()
returned a pointer to an entry that does not exist, using an
uninitialised index.

Use all the OPPs when the hardware version is unknown, as if the
property was not there, which is what the driver did before the
property was honored.  Also make cpufreq_dt_find_opp() return NULL for
an empty table, as its callers already expect.

Fixes:  7178a47a4ffd ("cpufreq_dt: Honor opp-supported-hw and opp-microvolt-<name>")
Reported by:    llm-postcr
DeltaFile
+14-2sys/dev/cpufreq/cpufreq_dt.c
+14-21 files

HardenedBSD/src 1f7a458 — sys/amd64/amd64 fpu.c, sys/dev/rtwn/rtl8192f r92f_calib.c

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/pledge
DeltaFile
+5-8sys/dev/rtwn/rtl8192f/r92f_calib.c
+11-2sys/amd64/amd64/fpu.c
+6-6sys/ofed/drivers/infiniband/ulp/nfsclrdma/xprt_verbs.c
+2-5sys/ofed/drivers/infiniband/ulp/nfsclrdma/clnt_rdma.c
+24-214 files

HardenedBSD/src 59418eb — sys/amd64/amd64 fpu.c, sys/dev/rtwn/rtl8192f r92f_calib.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+5-8sys/dev/rtwn/rtl8192f/r92f_calib.c
+11-2sys/amd64/amd64/fpu.c
+6-6sys/ofed/drivers/infiniband/ulp/nfsclrdma/xprt_verbs.c
+2-5sys/ofed/drivers/infiniband/ulp/nfsclrdma/clnt_rdma.c
+24-214 files

HardenedBSD/src 3343e51 — sys/dev/rtwn/rtl8192f r92f_calib.c

rtwn: fix the build without RTWN_DEBUG

RTWN_DPRINTF() compiles to nothing without RTWN_DEBUG, which leaves four
of the IQK result copies in r92f_iq_calib() set but never read.  Kernels
with "device rtwn" in their config, LINT among them, then fail with
-Werror,-Wunused-but-set-variable.  The module build does not hit this
because its generated opt_rtwn.h always defines RTWN_DEBUG.

Print the result array directly and drop the four locals.

Fixes:          1f0e186e1832 ("rtwn: added support for Realtek RTL8192FU...")
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+5-8sys/dev/rtwn/rtl8192f/r92f_calib.c
+5-81 files

HardenedBSD/src 8a8a527 — sys/amd64/amd64 fpu.c

amd64: Avoid redundant CR0 writes on switches to kernel threads

fpu_activate_sw() sets CR0.TS whenever it switches to a kernel thread,
or to a thread inside fpu_kern_enter().  The bit is clear only while a
thread owns the FPU, and at a context switch the only possible owner is
the old thread.  When fpcurthread is NULL the bit is already set and
the write to CR0, which is serializing, changes nothing.  That is the
common case for switches between kernel threads, such as the idle
thread and interrupt threads on a router.

Write CR0 only when fpcurthread was set, as cpu_switch() did before
the eager FPU switch became the default in d1a07e31e5cc, and assert
that TS is set otherwise.

Reviewed by:            kib
MFC after:              1 week
Sponsored by:           Rubicon Communications, LLC ("Netgate")
Differential Revision:  https://reviews.freebsd.org/D62206
DeltaFile
+11-2sys/amd64/amd64/fpu.c
+11-21 files

HardenedBSD/src b75ceca — sys/ofed/drivers/infiniband/ulp/nfsclrdma clnt_rdma.c xprt_verbs.c

nfsclrdma: Fix a few things in the RDMA client module

This patch fixes a few things in the nfsclrdma module:
- A typo that caused _rpcrdma_get_srcaddr() to return 0
  when it should have returned 1.
- Don't consider a server returning RPC_SYSTEMERROR or
  RPC_FAILED as needing a new connection, to be compatible
  with clnt_vc.c for TCP.
- Fix off by one checks in the KASSERT()s for the RPC index.

Reported by:    llm-postcr
MFC after:      1 month
Fixes:  80bee4d83637 ("nfsclrdma: Add code to support client side NFS over RDMA")
DeltaFile
+6-6sys/ofed/drivers/infiniband/ulp/nfsclrdma/xprt_verbs.c
+2-5sys/ofed/drivers/infiniband/ulp/nfsclrdma/clnt_rdma.c
+8-112 files

HardenedBSD/src c5986e6 — sys/contrib/dev/rtwn rtwn-rtl8192fufw.fw.uu, sys/dev/rtwn/rtl8192f r92f_calib.c

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/pledge
DeltaFile
+8,751-0sys/powerpc/linux/linux_systrace_args.c
+2,209-0sys/powerpc/linux/syscalls.master
+2,095-0sys/powerpc/linux/linux_proto.h
+1,087-0sys/dev/rtwn/rtl8192f/r92f_calib.c
+848-0sys/powerpc/linux/linux_sysvec.c
+695-0sys/contrib/dev/rtwn/rtwn-rtl8192fufw.fw.uu
+15,685-078 files not shown
+21,364-6184 files

HardenedBSD/src 74fb2f4 — sys/contrib/dev/rtwn rtwn-rtl8192fufw.fw.uu, sys/dev/rtwn/rtl8192f r92f_calib.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+8,751-0sys/powerpc/linux/linux_systrace_args.c
+2,209-0sys/powerpc/linux/syscalls.master
+2,095-0sys/powerpc/linux/linux_proto.h
+1,087-0sys/dev/rtwn/rtl8192f/r92f_calib.c
+848-0sys/powerpc/linux/linux_sysvec.c
+695-0sys/contrib/dev/rtwn/rtwn-rtl8192fufw.fw.uu
+15,685-078 files not shown
+21,364-6184 files

HardenedBSD/src 86d2198 —

Merge branch 'freebsd/15-stable/main' into hardened/15-stable/main
DeltaFile
+0-00 files

HardenedBSD/src 493c847 — etc/mtree BSD.tests.dist, lib/libsys Makefile

libsys: add test checking that -lsys alone is linkable

Reviewed by:    jrtc27 (previous version)
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D62131
DeltaFile
+25-0lib/libsys/tests/Makefile
+24-0lib/libsys/tests/hermetic_test.sh
+18-0lib/libsys/tests/hermetic.c
+3-0lib/libsys/Makefile
+2-0etc/mtree/BSD.tests.dist
+72-05 files

HardenedBSD/src d64d2be — lib/libsys Makefile

libsys: do not link in csu, and compile as freestanding

This is a library below implementation of the C runtime.  It should not
(and really cannot) use any of that.

In particular, libsys no longer has undef __cxa_finalize.

Reviewed by:    brooks, jrtc27
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D62131
DeltaFile
+3-0lib/libsys/Makefile
+3-01 files

HardenedBSD/src 98a7f08 — lib/libsys Makefile

libsys: this is libsys, not libc

Reviewed by:    brooks, jrtc27
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D62131
DeltaFile
+1-1lib/libsys/Makefile
+1-11 files

HardenedBSD/src 0425a73 — lib/libsys Makefile

libsys: link internal copies of fls*(3), str*(3), and mem*(3) functions used by libsys

To avoid undef symbols which get resolved from libc.

Reviewed by:    brooks, jrtc27
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D62131
DeltaFile
+10-1lib/libsys/Makefile
+10-11 files