HardenedBSD/src 9bf66edlib/libbsdconf bsdconf.3 bsdconf_stmt.c, share/misc bsd-family-tree

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/cross-dso-cfi
DeltaFile
+39-420lib/libbsdconf/bsdconf.c
+133-0lib/libbsdconf/bsdconf_stmt.c
+44-18lib/libbsdconf/bsdconf.3
+23-20share/misc/bsd-family-tree
+23-0usr.sbin/sysconf/tests/sysconf_test.sh
+0-16usr.sbin/sysconf/sysconf_scan.c
+262-47415 files not shown
+315-50421 files

HardenedBSD/src ddd28e3lib/libbsdconf bsdconf.3 bsdconf_stmt.c, share/misc bsd-family-tree

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/pledge
DeltaFile
+39-420lib/libbsdconf/bsdconf.c
+133-0lib/libbsdconf/bsdconf_stmt.c
+44-18lib/libbsdconf/bsdconf.3
+23-20share/misc/bsd-family-tree
+23-0usr.sbin/sysconf/tests/sysconf_test.sh
+0-16usr.sbin/sysconf/sysconf_scan.c
+262-47415 files not shown
+315-50421 files

HardenedBSD/src bca3c76lib/libbsdconf bsdconf.3 bsdconf_stmt.c, share/misc bsd-family-tree

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+39-420lib/libbsdconf/bsdconf.c
+133-0lib/libbsdconf/bsdconf_stmt.c
+44-18lib/libbsdconf/bsdconf.3
+23-20share/misc/bsd-family-tree
+23-0usr.sbin/sysconf/tests/sysconf_test.sh
+0-16usr.sbin/sysconf/sysconf_scan.c
+262-47415 files not shown
+315-50421 files

HardenedBSD/src 5d169b5usr.sbin/bsnmpd/tools/libbsnmptools bsnmptools.c

bsnmpget: initialise the suboption value in getsubopt1()

Otherwise, "bsnmpget -o verbose -I cut" crashes.

Reported by:    clang static analyzer
MFC after:      2 weeks
DeltaFile
+1-0usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
+1-01 files

HardenedBSD/src 74cab6elib/libbsdconf bsdconf.h bsdconf.3, usr.sbin/sysconf sysconf_scan.c

libbsdconf: parse from a bounded in-memory buffer

Copy the descriptor into a buffer of at most 64 MiB (raise it with
BSDCONF_MAX_BYTES) and tokenize with bsdconf_scan(), the walker
bsdconf_put() already uses.  Input above the cap fails with EFBIG.
Bump libbsdconf to 1.2.0 and sysconf(8) to 2.0.

Suggested by:   fuz
Reviewed by:    fuz
Differential Revision:  https://reviews.freebsd.org/D59751
DeltaFile
+39-420lib/libbsdconf/bsdconf.c
+133-0lib/libbsdconf/bsdconf_stmt.c
+44-18lib/libbsdconf/bsdconf.3
+23-0usr.sbin/sysconf/tests/sysconf_test.sh
+0-16usr.sbin/sysconf/sysconf_scan.c
+9-3lib/libbsdconf/bsdconf.h
+248-4576 files not shown
+267-46312 files

HardenedBSD/src 7b7ef79share/misc bsd-family-tree

bsd-family-tree: add NetBSD 10.2
DeltaFile
+23-20share/misc/bsd-family-tree
+23-201 files

HardenedBSD/src 296e3fdusr.sbin/bsnmpd/tools/bsnmptools bsnmpget.c, usr.sbin/bsnmpd/tools/libbsnmptools bsnmptools.c

bsnmp: validate the lower bound of error_index in responses

Check if the response's error_index is within a sane interval.
Otherwise, a rogue peer could crash us.

PR:             298222
Reported by:    Robert Morris
Reviewed by:    markj
Discussed with: secteam (markj)
MFC after:      2 weeks
Analyzed with:  Claude Code Opus 5
DeltaFile
+6-2usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c
+2-1usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
+8-32 files

HardenedBSD/src b94772dsys/dev/clk/spacemit k1_clk.c k1_apmu.c

clk: Fix a few typos in the spacemit CCU driver

Fixes:  dcb10e3add17
Reported by:    Bruno Banelli <bruno.banelli at sartura.hr> (p_idx typo)
DeltaFile
+3-3sys/dev/clk/spacemit/k1_apmu.c
+2-2sys/dev/clk/spacemit/k1_clk.c
+5-52 files

HardenedBSD/src 3d03013sys/net/route fib_algo.c

route/fib_algo: Respect immediate_sync in fd_ref_nhop

Now fd_ref_nhop() returns zero for cross family routes,
Do not schedule nhop references and try to rebuild it immediately
for connected and static routes.

