]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 months agopf: fix packet-to-big for route-to as well
Kristof Provost [Tue, 27 Feb 2024 13:24:25 +0000 (14:24 +0100)]
pf: fix packet-to-big for route-to as well

When we handle a packet via route-to (i.e. pf_route6()) we still need to
verify the MTU. However, we only run that check in the forwarding case.

Set the PFIL_FWD tag when running the pf_test6(PF_OUT) check from
pf_route6(). We are in fact forwarding, so should call the test function
as such. This will cause us to run the MTU check, and generate an ICMP6
packet-too-big error when required.

See also: 54c62e3e5d8cd90c5571a1d4c8c5f062d580480e
See also: f1c0030bb05cfa01bdd500e50befbb425fecc4c4
See also: https://redmine.pfsense.org/issues/14290
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 months agopci_vendors: update to 2024.02.02
Baptiste Daroussin [Tue, 27 Feb 2024 13:01:11 +0000 (14:01 +0100)]
pci_vendors: update to 2024.02.02

3 months agodumprestore.h: Fix typos in source code comments
Gordon Bergling [Tue, 27 Feb 2024 12:49:21 +0000 (13:49 +0100)]
dumprestore.h: Fix typos in source code comments

- s/dumpped/dumped/

MFC after: 3 days

3 months agovge(4): Fix a typo in a source code comment
Gordon Bergling [Tue, 27 Feb 2024 12:42:10 +0000 (13:42 +0100)]
vge(4): Fix a typo in a source code comment

- s/opration/operation/

MFC after: 3 days

3 months agostress2: Added a few regression tests
Peter Holm [Tue, 27 Feb 2024 10:05:26 +0000 (11:05 +0100)]
stress2: Added a few regression tests

3 months agosched: Simplify sched_lend_user_prio_cond()
Olivier Certner [Fri, 9 Feb 2024 18:03:22 +0000 (19:03 +0100)]
sched: Simplify sched_lend_user_prio_cond()

If 'td_lend_user_pri' has the expected value, there is no need to check
the fields that sched_lend_user_prio() modifies, they either are already
good or soon will be ('td->td_lend_user_pri' has just been changed by
a concurrent update).

Reviewed by:            kib
Approved by:            emaste (mentor)
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D44050

3 months agoPP mutexes: lock: Reduce 'umtx_lock' holding before taking the user lock
Olivier Certner [Thu, 22 Feb 2024 09:13:38 +0000 (10:13 +0100)]
PP mutexes: lock: Reduce 'umtx_lock' holding before taking the user lock

There is no need to have it for the priority check (that the thread
doesn't have a higher priority than the mutex's ceiling), and there's
also no need to take it if the thread doesn't have privileges to set its
priority to the mutex's ceiling.

While here, turn 'su' into a 'bool' and compute the internal priority
corresponding to the mutex's ceiling once and for all, putting it in new
'new_pri'.

Reviewed by:            kib
Approved by:            emaste (mentor)
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D44045

3 months agoPP mutexes: lock: Check if priority is too high against base one
Olivier Certner [Thu, 22 Feb 2024 08:53:51 +0000 (09:53 +0100)]
PP mutexes: lock: Check if priority is too high against base one

Doing this instead of using the current (user) priority, which includes
current lendings, prevents gratuitous failures for threads involved in
multiple locking groups, where each group is defined as the threads that
can lock a particular PP or PI mutex.  No deadlock can occur in this
case.  Indeed, if a thread holds such a lock A giving it a higher
priority than the ceiling of some other lock B that is PP, and B is
acquired by another thread, effectively the latter may not be able to
run but this situation can only last until the first thread releases A,
which it will do eventually.

Reviewed by:            kib
Approved by:            emaste (mentor)
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D44044

3 months agoPP mutexes: unlock: Reset inherited prio regardless of privileges
Olivier Certner [Tue, 20 Feb 2024 13:52:40 +0000 (14:52 +0100)]
PP mutexes: unlock: Reset inherited prio regardless of privileges

'uq_inherited_pri' contains the current priority inherited from Priority
Protection mutexes.  If -1 is passed through 'm_ceilings[1]', meaning
that there are no such mutexes held anymore, this must be reflected into
it by setting it to PRI_MAX, regardless of whether the thread has
privilege to set realtime priorities (PRI_MAX is also obviously not
a realtime priority level).  By contrast, it shall not be updated and
the computed 'new_inherited_pri' shall stay unused if the thread doesn't
have the ability to set a realtime priority, possibly keeping an older
such priority acquired previously.

Reviewed by:            kib
Approved by:            emaste (mentor)
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43984

3 months agopam_xdg: Reset rv to 0
Emmanuel Vadot [Tue, 27 Feb 2024 07:05:00 +0000 (08:05 +0100)]
pam_xdg: Reset rv to 0

Otherwise on success it ontain the return value of asprintf.

Sponsored by: Beckhoff Automation GmbH & Co. KG
Fixes: 2d2950c88933 ("pam_xdg: Check asprintf return value")

3 months agopam_xdg: Check asprintf return value
Emmanuel Vadot [Tue, 27 Feb 2024 06:41:59 +0000 (07:41 +0100)]
pam_xdg: Check asprintf return value

Reported by: Shawn Webb <shawn.webb@hardenedbsd.org>
Sponsored by:   Beckhoff Automation GmbH & Co. KG
Fixes: 6e69612d5df1 ("pam: Add pam_xdg module")
3 months agopam_xdg: Remove leftover debug printf
Emmanuel Vadot [Tue, 27 Feb 2024 06:39:13 +0000 (07:39 +0100)]
pam_xdg: Remove leftover debug printf

Sponsored by: Beckhoff Automation GmbH & Co. KG
Fixes: 6e69612d5df1 ("pam: Add pam_xdg module")

3 months agoloader: Add loader.exit
Warner Losh [Tue, 27 Feb 2024 03:19:58 +0000 (20:19 -0700)]
loader: Add loader.exit

