]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
23 hours agobeinstall: retire mergemaster support main
Ed Maste [Sat, 9 Sep 2023 16:17:11 +0000 (12:17 -0400)]
beinstall: retire mergemaster support

Mergemaster has been deprecated for some time, and will be retired.

Reviewed by: kevans
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41799

25 hours agolibgcc_s: 80-bit long double function are x86-only
Brooks Davis [Wed, 1 May 2024 20:49:47 +0000 (21:49 +0100)]
libgcc_s: 80-bit long double function are x86-only

Don't try to expose them on other architectures.

Reviewed by: arichardson
Differential Revision: https://reviews.freebsd.org/D45028

26 hours agoguestrpc module to handle VMware backdoor port GuestRPC functionality
Stephen J. Kiernan [Wed, 1 May 2024 19:45:45 +0000 (15:45 -0400)]
guestrpc module to handle VMware backdoor port GuestRPC functionality

Convert existing FreeBSD vmware_hvcall function to take a channel
and parameter arguments.

Added vmware_guestrpc_cmd() to send GuestRPC commands to the VMware
hypervisor. The sbuf argument is used for both the command to send
and to store the data to return to the caller.

The following KPIs can be used to get and set FreeBSD-specific guest
information in key/value pairs:
 * vmware_guestrpc_set_guestinfo
   - set a value into the guestinfo.fbsd.<keyword> key
 * vmware_guestrpc_get_guestinfo
   - get the value stored in the guestinfo.fbsd.<keyword> key

Add VMware devices to x86 NOTES

Reviewed by: jhb
Obtained from: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D44528

28 hours agorelease: Stage non-UFS images in vm-images-stage
Colin Percival [Wed, 1 May 2024 17:56:51 +0000 (10:56 -0700)]
release: Stage non-UFS images in vm-images-stage

When the VM image building code was updated to support building
non-UFS images, the vm-images-stage target was not updated to
install those newly built images to the FTP site.  As a result, we
have been sending weekly snapshot announcements since August claiming
that ZFS VM images are available when they are not in fact present
anywhere publicly accessible.

Fixes: 32ae9a6b3937 "release: Build UFS and ZFS VM images"
Reported by: Michael Dexter
MFC after: 5 days

28 hours agoFix up a mistake in the CFLAGS added. Pointed out by jrtc.
George V. Neville-Neil [Wed, 1 May 2024 17:21:59 +0000 (13:21 -0400)]
Fix up a mistake in the CFLAGS added.  Pointed out by jrtc.

29 hours agoOut of tree modules should be built with DTrace by default.
George V. Neville-Neil [Wed, 1 May 2024 17:00:52 +0000 (13:00 -0400)]
Out of tree modules should be built with DTrace by default.

30 hours agoexamples: Install bhyve files on arm64
Mark Johnston [Wed, 1 May 2024 15:24:05 +0000 (11:24 -0400)]
examples: Install bhyve files on arm64

Sponsored by: Innovate UK

31 hours agobhyve: Move lock of uart frontend to uart backend
SHENG-YI HONG [Wed, 1 May 2024 15:09:31 +0000 (15:09 +0000)]
bhyve: Move lock of uart frontend to uart backend

Currently, lock of uart in bhyve is placed in frontend. There are some
problems about it:

1. If every frontend should has a lock, why not move it inside backend
   as they all have same uart_softc.
2. If backend needs to modify the information of uart after initialize,
   it will be impossible as backend cannot use lock. For example, if we
   want implement a telnet support for uart in backend, It should wait
   for connection when initialize. After some remote process connect it,
   it needs to modify rfd and wfd in backend.

So I decide to move it to backend.

Reviewed by: corvink, jhb, markj
Differential Revision: https://reviews.freebsd.org/D44947

33 hours agovmrun.sh: Add arm64 support
Mark Johnston [Wed, 1 May 2024 12:36:30 +0000 (08:36 -0400)]
vmrun.sh: Add arm64 support

For now, we enumerate disk devices before network devices.  This is to
work around a problem wherein u-boot remaps BARs during boot in a way
that bhyve does not handle.  Some discussion and experiments suggest
that this can be handled by having bhyve not map BARs during boot on
arm64; until a solution is implemented, however, this workaround is
sufficient for simple usage and doesn't have any real downsides.

The console and bootrom are specified slightly differently versus amd64,
and a few of vmrun.sh's command-line options are amd64-only.

Reviewed by: corvink, jhb
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D44933

33 hours agobhyvectl: Add arm64 bits and hook it up to the build
Mark Johnston [Wed, 1 May 2024 12:33:23 +0000 (08:33 -0400)]
bhyvectl: Add arm64 bits and hook it up to the build

For now this implementation doesn't provide any machine dependent
functionality on arm64, but it's enough to be able to reset and destroy
VMs.

Reviewed by: jhb
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D44932

33 hours agobhyvectl: Prepare to add arm64 support
Mark Johnston [Wed, 1 May 2024 12:31:00 +0000 (08:31 -0400)]
bhyvectl: Prepare to add arm64 support

Move MD code into a separate directory and add a simple interface which
lets the MD bits register options and handle them.

No functional change intended.

Reviewed by: jhb
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D44932

34 hours agosdt: Add macros which expand to probe and provider structure names
Mark Johnston [Wed, 1 May 2024 11:17:29 +0000 (07:17 -0400)]
sdt: Add macros which expand to probe and provider structure names

No functional change intended.

MFC after: 1 week

