FreeBSD/src 4a0fc13tools/test README, tools/test/arc4random biastest.c

tools: add arc4random_uniform() bias test

This test program executed arc4random_uniform() repeatedly and
analyzes the distribution of return values, showing how similar
the parameters of the observed outcome are to the expected
parameters of an equidistribution.

This cannot be a unit test as it takes quite a while to run and
lots of memory (~3 GB) to execute.

Reviewed by:    cem
Approved by:    emaste
Differential Revision:  https://reviews.freebsd.org/D47659
DeltaFile
+216-0tools/test/arc4random/biastest.c
+1-1tools/test/README
+217-12 files

FreeBSD/src 127709dlib/libc/gen arc4random_uniform.c arc4random.3

lib/libc/gen: use Lemire's algorithm for arc4random_uniform().

Daniel Lemire has published a more efficient range reduction algorithm
for finding a random number in a given range without bias, reducing the
number of divisions to none in the common case and 1 in case the initial
sample is rejected.

This speeds up performance by 22% on amd64, 15% on i386, and 70% on armv7.

os: FreeBSD
arch: amd64
cpu: Intel(R) Core(TM) i7-4910MQ CPU @ 2.90GHz
                   │ benchmark.out │
                   │    sec/op     │
Arc4random_uniform     56.53n ± 0%
Fast_uniform           44.00n ± 0%
geomean                49.87n

Reviewed by:    cem

    [2 lines not shown]
DeltaFile
+31-40lib/libc/gen/arc4random_uniform.c
+12-1lib/libc/gen/arc4random.3
+43-412 files

FreeBSD/src 1730b5clib/libc/tests/gen arc4random_test.c

lib/libc/tests: add unit test for arc4random_uniform()

The new unit test validates that the range reduction works correctly.
We do not currently validate that there is no bias as that would take
too much time and memory for a unit test.

Reviewed by:    cem
Approved by:    emaste
Differential Revision:  https://reviews.freebsd.org/D47659
DeltaFile
+26-0lib/libc/tests/gen/arc4random_test.c
+26-01 files

FreeBSD/src 447a1e6sys/netpfil/ipfw ip_fw_table_algo.c

ipfw: fix order of memcpy arguments.

This fixes `ipfw table N lookup addr` command for MAC tables.

(cherry picked from commit e012d79c9c732a6aef21066feba2e5e48833cca4)
DeltaFile
+1-1sys/netpfil/ipfw/ip_fw_table_algo.c
+1-11 files

FreeBSD/src 628e76asys/netipsec ipsec_output.c

ipsec: fix IPv6 over IPv4 tunneling.

Properly initialize setdf variable in ipsec_encap().
It is used for AF_INET6 case when IPv6 datagram is going to be
encapsulated into IPv4 datagram.

PR:             282535
Fixes:          4046178557e1

(cherry picked from commit c94d6389e428fac55946bfcdbbc3162c06a9278e)
DeltaFile
+4-10sys/netipsec/ipsec_output.c
+4-101 files

FreeBSD/src a731e69sys/netpfil/ipfw ip_fw_table_algo.c

ipfw: fix order of memcpy arguments.

This fixes `ipfw table N lookup addr` command for MAC tables.

(cherry picked from commit e012d79c9c732a6aef21066feba2e5e48833cca4)
DeltaFile
+1-1sys/netpfil/ipfw/ip_fw_table_algo.c
+1-11 files

FreeBSD/src ff1aec7sys/netpfil/ipfw ip_fw_pfil.c

ipfw: do not reset fwmark when one_pass is disabled.

Fixes:  fc727ad63d3f8
MFC after:      1 week
DeltaFile
+1-1sys/netpfil/ipfw/ip_fw_pfil.c
+1-11 files

FreeBSD/src 0482974sys/dev/sfxge sfxge.c

sfxge: defer ether_ifattach to when ifmedia_init is done

Otherwise the ifmedia subsystem may call unguarded NULL function
pointers.  Same issue that was fixed for cxgb(4) in f2daf8995.

Also see:       https://github.com/opnsense/src/issues/228
MFC after:      1 week
DeltaFile
+3-7sys/dev/sfxge/sfxge.c
+3-71 files

FreeBSD/src 991bd46lib/libsbuf/tests sbuf_string_test.c sbuf_core_test.c

lib/libsbuf/tests: reformat with `clang-format`

This change is being done first so any functional changes from the tests
will be clearer to reviewers.

