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
tcp/rack: reject wma_divisor values <= 0
The net.inet.tcp.rack.measure.wma_divisor sysctl is the divisor
of the goodput weighted moving average used when the dynamic
goodput multiplier is enabled. Setting it to 0 panics the kernel.
Make the variable and the sysctl unsigned, reject 0 and values
above INT32_MAX.
MFC after: 1 month
Found with: Claude Code Opus 5.5
Reviewed by: tuexen, glebius, markj (early version)
Differential Revision: https://reviews.freebsd.org/D60759
(cherry picked from commit 7668705cb9837d4c3a6db9b3434b3a522220c8ea)
Merge commit 72a20b8e2987 from llvm git (by Gabriel Baraldi):
[SLPVectorizer] Check std::optional coming out of getPointersDiff (#175784)
Fixes https://github.com/llvm/llvm-project/issues/175768
There are other unchecked uses std::optional in this pass but I couldn't
figure out a test that triggers them
This fixes a clang crash in the SLP vectorizer, hit when building
audio/csound on powerpc64le. The hardened libc++ traps on the disengaged
optional, so clang dies with exit code 133. The second hunk is adapted to
llvm 21, where analyzeConstantStrideCandidate() is still isStridedLoad().
Approved by: re (cperciva)
Reviewed by: dim
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D61354
[2 lines not shown]
mps(4): add support for hostboot
If the mps/mpr(4) device has corrupted or missing firmware then
it will fail to attach.
Add an interface to use firmware(9) to load the firmware at boot.
Loosely based on https://github.com/marcan/lsirec/
Assisted-by: Claude Code (Opus 5)
Reviewed by: imp
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D59854
nuageinit: Skip ssh keys if default user adduser fails
Commit d9fa6016011e ("nuageinit; Skip SSH keys and doas/sudo if adduser
fails") handled nil return from a failing adduser when adding secondary
users, but the same issue also existed in the default user handling.
Reported by: llm-postcr
Reviewed by: dtxdf
Supported by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61511
tcp bbr: improve handling of retransmissions in LAST-ACK
When performing a timer based retransmission, clear the
BBR_RWND_COLLAPSED flag. If it sticks, t_rxtshift is never incremented
resulting in unlimited retransmissions in the LAST-ACK state.
Reported by: Illia Vynohradov
Reviewed by: Peter Lei
MFC after: 3 days
MFC to: stable/15
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61586
asmc: make asmc_sysctl_add_system() void
Its only caller already discarded the return value with (void). Match
the other sysctl subtree builders.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D61537
asmc: do not report absent sensors as a temperature
A key can exist for a sensor the model was never built with; the SMC
answers those with a fixed sentinel instead of an error. Return ENXIO
for the sentinel instead of publishing it as a reading.
MFC after: 3 days
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D61489
asmc: report temperatures in deciKelvin
The handler returned the raw key's high byte, dropping the sign and
fraction of the sp78 encoding, and published -1 on a failed read.
Read through asmc_sensor_read() instead, convert to deciKelvin, and
register the leaves as "IK". Changes the unit of dev.asmc.N.temp.*.
MFC after: 3 days
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D61487
asmc.4: fix the unterminated SYNOPSIS and FILES blocks
The SYNOPSIS .Bd and the FILES .Bl were both left open, producing two
mandoc block-nesting errors. Reduce SYNOPSIS to the .Cd line man4
style calls for, and close the FILES list.
MFC after: 3 days
Reviewed by: ziaee, ngie
Differential Revision: https://reviews.freebsd.org/D61486
asmc: propagate sysctl read and write errors
Several handlers discarded the key transport's result: fan speed, SMS
and ambient light handlers published a value regardless of read
success; a rejected fan speed or keyboard backlight write reported success;
fan id returned EPERM on an unreadable key instead of ENXIO.
asmc_fan_getvalue()/asmc_fan_setvalue() now return the error and pass
the speed out by reference instead of returning -1 for failure.
MFC after: 3 days
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D61485
asmc: register the fan id sysctl with a string format
Every fan sysctl was registered with a hardcoded "I" format, but id
is CTLTYPE_STRING. Carry the format in the table instead.
MFC after: 3 days
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D61484
asmc: clear the sensor counts in detach
The key arrays are freed but the counts were left set, leaving the
softc describing freed memory. Reachable via the attach error path,
which calls detach directly.
MFC after: 3 days
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D61483
asmc: do not drop shutdown notification when the system node fails
asmc_attach() registered the MBSS shutdown-cause handler
(EVENTHANDLER_REGISTER(shutdown_pre_sync, asmc_shutdown, ...))
after attempting to add the dev.asmc.N.system sysctl subtree. If that
subtree registration failed, the error path took goto nosms, jumping clean
over the shutdown-handler registration. On T2 Macs this silently drops
the only thing standing between a clean shutdown and bridgeOS's
watchdog power-cycling the machine.
MFC after: 3 days
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D61482
asmc: remove the unused sc_dev softc field
It was never assigned or read. legacy code.
MFC after: 3 days
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D61481
asmc: print the last field of the SMC revision correctly
Use be16dec() at the correct offset instead of an unaligned,
off-by-two-bytes read through a cast pointer.
MFC after: 3 days
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D61479
asmc: restore SMC state across suspend/resume
Reinit the SMS interrupt mask, motion thresholds, and shock window on
resume. Guard the backlight rewrite on sc_has_light. Add
device_suspend to release manual fan control before sleep and restore
it on resume.
MFC after: 3 days
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D61478
tcp bbr: improve persits timeout computation
t_srtt and t_rttvar use different lengths of fractions, therefore use
the appropriate shift value.
Reviewed by: Peter Lei
MFC after: 3 days
MFC to: stable/15
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61600
Merge commit 72a20b8e2987 from llvm git (by Gabriel Baraldi):
[SLPVectorizer] Check std::optional coming out of getPointersDiff (#175784)
Fixes https://github.com/llvm/llvm-project/issues/175768
There are other unchecked uses std::optional in this pass but I couldn't
figure out a test that triggers them
This fixes a clang crash in the SLP vectorizer, hit when building
audio/csound on powerpc64le. The hardened libc++ traps on the disengaged
optional, so clang dies with exit code 133. The second hunk is adapted to
llvm 21, where analyzeConstantStrideCandidate() is still isStridedLoad().
Reviewed by: dim
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D61354
(cherry picked from commit e56090afb68b6c036d6b54c7b66d762d98bd96d0)
tcp bbr: improve retransmit timout calculation
The retransmission timeout should the srtt + 4 * rttvar.
The srtt is using 5 bits of fractions and rttvar is using 4 bits of
fractions, some specific shifting is required.
Reviewed by: Peter Lei
MFC after: 3 days
MFC to: stable/15
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61581