41 hours agofattime: fix fattime to timespec conversion of dates beyond 2106-02-06
Josef 'Jeff' Sipek [Mon, 29 Apr 2024 13:40:31 +0000 (09:40 -0400)]
fattime: fix fattime to timespec conversion of dates beyond 2106-02-06

It turns out that the only conversion issue was in fattime2timespec, where
multiplying the number of seconds in a day by the number of days overflowed
32-bit unsigned int for dates beyond 2106-02-07 06:28:15.

Casting one of the multiplicands as time_t forces a 64-bit multiplication on
systems where time_t is 64-bits and produces no binary changes on the one
remaining system with 32-bit time_t (namely i386).

Since the code is now tested & fixed, this change removes the fixme comments.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D44755

41 hours agofattime: make the test code check beyond 32-bit time_t limits
Josef 'Jeff' Sipek [Mon, 29 Apr 2024 13:40:30 +0000 (09:40 -0400)]
fattime: make the test code check beyond 32-bit time_t limits

On systems that have a 64-bit time_t, the test code now exercises the whole
range of fattime.  To do this, this commit...

1. replaces the call to random() with two calls to arc4random() to
   generate a 33-bit number of seconds in order to cover the entire range of
   fattime [1970,2107].  (32-bits stops just short - in January 2106.)
   On systems with 32-bit time_t, the extra bits are discarded and only the
   time_t expressible range is tested.
2. casts time_t values passed to printf as longs and changes the format
   string to match.

Now, the test code builds, runs, and exercises what it can (i.e., the whole
fattime range or the 32-bit time_t subset of it) on both 32-bit and 64-bit
time_t systems.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D44754

41 hours agofattime: make the test code build again
Josef 'Jeff' Sipek [Mon, 29 Apr 2024 13:40:29 +0000 (09:40 -0400)]
fattime: make the test code build again

This change...

1. replaces calls to timet2fattime/fattime2timet with calls to
   timespec2fattime/fattime2timespec.  The functions got renamed shortly
   after they landed in the kernel but the test code wasn't updated (see
   7ea93e912bf0ef).
2. adds a utc_offset stub.

With this, the test code builds and runs as a 32-bit binary (cc -Wall -O2
-m32 subr_fattime.c).

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D44753

46 hours agocxgbe/tom: Fix the rx channel selection in options2.
Navdeep Parhar [Mon, 15 Apr 2024 20:04:49 +0000 (13:04 -0700)]
cxgbe/tom: Fix the rx channel selection in options2.

This affects TOE operation when multiple rx c-channels are in use for
offload, which is an unusual configuration.

MFC after: 1 week
Sponsored by: Chelsio Communications

46 hours agocxgbe(4): Query TPCHMAP once and not once per port.
Navdeep Parhar [Tue, 30 Apr 2024 23:32:55 +0000 (16:32 -0700)]
cxgbe(4): Query TPCHMAP once and not once per port.

MFC after: 1 week
Sponsored by: Chelsio Communications

47 hours agocxgbe(4): Rename rx_c_chan to rx_chan.
Navdeep Parhar [Tue, 30 Apr 2024 23:07:24 +0000 (16:07 -0700)]
cxgbe(4): Rename rx_c_chan to rx_chan.

It is the equivalent of tx_chan but for receive so rx_chan is a better
name.  Initialize both using helper functions and make sure both are
displayed in the sysctl MIB.

MFC after: 1 week
Sponsored by: Chelsio Communications

2 days agoclang-format: Minor tweaks
Mark Johnston [Tue, 30 Apr 2024 21:32:38 +0000 (17:32 -0400)]
clang-format: Minor tweaks

Invert KeepEmptyLinesAtTheStartOfBlocks.  We used to require an empty
line at the beginning of functions with no local variables, which I
believe is the reason for this setting.  Now it is discouraged in new
code.

Tell clang-format to align consecutive macros, since we tend to do that.
clang-format's output isn't quite what we want here.  Typically we have
a tab after a #define for some reason, and clang-format doesn't appear
to have an option for that.  clang-format will also use a mix of tabs
and spaces to minimize indentation, which is also against our
convention.  However, the result looks better with this setting than
without.

Reviewed by: emaste
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D29870

2 days agoarm: Remove duplicate definitions in armreg.h
Mark Johnston [Tue, 30 Apr 2024 20:31:11 +0000 (16:31 -0400)]
arm: Remove duplicate definitions in armreg.h

No functional change intended.

MFC after: 1 week

2 days agouserboot: support environment and symlinks in test application
Stephen J. Kiernan [Tue, 30 Apr 2024 20:40:18 +0000 (16:40 -0400)]
userboot: support environment and symlinks in test application

Pass the environment on to the loader.
Also define USERBOOT=1 in the environment varables.

Add support for symlinks in the test application open callback.

stat the root directory when opening file
Without this, running "ls" command on the root directory encounters
issues getting the directory listing.

Reviewed by: jhb
Obtained from: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D44625

2 days agocons: Add boot option to mute boot messages after banner
Justin Hibbits [Tue, 30 Apr 2024 20:07:30 +0000 (16:07 -0400)]
cons: Add boot option to mute boot messages after banner

This is useful for embedded systems, where it provides feedback that the
kernel has booted, but avoids printing the probe messages.  If both
mutemsgs and verbose are set, verbose cancels the mute.

Additionally, this unmutes the console on panic, so a user can see what
happened leading up to the panic.

Obtained from:  Juniper Networks, Inc.

2 days agocxgbe(4): Minor tweaks to comments.
Navdeep Parhar [Tue, 30 Apr 2024 20:01:07 +0000 (13:01 -0700)]
cxgbe(4): Minor tweaks to comments.

No functional change intended.