Add loader.exit(status). While one can get alomst this behavior with
loader.perform("quit"), quit doesn't allow a value to be returned to the
firmware. The interpretation of 'status' is firmware specific. This can
be used when autobooting doesn't work in scripts, for example, to allow
the firmware to try something else...

Sponsored by: Netflix

Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D44094

3 months agopcm.4: Fix lint warnings
Christos Margiolis [Mon, 26 Feb 2024 23:28:53 +0000 (00:28 +0100)]
pcm.4: Fix lint warnings

Ignore the "manual not found" warnings for snd_ai2s(4) and
snd_davbus(4).

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D43996

3 months agosnd_uaudio(4): Fix sample rate selection after 42fdcd9fd917.
Florian Walpen [Mon, 26 Feb 2024 23:27:47 +0000 (00:27 +0100)]
snd_uaudio(4): Fix sample rate selection after 42fdcd9fd917.

The sample rate selection of snd_uaudio(4) at runtime was implicitly
relying on a specific order in the device config list. In case a default
was set through the hw.usb.uaudio.default_rate sysctl tunable, commit
42fdcd9fd917 removed a duplicate sample rate entry from that list, which
inadvertently broke sample rate selection at runtime. Implement sample
rate selection in a way that works for any order in the device config
list.

Reported by: Lexi Winter <lexi@le-fay.org>
MFC after: 1 week
Reviewed by: christos
Differential Revision: https://reviews.freebsd.org/D44051

3 months agoofwdump: Convert ints that are booleans to bool.
Warner Losh [Mon, 26 Feb 2024 23:14:53 +0000 (16:14 -0700)]
ofwdump: Convert ints that are booleans to bool.

No functional changes...

Sponsored by: Netflix

3 months agortld-elf: support either byte-order of hints file
Stefan Eßer [Mon, 26 Feb 2024 22:18:12 +0000 (23:18 +0100)]
rtld-elf: support either byte-order of hints file

Accept either little-endian or big-endian representation of the ELF
hints magic number in the header of a hints file and convert the
parameters to the native byte-order of the repsective system.

This is a pre-requisite for a planned change to always write the byte
order in little-endian format on all architectures. The only relvant
architecture that uses big-endian data is powerpc64, and it is not
likely that new architectures will choose that representation of data
in memory.

When all supported architectures use little-endian data in the hints
file, the byte swap logic can be enabled for big-endian CPUs at
compile time. Up to that point, there is a very small run-time penalty
that is paid on all systems to check the byte-order of the hints file
and to provide the option to byte-swap the parameters read from the
hints file header.

This commit contains the changes from review D44080 (which had been
split off from this patch for easier review),

Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D44053

3 months agokern: fix panic with disabled ttys
Ed Maste [Mon, 26 Feb 2024 15:38:45 +0000 (10:38 -0500)]
kern: fix panic with disabled ttys

PR: 277240, 277329
Reviewed by: kib (earlier version)
Fixes: f1d0a0cbecf2 ("jail: Fix information leak.")
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D44086

3 months agodiff: Bump manual page date.
Dag-Erling Smørgrav [Mon, 26 Feb 2024 18:21:40 +0000 (19:21 +0100)]
diff: Bump manual page date.

Sponsored by: Klara, Inc.

3 months agodiff: Fix --expand-tabs and --side-by-side.
Dag-Erling Smørgrav [Mon, 26 Feb 2024 18:08:06 +0000 (19:08 +0100)]
diff: Fix --expand-tabs and --side-by-side.

* Overhaul column width and padding calculation.
* Rewrite print_space() so it is now a) correct and b) understandable.
* Rewrite tab expansion in fetch() for the same reason.

This brings us in line with GNU diff for all cases I could think of.

Sponsored by: Klara, Inc.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D44014

3 months agopam: Always use pam_xdg for session and xdm
Emmanuel Vadot [Thu, 22 Feb 2024 05:46:08 +0000 (06:46 +0100)]
pam: Always use pam_xdg for session and xdm

This ensure that the XDG_RUNTIME_DIR is always created and the environment
variable is present which is a must for any wayland user (at least).
The only "cost" of it is a directory is created and unused.

Reviewed by: des
Differential Revision: https://reviews.freebsd.org/D44012
Sponsored by: Beckhoff Automation GmbH & Co. KG

3 months agopam: Add pam_xdg module
Emmanuel Vadot [Wed, 21 Feb 2024 14:51:05 +0000 (15:51 +0100)]
pam: Add pam_xdg module

This is a module to setup the XDG directories and environment variables.
For now the only usage is to have a XDG_RUNTIME_DIR environment setup at
user login.
All other environment variable have a default fallback so no need to export
them in this module.
The directory is created according to the XDG Base directory specification.

The default base directory is /var/run/xdg/<username> but can be configured
using the runtime_dir=<dir> module option.

According to the spec the directory *must* not survive a reboot so adding
var_run_enable="YES" to rc.conf is highly recommanded.

Reviewed by: des, pauamma (manpages)
Differential Revision: https://reviews.freebsd.org/D44011
Sponsored by: Beckhoff Automation GmbH & Co. KG

3 months agoipsec esp: avoid dereferencing freed secasindex
Konstantin Belousov [Sun, 25 Feb 2024 10:30:48 +0000 (12:30 +0200)]
ipsec esp: avoid dereferencing freed secasindex

It is possible that SA was removed while processing packed, in which
case it is changed to the DEAD state and it index is removed from the
tree. Dereferencing sav->sah then touches freed memory.

Reviewed by: ae
Sponsored by: NVIDIA networking
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D44079

3 months agoloader: we can only env_discard() existing variable
Toomas Soome [Sun, 25 Feb 2024 22:34:00 +0000 (00:34 +0200)]
loader: we can only env_discard() existing variable

While dropping nvpair from nvstore, we also remove the corresponding
environment variable. By doing so, we should be careful not to try
to unset non-existing variable.