No functional change intended.

MFC after:      2 weeks
Ref:     https://reviews.freebsd.org/D47826
DeltaFile
+32-28lib/libsbuf/tests/sbuf_string_test.c
+16-16lib/libsbuf/tests/sbuf_core_test.c
+10-11lib/libsbuf/tests/sbuf_stdio_test.c
+58-553 files

FreeBSD/src a0e45dbcontrib/wpa/src/drivers driver_bsd.c

contrib/wpa: pass IFM_IEEE80211_VHT5G if vht_enabled on the channel

Set media mode correctly to IFM_IEEE80211_VHT5G if vht_enabled is set
on the channel.  Otherwise we'll end up setting 11NA.
Not a problem on first sight given net80211 does the upgrade to VHT
for us.  But we would not set iv_des_mode ("desired mode") on the vap.
Setting this will put a contraint on/help scanning for our desired
(VHT) channels to my understanding of the code.

Sponsored by:   The FreeBSD Foundation
MFC after:      6 weeks
Reviewed by:    cy, adrian
Differential Revision:  https://reviews.freebsd.org/D35978
DeltaFile
+1-0contrib/wpa/src/drivers/driver_bsd.c
+1-01 files

FreeBSD/src 96b72aasys/kern vfs_cache.c

kern___realpathat(): honor uio_seg argument

(cherry picked from commit bde575b273eeb17abe878e43dd018e8373741298)
DeltaFile
+9-1sys/kern/vfs_cache.c
+9-11 files

FreeBSD/src 8e9f1e1sys/amd64/amd64 pmap.c

amd64 pmap: assert and explain why pmap_qremove() is safe WRT supermappings

(cherry picked from commit 2d6923790b16785ac691cedb23234067672fe1cc)
DeltaFile
+12-0sys/amd64/amd64/pmap.c
+12-01 files

FreeBSD/src 057da12sys/kern vfs_cache.c

kern___realpathat(): do not copyout past end of string

(cherry picked from commit 67218bcea847c93ccd002335748884b02a3ca807)
DeltaFile
+1-1sys/kern/vfs_cache.c
+1-11 files

FreeBSD/src 7302cddsys/amd64/amd64 pmap.c

amd64: switch pmap_map_io_transient() to use pmap_kenter_attr()

(cherry picked from commit 6ec4ff70885d8048be8de9b9d690dd371e3d4a3e)
DeltaFile
+3-7sys/amd64/amd64/pmap.c
+3-71 files

FreeBSD/src 243f692sbin/ifconfig ifieee80211.c, sys/net80211 ieee80211_ioctl.c ieee80211_var.h

net80211: 11ac: add options to manage VHT STBC

Add IEEE80211_FVHT_STBC_(TX|RX) flags to allow userspace to manage
if STBC will be allowed for VHT RX/TX.
For RX this will only allow us to turn it off but no fine grained
control of the number of supported spatial streams.

Introduce IEEE80211_FVHT_CHANWIDTH_MASK as a helper to make the
spelling out of the IEEE80211_FVHT_MASK more readable.

Update ifconfig to allow setting of these flags.

Sponsored by:   The FreeBSD Foundation
MFC atfer:      3 days
Reviewed by:    adrian
Differential Revision: https://reviews.freebsd.org/D47838
DeltaFile
+20-0sys/net80211/ieee80211_ioctl.c
+10-2sys/net80211/ieee80211_var.h
+8-0sbin/ifconfig/ifieee80211.c
+2-4sys/net80211/ieee80211_vht.c
+4-0sys/net80211/ieee80211.c
+44-65 files

FreeBSD/src 1161021sys/net80211 ieee80211.h

net80211: name IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_{NONE -> NO160}

IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_NONE is confusing as the field does
indicate that the STA does not support 160 (or 80+80) Mhz.
[802.11ac: Table 8-183v-Subfields of the VHT Capabilities Info field]
All the other bits are related to the support of 160Mhz so make it
clear that it does not mean that we do not support any VHT CHAN WIDTH
but merely do not support the optional 160/80+80.

Sponsored by:   The FreeBSD Foundation
MFC after:      3 days
Reviewed by:    adrian
Differential Revision: https://reviews.freebsd.org/D47837
DeltaFile
+1-1sys/net80211/ieee80211.h
+1-11 files

FreeBSD/src d4dd9e2libexec/comsat comsat.c

