HardenedBSD/src ef9579csys/cam cam_ccb.h, sys/dev/asmc asmc.c asmcvar.h

Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/cross-dso-cfi
DeltaFile
+17-8sys/dev/asmc/asmc.c
+8-7sys/cam/cam_ccb.h
+1-0sys/dev/asmc/asmcvar.h
+26-153 files

HardenedBSD/src 562184dsys/cam cam_ccb.h, sys/dev/asmc asmc.c asmcvar.h

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+17-8sys/dev/asmc/asmc.c
+8-7sys/cam/cam_ccb.h
+1-0sys/dev/asmc/asmcvar.h
+26-153 files

HardenedBSD/src 2a7c468sys/dev/asmc asmc.c asmcvar.h

asmc: improve asmc_dumpall to read actual SMC key count

The asmc_dumpall debug function previously used a hardcoded loop limit
of 0x100 (256) keys with a "XXX magic number" comment.

This change improves asmc_dumpall to:

* Read the actual number of keys from the ASMC_NKEYS SMC key
* Print the key count being dumped for better debugging output
* Loop only up to the actual key count (e.g., 297 on Mac Mini 5,1)

This provides more accurate debug output and removes the magic number.

Tested on Mac Mini 5,1 (FreeBSD 16.0-CURRENT):

* Rebuild kernel with DEBUG enabled in asmc driver
* Boot with new kernel
* Verify dmesg shows "asmc_dumpall: dumping 297 keys" (or actual count)
* Verify all 297 keys are dumped

    [3 lines not shown]
DeltaFile
+17-8sys/dev/asmc/asmc.c
+1-0sys/dev/asmc/asmcvar.h
+18-82 files

HardenedBSD/src 8ac77easys/cam cam_ccb.h

cam: Minor comment cleanup

Some minor comment cleanup, add a comment about an unused value, etc.
No functional change.

Sponsored by:           Netflix
DeltaFile
+8-7sys/cam/cam_ccb.h
+8-71 files

HardenedBSD/src 937d036lib/libgeom geom_xml2tree.c libgeom.h, sys/compat/linuxkpi/common/include/linux kstrtox.h

Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/cross-dso-cfi
DeltaFile
+97-61lib/libgeom/geom_xml2tree.c
+5-11sys/compat/linuxkpi/common/include/linux/kstrtox.h
+1-1lib/libgeom/libgeom.h
+103-733 files

HardenedBSD/src f75093alib/libgeom geom_xml2tree.c libgeom.h, sys/compat/linuxkpi/common/include/linux kstrtox.h

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+97-61lib/libgeom/geom_xml2tree.c
+5-11sys/compat/linuxkpi/common/include/linux/kstrtox.h
+1-1lib/libgeom/libgeom.h
+103-733 files

HardenedBSD/src fad6707lib/libgeom geom_xml2tree.c libgeom.h

libgeom: Clean up xml2tree code

MFC after:      1 week
Reviewed by:    imp
Differential Revision:  https://reviews.freebsd.org/D54453
DeltaFile
+51-49lib/libgeom/geom_xml2tree.c
+1-1lib/libgeom/libgeom.h
+52-502 files

HardenedBSD/src 27894e2lib/libgeom geom_xml2tree.c

libgeom: Fix segfault in 32-on-64 case

We were using strtoul() to parse object identifiers, which are kernel
pointers.  This works fine as long as the kernel and userland match,
but in a 32-bit libgeom on a 64-bit kernel this will return ULONG_MAX
for all objects, resulting in memory corruption when we later pick the
wrong object while resolving consumer-producer references.

MFC after:      1 week
PR:             292127
Reviewed by:    imp
Differential Revision:  https://reviews.freebsd.org/D54452
DeltaFile
+2-2lib/libgeom/geom_xml2tree.c
+2-21 files

HardenedBSD/src 4b0d5d1lib/libgeom geom_xml2tree.c

libgeom: Improve type safety of xml2tree code

