HardenedBSD/src 5a9b97d — libexec/tftpd tftpd.c tftp-utils.c, sys/dev/irdma irdma_utils.c irdma_cm.c

Merge branch 'freebsd/15-stable/main' into hardened/15-stable/main
DeltaFile
+14-15libexec/tftpd/tftp-options.c
+20-2sys/dev/irdma/irdma_cm.c
+7-8libexec/tftpd/tftp-utils.c
+7-6libexec/tftpd/tftpd.c
+13-0sys/dev/irdma/irdma_utils.c
+10-1sys/netinet/tcp_output.c
+71-324 files not shown
+76-3910 files

HardenedBSD/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

HardenedBSD/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

HardenedBSD/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

HardenedBSD/src c9ba3eb — sys/kern kern_module.c

HBSD: Resolve merge conflict

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
DeltaFile
+4-23sys/kern/kern_module.c
+4-231 files

HardenedBSD/src f513d48 — sys/crypto/openssl/aarch64 sm4-armv8.S vpsm4_ex-armv8.S, sys/crypto/openssl/i386 rc5-586.S cast-586.S

Merge remote-tracking branch 'rad/freebsd/15-stable/main' into hardened/15-stable/main

Conflicts:
        sys/kern/kern_module.c (unresolved)
DeltaFile
+0-5,021sys/crypto/openssl/aarch64/vpsm4-armv8.S
+0-4,543sys/crypto/openssl/aarch64/vpsm4_ex-armv8.S
+0-2,002sys/crypto/openssl/i386/cast-586.S
+0-1,264sys/crypto/openssl/i386/rc5-586.S
+0-1,093sys/crypto/openssl/aarch64/sm4-armv8.S
+0-988sys/crypto/openssl/powerpc/aes-gcm-ppc.S
+0-14,91118 files not shown
+738-16,46624 files

HardenedBSD/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

HardenedBSD/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

HardenedBSD/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

HardenedBSD/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

HardenedBSD/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

HardenedBSD/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

HardenedBSD/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

HardenedBSD/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

HardenedBSD/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

HardenedBSD/src 755ab53 — sys/dev/irdma irdma_utils.c irdma_cm.c

irdma: improve TCP header validation

iWARP handling code deals with TCP header processing outside of the normal TCP stack.
Add validation checks to verify the internal integrity of the TCP headers.

Reviewed By: tuexen, O11 Intel Networking group, #transport, bartosz.sobczak_intel.com
Sponsored by: NetApp, Inc.
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D58323

(cherry picked from commit e0c6b88706a9fff9e4090803ba2338dd0ce97eba)
DeltaFile
+20-2sys/dev/irdma/irdma_cm.c
+13-0sys/dev/irdma/irdma_utils.c
+33-22 files

HardenedBSD/src 5874698 — . Makefile.inc1

pkgbase: build the rwhich database repository

Reviewed by:    ivy, bdrewery, lwhsu
Differential Revision:  https://reviews.freebsd.org/D60440
DeltaFile
+1-0Makefile.inc1
+1-01 files

HardenedBSD/src f5797fc — 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.

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

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

HardenedBSD/src 46ce9ac — usr.bin/elfctl elfctl.1 elfctl.c

elfctl: add la52 for powerpc64

The 0x40 feature bit is la57 on amd64 and la52 on powerpc64. Tag each
feature with the machine it belongs to and only accept and show the
names that match the file's e_machine, so la57 is only known for amd64
files and la52 only for powerpc64 ones.

Reviewed by:    kib
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D61331
DeltaFile
+31-15usr.bin/elfctl/elfctl.c
+12-1usr.bin/elfctl/elfctl.1
+43-162 files

HardenedBSD/src 5f29566 — share/man/man7 arch.7, sys/powerpc/include proc.h procctl.h

powerpc64: give processes a 48-bit address space by default

Since ASLR got enabled for ELFv2, the random bases for the heap, the
dynamic linker and PIE binaries can land anywhere in the 52-bit address
space radix gives us. A lot of userland doesn't like that: SpiderMonkey,
JavaScriptCore, QV4 and friends pack pointers into 47 or 48 bits and
crash on startup (gjs, cjs, qml, ...).

Do what amd64 does on LA57 hardware: keep the full range in the kernel
and give processes a smaller map by default through a second set of
sysvecs. The default is 48 bits (256 TiB), the same as arm64.

One caveat for 48 bits: SpiderMonkey's GC allocator has no fallback
there and relies on mmap(2) hints staying 1 MiB-aligned, which ASLR on
FreeBSD breaks (hinted mappings move in 4 KiB steps, 64 KiB on arm64).
The versions in ports need Mozilla's bug 1876632 (MAP_ALIGNED on
FreeBSD, in Firefox 143) to be reliable; with it gjs runs clean.