MFC after: 1 week
Sponsored by: Chelsio Communications

2 days agocxgbe(4): Initialize mps_bg_map to an invalid value if it's not known.
Navdeep Parhar [Tue, 30 Apr 2024 19:51:29 +0000 (12:51 -0700)]
cxgbe(4): Initialize mps_bg_map to an invalid value if it's not known.

MFC after: 1 week
Sponsored by: Chelsio Communications

2 days agocxgbe(4): Do not read hardware registers to determine the number of ports.
Navdeep Parhar [Tue, 30 Apr 2024 19:42:14 +0000 (12:42 -0700)]
cxgbe(4): Do not read hardware registers to determine the number of ports.

PORTVEC obtained from the firmware is the authoritative source of this
information, and nports (calculated from PORTVEC) is available by the
time t4_port_init runs.

MFC after: 1 week
Sponsored by: Chelsio Communications

2 days agoFix new users of MAXPHYS and hide it from the kernel namespace
Andrew Gallatin [Mon, 29 Apr 2024 23:11:56 +0000 (19:11 -0400)]
Fix new users of MAXPHYS and hide it from the kernel namespace

In cd8537910406, kib made maxphys a load-time tunable.  This made
the #define MAXPHYS in sys/param.h  almost entirely obsolete, as
it could now be overridden by kern.maxphys at boot time, or by
opt_maxphys.h.

However, decades of tradition have led to several new, incorrect, uses
of MAXPHYS in other parts of the kernel, mostly by seasoned
developers.  I've corrected those uses here in a mechanical fashion,
and verified that it fixes a bug in the md driver that I was
experiencing.

Since using MAXPHYS is such an easy mistake to make, it is best to
hide it from the kernel namespace.  So I've moved its definition to
_maxphys.h, which is now included in param.h only for userspace.

That brings up the fact that lots of userspace programs use MAXPHYS
for different reasons, most of them probably wrong.  Userspace consumers
that really need to know the value of maxphys should probably be
changed to use the kern.maxphys sysctl.  But that's outside the scope
of this change.

Reviewed by: imp, jkim, kib, markj
Fixes: 30038a8b4efc ("md: Get rid of the pbuf zone")
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D44986

2 days agocxgbe(4): Allocate a taskqueue per port instead of per channel.
Navdeep Parhar [Tue, 30 Apr 2024 17:51:45 +0000 (10:51 -0700)]
cxgbe(4): Allocate a taskqueue per port instead of per channel.

All the channels are not used on all boards and there's no point
allocating taskqueues that will never be used.

MFC after: 1 week
Sponsored by: Chelsio Communications

2 days agolibsys: don't try to expose freebsd7___semctl
Brooks Davis [Tue, 30 Apr 2024 02:43:30 +0000 (03:43 +0100)]
libsys: don't try to expose freebsd7___semctl

This has always been in libc and never exported directly.  I accidently
included it along side some freebsd11_* symbols based on a tree where I
moved semctl(2).

Fixes: df1a09ba524d0 libsys: expose a few more symbols for libc's use

2 days agotftpd: Untangle a conditional.
Dag-Erling Smørgrav [Tue, 30 Apr 2024 14:56:10 +0000 (16:56 +0200)]
tftpd: Untangle a conditional.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D45026

2 days agovm: Fix error handling in vm_thread_stack_back()
Mark Johnston [Mon, 29 Apr 2024 16:22:36 +0000 (12:22 -0400)]
vm: Fix error handling in vm_thread_stack_back()

vm_object_page_remove() wants to busy the page, but that won't work
here.  (Kernel stack pages are always busy.)

Make the error handling path look more like vm_thread_stack_dispose().

Reported by: pho
Reviewed by: kib, bnovkov
Fixes: 7a79d0669761 ("vm: improve kstack_object pindex calculation to avoid pindex holes")
Differential Revision: https://reviews.freebsd.org/D45019

2 days agoRemove remnants of portsnap(8)
Olivier Certner [Mon, 22 Apr 2024 13:02:46 +0000 (22:02 +0900)]
Remove remnants of portsnap(8)

This was prompted by noticing that '/var/db/portsnap' still exists on
newly-installed machines.

With this change, all mentions of portsnap(8) in the tree are gone,
except for the historical note in the AUTHORS section of manpage
phttpget(8).

locate(1) will thus start indexing again '/var/db/portsnap' on machines
where this directory still exists, which may be a good way to push
administrators to delete it.

Reviewed by:            cperciva
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D45023

2 days agolibarchive: merge bugfixes from vendor branch
Martin Matuska [Tue, 30 Apr 2024 09:53:06 +0000 (11:53 +0200)]
libarchive: merge bugfixes from vendor branch

 #2147 archive_string: clean up strncat_from_utf8_to_utf8 (36047967a)
 #2153 archive_match: check archive_read_support_format_raw()
       return value (0ce1b4c38)
 #2154 archive_match: turn counter into flag (287e05d53)
 #2155 lha: Do not allow negative file sizes (93b11caed)
 #2156 tests: setenv LANG to en_US.UTF-8 in bsdunzip test_I.c (83e8b0ea8)

MFC after: 3 days

2 days agoUpdate vendor/libarchive to libarchive master 83e8b0ea8
Martin Matuska [Tue, 30 Apr 2024 09:41:59 +0000 (11:41 +0200)]
Update vendor/libarchive to libarchive master 83e8b0ea8

 #2147 archive_string: clean up strncat_from_utf8_to_utf8 (36047967a)
 #2153 archive_match: check archive_read_support_format_raw()
       return value (0ce1b4c38)
 #2154 archive_match: turn counter into flag (287e05d53)
 #2155 lha: Do not allow negative file sizes (93b11caed)
 #2156 tests: setenv LANG to en_US.UTF-8 in bsdunzip test_I.c (83e8b0ea8)