When resolving references, assert that the type of the object we find
is what we expect.  This will help prevent memory corruption if two
objects of different types somehow end up with the same identifier.

MFC after:      1 week
Reviewed by:    imp
Differential Revision:  https://reviews.freebsd.org/D54454
DeltaFile
+44-10lib/libgeom/geom_xml2tree.c
+44-101 files

HardenedBSD/src f86148dsys/compat/linuxkpi/common/include/linux kstrtox.h

linuxkpi: Correct kstrtobool

Implement the exact same logic as in Linux:

* Accept 'e', 't', 'y', '1', "on" for true.

* Accept 'd', 'f', 'n', '0', "of" for false.

* Disregard any characters beyond that.

* Check that the string is not null, but don't check the result pointer.

MFC after:      1 week
Sponsored by:   Klara, Inc.
Sponsored by:   NetApp, Inc.
Reviewed by:    bz, emaste
Differential Revision:  https://reviews.freebsd.org/D54451
DeltaFile
+5-11sys/compat/linuxkpi/common/include/linux/kstrtox.h
+5-111 files

HardenedBSD/src 42a3a12sys/net if_bridge.c, sys/x86/cpufreq hwpstate_amd.c

Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/cross-dso-cfi
DeltaFile
+336-25sys/x86/cpufreq/hwpstate_amd.c
+0-3sys/net/if_bridge.c
+1-0sys/x86/include/specialreg.h
+337-283 files

HardenedBSD/src eb5ea27sys/net if_bridge.c, sys/x86/cpufreq hwpstate_amd.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+336-25sys/x86/cpufreq/hwpstate_amd.c
+0-3sys/net/if_bridge.c
+1-0sys/x86/include/specialreg.h
+337-283 files

HardenedBSD/src 3642ba2sys/x86/cpufreq hwpstate_amd.c

hwpstate_amd: Fix compile error

Add parentheses between OR and AND operator to pass the compiler check.

Approved by:    lwhsu (mentor)
Fixes:  3e6e4e4a0d42 ("hwpstate: add CPPC support for pstate driver on AMD")
MFC aftert:     2 weeks
Differential Revision: https://reviews.freebsd.org/D54465
DeltaFile
+1-1sys/x86/cpufreq/hwpstate_amd.c
+1-11 files

HardenedBSD/src 2e92aeesys/net if_bridge.c

bridge: Allow BRDGSIFVLANSET without IFBRF_VLANFILTER

Currently, we disallow BRDGSIFVLANSET when IFBRF_VLANFILTER is disabled.
There's no particular reason to do this, and it causes some undesirable
behaviour such as not being able to remove the tagged config on a member
after disabling vlanfilter on the bridge.

Remove the restriction so BRDGSIFVLANSET is always accepted.

PR:     292019
MFC after:      1 week
Reviewed by:    zlei, p.mousavizadeh_protonmail.com
Sponsored by:   https://www.patreon.com/bsdivy
Differential Revision:  https://reviews.freebsd.org/D54435
DeltaFile
+0-3sys/net/if_bridge.c
+0-31 files

HardenedBSD/src 3e6e4e4sys/x86/cpufreq hwpstate_amd.c, sys/x86/include specialreg.h

hwpstate: add CPPC support for pstate driver on AMD

Implement CPPC interface for AMD Pstate Driver.
This feature is only enabled when the CPUID shows it support CPPC.

The CPPC is implemneted by the following steps:

1. Write MSR to enable it.
2. Read capability registert which indicates binary value of levels
about lowest, best energy efficient, guarantee, and max performance.
3. Write request register with epp in energy balanced mode. And let
CPU and firmware to enter autonomous mode.

Also, create a sysctl handler to allow userspace to change epp value.
In intel's hwpstate, The epp value can be in package level and core level.
However, in AMD's one, there is only core level. Thus, to sync with the
intel's code, we implement package level control in software and provide
another sysctl (machdep.hwpstate_pkg_ctrl) to control it.


    [5 lines not shown]