comsat: Use initgroups and setgid not just setuid

PR:             270404
Reviewed by:    jlduran
Obtained from:  NetBSD
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47828
DeltaFile
+5-4libexec/comsat/comsat.c
+5-41 files

FreeBSD/src 4294f1csys/net80211 ieee80211.h

net80211: add missing reference for struct ieee80211_vht_mcs_info

Sponsored by:   The FreeBSD Foundation
Reviewed by:    adrian
MFC after:      3 days
Differential Revision: https://reviews.freebsd.org/D47836
DeltaFile
+1-0sys/net80211/ieee80211.h
+1-01 files

FreeBSD/src 943a19csys/compat/linuxkpi/common/src linux_80211.c

LinuxKPI: 802.11: make HT compile again

Bring in changes missed during the last driver updates to make HT
compile when enabled.

Sponsored by:   The FreeBSD Foundation
Fixes:          7b43f4d064195
MFC after:      3 days
DeltaFile
+3-3sys/compat/linuxkpi/common/src/linux_80211.c
+3-31 files

FreeBSD/src 885f3adsys/powerpc/powernv opal_sensor.c

powernv/opal: Add missing DEVMETHOD_END to method list

Reported by:    ehem_freebsd_m5p.com
MFC after:      1 week
DeltaFile
+3-1sys/powerpc/powernv/opal_sensor.c
+3-11 files

FreeBSD/src 30d2f84sys/compat/linuxkpi/common/src linux_firmware.c

LinuxKPI: firmware: change order filenames trying to load firmware

Given we have the support in main and stable/14 to load plain firmware
files from /boot/firmware/ make use of that.  Switch the order to
try the original unmangled filename and path first before trying any
replacements.
This reduces time and console noise (especially under bootverbose).

Sponsored by:   The FreeBSD Foundation
MFC after:      3 days
Reviewed by:    emaste
Differential Revision: https://reviews.freebsd.org/D47682
DeltaFile
+11-11sys/compat/linuxkpi/common/src/linux_firmware.c
+11-111 files

FreeBSD/src f7cf62cusr.sbin/pw/tests pw_useradd_test.sh

pw: tests: add a test for -M with a pre-existing home directory

Previous versions of pw(8) wouldn't chmod the home directory if it
already existed prior to user creation, rendering adduser(8) -M
ineffective in some cases.  Add a test to cover that situation.

PR:             280099
Reviewed by:    kevans
DeltaFile
+16-0usr.sbin/pw/tests/pw_useradd_test.sh
+16-01 files

FreeBSD/src 6a7238fusr.sbin/adduser adduser.8, usr.sbin/pw cpdir.c

pw: set the user's home directory mode if it existed

The adduser(8) prompt allows one to set the mode of a new home
directory, but pw(8) doesn't honor the -M mode if the home directory
already exists at creation time.  It doesn't seem to make sense to
ignore the mode (which may lead to a security issue on the system being
configured) when we'll happily chown an existing directory, so fix the
inconsistency.

PR:             280099
Reviewed by:    des, jlduran (previous version)
Differential Revision:  https://reviews.freebsd.org/D46443
DeltaFile
+21-6usr.sbin/pw/cpdir.c
+4-2usr.sbin/adduser/adduser.8
+25-82 files

FreeBSD/src 59677aeinclude string.h time.h

Expose POSIX functions incorporated into C23

C23 has incoporated a small number of POSIX functions, so these
should be exposed for C23, regardless of POSIX.

Reviewed by:    imp, emaste
Differential Revision:  https://reviews.freebsd.org/D47856
DeltaFile
+5-3include/string.h
+2-0include/time.h
+7-32 files

FreeBSD/src 955208dcontrib/one-true-awk run.c FIXES

ota: Merge 20240728 (bsd-feature) from ota 3319c34a8713

Jul 28, 2024
        Fixed readcsvrec resize segfault when reading csv records longer
        than 8k. Thanks to Ozan Yigit.
        mktime() added to bsd-features branch. Thanks to Todd Miller.

(cherry picked from commit 8d457988a72487b35ee3922671775d73169339e3)
DeltaFile
+21-1contrib/one-true-awk/run.c
+5-0contrib/one-true-awk/FIXES
+1-1contrib/one-true-awk/b.c
+1-1contrib/one-true-awk/lib.c
+1-1contrib/one-true-awk/main.c
+1-0contrib/one-true-awk/awk.h
+30-41 files not shown
+31-47 files