Obtained from: libarchive
Libarchive commit: 83e8b0ea8c3b07e07ac3dee90a8724565f8e53fd

2 days agoarm64: Check for virtio for scmi_virtio.c
Andrew Turner [Tue, 30 Apr 2024 08:50:38 +0000 (08:50 +0000)]
arm64: Check for virtio for scmi_virtio.c

scmi_virtio.c depends on virtio. Check for this before including it in
the kernel.

Reported by: Isaac Cilia Attard (via cperciva)
Sponsored by: Arm Ltd

2 days agokcmp_pget(): do not accept TIDs
Konstantin Belousov [Mon, 29 Apr 2024 21:04:25 +0000 (00:04 +0300)]
kcmp_pget(): do not accept TIDs

Otherwise pget() might still look up and hold the current process.

Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 days agokcmp_pget(): add an assert that we did not hold the current process
Konstantin Belousov [Mon, 29 Apr 2024 18:51:53 +0000 (21:51 +0300)]
kcmp_pget(): add an assert that we did not hold the current process

Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 days agolinuxkpi: Add linuxkpi_video module
Emmanuel Vadot [Wed, 24 Apr 2024 08:14:36 +0000 (10:14 +0200)]
linuxkpi: Add linuxkpi_video module

This contain the hdmi code and the aperture code like in linux.

Differential Revision: https://reviews.freebsd.org/D44925
Reviewed by: bz
Obtained from: drm-kmod
Sponsored by: Beckhoff Automation GmbH & Co. KG

2 days agolinuxkpi: hdmi: Split the module declaration to a new file
Emmanuel Vadot [Wed, 24 Apr 2024 07:59:20 +0000 (09:59 +0200)]
linuxkpi: hdmi: Split the module declaration to a new file

In order to have a proper linuxkpi_video kmod, move the module declaration
to a new file as linuxkpi_video will also include linux_hdmi.c

Differential Revision: https://reviews.freebsd.org/D44926
Reviewed by: bz, emaste, wulf
Sponsored by: Beckhoff Automation GmbH & Co. KG

2 days agortld.1: clarify interaction between -u and -o
Konstantin Belousov [Sun, 28 Apr 2024 21:45:12 +0000 (00:45 +0300)]
rtld.1: clarify interaction between -u and -o

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

2 days agortld direct exec: make -u behavior match the description
Konstantin Belousov [Sun, 28 Apr 2024 20:57:54 +0000 (23:57 +0300)]
rtld direct exec: make -u behavior match the description

Instead of only ignoring insecure env vars, clear them all.

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

2 days agortld: add direct-exec option -o
Konstantin Belousov [Sun, 28 Apr 2024 03:19:39 +0000 (06:19 +0300)]
rtld: add direct-exec option -o

allowing to set any known LD_ parameter for the current rtld invocation,
but without polluting the activated' binary environment.  In other
words, the set parameter is not exported into the environment.

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

3 days agocxgbe(4): Shared code update to deal with partial failure in query_params.
Navdeep Parhar [Wed, 14 Feb 2024 01:28:53 +0000 (17:28 -0800)]
cxgbe(4): Shared code update to deal with partial failure in query_params.

Obtained from: Chelsio Communications
MFC after: 1 week
Sponsored by: Chelsio Communications

3 days agocxgbe(4): Reword the comment explaining the atid/cookie split.
Navdeep Parhar [Sat, 1 Apr 2023 23:07:36 +0000 (16:07 -0700)]
cxgbe(4): Reword the comment explaining the atid/cookie split.

Avoid a magic constant while here.  No functional change intended.

MFC after: 1 week
Sponsored by: Chelsio Communications

3 days agocxgbe(4): Add missing description for a port type.
Navdeep Parhar [Mon, 29 Apr 2024 20:27:48 +0000 (13:27 -0700)]
cxgbe(4): Add missing description for a port type.

MFC after: 1 week
Sponsored by: Chelsio Communications

3 days agocxgbe(4): Retire t4_intr_clear.
Navdeep Parhar [Fri, 26 Apr 2024 00:39:55 +0000 (17:39 -0700)]
cxgbe(4): Retire t4_intr_clear.

The firmware clears the interrupts already and it has a better idea of
exactly what to clear for which generation of the ASIC.  There is no
need for the driver to get involved.

MFC after: 1 week
Sponsored by: Chelsio Communications

3 days agocxgbe(4): Add a helper function to locate MPS/MAC registers.
Navdeep Parhar [Thu, 25 Apr 2024 05:24:49 +0000 (22:24 -0700)]
cxgbe(4): Add a helper function to locate MPS/MAC registers.

These register blocks are at different locations in different chips.

MFC after:      1 week
Sponsored by:   Chelsio Communications

3 days agocxgbe(4): Remove tx_modq lookup table.
Navdeep Parhar [Fri, 29 Mar 2024 05:49:32 +0000 (22:49 -0700)]
cxgbe(4): Remove tx_modq lookup table.

The driver always uses the same modulation queue as the channel and the
table is unnecessary.

MFC after:      1 week
Sponsored by:   Chelsio Communications

3 days agopflow: handle unattached states
Kristof Provost [Mon, 29 Apr 2024 09:51:17 +0000 (11:51 +0200)]
pflow: handle unattached states

It's possible for states to be cleaned up (through pf_detach_state()) that
have not been fully attached. For example if there's an ID conflict during
pf_state_insert().