Reviewed by: imp
MFC after:      2 week
Differential revision:  https://reviews.freebsd.org/D44083

3 months agoMFV: xz 5.6.0.
Xin LI [Sun, 25 Feb 2024 23:46:22 +0000 (15:46 -0800)]
MFV: xz 5.6.0.

MFC after: 2 weeks

3 months agosnd_hdspe(4): Optional unified pcm device.
Florian Walpen [Sun, 25 Feb 2024 21:39:36 +0000 (21:39 +0000)]
snd_hdspe(4): Optional unified pcm device.

Add a sysctl tunable to unify all physical ports of an HDSPe sound card
into one pcm device, with up to 14 (AIO) or 36 (RayDAT) channels. This
makes all ports available in multi-channel audio software.

Differential Revision: https://reviews.freebsd.org/D43798

3 months agolibc/sys: add errno test
Konstantin Belousov [Sat, 24 Feb 2024 23:39:02 +0000 (01:39 +0200)]
libc/sys: add errno test

Despite looking trivial, it requires proper split of exports from libsys
and libc, proper filtering work in rtld, and operational libsys.

Reviewed by: emaste, imp
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D44075

3 months agoVendor import of xz 5.6.0 (trimmed)
Xin LI [Sun, 25 Feb 2024 19:07:13 +0000 (11:07 -0800)]
Vendor import of xz 5.6.0 (trimmed)

3 months agotcp: need default in switch statement for enum.
Richard Scheffenegger [Sun, 25 Feb 2024 07:23:07 +0000 (08:23 +0100)]
tcp: need default in switch statement for enum.
fix clang error after c9b6241e250a4f1156e2150ccdbad0d3029dcef6

Reviewed By: imp
Differential Revision: https://reviews.freebsd.org/D44081

3 months agotcp: address enum-int-mismatch
Richard Scheffenegger [Sun, 25 Feb 2024 03:45:05 +0000 (04:45 +0100)]
tcp: address enum-int-mismatch
fix gcc13 error after f74352fbcf15341accaf5a92240871f98323215d

3 months agotcp_rack.4: Fix a link in the SEE ALSO section
Gordon Bergling [Sun, 25 Feb 2024 09:16:25 +0000 (10:16 +0100)]
tcp_rack.4: Fix a link in the SEE ALSO section

The URL of the paper at arxiv.org has changed so link the
PDF-file directly.

MFC after: 3 days

3 months agosigsys test: correct count of delivered signals
Konstantin Belousov [Sun, 25 Feb 2024 01:36:27 +0000 (03:36 +0200)]
sigsys test: correct count of delivered signals

When knob is zero, intent is that no SIGSYS signals are delivered.
Comparing zero to zero does not test much, we should compare the count
of delivered SIGSYSs to zero.

Reviewed by: dchagin, imp
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D44077

3 months agoloader/efi: Only include interpreter's linker script
Warner Losh [Sun, 25 Feb 2024 00:57:29 +0000 (17:57 -0700)]
loader/efi: Only include interpreter's linker script

For safety, only include the interpreter's linker script. Note that the
simple loader doesn't have one, but it's not an error to copy a ELF
section that does not exist. No functional change, however.

Sponsored by: Netflix
Reviewed by: tsoome, kevans
Differential Revision: https://reviews.freebsd.org/D44064

3 months agoloader/ficl: Rename the ficl compile set to X4th_compile_set
Warner Losh [Sun, 25 Feb 2024 00:57:21 +0000 (17:57 -0700)]
loader/ficl: Rename the ficl compile set to X4th_compile_set

And upcoming change will need this set to be named this. Since it's only
used in the efi Makefile, and inside if ficl itself, the change should
be a nop.

Sponsored by: Netflix
Reviewed by: tsoome, kevans
Differential Revision: https://reviews.freebsd.org/D44063

3 months agoloader/efi: Use unique linker set for lua
Warner Losh [Sun, 25 Feb 2024 00:57:13 +0000 (17:57 -0700)]
loader/efi: Use unique linker set for lua

After the linker set cleanup in ldscripts, there's now only one place we
need to know the linkerset name, so go ahead and change the lua
interpreter augmentation linker set to be uniquely named.

Sponsored by: Netflix
Reviewed by: tsoome, kevans
Differential Revision: https://reviews.freebsd.org/D44062

3 months agoloader/efi: Linker sets not needed.
Warner Losh [Sun, 25 Feb 2024 00:57:04 +0000 (17:57 -0700)]
loader/efi: Linker sets not needed.

We don't need linker sets listed as sections. They are explicitly
included in the objcopy we use to create the .efi file. This practice
was added in 2002 by peter@ in a6d81d83a280 to make ia64 builds
self-hosted. However, it was added back to the objcopy in 2010 by rpaulo
in 8df7a05edd36 for i386 EFI support, though the ldscript file then
retained them needlessly. The gcc/binutils bug having been fixed in the
interim. We've not needed them since then, but the redundancy didn't
matter.

Sponsored by: Netflix
Reviewed by: tsoome, kevans
Differential Revision: https://reviews.freebsd.org/D44061

3 months agoloader/kboot: simplify linker set inclusion a little
Warner Losh [Sun, 25 Feb 2024 00:56:56 +0000 (17:56 -0700)]
loader/kboot: simplify linker set inclusion a little

Linker set sections are included by default. No need to do so
explicitly.  These were bogusly copied from the efi ldscripts. They were
there due to a workaround introduced in 2002 by peter@ for a gcc
upgrade, but whatever bugs necessitated it were filed by 2010 when
rpaulo@ imported the i386 support (though they were copied even though
the objcopy retained them correctly, the gcc bug having been
fixed). They've never been needed.

Sponsored by: Netflix
Reviewed by: tsoome, kevans
Differential Revision: https://reviews.freebsd.org/D44060

3 months agoloader/uboot: Move to foo.ldconfig
Warner Losh [Sun, 25 Feb 2024 00:56:48 +0000 (17:56 -0700)]
loader/uboot: Move to foo.ldconfig