PR:     298733
Fixes:  633438224304 ("route/fib_algo: Fix nexthop index ...")
DeltaFile
+4-2sys/net/route/fib_algo.c
+4-21 files

HardenedBSD/src 50eae68sys/net/route fib_algo.c

route/fib_algo: Remove redundant zeroing of fd_af

fd is allocated with M_ZERO and fd_num_af never decreases.
Therefore, no need for zeroing nhaf_count and nhaf_base here.

Fixes:  633438224304 ("route/fib_algo: Fix nexthop index ...")
DeltaFile
+0-2sys/net/route/fib_algo.c
+0-21 files

HardenedBSD/src ab636e4usr.sbin/jail config.c

jail(8): Preserve const qualifier on strchr(3) results

Reviewed by:    fuz, dteske
Approved by:    fuz (mentor), dteske (mentor)
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D59876
DeltaFile
+3-3usr.sbin/jail/config.c
+3-31 files

HardenedBSD/src 26b3ff1sys/compat/linux linux.c

Ignore LINUX_POLLREMOVE

This matches upstream behaviour since Linux's demangle_poll()
silently discards POLLREMOVE from the requested events.

Reviewed by:    emaste
Sponsored by:   Sippy Software, Inc.
Differential Revision:  https://reviews.freebsd.org/D59914
MFC after:      1 week
PR:             297467
DeltaFile
+4-2sys/compat/linux/linux.c
+4-21 files

HardenedBSD/src 0cb85c5share/man/man4 aq.4

aq.4: Remove experimental note

I added the text when this driver was merely an import of
https://github.com/Aquantia/aqtion-freebsd with patches from ports applied.
nprice@ resolved issues and added support for newer cards and the note is
no longer applicable.

Reviewed by:    adrian
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D59909
DeltaFile
+0-4share/man/man4/aq.4
+0-41 files

HardenedBSD/src 5cada16contrib/atf NEWS, contrib/atf/atf-c++/detail auto_array.hpp auto_array_test.cpp

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/cross-dso-cfi
DeltaFile
+0-336contrib/atf/doc/atf-test-case.4
+328-0contrib/atf/doc/atf-test-case.7
+0-302contrib/atf/atf-c++/detail/auto_array_test.cpp
+269-0sys/riscv/starfive/jh7110_temp.c
+147-53contrib/atf/NEWS
+0-175contrib/atf/atf-c++/detail/auto_array.hpp
+744-866156 files not shown
+2,134-1,707162 files

HardenedBSD/src 13b82fbcontrib/atf NEWS, contrib/atf/atf-c++/detail auto_array.hpp auto_array_test.cpp

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/pledge
DeltaFile
+0-336contrib/atf/doc/atf-test-case.4
+328-0contrib/atf/doc/atf-test-case.7
+0-302contrib/atf/atf-c++/detail/auto_array_test.cpp
+269-0sys/riscv/starfive/jh7110_temp.c
+147-53contrib/atf/NEWS
+0-175contrib/atf/atf-c++/detail/auto_array.hpp
+744-866156 files not shown
+2,134-1,707162 files

HardenedBSD/src 8594be5lib/libarchive/tests Makefile, share/man/man4 dtrace_pid.4

Merge remote-tracking branch 'rad/hardened/15-stable/main' into hardened/15-stable/pledge
DeltaFile
+18-17lib/libarchive/tests/Makefile
+17-7sys/dev/sound/pcm/dsp.c
+22-2share/man/man4/dtrace_pid.4
+15-7sys/dev/sound/pci/hdspe-pcm.c
+17-5sys/powerpc/aim/mmu_radix.c
+15-2sys/dev/sound/pci/hdsp-pcm.c
+104-4012 files not shown
+117-6018 files

HardenedBSD/src 0e516e6contrib/atf NEWS, contrib/atf/atf-c++/detail auto_array.hpp auto_array_test.cpp

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+0-336contrib/atf/doc/atf-test-case.4
+328-0contrib/atf/doc/atf-test-case.7
+0-302contrib/atf/atf-c++/detail/auto_array_test.cpp
+269-0sys/riscv/starfive/jh7110_temp.c
+147-53contrib/atf/NEWS
+0-175contrib/atf/atf-c++/detail/auto_array.hpp
+744-866145 files not shown
+1,998-1,697151 files

HardenedBSD/src 32137c4sys/arm/allwinner a10_codec.c, sys/arm/broadcom/bcm2835 bcm2835_audio.c

sound: Retire the version constants

They exist only to fill in MODULE_DEPEND() and MODULE_VERSION(), and
every consumer passed the same value for all three, so the version
range never did anything. Use 1, like the rest of the tree does.

MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Reviewed by:    kib, emaste
Differential Revision:  https://reviews.freebsd.org/D59873
DeltaFile
+0-6sys/dev/sound/pcm/sound.h
+1-1sys/dev/firewire/fwisound.c
+1-1sys/arm/freescale/vybrid/vf_sai.c
+1-1sys/arm/freescale/imx/imx6_ssi.c
+1-1sys/arm/broadcom/bcm2835/bcm2835_audio.c
+1-1sys/arm/allwinner/a10_codec.c
+5-1133 files not shown
+38-4439 files

HardenedBSD/src 57d542clib/libc/tests/stdlib test-search.h bsearch_test.c

libc: Preserve const qualifier on bsearch(3) results in tests

Reviewed by:    dteske, fuz
Approved by:    dteske (mentor), fuz (mentor)
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D59611

(cherry picked from commit 3caa8d2c58b2787e4c4c64d9ac1831dadd7b0b47)
DeltaFile
+1-1lib/libc/tests/stdlib/test-search.h
+1-1lib/libc/tests/stdlib/bsearch_test.c
+1-1lib/libc/tests/stdlib/bsearch_s_test.c
+1-1lib/libc/tests/stdlib/bsearch_b_test.c
+4-44 files

HardenedBSD/src b169b80lib/libc/aarch64/string strpbrk.c, lib/libc/amd64/string strpbrk.c

libc: Parenthesise qualifier-preserving function definitions

Required to prevent function-like macros with the same name from
being expanded in the definitions once they become active in a
later C mode.  Without the parentheses, the macro would rewrite
the declarator, and the file would consequently fail to compile.
This style is already used for similar cases such as mempcpy().

Reviewed by:    fuz
Approved by:    fuz (mentor)
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D59600

(cherry picked from commit c389738f21c09931cd88a84a357be514b5c60030)
DeltaFile
+3-3lib/libc/stdlib/bsearch.c
+1-1lib/libc/string/memrchr.c
+1-1lib/libc/string/memmem.c
+1-1lib/libc/string/memchr.c
+1-1lib/libc/amd64/string/strpbrk.c
+1-1lib/libc/aarch64/string/strpbrk.c
+8-812 files not shown
+20-2018 files

HardenedBSD/src 91973f5lib/libc/stdlib bsearch.c bsearch.3, lib/libc/tests/stdlib test-search.h bsearch_b_test.c

libc: Implement bsearch_s(), document bsearch_b(), and add unit tests

- Implement bsearch_s() as per §K.3.6.3.2 in C23, first specified
  in C11.  It behaves identically to bsearch(), except the callback
  is called with a third argument, context, which is passed through
  from the caller, and it also performs runtime constraint checking
  on its arguments.
- Document bsearch_b(), bsearch_s(), and add history section
- Add rudimentary unit tests for bsearch(), bsearch_b(), and bsearch_s()

Reviewed by:    dteske, fuz
Approved by:    dteske (mentor), fuz (mentor)
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D58876

(cherry picked from commit d59c7ea2701fe7b73b32eef49a7c712ef38de5a0)
DeltaFile
+134-0lib/libc/tests/stdlib/bsearch_s_test.c
+103-5lib/libc/stdlib/bsearch.3
+92-0lib/libc/tests/stdlib/bsearch_test.c
+58-0lib/libc/tests/stdlib/bsearch_b_test.c
+51-0lib/libc/tests/stdlib/test-search.h
+38-0lib/libc/stdlib/bsearch.c
+476-55 files not shown
+503-611 files

HardenedBSD/src 8b66c7b. MAINTAINERS, .github CODEOWNERS

MAINTAINERS: Add myself to routing subsystem

Add myself as the maintainer for routing subsystem
in the GitHub CODEOWNERS and MAINTAINERS files.
DeltaFile
+1-0MAINTAINERS
+1-0.github/CODEOWNERS
+2-02 files

HardenedBSD/src f120213lib/libc/stdlib bsearch.3, lib/libc/string memchr.3 strchr.3

libc: Use C23 pseudo-types in qualifier-preserving man page synopses

Reviewed by:    fuz
Approved by:    fuz (mentor)
MFC after:      1 month
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2288

(cherry picked from commit f9dfe9b8deee0054949eda22f5c0aae8ba3d432d)
DeltaFile
+10-10lib/libc/string/wmemchr.3
+8-8lib/libc/string/strstr.3
+8-8lib/libc/string/string.3
+6-6lib/libc/string/strchr.3
+4-4lib/libc/string/memchr.3
+2-2lib/libc/stdlib/bsearch.3
+38-383 files not shown
+44-449 files

HardenedBSD/src 4bdbd68include wchar.h string.h, lib/libc/string string.3 strstr.3