pflow exports states from pf_detach_state(), so it can get called on such
states, but did not account for this and could end up dereferencing a NULL
state key.

Check for this in export_pflow() and do not export unattached states.

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

3 days agoctl: Fix CTL GET EVENT STATUS NOTIFICATION valid bits
HP van Braam [Mon, 29 Apr 2024 14:34:46 +0000 (08:34 -0600)]
ctl: Fix CTL GET EVENT STATUS NOTIFICATION valid bits

Linux as an initiator periodically sends the following to SCSI cdrom
devices: 4a 01 00 00 10 00 00 00 08 00

According to the ctl_cmd_entry for this command this is invalid which
leads to a lot of failed SCSI commands.

The mask in this commit is based off of an early draft of the mmc
standard, https://www.t10.org/ftp/t10/document.97/97-108r0.pdf,
as well as subsequent standards (mmc2 through mmc6).

This solves the issue with Linux initiators.

Signed-off-by: HP van Braam <hp@tmm.cx>
Reviewed by: imp, mav
Pull Request: https://github.com/freebsd/freebsd-src/pull/1201

3 days agopf: convert DIOCGETSTATUS to netlink
Kristof Provost [Sat, 23 Mar 2024 06:31:51 +0000 (07:31 +0100)]
pf: convert DIOCGETSTATUS to netlink

Introduce pfctl_get_status_h() because we need the pfctl_handle. In this variant
use netlink to obtain the information.

Sponsored by: Rubicon Communications, LLC ("Netgate")

3 days agolibpfctl: allow access to the fd
Kristof Provost [Wed, 24 Apr 2024 06:40:05 +0000 (08:40 +0200)]
libpfctl: allow access to the fd

pfctl_open() opens both /dev/pf and a netlink socket. Allow access to the /dev/
pf fd via pfctl_fd().
This means that libpfctl users no longer have to open /dev/pf themselves for any
calls that are not yet available in libpfctl.

Sponsored by: Rubicon Communications, LLC ("Netgate")
MFC after: 2 weeks

3 days agolibpfctl: fix incorrect pcounters array size
Kristof Provost [Fri, 26 Apr 2024 14:07:38 +0000 (16:07 +0200)]
libpfctl: fix incorrect pcounters array size

The array is 2 x 2 x 2, not 2 x 2 x 3.

Sponsored by: Rubicon Communications, LLC ("Netgate")
MFC after: 2 weeks

3 days agopackage: fix dependency generation
Lexi Winter [Mon, 29 Apr 2024 14:30:46 +0000 (08:30 -0600)]
package: fix dependency generation

A bug in release/packages/generate-ucl.sh causes package dependencies
(other than shlib depends) to not be generated correctly, meaning
packages are missing their dependencies.

generate-ucl.sh creates the UCL file by:

1. copying ${uclsource} (template.ucl) to ${uclfile}
2. appending dependencies to ${uclfile}
3. calling generate-ucl.lua on ${uclsource} to create ${uclfile}

This breaks because the dependencies added in step 2 are overwritten in
step 3.

Fix this by calling generate-ucl.lua with ${uclfile} as both the input
and output file, so anything we added to ${uclfile} is preserved.

Reviewed by: des, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1203

3 days agopackage: FreeBSD-periodic should depend on FreeBSD-cron
Lexi Winter [Mon, 29 Apr 2024 14:29:13 +0000 (08:29 -0600)]
package: FreeBSD-periodic should depend on FreeBSD-cron

Reported by: des
Reviewed by: imp, des
Pull Request: https://github.com/freebsd/freebsd-src/pull/1204

3 days agoservices.5: describe better
Alexander Ziaee [Mon, 29 Apr 2024 14:00:01 +0000 (08:00 -0600)]
services.5: describe better

Use a more specific description for this man page, and add SDPX tag
while here.

Reviewed by: imp, meena
Signed-off-by: Alexander Ziaee <concussious@runbox.com>
Pull Request: https://github.com/freebsd/freebsd-src/pull/1194

3 days agoAdd libxo support to du
Nathan Huff [Mon, 29 Apr 2024 04:59:18 +0000 (22:59 -0600)]
Add libxo support to du

Convert du to use libxo enabling structured output.

[[ minor style fixes by imp ]]

Signed-off-by: Nathan Huff <nhuff@acm.org>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1145

3 days agoarm64/vmm: Handle VM_EXITCODE_SUSPENDED
Mark Johnston [Mon, 29 Apr 2024 14:19:27 +0000 (10:19 -0400)]
arm64/vmm: Handle VM_EXITCODE_SUSPENDED

This is required for bhyve reboot to work.  In particular, unless we
suspend vcpu threads here, vm_reinit() will fail with EBUSY.

The implementation is copied from amd64; in the not-too-distant future
the amd64 and arm64 copies of vmm.c and vmm_dev.c will be merged, so
for now it's useful to minimize diffs between amd64 and arm64.

Reviewed by: corvink, andrew
MFC after: 2 weeks
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D44934

3 days agobhyve: Fix handling of -r
Mark Johnston [Mon, 29 Apr 2024 14:13:50 +0000 (10:13 -0400)]
bhyve: Fix handling of -r

Just make "restore_file" a global variable so that it can be set by the
MD option handler.

Reviewed by: corvink
Reported by: bdrewery
Fixes: 981f9f7495bb ("bhyve: Push option parsing down into bhyverun_machdep.c")
Differential Revision: https://reviews.freebsd.org/D44974