DeltaFile
+336-25sys/x86/cpufreq/hwpstate_amd.c
+1-0sys/x86/include/specialreg.h
+337-252 files

HardenedBSD/src 93f0af4. Makefile.inc1, share/man/man4 jedec_dimm.4 smbus.4

Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/cross-dso-cfi
DeltaFile
+5-1share/man/man4/jedec_dimm.4
+2-1share/man/man4/smbus.4
+2-1share/mk/bsd.sys.mk
+1-1Makefile.inc1
+10-44 files

HardenedBSD/src 10f6093. Makefile.inc1, share/man/man4 jedec_dimm.4 smbus.4

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+5-1share/man/man4/jedec_dimm.4
+2-1share/mk/bsd.sys.mk
+2-1share/man/man4/smbus.4
+1-1Makefile.inc1
+10-44 files

HardenedBSD/src 9c0bedbsys/contrib/openzfs/include/os/freebsd/spl/sys cmn_err.h kmem.h, sys/contrib/openzfs/include/sys spa.h vdev.h

zfs: rename several printf attribute declarations to __printf__

For kernel builds, we redefine `__printf__` to `__freebsd_kprintf__`, to
support FreeBSD kernel printf(9) extensions with clang.

In OpenZFS various printf related functions are declared with
__attribute__((format(printf, X, Y))), so these won't work with the
above redefinition. With clang 21 and higher, this leads to errors
similar to:

    sys/contrib/openzfs/module/zfs/spa_misc.c:414:38: error: passing 'printf' format string where 'freebsd_kprintf' format string is expected [-Werror,-Wformat]
      414 |         (void) vsnprintf(buf, sizeof (buf), fmt, adx);
          |                                             ^

Since attribute names can always be spelled with leading and trailing
double underscores, rename these instances.

Note that in FreeBSD proper we usually use `__printflike` from
<sys/cdefs.h>, but that does not apply to OpenZFS.

    [6 lines not shown]
DeltaFile
+8-8sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h
+2-2sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h
+2-2sys/contrib/openzfs/include/sys/spa.h
+1-1sys/contrib/openzfs/include/sys/vdev.h
+1-1sys/contrib/openzfs/include/sys/zfs_debug.h
+14-145 files

HardenedBSD/src c17271fsys/crypto/chacha20 chacha.c

crypto: avoid warnings about too-long initializer strings

Mark `sigma` and `tau` as `__non_string`, to avoid warnings from clang
21 similar to:

    sys/crypto/chacha20/chacha.c:53:31: error: initializer-string for character array is too long, array size is 16 but initializer has size 17 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
       53 | static const char sigma[16] = "expand 32-byte k";
          |                               ^~~~~~~~~~~~~~~~~~
    sys/crypto/chacha20/chacha.c:54:29: error: initializer-string for character array is too long, array size is 16 but initializer has size 17 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
       54 | static const char tau[16] = "expand 16-byte k";
          |                             ^~~~~~~~~~~~~~~~~~

MFC after:      3 days
Reviewed by:    markj
Differential Revision: https://reviews.freebsd.org/D54364

(cherry picked from commit 710ec409dffed3306ced253bba85dbdc7758510b)
DeltaFile
+2-2sys/crypto/chacha20/chacha.c
+2-21 files

HardenedBSD/src bc17408contrib/ncurses/progs infocmp.c

ncurses: avoid warnings about too-long initializer strings

Increase the size of `assoc::from` to 8 bytes, to avoid warnings from
clang 21 similar to:

    contrib/ncurses/progs/infocmp.c:702:10: error: initializer-string for character array is too long, array size is 4 but initializer has size 5 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
      702 |     DATA("\033[2J", "ED2"),     /* clear page */
          |          ^~~~~~~~~
    contrib/ncurses/progs/infocmp.c:716:10: error: initializer-string for character array is too long, array size is 4 but initializer has size 5 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
      716 |     DATA("\033[!p", "DECSTR"),  /* soft reset */
          |          ^~~~~~~~~

