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)
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]
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)
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)
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
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
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]
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")
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
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
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)
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)
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)
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)
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)
swapoff: release vnode held since swapon
kern_swapon looks up the proposed swap path and aquires a vnode which is
held (unlocked) throughout the life of the swap device. In the device
case (swapgeom) it was never released in the swapoff path.
Remove an incorrect comment about swapgeom_close being called from
biodone. It is only called directly via swapoff(2) or at the end of the
shutdown path.
Reviewed by: kib, markj
Reported by: llm-postcr
MFC after: 3 days
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D61465
top: fix off-by-one in screenbuf
There is a heap overflow for screenbuf originating from
the top import to the tree. The i_process()/u_process() functions
write a terminating NUL one byte past each screenbuf line slot
when the line fills the slot, which is a 1-byte heap overflow on the last slot.
The display_resize() function allocates screen_width bytes per line.
i_process() and u_process() cut lines to screen_width characters and
then stpcpy() them into the slot, which writes screen_width + 1 bytes.
line_update() can do the same with *old = ch. For inner slots,
the NUL lands in byte 0 of the next slot. This can corrupt the saved
contents used when updating the next line. For the last slot, it writes
one byte past the end of screenbuf.
Fix by allocating (screen_width + 1) bytes per line and updating the
line offsets to fit the terminating NUL.
Reviewed by: kib
[3 lines not shown]
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
[11 lines not shown]
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
[11 lines not shown]
sched_ule: Fix two typos in comments introduced in previous commit
Reported by: kib
Fixes: 538c48bf6247 ("sched_ule: Fix rare deadlock on stealing a migrated lock-blocked thread")
Sponsored by: The FreeBSD Foundation
openssl: build legacy provider as upstream does
- Build with libcrypto's compile flags: modules/Makefile.inc now
includes libcrypto's Makefile.inc, which brings in Makefile.common
(NDEBUG, the asm dispatch defines, OPENSSL_PIC, the directory
defines). Before this change, assertions were enabled in legacy.so.
- Use upstream's per-architecture source list: the provider's own CPU
capability code (cpuid asm and armcap.c/ppccap.c, or mem_clr.c
without asm), and the MD5, RC4 and DES asm where upstream uses it.
The provider no longer uses libcrypto's exported RC4, SHA1 and
CRYPTO_*128 functions.
- Drop the objects that upstream's linker leaves out of legacy.so
(fcrypt_b.c, md5_one.c, md5_sha1.c, provider_err.c and
ciphercommon_{ccm,gcm}*.c / ciphercommon_hw.c). Without them,
params_idx.c is not needed either.
- Add a version script, a copy of upstream's providers/legacy.ld, so
that only OSSL_provider_init is exported. Around 209 symbols were
exported before.
[5 lines not shown]
openssl: fix engine defines to match upstream
Two engine Makefiles define different macros from upstream's
engines/build.info:
- padlock: engines/e_padlock.c builds the engine only when PADLOCK_ASM
is defined. Upstream defines it on x86 and x86_64, but our Makefile
never did, so padlock.so has been a stub whose bind_engine() returns
0 and the e_padlock-x86*.S code it links was never called. Define
PADLOCK_ASM on amd64 and i386, where that asm is built.
- loader_attic: upstream defines OPENSSL_NO_PROVIDER_CODE; the Makefile
had OPENSSL_NO_PROVIDER_CORE. No source tests either name, so the
build does not change; this only follows upstream.
Found by comparing per-file compile flags against an upstream 3.5.9
build. Checked by preprocessing e_padlock.c for amd64 and i386:
COMPILE_PADLOCKENG is now defined.
[5 lines not shown]
openssl: export only the engine entry points
Upstream links every dynamic engine with a version script,
engines/<name>.ld, that exports bind_engine and v_check and makes
everything else local. FreeBSD's engines had no version script, so
they exported every global symbol, including _init and _fini.
loader_attic.so compiles its own copy of crypto/pem/pvkfmt.c and so
also exported 21 of its functions; 14 of them (b2i_*, i2b_*) have the
same names as public libcrypto functions.
Add one Version.map for all engines, the same as upstream's, and use it
from engines/Makefile.inc.
The engines are loaded only with dlopen(), and libcrypto looks up only
bind_engine and v_check, so hiding the other symbols does not affect
any consumer.
Tested via tinderbox: capi.so, devcrypto.so and loader_attic.so link
with --no-undefined-version and export only bind_engine and v_check.
[8 lines not shown]
openssl: stop generating asm that nothing builds
Makefile.asm generated eight perlasm outputs that neither libcrypto nor
the kernel builds. Additionally, upstream does not build them for these
architectures with FreeBSD's configuration:
- aarch64: ecp_sm2p256-armv8, sm3-armv8, sm4-armv8, vpsm4-armv8 and
vpsm4_ex-armv8. SM2, SM3 and SM4 are disabled (disable-sm2/sm3/sm4).
- i386: cast-586 (upstream's x86 configuration uses the C CAST code)
and rc5-586 (RC5 is disabled by default).
- powerpc: aes-gcm-ppc. Upstream builds it only for 64-bit
little-endian; libcrypto and ossl(4) use it only on powerpc64 and
powerpc64le, whose copies stay.
Remove them from Makefile.asm and delete the generated files, so the
next vendor import does not regenerate them. If one of these algorithms
is ever enabled, add its script back to Makefile.asm and run "make
buildasm".
[10 lines not shown]
openssl: restore removed libcrypto symbols as compat symbols
c01c0a27cb82 (D60397) stopped exporting 52 names from libcrypto.so.35 that
upstream does not export. Binaries and libraries linked against the
earlier libcrypto.so.35 can still import them; the libssl.so.35 from
15.0 and 15.1 imports 15 of them, so it fails to load with the new
libcrypto.
Provide all 52 again as non-default (compat) versions, in the version
nodes they had before: OPENSSL_cpuid_setup at OPENSSL_3_0_9, the others
@OPENSSL_3_5_0. Existing consumers resolve them; new links cannot bind
to them. The default exports do not change and still match upstream.
The wrappers live in a new FreeBSD-only file, compat.c. Remove it at
the next SHLIB_MAJOR bump.
Reviewed by: ngie
Fixes: c01c0a27cb82 ("openssl: make libcrypto export the same symbols as upstream")
Event: FreeBSD Vendor Summit 2026
[3 lines not shown]
openssl: make libcrypto export the same symbols as upstream
Make the libcrypto Version.map export the same symbol names as upstream
3.5.8 (and 3.5.9, no new symbols were added).
Remove 52 names that upstream does not export:
- the internal threading and record layer functions (ossl_crypto_*,
ssl3_cbc_*, tls1_cbc_*), which only libssl used;
- the internal WPACKET_quic_* functions;
- OPENSSL_cpuid_setup;
- ASN.1 item functions that are not in util/libcrypto.num.
Add 7 public names that were missing (ASYNC_get_mem_functions,
ASYNC_set_mem_functions, CMS_EnvelopedData_it, EVP_CipherPipeline*) to
OPENSSL_3_5_0, where the other symbols from upstream 3.1 to 3.5 are.
EC_GFp_nistp224_method, EC_GFp_nistp256_method and
EC_GFp_nistp521_method stay unexported (see 6f6446b33064).
[10 lines not shown]
uefisign: use ASN1_STRING_set0() instead of ASN1_STRING_set()
Prepare for future OpenSSL API changes.
OpenSSL 4.1 deprecates ASN1_STRING_set. Move to ASN1_STRING_set0 which
requires the DER buffer to be allocated with OPENSSL_zalloc so ownership
can be assumed by the string.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D61532