Move to the foo.ldconfig convention to match the rest of the boot
loader. No functional change intended.

Sponsored by: Netflix
Reviewed by: tsoome, kevans
Differential Revision: https://reviews.freebsd.org/D44059

3 months agoloader/powerpc: Share ldscript
Warner Losh [Sun, 25 Feb 2024 00:56:31 +0000 (17:56 -0700)]
loader/powerpc: Share ldscript

Share ldscript between the different ppc versions. There's two different
scripts since we build 32-bit binaries for all types of powerpc, but
have little endian and big endian variations that are different by only
two lines. Set the output format and include the rest.

Move to foo.ldscript as well.

Sponsored by: Netflix
Reviewed by: tsoome, kevans
Differential Revision: https://reviews.freebsd.org/D44058

3 months agokboot: Centralize ldscript addition
Warner Losh [Sun, 25 Feb 2024 00:56:23 +0000 (17:56 -0700)]
kboot: Centralize ldscript addition

Make the pattern for ldscripts always be
arch/$MACHINE_ARCH/$MACHINE_ARCH.ldscript so we can add it from a
central Makefile. This also moves from ldscript.arch to arch.ldscript to
match the loader's new convention.

Sponsored by: Netflix
Reviewed by: tsoome, kevans
Differential Revision: https://reviews.freebsd.org/D44057

3 months agoloader: Move ldscripts to match more standard practices
Warner Losh [Sun, 25 Feb 2024 00:56:14 +0000 (17:56 -0700)]
loader: Move ldscripts to match more standard practices

In the larger open source community, ld scripts are foo.ldscrpt rather
than ldscript.arch like we use here. This moves the EFI ldscripts.

Sponsored by: Netflix
Reviewed by: tsoome, kevans, emaste
Differential Revision: https://reviews.freebsd.org/D44056

3 months agotcp: retain some CC signals outside of kernel scope
Richard Scheffenegger [Sat, 24 Feb 2024 20:01:54 +0000 (21:01 +0100)]
tcp: retain some CC signals outside of kernel scope

Summary: fix build error after f74352fbcf15341accaf5a92240871f98323215d

Reviewers: #transport!

Subscribers: imp, melifaro, glebius

Differential Revision: https://reviews.freebsd.org/D44066

3 months agosctp: improve sending of packets containing an INIT ACK chunk
Michael Tuexen [Sat, 24 Feb 2024 18:16:36 +0000 (19:16 +0100)]
sctp: improve sending of packets containing an INIT ACK chunk

If the peer announced support of zero checksums, do so when sending
packets containing an INIT ACK chunk.

MFC after: 1 week

3 months agotcp: cubic - restart epoch after RTO
Richard Scheffenegger [Sat, 24 Feb 2024 16:07:25 +0000 (17:07 +0100)]
tcp: cubic - restart epoch after RTO

This is a migitation to avoid sudden extreme jumps in
cwnd, as t_epoch can be very out of date after an RTO.
Per RFC9438, sec 4.8, t_epoch is to be reset whenever
cwnd grows beyond ssthresh (CC phase transitions from
slow start to congestion avoidance), to be fixed with
the upcoming cc_cubic changes.

MFC after: 3 days
Reviewed By: cc, #transport
Sponsored by: NetApp, Inc
Differential Revision: https://reviews.freebsd.org/D44023

3 months agotcp: provide correct snd_fack on post_recovery
Richard Scheffenegger [Sat, 24 Feb 2024 15:53:32 +0000 (16:53 +0100)]
tcp: provide correct snd_fack on post_recovery

Ensure that snd_fack holds a valid value when doing
the post_recovery CC processing, for preparation of
the cc_cubic update, so that local pipe calculations
can correctly refer to snd_fack during and after CC events.

Reviewed By: tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D43957

3 months agotcp: use enum for all congestion control signals
Richard Scheffenegger [Sat, 24 Feb 2024 15:41:31 +0000 (16:41 +0100)]
tcp: use enum for all congestion control signals

Facilitate easier troubleshooting by enumerating
all congestion control signals. Typecast the
enum to int, when a congestion control module uses
private signals.

No external change.

Reviewed By: glebius, tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D43838

3 months agotcp: prevent div by zero in cc_htcp
Richard Scheffenegger [Sat, 24 Feb 2024 15:35:23 +0000 (16:35 +0100)]
tcp: prevent div by zero in cc_htcp

Make sure the divident is at least one. While cwnd should
never be smaller than t_maxseg, this can happen during
Path MTU Discovery, or when TCP options are considered
in other parts of the stack.

PR: 276674
MFC after: 3 days
Reviewed By: tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D43797

3 months agoif_hn: Fix two typos in source code comments
Gordon Bergling [Sat, 24 Feb 2024 09:13:44 +0000 (10:13 +0100)]
if_hn: Fix two typos in source code comments

- s/managment/management/
- s/transacion/transaction/

Obtained from: NetBSD
MFC after: 3 days

3 months agostress2: Add a helper tool
Peter Holm [Sat, 24 Feb 2024 06:26:16 +0000 (07:26 +0100)]
stress2: Add a helper tool

3 months agostress2: Added a new NFS test scenario
Peter Holm [Sat, 24 Feb 2024 05:47:12 +0000 (06:47 +0100)]
stress2: Added a new NFS test scenario

3 months agoloader: rename gfx_interp_md to gfx_interp_ref
Warner Losh [Sat, 24 Feb 2024 04:22:08 +0000 (21:22 -0700)]
loader: rename gfx_interp_md to gfx_interp_ref

We have the call to gfx_interp_ref to bring in the .o so that we get the
linker set item to add the language bindings at the right time. Where we
call it is not the right time... So the _ref name is better. Change it
before we have too many others like it.

Sponsored by: Netflix

3 months agolagg: wrap lagg_port2req() into LAGG_SLOCK()
Gleb Smirnoff [Sat, 24 Feb 2024 01:56:46 +0000 (17:56 -0800)]
lagg: wrap lagg_port2req() into LAGG_SLOCK()