Reviewed by:    markj
Obtained from:  https://invisible-island.net/archives/ncurses/6.5/ncurses-6.5-20241207.patch.gz
MFC after:      3 days
Differential Revision: https://reviews.freebsd.org/D54371

(cherry picked from commit 667259b392ec0a86d066ccc6ba0f4025b3d2a083)
DeltaFile
+1-1contrib/ncurses/progs/infocmp.c
+1-11 files

HardenedBSD/src 7d02433sys/compat/linux linux_timer.c

compat: linux: use appropriate variables for copying out old timers

We copyout &l_oval but do the conversions into &l_val, leaving us with
stack garbage.  A build with an LLVM21 cross-toolchain seems to catch
this.

Reported by:    Florian Limberger <flo purplekraken com>
Reviewed by:    markj
Fixes:          a1fd2911ddb06 ("linux(4): Implement timer_settime64 syscall.")
MFC after:      3 days
Differential Revision: https://reviews.freebsd.org/D52985

(cherry picked from commit 541a98d7e28a8e4697ac2fa78dd4c4203c2c3a9c)
DeltaFile
+2-2sys/compat/linux/linux_timer.c
+2-21 files

HardenedBSD/src 2198726share/mk bsd.sys.mk

bsd.sys.mk: suppress some new clang 21 warnings for C++

Otherwise, these lead to many -Werror warnings in libc++ headers, due to
our use of -Wsystem-headers, which is not officially supported upstream:

Suppress -Wc++20-extensions, due to:

    /usr/include/c++/v1/__algorithm/simd_utils.h:96:50: error: explicit template parameter list for lambdas is a C++20 extension [-Werror,-Wc++20-extensions]
       96 | inline constexpr size_t __simd_vector_size_v = []<bool _False = false>() -> size_t {
          |                                                  ^

Suppress -Wc++23-lambda-attributes, due to:

    /usr/include/c++/v1/__format/format_functions.h:462:32: error: an attribute specifier sequence in this position is a C++23 extension [-Werror,-Wc++23-lambda-attributes]
      462 |   if (bool __is_identity = [&] [[__gnu__::__pure__]] // Make sure the compiler knows this call can be eliminated
          |                                ^

Suppress -Wnullability-completeness, due to:


    [7 lines not shown]
DeltaFile
+5-0share/mk/bsd.sys.mk
+5-01 files

HardenedBSD/src b93a331bin/sh options.h, bin/test test.c

sh: avoid warnings about too-long initializer strings

Mark `optletter` and `t_op::op_text` as `__non_string`, to avoid
warnings from clang 21 similar to:

    bin/sh/options.h:77:36: error: initializer-string for character array is too long, array size is 19 but initializer has size 20 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
       77 | const char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh";
          |                                    ^~~~~~~~~~~~~~~~~~~~~
    bin/test/test.c:153:3: error: initializer-string for character array is too long, array size is 2 but initializer has size 3 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
      153 |         {"==",  STREQ},
          |          ^~~~

MFC after:      3 days
Reviewed by:    jilles
Differential Revision: https://reviews.freebsd.org/D54362

(cherry picked from commit e6546807f4c1a8a6a6fa53fceab7b8c80e3ed802)
DeltaFile
+1-1bin/sh/options.h
+1-1bin/test/test.c
+2-22 files

HardenedBSD/src 7c6a0batools/build/mk OptionalObsoleteFiles.inc

OptionalObsoleteFiles.inc: fix up WITH_LLVM_LINK_STATIC_LIBRARIES cases

In commit cf1eaaf41cef I added the WITH_LLVM_LINK_STATIC_LIBRARIES
src.conf(5) build knob, which also affects OptionalObsoleteFiles.inc.

However, the checks were incorrect: when WITH_LLVM_LINK_STATIC_LIBRARIES
is active, the OLD_LIBS libprivatellvm.so.19, libprivateclang.so.19 and
libprivatelldb.so.19 should always be cleaned up.

Fixes:          cf1eaaf41cef
MFC after:      1 week

(cherry picked from commit 160077a4d75186a979f28f0778259c66d8cac8be)
DeltaFile
+6-6tools/build/mk/OptionalObsoleteFiles.inc
+6-61 files

HardenedBSD/src ded12d6lib/clang/libclang Makefile, lib/clang/liblldb Makefile

src.conf: Add WITH_LLVM_LINK_STATIC_LIBRARIES build knob

In commit 2e47f35be5dc libllvm, libclang and liblldb were converted into
private shared libraries. This allowed clang, lld, lldb, and other llvm
tools to be linked against these shared libraries, which makes them
smaller and avoids duplication.

However, this also comes at the cost of some performance, since the
dynamic libraries are quite large, and contain lots of long symbols
(mangled C++ identifiers).

Add a WITH_LLVM_LINK_STATIC_LIBRARIES build knob that can be used to go
back to the previous behavior: libllvm, libclang and liblldb are built
as internal static libraries, i.e. only available during buildworld, and
fully linked into the various executables such as clang, lld, etc.

PR:             287447
Reviewed by:    emaste
MFC after:      1 week

    [3 lines not shown]
DeltaFile
+12-1lib/clang/liblldb/Makefile
+8-3tools/build/mk/OptionalObsoleteFiles.inc
+4-5lib/clang/libllvm/Makefile
+8-1share/man/man5/src.conf.5
+4-4lib/clang/libclang/Makefile
+6-0tools/build/options/WITH_LLVM_LINK_STATIC_LIBRARIES
+42-147 files not shown
+61-1713 files

HardenedBSD/src 62a7fdcshare/mk bsd.sys.mk

bsd.sys.mk: suppress another gcc warning for libc++

Similar to base 63d1c3c43690, suppress -Wc++20-extensions for gcc.
Otherwise libc++ headers will lead to many -Werror warnings, due to our
use of -Wsystem-headers, which is not officially supported upstream.

MFC after:      3 days
DeltaFile
+2-1share/mk/bsd.sys.mk
+2-11 files

HardenedBSD/src a6afa19. Makefile.inc1

Makefile.inc1: Indicate that no-clean builds are on by default

PR:             292130
DeltaFile
+1-1Makefile.inc1
+1-11 files

HardenedBSD/src f70c605sbin/ipfw ipfw.8

MFC: ipfw.8: document how to delete nat configuration instance

(cherry picked from commit e51047118cb1d15abe8077a5b47b8063fa364ad9)
DeltaFile
+15-1sbin/ipfw/ipfw.8
+15-11 files

HardenedBSD/src b52347fshare/man/man4 jedec_dimm.4 smbus.4

jdec_dimm(4): add a reference to smbmsg(8) to jedec_dimm(4) and smbus(4)

Add a cross reference to smbmsg(8) which is useful for discovering local
devices and difficult to find otherwise.

PR: 247749
Reviewed by: pauamma at gundo.com
Differential Review: https://reviews.freebsd.org/D40839
DeltaFile
+5-1share/man/man4/jedec_dimm.4
+2-1share/man/man4/smbus.4
+7-22 files

HardenedBSD/src 1d0d0a8sbin/ipfw ipfw.8

ipfw.8: fix documentation bug for setmark

A mark set with "setmark" keyword is intended to be "sticky"
and documented as such but in fact it is not yet,
as current implementation lacks "sticky" feature
and its implementation will be not MFC'd, most probably.

Correct the manual page until the implementation improved.

Discussed with: Boris Lytochkin <lytboris at gmail.com> (author)

(cherry picked from commit a7b8a5d37bcb0009297962137bfb6c6570e5af12)
(cherry picked from commit 9fdf49e8a501047b61a615ab1b4b133159ad76e1)
DeltaFile
+6-2sbin/ipfw/ipfw.8
+6-21 files