libc: Implement qualifier-preserving standard library functions

Several standard library functions are specified to return an unqualified
pointer while accepting a pointer to a potentially const-qualified object.
N3020 addresses this behaviour, discarding qualifiers due to incompatible
pointer types, by introducing qualifier-preserving macros for the affected
set of standard library functions.

Add `__qualsel()` helper to `<sys/cdefs.h>`, implemented using the generic
selection, and define qualifier-preserving macros for that set of functions
in `<string.h>`, `<wchar.h>`, and `<stdlib.h>`.

Macros are gated on `_STDC_VERSION__ >= 202311L && !__cplusplus`, therefore
there is no behavioural change for earlier C modes or C++ translation units.
The kernel is likewise unaffected, as it does not include userland headers.

As function-like macros, they are transparent except at a call site where
the address-of operator is applied, the macro is suppressed via `#undef`,
or the identifier appears in parenthesised form; all of which cause the

    [8 lines not shown]
DeltaFile
+46-10lib/libc/string/wmemchr.3
+28-0include/string.h
+17-4lib/libc/string/strstr.3
+21-0sys/sys/cdefs.h
+11-5lib/libc/string/string.3
+14-0include/wchar.h
+137-197 files not shown
+187-3313 files

HardenedBSD/src cea39b9sys/kern vfs_bio.c

buf: Avoid calling bufdomain() on newly initialized bufs

bufinit() inserts newly initialized bufs into the QUEUE_EMPTY queue, at
which point they haven't yet been assigned a domain.  Thus, bufdomain()
returns &bdomain[-1], which trips the array-bounds sanitizer.

This is harmless since we don't use the result in that case, but let's
avoid the invalid access to begin with.  This is sufficient to let an
amd64 kernel boot to a login prompt with -fsanitize=array-bounds
configured.

Reported by:    Andrew Griffiths <andrew at calif.io>
Reviewed by:    rlibby, kib
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D59381

(cherry picked from commit e1d903bbfaf91060c43209b35b78a9992fbffe5e)
DeltaFile
+4-4sys/kern/vfs_bio.c
+4-41 files

HardenedBSD/src ccaeaa8sys/amd64/amd64 pmap.c

amd64/pmap: Return la57 in amd nested page

AMD doesn't encode page depth in eptp. As a result, the page level is
decided by the host la57 value. Without this, it uses 4 level page and
therefore cause machine enable la57 have garbage page translation.

PR:             291768
Reviewed by:    kib
Tested by:      Antranig Vartanian <antranigv at freebsd.am>
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D57978

(cherry picked from commit ef26f64c11220ea303de16d088c585f9d2908b0f)
DeltaFile
+13-1sys/amd64/amd64/pmap.c
+13-11 files

HardenedBSD/src 627c766sys/dev/ntb/test ntb_tool.c

ntb_tool: Bound memory window option strings

parse_mw_buf() copies option names from privileged sysctl input into
eight-byte stack buffers.  Unbounded %s conversions permit option tokens
longer than seven bytes to write past those buffers before the parser
validates them.

Limit each conversion to seven characters, leaving space for the
terminating NUL.

Signed-off-by: Yudi Yang <yudi.yang at rice.edu>

Fixes:          96f556f5044a ("NTB Tool: Test driver for NTB hardware drivers.")
Reviewed by:    markj
MFC after:      1 week

(cherry picked from commit 602d1b994a22949fff7e4a87cb6e54d6fbad13b6)
DeltaFile
+1-1sys/dev/ntb/test/ntb_tool.c
+1-11 files

HardenedBSD/src a4c71d0libexec/atf/atf-sh/tests Makefile

atf-sh: install kmod_test added as part of the 0.26 release

Fixes:  952231086100 ("contrib/atf: upgrade to 0.26")
DeltaFile
+1-0libexec/atf/atf-sh/tests/Makefile
+1-01 files

HardenedBSD/src e02620asys/dev/sound/pci hdspe-pcm.c

HBSD: Resolve merge conflict

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
DeltaFile
+0-9sys/dev/sound/pci/hdspe-pcm.c
+0-91 files

HardenedBSD/src b736970lib/libarchive/tests Makefile, share/man/man4 dtrace_pid.4

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

Conflicts:
        sys/dev/sound/pci/hdspe-pcm.c (unresolved)
DeltaFile
+18-17lib/libarchive/tests/Makefile
+17-7sys/dev/sound/pcm/dsp.c
+22-2share/man/man4/dtrace_pid.4
+17-5sys/powerpc/aim/mmu_radix.c
+18-1sys/dev/sound/pci/hdspe-pcm.c
+15-2sys/dev/sound/pci/hdsp-pcm.c
+107-3412 files not shown
+120-5418 files