Although a port addition is coded in a sequence where first all softc
information is fulfilled and only then it is attached to the lagg, we
still need a locking primitive to guarantee cache invalidation.  Panic
observed in the wild shows that lacp_portreq() called via
lagg_port_ioctl(SIOCGLAGGPORT) immediately after port creation may see
lp->lp_psc as NULL and panic.  In the core file we will see valid data
all around.  A race via lagg_ioctl() wasn't observed but potentially
is possible.

Differential Revision: https://reviews.freebsd.org/D43501

3 months agotests/fdgrowtable: perform the threaded test in a child process
Gleb Smirnoff [Sat, 24 Feb 2024 01:49:53 +0000 (17:49 -0800)]
tests/fdgrowtable: perform the threaded test in a child process

The test needs to be performed in a new process that was forked with
RFCFDG flag.  The will guarantee that the table will start to grow from 20
file descriptors, no matter what kyua(1) or a bare shell was doing before
executing this test.  This should fix  repetitive test runs from a shell
as well as failures with kyua(1) in some environments.

3 months agoRevert "tests/fdgrowtable: open more files in the threaded case"
Gleb Smirnoff [Sat, 24 Feb 2024 01:47:29 +0000 (17:47 -0800)]
Revert "tests/fdgrowtable: open more files in the threaded case"

This reverts commit fa6a02f50e65c47540f51b3177f5080bc6af168e.

It makes the test less probable to fail, but it doesn't fix the
root issue - that on entry the parent process may have already
a large file descriptor table.

3 months agoposixmqcontrol(1): manage posix message queues
Rick Parrish [Thu, 22 Feb 2024 12:33:12 +0000 (06:33 -0600)]
posixmqcontrol(1): manage posix message queues

Reviewed by: kib, paumma
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D43845

3 months agolibsys: remove duplicate, commented out code
Brooks Davis [Fri, 23 Feb 2024 18:01:18 +0000 (18:01 +0000)]
libsys: remove duplicate, commented out code

3 months agosctp: improve consistency
Michael Tuexen [Fri, 23 Feb 2024 20:40:46 +0000 (21:40 +0100)]
sctp: improve consistency

MFC after: 1 week

3 months agosnd_hda: add 32-bit memory quirk for Creative Sound Blaster Audigy FX
Gleb Smirnoff [Fri, 23 Feb 2024 19:30:13 +0000 (11:30 -0800)]
snd_hda: add 32-bit memory quirk for Creative Sound Blaster Audigy FX

Despite still being in production the device appeared not able to use
memory above BUS_SPACE_MAXADDR_32BIT, and if your desktop has a lot of
memory there is a high chance driver would allocate inaccessible memory.

Submitted by: wulf
Reviewed by: mav

3 months agolibsys: fix sleep(3)/usleep(3) cancel behavior
Konstantin Belousov [Fri, 23 Feb 2024 14:53:10 +0000 (16:53 +0200)]
libsys: fix sleep(3)/usleep(3) cancel behavior

Move functions back to libc/gen sources; they are only versioned from
libc and not libsys.
Access libsys interposing slots using __libsys_interposing_slot()
instead of direct __libsys_interposing array dereference, which cannot
work from libc.

Reported by: glebius
Reviewed by: brooks
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D44042

3 months agolibsys: link symbolic
Konstantin Belousov [Thu, 22 Feb 2024 21:13:02 +0000 (23:13 +0200)]
libsys: link symbolic

so that libc/libthr do not preempt libsys symbols, esp. errno-related.

The issue is, if libsys is linked with DT_BIND_NOW flag, and then loaded
as filter, rtld tries to relocate its PLT symbols immediately, not as
filter.  There, during symbol lookup, rtld finds filtering symbols in
libc, and since libc is in loading filters mode, the resolution stops
there.  The end result is that libsys links to libc.

Reviewed by: brooks
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D44027

3 months agofs/msdosfs fatblock: use ulmin() rather than min()
Konstantin Belousov [Fri, 23 Feb 2024 17:30:10 +0000 (19:30 +0200)]
fs/msdosfs fatblock: use ulmin() rather than min()

to avoid truncation of pmp->pm_FATsecs.

Submitted by: Robert Morris <rtm@lcs.mit.edu>
PR: 277237
MFC after: 1 week

3 months agopf: Correct SPDX identifier
Tom Jones [Fri, 23 Feb 2024 15:58:38 +0000 (15:58 +0000)]
pf: Correct SPDX identifier

Pointed out by: Mike Karels <karels@FreeBSD.org>

3 months agopf: Add a TCP rdr test on IPv6
Tom Jones [Fri, 6 Oct 2023 13:19:31 +0000 (14:19 +0100)]
pf: Add a TCP rdr test on IPv6

Reviewed by:    kp
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision: https://reviews.freebsd.org/D42105

3 months agotests: Fixing incomplete atf_skip if missing jail condition
Olivier Cochard [Fri, 23 Feb 2024 12:02:40 +0000 (13:02 +0100)]
tests: Fixing incomplete atf_skip if missing jail condition

Testing the scripts outside kyua(1) was a bad idea:
It didn't allow me to detect that they were faulty.

Sponsored by: Netflix

3 months agohostname(1): skip test if jail binary is missing
Olivier Cochard [Fri, 23 Feb 2024 09:46:34 +0000 (10:46 +0100)]
hostname(1): skip test if jail binary is missing

Approved by: lwhsu
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D44005

3 months agojail: skip sysctl_security_jail_children if jail binary missing
Olivier Cochard [Fri, 23 Feb 2024 09:43:54 +0000 (10:43 +0100)]
jail: skip sysctl_security_jail_children if jail binary missing

Approved by: lwhsu
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D44010

3 months agoefibootmgr: Simplify make_next_boot_var_name and fix cnt == 0 case
Jessica Clarke [Fri, 23 Feb 2024 02:36:21 +0000 (02:36 +0000)]
efibootmgr: Simplify make_next_boot_var_name and fix cnt == 0 case