3 days agoadduser: Really fix a syntax error
Dag-Erling Smørgrav [Mon, 29 Apr 2024 10:29:35 +0000 (12:29 +0200)]
adduser: Really fix a syntax error

Fixes: 5cafc38f1129
Differential Revision: https://reviews.freebsd.org/D44871

3 days agolibulog: Make sure ut_line, ut_user, ut_host are terminated.
Dag-Erling Smørgrav [Mon, 29 Apr 2024 10:11:12 +0000 (12:11 +0200)]
libulog: Make sure ut_line, ut_user, ut_host are terminated.

MFC after: 3 days
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D45004

3 days agolibarchive: merge from vendor branch
Martin Matuska [Mon, 29 Apr 2024 08:15:04 +0000 (10:15 +0200)]
libarchive: merge from vendor branch

Libarchive 3.7.4 + three fixes from master

Security fixes:
 #2135 rar: Fix OOB in rar e8 filter (CVE-2024-26256)
 #2145 zip: Fix out of boundary access
 #2148 rar: Fix OOB in rar delta filter
 #2149 rar: Fix OOB in rar audio filter

Important bugfixes:
 #2131 7zip: Limit amount of properties
 #2110 bsdtar: Fix error handling around strtol() usages
 #2116 passphrase: Never allow empty passwords
 #2124 rar: Fix "File CRC Error" when extracting specific rar4 archives
 #2123 xar: Avoid infinite link loop
 #2150 xar: Fix another infinite loop and expat error handling
 #2108 zip: Update AppleDouble support for directories
 #2071 zstd: Implement core detectiongit

PR: 278588 (exp-run)
MFC after: 1 day

3 days agoCherry-pick commits from libarchive to vendor/libarchive
Martin Matuska [Mon, 29 Apr 2024 07:18:17 +0000 (09:18 +0200)]
Cherry-pick commits from libarchive to vendor/libarchive

 #2148 fix: OOB in rar delta filter (a1cb648d5)
 #2149 fix: OOB in rar audio filter (3006bc5d0)
 #2150 xar: Fix another infinite loop and expat error handling (b910cb70d)

Obtained from: libarchive
Libarchive commits: b910cb70d4c1b311c9d85cd536a6c91647c43df7
a1cb648d52f5b6d3f31184d9b6a7cbca628459b7
3006bc5d02ad3ae3c4f9274f60c1f9d2d834734b

3 days agorights.4: various corrections on capability rights
CismonX [Mon, 29 Apr 2024 04:48:26 +0000 (22:48 -0600)]
rights.4: various corrections on capability rights

- A file descriptor obtained from accept(2), accept4(2) and openat(2)
  is not always assigned all capability rights.  Instead, it inherits
  capability rights from the "parent" socket/dir file descriptor.
- getdents(2) and getdirentries(2) requires CAP_READ.
- openat(2) with O_WRONLY|O_TRUNC does not require CAP_SEEK.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1207

3 days agoglabel: Add support for Linux swap
Ricardo Branco [Mon, 29 Apr 2024 04:38:15 +0000 (22:38 -0600)]
glabel: Add support for Linux swap

Reviewed by: imp, kib
Pull Request: https://github.com/freebsd/freebsd-src/pull/1205

3 days agopackage: move OpenBSM auditing into its own package
Lexi Winter [Wed, 24 Apr 2024 17:54:44 +0000 (18:54 +0100)]
package: move OpenBSM auditing into its own package

Move auditing runtime (auditd, etc.) into the new FreeBSD-audit package.
Also move the runtime OpenBSM manual pages from libbsm into auditd so
they get installed with the right package.

Add an UPDATING entry noting the new packages.

Reviewed by: imp, manu
Pull Request: https://github.com/freebsd/freebsd-src/pull/1197

3 days agopackage: move authpf into the FreeBSD-pf package
Lexi Winter [Mon, 29 Apr 2024 04:31:02 +0000 (22:31 -0600)]
package: move authpf into the FreeBSD-pf package

Reviewed by: imp, manu
Pull Request: https://github.com/freebsd/freebsd-src/pull/1198

3 days agoUPDATING: add entry for recent pkgbase changes
Lexi Winter [Mon, 29 Apr 2024 04:28:49 +0000 (22:28 -0600)]
UPDATING: add entry for recent pkgbase changes

Reviewed by: imp, manu
Pull Request: https://github.com/freebsd/freebsd-src/pull/1196

3 days agosetkey: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Tue, 7 Nov 2023 17:38:15 +0000 (18:38 +0100)]
setkey: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agoipf: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Tue, 7 Nov 2023 17:38:03 +0000 (18:38 +0100)]
ipf: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agocamcontrol: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Tue, 7 Nov 2023 17:37:33 +0000 (18:37 +0100)]
camcontrol: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agoipfw: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Tue, 7 Nov 2023 17:36:35 +0000 (18:36 +0100)]
ipfw: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agozonectl: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Tue, 7 Nov 2023 17:14:45 +0000 (18:14 +0100)]
zonectl: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agowlandebug: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Tue, 7 Nov 2023 17:14:34 +0000 (18:14 +0100)]
wlandebug: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agousbconfig: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Tue, 7 Nov 2023 17:14:17 +0000 (18:14 +0100)]
usbconfig: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agorwhod: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Tue, 7 Nov 2023 17:13:47 +0000 (18:13 +0100)]
rwhod: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agopstat: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Tue, 7 Nov 2023 17:13:32 +0000 (18:13 +0100)]
pstat: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agoppp: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Tue, 7 Nov 2023 17:13:19 +0000 (18:13 +0100)]
ppp: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agondp: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Tue, 7 Nov 2023 17:13:02 +0000 (18:13 +0100)]
ndp: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agomoused: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Tue, 7 Nov 2023 17:12:44 +0000 (18:12 +0100)]
moused: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agokbdcontrol: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Tue, 7 Nov 2023 17:11:56 +0000 (18:11 +0100)]
kbdcontrol: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agoctld: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Tue, 7 Nov 2023 17:11:34 +0000 (18:11 +0100)]
ctld: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agoctladm: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Tue, 7 Nov 2023 17:11:10 +0000 (18:11 +0100)]
ctladm: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agobtxld: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Tue, 7 Nov 2023 17:10:52 +0000 (18:10 +0100)]
btxld: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agortadvctl: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Mon, 29 Apr 2024 02:55:30 +0000 (20:55 -0600)]
rtadvctl: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agortadvd: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Mon, 29 Apr 2024 02:55:30 +0000 (20:55 -0600)]
rtadvd: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agobluetooth: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Elyes Haouas [Mon, 29 Apr 2024 02:55:30 +0000 (20:55 -0600)]
bluetooth: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