FreeBSD/src 646e167contrib/one-true-awk b.c main.c, contrib/one-true-awk/testdir T.argv

ota: Merge 20240623 (bsd-features) from ota 9f971fba471b

Merge from upstream. The system-status test was modifed upstream, but it
still doesn't fit into ATF, so those changes weren't brought in.

From FIXES:

Jun 23, 2024
        Fix signal for system-status test. Thanks to Tim van der Molen.
        Rewrite if-else chain as switch. Thanks to Andrew Sukach.

May 27, 2024
        Spelling fixes and removal of unneeded prototypes and extern.
        Thanks to Jonathan Gray.

May 4, 2024
        Fixed a use-after-free bug with ARGV for "delete ARGV".
        Also ENVtab is no longer global. Thanks to Benjamin Sturz
        for spotting the ARGV issue and Todd Miller for the fix.

    [7 lines not shown]
DeltaFile
+34-21contrib/one-true-awk/b.c
+34-14contrib/one-true-awk/main.c
+21-5contrib/one-true-awk/FIXES
+23-0contrib/one-true-awk/testdir/T.argv
+12-10contrib/one-true-awk/tran.c
+5-3contrib/one-true-awk/lib.c
+129-5311 files not shown
+141-6917 files

FreeBSD/src b802ab1sys/sys param.h

Bump __FreeBSD_version for llvm 19.1.4 merge

PR:             280562
MFC after:      1 month

(cherry picked from commit f3dbef108212460489ae68b4c47e20b73984f433)
DeltaFile
+1-1sys/sys/param.h
+1-11 files

FreeBSD/src a58eb66cddl/lib/libzpool Makefile

libzpool: add workaround for MIPS-specific llvm bug compiling arc.c

This works around an assertion in llvm's shrink wrapping analysis pass,
when compiling arc.c for mips and mips64:

  Assertion failed: (PhysReg.isPhysical() && "Unallocated register?!"), function useOrDefCSROrFI, file /usr/src/contrib/llvm-project/llvm/lib/CodeGen/ShrinkWrap.cpp, line 341.

The bug will also be submitted upstream.

Direct commit to stable/13, since MIPS support was removed in 14.0.
DeltaFile
+8-0cddl/lib/libzpool/Makefile
+8-01 files

FreeBSD/src 5dc0616contrib/llvm-project/clang/include/clang/Basic BuiltinsLoongArchLASX.def BuiltinsLoongArchLSX.def, contrib/llvm-project/compiler-rt/lib/sanitizer_common sanitizer_linux.cpp

Merge llvm-project release/19.x llvmorg-19.1.4-0-gaadaa00de76e

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/19.x llvmorg-19.1.4-0-gaadaa00de76e,
a.k.a. 19.1.4 release.

PR:             280562
MFC after:      1 month

(cherry picked from commit 415efcecd8b80f68e76376ef2b854cb6f5c84b5a)
DeltaFile
+73-73contrib/llvm-project/clang/include/clang/Basic/BuiltinsLoongArchLASX.def
+66-66contrib/llvm-project/clang/include/clang/Basic/BuiltinsLoongArchLSX.def
+39-16contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+8-45contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
+17-21contrib/llvm-project/llvm/lib/IR/Mangler.cpp
+31-3contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
+234-22429 files not shown
+371-26935 files

FreeBSD/src cdbdcbdcontrib/llvm-project/clang/include/clang/AST ExternalASTSource.h, contrib/llvm-project/clang/lib/CodeGen CGBuiltin.cpp

Merge llvm-project release/19.x llvmorg-19.1.3-0-gab51eccf88f5

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/19.x llvmorg-19.1.3-0-gab51eccf88f5,
a.k.a. 19.1.3 release.

PR:             280562
MFC after:      1 month

(cherry picked from commit d686ce931cab72612a9e1ada9fe99d65e11a32a3)
DeltaFile
+35-13contrib/llvm-project/clang/include/clang/AST/ExternalASTSource.h
+20-25contrib/llvm-project/clang/lib/CodeGen/CGBuiltin.cpp
+29-6contrib/llvm-project/llvm/include/llvm/TargetParser/Triple.h
+18-3contrib/llvm-project/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+4-8contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+7-5contrib/llvm-project/llvm/lib/Transforms/Utils/ModuleUtils.cpp
+113-6031 files not shown
+203-9737 files