random: Allow pure entropy sources to provide a min-entropy estimate
The current implementation of the NIST health tests assumes a
min-entropy estimate of one bit per sample, which is quite conservative.
For so-called "pure" sources (e.g., virtio-random, TPM) it might be nice
to support larger estimates so that the tests catch failed devices more
quickly.
Thus:
- let each pure random source provide an estimate, so that downstreams
or driver implementors can override defaults if they want to;
- increase the default estimate for pure sources;
- for pure sources initialize the state machine at source registration
time.
Reviewed by: cem
MFC after: 2 weeks
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D52232
random: Make the entropy source registration interface more uniform
Most pure sources work under a "pull" model wherein a dedicated thread
polls the source at regular intervals (every 100ms). A couple of
sources, however, will instead call random_harvest_direct() to provide
entropy samples. Such sources were not calling random_source_register()
and thus weren't in the global random source list.
Modify "push" sources to use random_source_register() like other sources
do. Such sources omit an implementation of rs_read and are thus skipped
by the above-mentioned thread. This makes it easier to allow pure
sources to provide a min-entropy estimate in a uniform way.
Reviewed by: cem
MFC after: 2 weeks
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D52229
random: Exclude the timestamp from healthtest for pure sources
So-called pure sources provide entropy at regular intervals, so the
timestamp counter provides little entropy. Exclude it from health
testing for such sources.
Reviewed by: cem, emaste
MFC after: 2 weeks
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D52233
random: Fix synchronization of hc_source_mask
This variable provides a mask of all registered entropy sources and is
updated when drivers attach and detach (or by sysctl). However, nothing
was synchronizing accesses to it. Use the harvest lock to provide
mutual exclusion for updates, and use atomic_load_int() to mark unlocked
reads.
Reviewed by: cem
MFC after: 2 weeks
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D52230
random: Make the min-entropy estimate configurable
Right now the cutoff values for the RCT and APT tests are computed with
a fixed min-entropy estimate of 1. In preparation for permitting
alternative estimates for "pure" sources (i.e., hardware noise sources),
extend the code to handle alternative estimates of an integer number of
bits.
For the RCT test, the cutoff is simply the formula from section 4.4.1 of
NIST SP 800-90B. For the APT test, I used Excel to compute a lookup
table using the formula provided in section 4.4.2.
Reviewed by: cem
MFC after: 2 weeks
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D52228
Revert "LinuxKPI: pci: allocate entire pci_dev hiereachy up to root port on attach"
It turns out this breaks the nvidia-drm drviers.
We'll try to rework things and put it back later.
This reverts commit bbeeb585315645db20118ef349a4e3dc83b148cc.
freebsd-update: Fix the pkgbase check
Even on a pkgbase system, it should be possible to use freebsd-update -j
to upgrade a non-pkgbase jail, at least for the time being. However,
the check_pkgbase() call came before get_params, so BASEDIR was always
set to /.
Make check_pkgbase() a pure function and call it after get_params().
While here, use pkg -r ${BASEDIR} instead of pkg -c ${BASEDIR} since the
latter requires root privileges. freebsd-update is supposed to be run
as root, but it doesn't actually check this that I can see, so let's not
make that assumption here since it affects the result of the function
(i.e., pkg -c ${BASEDIR} always fails as a non-root user).
Reviewed by: des
Fixes: 856e158dc4aa ("freebsd-update: improve pkgbase check")
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D51770
(cherry picked from commit 66c75fa63aff40e9c587345b2cc6b8148e396de8)
libc/amd64: rewrite memrchr() baseline impl. to read the string from the back
This ensures O(1) behaviour if the character is a constant offset
from the end of the string, regardless of how long the string is.
Reported by: Mikael Simonsson <m at mikaelsimonsson.com>
Reviewed by: benni
PR: 288321
MFC after: 1 month
(cherry picked from commit 4b15965daa99044daf184221b7c283bf7f2d7e66)
libc/amd64: rewrite memrchr() scalar impl. to read the string from the back
A very simple implementation as I don't have the patience right now
to write a full SWAR kernel. Should still do the trick if you wish
to opt out of SSE for some reason.
Reported by: Mikael Simonsson <m at mikaelsimonsson.com>
Reviewed by: strajabot
PR: 288321
MFC after: 1 month
(cherry picked from commit 30acc84270266e41f66cf572f67c3290d923da2f)
kern: replace several EBADF with EINVAL
EBADF semantic is that the passed fd is invalid, not that it is of wrong
type. Using EBADF in these places in kern_event.c and sys_procdesc.c
give bad examples to copy from.
Note that places in kern_event.c that checks KQ_CLOSING and return EBADF
are kept, since KQ_CLOSING is the transient state before the fd is
finally closed and become eligible for EBADF.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D52410
[net80211] Quieten the logging from ieee80211_vht_get_vhtflags()
The commit in Fixes: introduced logging the output bits from
ieee80211_vht_get_vhtflags(). This ends up causing quite a lot
of logging when net80211 is doing things like processing
received beacons.
So just remove the logging; if it's needed again then a developer
can add it back to that location, or just use dtrace to capture
the return value.
Fixes: 4bf049bfeefd9
Differential Revision: https://reviews.freebsd.org/D52142
Reviewed by: bz
man: Add -l option
Add a -l option which causes man to interpret all arguments as paths to
open directly rather than man pages to search for in MANPATH. See the
PR for a detailed rationale.
PR: 289245
MFC after: 1 week
Reviewed by: ziaee, emaste
Differential Revision: https://reviews.freebsd.org/D52385
contrib/libxo: fix API header files inclusions in C++ source files
C++ source files need `extern "C"` to disable C++ name mangling.
MFC after: 1 week
Reviewed by: aokblast (previous version), phil, imp (previous version)
Differential Revision: https://reviews.freebsd.org/D47930
share/mk: Fix a heuristic in bsd.cpu.mk
When cross-building from MacOS we have MACHINE=arm64 MACHINE_ARCH=arm,
so bsd.cpu.mk infers that sizeof(long) == 4, but of course it isn't.
This breaks the bootstrap build of openssl, which tests
MACHINE_ABI:Mlong64 to decide whether to build ecp_nistp224.c. It
doesn't, and crypto/openssl/freebsd/include/openssl/configuration.h
undefines OPENSSL_NO_EC_NISTP_64_GCC_128, so we end up with a link
error.
Reviewed by: ngie, emaste
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D52340
BSD.usr.dist: remove obsolete usr/share/examples/drivers entry
In base 8f0a6a9aadb1f, usr/share/examples/drivers was cleaned up,
because it contained unmaintained scripts. The directory itself is
cleaned up by ObsoleteFiles.inc, but there was still an entry in
BSD.usr.dist that re-created the directory. Remove it.
Fixes: 8f0a6a9aadb1
MFC after: 3 days
nfsd: Fix the NFSv4 Readdir operation for an empty ZFS dir
Commit 9a3edc8 modified the behaviour of ZFS's
VOP_READDIR() such that it will reply EINVAL for
an offset past EOF on the directory.
This exposed a latent bug in the NFSv4 Readdir
code, which would attempt a Readdir with an
offset beyond EOF for a directory that consists
of only "." and "..". This happened because NFSv4
does not reply "." or ".." to the client and, after
skipping over them, attempted another VOP_READDIR().
This patch fixes the problem by checking the eofflag
for the case where all entries have been skipped over.
Reviewed by: kib
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D52370
[2 lines not shown]
rtwn: enable seqno offload; migrate to use ieee80211_output_seqno_assign()
This should both enable the sequence number offloading and disable
the net80211 TX lock from being acquired/released/checked.
Locally tested:
* RTL8812AU, STA mode
Reviewed by: bz
Differential Revision: https://reviews.freebsd.org/D52301
Differential Revision: https://reviews.freebsd.org/D50693
stand: Remove Spleen 32x64 fonts from INDEX
The Spleen 32x64 fonts cause some systems such as the AMD Framework 16
to boot extremely slowly. Adding screen.font="16x32" to
/boot/loader.conf is a partial workaround, but text displayed before the
boot menu still takes ~30 seconds to render on that laptop. With this
change, the same text renders immediately.
By leaving the font files in place but removing them from the INDEX,
users who want to use them can still load them manually. Once pending
work is committed to allow normal booting with these fonts, they can be
added back to the INDEX.
PR: 289007
Reviewed by: emaste, kevans, tsoome, ziaee
Fixes: 1ec2c8b2f364 (stand: Enable Spleen 32x64 font in the bootloader)
Sponsored by: The FreeBSD Foundation
LinuxKPI: devres: divorce dem_kfree from lkpi_devm_kmalloc_release
dem_kfree() is called from all over the place and should actually
do something; contrary to lkpi_devm_kmalloc_release() it can also
take a const void *. We have to __DECONST() that though as the
entire devres framework does otherwise not take a const argument.
This was discovered during the rtw89 upadte to 6.16.
Sponsored by: The FreeBSD Foundation (initially)
MFC after: 3 days
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52082