Pull Request: https://github.com/freebsd/freebsd-src/pull/888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
3 days agoaxgbe: Various stability improvements
Stephan de Wit [Mon, 29 Apr 2024 01:57:26 +0000 (19:57 -0600)]
axgbe: Various stability improvements

Hook in RSS glue.

Default to "off" for the split header feature to ensure netmap
compatibility.

Change the PCS indirection register values based on hardware type
(ported from Linux).

Move tunable settings to sysctl_init() and set the defaults there.
Ensure it's called at the right time by moving it back.

Reset PHY RX data path when mailbox command times out (Ported from
Linux).

Check if VLAN HW tagging is enabled before assuming a VLAN tag
is present in a descriptor.

Disable the hardware filter since multicast traffic is dropped
in promisc mode.

Remove unnecessary return statement.

Missing sfp_get_mux, causing a race between ports to read
SFP(+) sideband signals.

Validate and fix incorrectly initialized polarity/configuration
registers.

Remove unnecessary SFP reset.

axgbe_isc_rxd_pkt_get has no error state, remove unnecessary
big packet check.

Enable RSF to prevent zero-length packets while in Netmap mode.

DMA cache coherency update (ported from Linux).

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1103

3 days agounionfs_rename: fix numerous locking issues
Jason A. Harmening [Sun, 18 Feb 2024 00:20:51 +0000 (18:20 -0600)]
unionfs_rename: fix numerous locking issues

There are a few places in which unionfs_rename() accesses fvp's private
data without holding the necessary lock/interlock.  Moreover, the
implementation completely fails to handle the case in which fdvp is not
the same as tdvp; in this case it simply fails to lock fdvp at all.
Finally, it locks fvp while potentially already holding tvp's lock, but
makes no attempt to deal with possible LOR there.

Fix this by optimistically using the vnode interlock to protect
the short accesses to fdvp and fvp private data, sequentially.
If a file copy or shadow directory creation is required to prepare
the upper FS for the rename operation, the interlock must be dropped
and fdvp/fvp locked as necessary.

Additionally, use ERELOOKUP (as suggested by kib@) to simplify the
locking logic and eliminate unionfs_relookup() calls for file-copy/
shadow-directory cases that require tdvp's lock to be dropped.

Reviewed by: kib (earlier version), olce
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D44788

4 days agoRELNOTES: Fix wrong commit hash
Christos Margiolis [Sun, 28 Apr 2024 19:59:17 +0000 (21:59 +0200)]
RELNOTES: Fix wrong commit hash

Fixes: 25723d66369f ("sound: Retire unit.*")
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 days agosound: Remove chn_timeout check from chn_init()
Christos Margiolis [Sun, 28 Apr 2024 19:47:33 +0000 (21:47 +0200)]
sound: Remove chn_timeout check from chn_init()

This check is not related to channel initializion, but is also
unnecessary, since sysctl_hw_snd_timeout() takes care of checking if
chn_timeout is within bounds.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D44992

4 days agosound: Add missing space in dev.pcm.X.mode description
Christos Margiolis [Sun, 28 Apr 2024 19:47:11 +0000 (21:47 +0200)]
sound: Add missing space in dev.pcm.X.mode description

Sponsored by: The FreeBSD Foundation
MFC after: 1 day
Reviewed by: markj, emaste
Differential Revision: https://reviews.freebsd.org/D44990

4 days agosound: Move pcm_chnref() and pcm_chnrelease() to pcm/channel.c
Christos Margiolis [Sun, 28 Apr 2024 19:46:55 +0000 (21:46 +0200)]
sound: Move pcm_chnref() and pcm_chnrelease() to pcm/channel.c

Improve code layering. These are channel functions, and so they do not
belong in pcm/sound.c.

While here, assert in chn_ref() that new refcount won't be negative.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D44985

4 days agosound: Merge pcm_chn_destroy() and chn_kill()
Christos Margiolis [Sun, 28 Apr 2024 19:46:08 +0000 (21:46 +0200)]
sound: Merge pcm_chn_destroy() and chn_kill()

pcm_chn_destroy() acts like a wrapper around chn_kill(), and
additionally calls a few more functions that should in fact be part of
chn_kill()'s logic. Merge pcm_chn_destroy()'s functionality in
chn_kill() to improve readability, as well as code layering.

While here, convert chn_kill() to void as it currently always returns 0.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D44984

4 days agosound: Retire unit.*
Christos Margiolis [Sun, 28 Apr 2024 19:44:35 +0000 (21:44 +0200)]
sound: Retire unit.*