The full 52 bits stay available per process through the la52 feature

    [8 lines not shown]
DeltaFile
+201-28sys/powerpc/powerpc/elf64_machdep.c
+85-3sys/powerpc/powerpc/vm_machdep.c
+20-5share/man/man7/arch.7
+22-3sys/powerpc/include/vmparam.h
+21-0sys/powerpc/include/procctl.h
+4-4sys/powerpc/include/proc.h
+353-432 files not shown
+359-468 files

HardenedBSD/src a637aa1 — usr.bin/proccontrol proccontrol.1 proccontrol.c

proccontrol: support la52 on powerpc64

powerpc64 is getting the same PROC_LA_CTL interface as amd64, but calls
the full address space la52 instead of la57. Take the mode name and the
constants from whichever one machine/procctl.h defines.

Reviewed by:    kib
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D61331
DeltaFile
+27-11usr.bin/proccontrol/proccontrol.c
+6-3usr.bin/proccontrol/proccontrol.1
+33-142 files

HardenedBSD/src 0bf5d86 — lib/libc/stdio printf-pos.c, lib/libc/tests/stdio swprintf_test.c snprintf_test.c

stdio: Fix error case for positional %wN / %wfN

In the case were N was not a valid bit width, we were taking the wrong
error path.

Fixes:          5e809bf1c93f ("stdio: Fix positional %wN / %wfN conversion")
DeltaFile
+2-2lib/libc/stdio/printf-pos.c
+2-0lib/libc/tests/stdio/swprintf_test.c
+2-0lib/libc/tests/stdio/snprintf_test.c
+6-23 files

HardenedBSD/src 8b508c9 — lib/msun/man iseqsig.3, lib/msun/src s_iseqsigl.c s_iseqsigf.c

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/pledge
DeltaFile
+191-0lib/msun/tests/iseqsig_test.c
+56-0lib/msun/man/iseqsig.3
+36-0lib/msun/src/math.h
+23-0lib/msun/src/s_iseqsig.c
+18-0lib/msun/src/s_iseqsigl.c
+18-0lib/msun/src/s_iseqsigf.c
+342-010 files not shown
+367-1616 files

HardenedBSD/src 70bd46e — lib/msun/man iseqsig.3, lib/msun/src s_iseqsigl.c s_iseqsigf.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+191-0lib/msun/tests/iseqsig_test.c
+56-0lib/msun/man/iseqsig.3
+36-0lib/msun/src/math.h
+23-0lib/msun/src/s_iseqsig.c
+18-0lib/msun/src/s_iseqsigl.c
+18-0lib/msun/src/s_iseqsigf.c
+342-010 files not shown
+367-1616 files

HardenedBSD/src 563c2f2 — sys/dev/sound/pci emu10k1.c cmi.c

sound: Remove stale midi module dependencies

midi(4) stopped being a module in 45bb10e0ed5a ("sound: Stop building
midi as a module"), so snd_cmi(4) and snd_emu10k1(4) fail to load
because they still depend on it.

Fixes:          45bb10e0ed5a ("sound: Stop building midi as a module")
Sponsored by:   The FreeBSD Foundation
MFC after:      1 day
DeltaFile
+0-1sys/dev/sound/pci/emu10k1.c
+0-1sys/dev/sound/pci/cmi.c
+0-22 files

HardenedBSD/src c8341e6 — lib/msun/man iseqsig.3, lib/msun/src s_iseqsigf.c s_iseqsigl.c

libm: Implement iseqsig()

C23 adds iseqsig(), the signaling counterpart of ==, which
raises FE_INVALID on any NaN rather than only on signaling
ones (as per §7.12.17.7).  The helpers raise it explicitly
instead of relying on relational operators, which the
compiler may emit as quiet comparisons, and the macro
dispatches on float_t so that wider-evaluated arguments
are not narrowed (§F.10.14.1).

Reviewed by:    kargl, fuz
Approved by:    fuz (mentor)
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D60642
DeltaFile
+191-0lib/msun/tests/iseqsig_test.c
+56-0lib/msun/man/iseqsig.3
+36-0lib/msun/src/math.h
+23-0lib/msun/src/s_iseqsig.c
+18-0lib/msun/src/s_iseqsigf.c
+18-0lib/msun/src/s_iseqsigl.c
+342-05 files not shown
+355-311 files

HardenedBSD/src 044b90b — 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

HardenedBSD/src ed8dc5e — 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

HardenedBSD/src 4a9770b — 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

HardenedBSD/src 0967b36 — 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