If cnt == 0 we access element 0 unconditionally, which is out of bounds,
and then if that doesn't crash and happens to be 0 we will access
element - 1, also out of bounds, and then if that doesn't crash will add
1 to whatever junk is there and use that for the variable. On CHERI,
though, this does crash. This code is also overly complicated, with
unnecessary special cases and tracking more state than needed.

Rewrite it in a more general manner that doesn't need those special
cases and naturally works for cnt == 0.

Found by: CHERI
Reviewed by: imp
Fixes: 1285bcc833a3 ("Import Netflix's efibootmgr to help manage UEFI boot variables")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D44029

3 months agogpiobus: Add missing DEVMETHOD for bus_get_rman
John Baldwin [Fri, 23 Feb 2024 00:14:58 +0000 (16:14 -0800)]
gpiobus: Add missing DEVMETHOD for bus_get_rman

Reported by: andrew
Fixes: 5bda26333a8e gpiobus: Use bus_generic_rman_*

3 months agoLinuxKPI: 802.11: implement a deferred RX path
Bjoern A. Zeeb [Mon, 12 Feb 2024 16:03:13 +0000 (16:03 +0000)]
LinuxKPI: 802.11: implement a deferred RX path

Some calls, e.g., action frames cause us to call through all the
way down to firmware from the RX path without any deferral in
net80211.

For LinuxKPI and iwlwifi this goes (with omissions) like this:
lkpi_napi_task -> linuxkpi_ieee80211_rx -> ieee80211_input_mimo ->
sta_input -> ht_recv_action_ba_addba_request ->
lkpi_ic_ampdu_rx_start -> iwl_mvm_mac_ampdu_action ->
iwl_trans_txq_send_hcmd.  At that point we are waiting for an
interrupt from the firmware but given the lkpi_napi_task has not
finished (and may have more to dispatch based on budget and what
was received) we will not see the new interrupt/fw response.
With no answer from the firmware, the software timeout in the
driver kills the command and the firmware and issues a complete
restart.

Implement the deferred RX path in LinuxKPI for the moment.
At a later point we should carefully shift this into net80211.

This fixes the hangs for (*ic_ampdu_rx_start)() calls with iwlwifi.

MFC after: 3 days
PR: 276083
Reviewed by: cc
Differential Revision: https://reviews.freebsd.org/D43968

3 months agodev/uart: name uart_class_set DATA_SET macro UART_CLASS()
Bjoern A. Zeeb [Mon, 19 Feb 2024 20:40:03 +0000 (20:40 +0000)]
dev/uart: name uart_class_set DATA_SET macro UART_CLASS()

Use the macro "UART_CLASS()" for the newly created data set
'uart_class_set' as we do for other data sets.
This further hides the data set name.
Also add UART_CLASS for quicc, which was previously not done.

MFC after: 1 week
Improves: 949670f8f466 dev/uart: Use a linker set to find uart classes
Obtained from: jhb, https://github.com/freebsd/freebsd/commit/269e99ac86902127bfaee1500d8747a3c7be5912
Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D43981

3 months agoath(4): always enable 11n
Bjoern A. Zeeb [Sun, 18 Feb 2024 18:16:24 +0000 (18:16 +0000)]
ath(4): always enable 11n

Enabling 11n for ath(4) so far was handled by a kernel option, which
was only enabled for certain kernel configurations.
In order to allow loading ath(4) as a module with 11n support on
all platforms, remove the kernel option and unconditionally enable
11n in ath(4).

Reported by: pkubaj
Discussed with: adrian in D43549.
Reviewed by: adrian, imp
Differential Revision: https://reviews.freebsd.org/D43964

3 months agorescue: Stop using LDADD_zstd
Jessica Clarke [Thu, 22 Feb 2024 20:56:05 +0000 (20:56 +0000)]
rescue: Stop using LDADD_zstd

Ideally we'd be able to use LDADD_foo here for all our various libs and
get the implicit dependencies, but rescue is a bit special. Historically
this was just used to pick up the "private" in the name automatically
(as far as I can tell), but now that _DP_pthread includes c we end up
pulling in a -lc from this (along with -lcompiler_rt and -lsys). This
results in -lc being before -lmd (and after, implictly, from the
compiler driver), which, for the specific situation here, results in
both libc.a's and libmd.a's md5c.o being included, giving duplicate
definitions of _libmd_MD5Init and other symbols. With LLD 16+ we
currently make that not an error for other reasons (which should
probably be fixed), but not for older versions, nor for BFD, and so the
build fails.

Fix all this by just using -lprivatezstd in place of LDADD_zstd, which
results in the exact same clang command line as we used to have prior to
adding c (and sys) to _DP_pthread when linking rescue. Note that bsdbox
already uses -lprivatezstd rather than LDADD_zstd.

This reverts commit 5fead429ebb3800fdd3fc0817d2c330b2a8d640f.

Reviewed by: imp
Fixes: 99ea67573164 ("lib{c,sys}: move auxargs more firmly into libsys")

3 months agobge(4): Fix some typos in source code comments
Gordon Bergling [Thu, 22 Feb 2024 19:38:50 +0000 (20:38 +0100)]
bge(4): Fix some typos in source code comments

- s/firwmare/firmware/
- s/recue/reduce/
- s/throughpout/throughput/
- s/hardwares/hardware/

Obtainted from: NetBSD
MFC after: 3 days

3 months agoAdd link from if_iwlwifi(4) to iwlwifi(4)
Li-Wen Hsu [Thu, 22 Feb 2024 18:45:22 +0000 (02:45 +0800)]
Add link from if_iwlwifi(4) to iwlwifi(4)

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

3 months agoacpi: Defer reserving resources for ACPI devices
John Baldwin [Thu, 22 Feb 2024 18:43:43 +0000 (10:43 -0800)]
acpi: Defer reserving resources for ACPI devices