The unit.* code is largely obsolete and imposes limits that are no
longer needed nowadays.

- Capping the maximum allowed soundcards in a given machine. By default,
  the limit is 512 (snd_max_u() in unit.c), and the maximum possible is
  2048 (SND_UNIT_UMAX in unit.h). It can also be tuned through the
  hw.snd.maxunit loader(8) tunable. Even though these limits are large
  enough that they should never cause problems, there is no need for
  this limit to exist in the first place.
- Capping the available device/channel types. By default, this is 32
  (snd_max_d() in unit.c). However, these types are pre-defined in
  pcm/sound.h (see SND_DEV_*), so the cap is unnecessary when we know
  that their number is constant.
- Capping the number of channels per-device. By default, the limit 1024
  (snd_max_c() in unit.c). This is probably the most problematic of the
  limits mentioned, because this limit can never be reached, as the
  maximum is hard-capped at either hw.snd.maxautovchans (16 by default),
  or SND_MAXHWCHAN and SND_MAXVCHANS.

These limtits are encoded in masks (see SND_U_MASK, SND_D_MASK,
SND_C_MASK in unit.h) and are used to construct a bitfield of the form
[dsp_unit, type, channel_unit] in snd_mkunit() which is assigned to
pcm_channel->unit.

This patch gets rid of everything unit.*-related and makes a slightly
different use of the "unit" field to only contain the channel unit
number. The channel type is stored in a new pcm_channel->type field, and
the DSP unit number need not be stored at all, since we can fetch it
from device_get_unit(pcm_channel->dev). This change has the effect that
we no longer need to impose caps on the number of soundcards,
device/channel types and per-device channels. As a result the code is
noticeably simplified and more readable.

Apart from the fact that the hw.snd.maxunit loader(8) tunable is also
retired as a side-effect of this patch, sound(4)'s behavior remains the
same.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Reviewed by: dev_submerge.ch
Differential Revision: https://reviews.freebsd.org/D44912

4 days agosound: Assert that we do not enter chn_sleep() with CHN_F_SLEEPING
Christos Margiolis [Sun, 28 Apr 2024 19:40:52 +0000 (21:40 +0200)]
sound: Assert that we do not enter chn_sleep() with CHN_F_SLEEPING

Sponsored by: The FreeBSD Foundation
MFC after: 1 day
Reviewed by: markj, emaste
Differential Revision: https://reviews.freebsd.org/D44959

4 days agosound: Fix panic caused by sleeping-channel destruction during asynchronous detach
Christos Margiolis [Sun, 28 Apr 2024 19:40:40 +0000 (21:40 +0200)]
sound: Fix panic caused by sleeping-channel destruction during asynchronous detach

Currently we are force-destroying all channels unconditionally in
pcm_killchan(). However, since asynchronous audio device detach is
possible as of 44e128fe9d92, if we do not check whether the channel is
sleeping or not and forcefully kill it, we will get a panic from
cv_timedwait_sig() (called from chn_sleep()), because it will try to use
a freed lock/cv.

Modify pcm_killchan() (renamed to pcm_killchans() since that's a more
appropriate name now) to loop through the channel list and destroy only
the channels that are awake, otherwise wake up the sleeping thread and
try again. This loop is repeated until all channels are awakened and
destroyed.

To reduce code duplication, implement chn_shutdown() which wakes up the
channel and sets CHN_F_DEAD, and use it in pcm_unregister() and
pcm_killchans().

Reported by: KASAN
Fixes: 44e128fe9d92 ("sound: Implement asynchronous device detach")
Sponsored by: The FreeBSD Foundation
MFC after: 1 day
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D44923

4 days agosound: Wrap dsp_clone() and mixer_clone() with bus_topo_lock()
Christos Margiolis [Sun, 28 Apr 2024 19:40:29 +0000 (21:40 +0200)]
sound: Wrap dsp_clone() and mixer_clone() with bus_topo_lock()

Make sure that the softc isn't freed in between the checks.

Sponsored by: The FreeBSD Foundation
MFC after; 1 day
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D44991

4 days agosound: Fix NULL dereference in dsp_clone() and mixer_clone()
Christos Margiolis [Sun, 28 Apr 2024 19:40:14 +0000 (21:40 +0200)]
sound: Fix NULL dereference in dsp_clone() and mixer_clone()

If we only have a single soundcard attached and we detach it right
before entering [dsp|mixer]_clone(), there is a chance pcm_unregister()
will have returned already, meaning it will have set snd_unit to -1, and
thus devclass_get_softc() will return NULL here.

While here, 1) move the calls to dsp_destroy_dev() and mixer_uninit()
below the point where we unset SD_F_REGISTERED, and 2) follow what
mixer_clone() does and make sure we don't use a NULL d->dsp_dev in
dsp_clone().

Reported by: KASAN
Sponsored by: The FreeBSD Foundation
MFC after: 1 day
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D44924

4 days agortld snprintf: do not erronously skip a char at the buffer boundary
Konstantin Belousov [Sun, 28 Apr 2024 06:37:24 +0000 (09:37 +0300)]
rtld snprintf: do not erronously skip a char at the buffer boundary

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

4 days agogettimeofday.2: Do mention improbable future removal
Mateusz Piotrowski [Sun, 28 Apr 2024 18:06:05 +0000 (20:06 +0200)]
gettimeofday.2: Do mention improbable future removal

As kib@ noted:

> Obviously gettimeofday(2) is not going to be removed
> even in the far future.

Reported by: kib
Fixes: 4395d3ced5cf Document that gettimeofday() is obsolescent
MFC after: 3 days