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
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]
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
ipfw: fix order of memcpy arguments.
This fixes `ipfw table N lookup addr` command for MAC tables.
(cherry picked from commit e012d79c9c732a6aef21066feba2e5e48833cca4)
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)
ipfw: fix order of memcpy arguments.
This fixes `ipfw table N lookup addr` command for MAC tables.
(cherry picked from commit e012d79c9c732a6aef21066feba2e5e48833cca4)
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
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
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
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
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
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
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
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
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
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
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
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
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)
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]
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.