The goal of reserving firmware-assigned resources is to ensure that
"wildcard" resource allocation requests will not claim an address
range that is actually in use even if no attached driver is actively
using that range.  However, the current approach can break in some
cases.

In particular, ACPI can enumerate devices behind PCI bridges that
don't show up in a normal PCI scan, but those device_t objects can end
up as direct children of acpi0.  Reserving resources for those devices
directly from acpi0 ends up conflicting with later attempts to reserve
the PCI bridge windows.

As a workaround, defer reserving unclaimed resources until after the
initial probe and attach scan.  Eventually this pass of reserving
unclaimed resources can be moved earlier, but it requires changes to
other drivers in the tree to permit enumerating devices and reserving
firmware-assigned resources in a depth-first traversal before
attaching devices whose drivers request wildcard allocations.

PR: 272507
Reported by: Justin Tocci <justin@tocci.org>
Reported by: john@feith.com, many others
Tested by: Oleg Sidorkin <osidorkin@gmail.com>, dch

3 months agoarm: Set NEW_PCIB in DEFAULTS rather than a subset of kernel configs
Jessica Clarke [Thu, 22 Feb 2024 18:27:45 +0000 (18:27 +0000)]
arm: Set NEW_PCIB in DEFAULTS rather than a subset of kernel configs

All other architectures set NEW_PCIB in DEFAULTS, with arm being the one
remaining straggler that only sets it for GENERIC and TEGRA124.
ARMADA38X and ARMADAXP contain device pci but don't set NEW_PCIB,
however GENERIC claims to support them and as part of that NEW_PCIB
support was added to mv_pci, so these configs are most likely just
stale. Other than NOTES that just leaves ALPINE as the one kernel with
PCI support not covered by GENERIC, but al_pci is supported by arm64
which enables NEW_PCIB, and it's just a generic_pcie_fdt_driver with
some fixup code to deal with quirks so should support PCI_RES_BUS just
fine. Therefore it is believed that all in-tree kernel configs support
NEW_PCIB in reality, and so let's take a step towards removing all the
non-NEW_PCIB code by having it always-on everywhere.

Reviewed by: emaste, jhb, manu
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D43806

3 months agox86/ucode: add support for early loading of CPU ucode on AMD.
Chuck Silvers [Thu, 22 Feb 2024 18:03:53 +0000 (10:03 -0800)]
x86/ucode: add support for early loading of CPU ucode on AMD.

Sponsored by: Netflix
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D43318

3 months agoAdd missing .endif
Warner Losh [Thu, 22 Feb 2024 17:16:37 +0000 (10:16 -0700)]
Add missing .endif

Last second move from inside the prior block to outside bites me.

Noticed by: jrtc23
Fixes: dcb621efd664
Sponsored by: Netflix

3 months agoloader: Mark BEARSSL broken on powerpc
Warner Losh [Thu, 22 Feb 2024 17:05:40 +0000 (10:05 -0700)]
loader: Mark BEARSSL broken on powerpc

When BEARSSL is enabled, we pull in libsecureboot, which has EFI
dependencies which don't exist on powerpc. This needs to be detangled,
but until then mark it as broken.

Sponsored by: Netflix

3 months agovge(4): Fix a typo in a source code comment
Gordon Bergling [Thu, 22 Feb 2024 16:33:35 +0000 (17:33 +0100)]
vge(4): Fix a typo in a source code comment

- s/embadded/embedded/

MFC after: 3 days

3 months agoloader: These files have no copyrightable material
Warner Losh [Thu, 22 Feb 2024 16:30:59 +0000 (09:30 -0700)]
loader: These files have no copyrightable material

These files have no copyrightable material, and so are in the public
domain.

Sponsored by: Netflix

3 months agolibsa: Remove redundant sys/cdefs.h
Warner Losh [Thu, 22 Feb 2024 15:18:02 +0000 (08:18 -0700)]
libsa: Remove redundant sys/cdefs.h

Sponsored by: Netflix

3 months agoloader: return errors from writing ZFS labels
Warner Losh [Thu, 22 Feb 2024 15:17:56 +0000 (08:17 -0700)]
loader: return errors from writing ZFS labels

vdev_write_bootenv_impl can only return success. Instead, return the
last error.  This will make any write errors more visible. The old code
masked kboot's inability to write bootenv.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D44018

3 months agokboot: Implement write support for hostdisk
Warner Losh [Thu, 22 Feb 2024 15:17:48 +0000 (08:17 -0700)]
kboot: Implement write support for hostdisk

Don't assume that strategy is only called for read. Check the passed
flag for F_READ or F_WRITE and fail if it is neither. Open the disks for
writing and call host_read/host_write depending on that flag.

Sponsored by: Netflix
Reviewed by: kevans, gallatin
Differential Revision: https://reviews.freebsd.org/D44016

3 months agoarm64: Tell userspace when BTI is supported
Andrew Turner [Thu, 26 Oct 2023 09:50:28 +0000 (10:50 +0100)]
arm64: Tell userspace when BTI is supported

To allow userspace to decide when to try enabling BTI report if it's
available via the ID register and hwcaps.

Sponsored by: Arm Ltd

3 months agoarm64: Enable BTI in the kernel ELF loader
Andrew Turner [Thu, 2 Nov 2023 09:56:09 +0000 (09:56 +0000)]
arm64: Enable BTI in the kernel ELF loader

Enable BTI in binaries loaded by the kernel. When the ELF file contains
the needed note indicating BTI is supported set the guarded page flag
for all segments.

Reviewed by: markj
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D42441

3 months agoAdd a BTI sysarch
Andrew Turner [Wed, 5 Apr 2023 12:45:19 +0000 (13:45 +0100)]
Add a BTI sysarch

This is used to enable the guard page when an elf binary is built with
BTI instructions.

Reviewed by: markj
Sponsored by: Arm Ltd
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39453

3 months agoarm64: Add BTI support to pmap
Andrew Turner [Wed, 5 Apr 2023 12:31:41 +0000 (13:31 +0100)]
arm64: Add BTI support to pmap

Add a rangeset to the arm64 pmap to describe which address space needs
the Branch Target Identification (BTI) Guard Page flag set in the page
table.

On hardware that supports BTI the Guard Page flag tells the hardware
to raise an exception if the target of a BR* and BLR* instruction is
not an appropriate landing pad instruction.

To support this in userspace we need to know which address space
should be guarded. For this add a rangeset to the arm64 pmap when the
hardware supports BTI. The kernel can then use pmap_bti_set and
pmap_bti_clear mark and unmark which address space is guarded.

Sponsored by: Arm Ltd
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42328

3 months agosk(4): Fix a typo in a source code comment
Gordon Bergling [Thu, 22 Feb 2024 16:16:49 +0000 (17:16 +0100)]
sk(4): Fix a typo in a source code comment

- /integeated/integrated/
- s/extented/extended/

Obtained from: NetBSD
MFC after: 3 days

3 months agouath(4): Fix a typo in a source code comment
Gordon Bergling [Thu, 22 Feb 2024 15:55:51 +0000 (16:55 +0100)]
uath(4): Fix a typo in a source code comment

- s/parmeter/parameter/

MFC after: 3 days

3 months agorandom(4): Fix a typo in a source code comment
Gordon Bergling [Thu, 22 Feb 2024 15:54:50 +0000 (16:54 +0100)]
random(4): Fix a typo in a source code comment

- s/parmeter/parameter/

MFC after: 3 days

3 months agox86/xen: use correct printf specifier.
Roger Pau Monné [Thu, 22 Feb 2024 14:26:56 +0000 (15:26 +0100)]
x86/xen: use correct printf specifier.

Use %p instead of wrongly casting to uintptr_t and printing with %lx.

Reported by: bapt
Fixes: 9a687d1fe3af ('x86/xen: introduce a Xen early init function')
Sponsored by: Cloud Software Group

3 months agoumcs(4): Fix two typos in source code comments
Gordon Bergling [Thu, 22 Feb 2024 13:14:08 +0000 (14:14 +0100)]
umcs(4): Fix two typos in source code comments

- s/frequences/frequencies/

MFC after: 3 days

3 months agox86/xen: implement early init hook
Roger Pau Monné [Fri, 2 Feb 2024 10:56:32 +0000 (11:56 +0100)]
x86/xen: implement early init hook

Unify the HVM and PVH early setup, byt making both rely on the hypervisor
initialization hook part of identify_hypervisor().

The current initialization takes care of the hypercall page, the sahred info
page and does any fixup necessary to metadata video console information if
FreeBSD is booted as the initial domain (so the video console is handed from
Xen into FreeBSD).

Note this has the nice side effect of also allowing to use the Xen console on
HVM guests, which allows to get rid of the QEMU emulated uart and still get
a nice text console.

Sponsored by: Cloud Software Group
Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D43764

3 months agox86/cpu: introduce an optional hook for early hypervisor initialization
Roger Pau Monné [Fri, 2 Feb 2024 10:36:52 +0000 (11:36 +0100)]
x86/cpu: introduce an optional hook for early hypervisor initialization

Hypervisor detection is done very early on x86, and so can be used to also do
some very early hypervisor related initialization.  Such initialization is
required when running as a Xen PVH guest, as for example the PIT needs to be
replaced with an hypervisor based timecounter.

Introduce an optional hook that gets called as part of the early hypervisor
detection.

No functional change intended.

Sponsored by: Cloud Software Group
Reviewed by: markj kib
Differential revision: https://reviews.freebsd.org/D43763

3 months agox86/xen: replace xen_cpuid_base with hv_base
Roger Pau Monné [Fri, 2 Feb 2024 11:04:50 +0000 (12:04 +0100)]
x86/xen: replace xen_cpuid_base with hv_base

Where possible, replace the usage of xen_cpuid_base for hv_base in preparation
for removing xen_cpuid_base.

No functional change intended.

Sponsored by: Cloud Software Group
Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D43935

3 months agox86/xen: do video console fixup as part of early initialization
Roger Pau Monné [Fri, 2 Feb 2024 10:29:57 +0000 (11:29 +0100)]
x86/xen: do video console fixup as part of early initialization

When FreeBSD is running as dom0 the video console metadata provided by the
bootloader might not be accurate, as Xen has very likely taken over the console
and possibly changed the mode.

Adjust the video console information in the kernel metadata as part of early
Xen initialization.

Sponsored by: Cloud Software Group
Reviewed by: imp
Differential revision: https://reviews.freebsd.org/D43934

3 months agox86/xen: move shared page setup to early init handler
Roger Pau Monné [Fri, 2 Feb 2024 10:20:33 +0000 (11:20 +0100)]
x86/xen: move shared page setup to early init handler

As done with the hypercall page, move the setup fo the shared info page into
the newly introduced helper, which the aim of having a single helper and call
site used by both HVM and PV in order to setup the basic Xen environment.

Sponsored by: Cloud Software Group
Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D43933

3 months agox86/xen: introduce a Xen early init function
Roger Pau Monné [Fri, 2 Feb 2024 10:00:31 +0000 (11:00 +0100)]
x86/xen: introduce a Xen early init function

Start by moving the hyeprcall setup to such function.

The aim is to have a function that does all the required Xen early
initialization for both HVM and PVH, instead of having it scattered across
different paths.

Sponsored by: Cloud Software Group
Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D43932

3 months agox86/xen: remove parameter from fixup_console()
Roger Pau Monné [Fri, 2 Feb 2024 08:32:15 +0000 (09:32 +0100)]
x86/xen: remove parameter from fixup_console()

And instead fetch the metadata inside of the function.

This is done in preparation for changing the call site of fixup_console(),
which will no longer have the kernel metedata pointer in context.

No functional change intended.

Sponsored by: Cloud Software Group
Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D43931