Commit graph

288823 commits

Author SHA1 Message Date
Bjoern A. Zeeb 61a0eaca0d MAINTAINERS: change linuxkpi review Phabricator group.
Direct the review request to #linuxkpi instead of #x11 as it
also is #wireless these days and possibly others in the future.
I would suggest #x11 reviewers also add themselves to #linuxkpi
instead.

Reviewed by:	manu, emaste
Differential Revision: https://reviews.freebsd.org/D43458
2024-01-16 19:23:39 +00:00
Gleb Smirnoff 507f87a799 sockets: retire sorflush()
With removal of dom_dispose method the function boils down to two
meaningful function calls: socantrcvmore() and sbrelease().  The latter is
only relevant for protocols that use generic socket buffers.

The socket I/O sx(9) lock acquisition in sorflush() is not relevant for
shutdown(2) operation as it doesn't do any I/O that may interleave with
read(2) or write(2).  The socket buffer mutex acquisition inside
sbrelease() is what guarantees thread safety.  This sx(9) acquisition in
soshutdown() can be tracked down to 4.4BSD times, where it used to be
sblock(), and it was carried over through the years evolving together with
sockets with no reconsideration of why do we carry it over.  I can't tell
if that sblock() made sense back then, but it doesn't make any today.

Reviewed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D43415
2024-01-16 10:30:49 -08:00
Gleb Smirnoff 289bee16be sockets: remove dom_dispose and PR_RIGHTS
Passing file descriptors (rights) via sockets is a feature specific to
PF_UNIX only, so fully isolate the logic into uipc_usrreq.c.

Reviewed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D43414
2024-01-16 10:30:49 -08:00
Gleb Smirnoff 5bba272807 sockets: make pr_shutdown fully protocol specific method
Disassemble a one-for-all soshutdown() into protocol specific methods.
This creates a small amount of copy & paste, but makes code a lot more
self documented, as protocol specific method would execute only the code
that is relevant to that protocol and nothing else.  This also fixes a
couple recent regressions and reduces risk of future regressions.  The
extended KPI for the new pr_shutdown removes need for the extra pr_flush
which was added for the sake of SCTP which could not perform its shutdown
properly with the old one.  Particularly for SCTP this change streamlines
a lot of code.

Some notes on why certain parts of code were copied or were not to certain
protocols:
* The (SS_ISCONNECTED | SS_ISCONNECTING | SS_ISDISCONNECTING) check is
  needed only for those protocols that may be connected or disconnected.
* The above reduces into only SS_ISCONNECTED for those protocols that
  always connect instantly.
* The ENOTCONN and continue processing hack is left only for datagram
  protocols.
* The SOLISTENING(so) block is copied to those protocols that listen(2).
* sorflush() on SHUT_RD is copied almost to every protocol, but that
  will be refactored later.
* wakeup(&so->so_timeo) is copied to protocols that can make a non-instant
  connect(2), can SO_LINGER or can accept(2).

There are three protocols (netgraph(4), Bluetooth, SDP) that did not have
pr_shutdown, but old soshutdown() would still perform sorflush() on
SHUT_RD for them and also wakeup(9).  Those protocols partially supported
shutdown(2) returning EOPNOTSUP for SHUT_WR/SHUT_RDWR, now they fully lost
shutdown(2) support.  I'm pretty sure netgraph(4) and Bluetooth are okay
about that and SDP is almost abandoned anyway.

Reviewed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D43413
2024-01-16 10:30:37 -08:00
Gleb Smirnoff c3276e02be sockets: make shutdown(2) how argument a enum
Reviwed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D43412
2024-01-16 10:26:27 -08:00
Roger Pau Monné b0165dc453 x86/xen: fix HVM guest hypercall page setup
c7368ccb68 didn't take into account that vm_guest will also get setup by
generic identify CPU code, and hence by the time xen_hvm_init() gets called
vm_guest will always be set if running as a Xen guest, either by the PVH entry
point code, or by generic CPU identification.

xen_hvm_init() and xen_hvm_init_hypercall_stubs() were relying on xen_domain()
returning false when running as an HVM guest, and used that into order to
figure out whether hypercall page needed to be populated.

Get rid of such assumptions and simplify the code since legacy PVH is no
longer supported.

This fixes booting FreeBSD as a Xen HVM guest.

Fixes: c7368ccb68 ('xen: remove xen_domain_type enum/variable')
Sponsored by: Cloud Software Group
2024-01-16 18:50:54 +01:00
Kristof Provost 81ea920435 pflowclt: fix gcc build error
gcc is unhappy with the nested extern declaration of __progname, so move
it out of the usage() function.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-01-16 18:18:09 +01:00
Kristof Provost 284d31605c pflowctl.8: fix copy/paste-o
The valid values line applies to the proto field, not domain.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-01-16 18:18:09 +01:00
Christos Margiolis 6b6914c1e2 subr_bus: introduce device_set_descf() and modify allocation logic
device_set_descf() is a printf-like version of device_set_desc().

Allocation code has been transferred from device_set_desc_internal() to
device_set_desc_copy() and device_set_descf() to avoid complicating
device_set_desc_internal(). The "copy" argument in
device_set_desc_internal() has been replaced with a flag which is set
when the description string has been allocated with M_BUS.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	imp, markj
Differential Revision:	https://reviews.freebsd.org/D43370
2024-01-16 18:49:15 +02:00
Christos Margiolis 45cd29412e usb: use only usb_devinfo() in device_set_usb_desc()
device_set_usb_desc() first tries to fetch device information through
the iInterface descriptor, otherwise it falls back to usb_devinfo().
Since usb_devinfo() is both guaranteed to work, and is more verbose, get
rid of the initial iInterface attempt.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	imp, markj
Differential Revision:	https://reviews.freebsd.org/D43383
2024-01-16 18:49:08 +02:00
Christos Margiolis ebc9b69c77 pcm.4: mention snd_uaudio auto-load
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43397
2024-01-16 18:49:02 +02:00
Christos Margiolis 3a79c3ac8a sound: add missing modules to snd_driver
While here, remove unnecessary break.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D43394
2024-01-16 18:48:56 +02:00
Christos Margiolis 06a4376346 snd_uaudio: prefix module declaration with "snd_"
Although the module is compiled "snd_uaudio.ko", follow the rest of the
sound modules' naming convention in the declaration as well.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D43396
2024-01-16 18:48:49 +02:00
Christos Margiolis 837cd192eb sound: remove PCM_KLDSTRING() and fix status strings
PCM_KLDSTRING() prints the kernel module associated with a given audio
device only when that module is not compiled in. Get rid of
PCM_KLDSTRING() altogether and print the driver name (even for modules
that are compiled in) instead, as it implies the module as well.

While here, convert all status strings to the following dmesg-like
format:

[<port|mem> <irq>] on <driver>

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	markj, imp
Differential Revision:	https://reviews.freebsd.org/D43349
2024-01-16 18:48:14 +02:00
Christos Margiolis 18d87fe4fe snd_uaudio: provide information about the device name and attached driver
Unlike the other sound drivers, snd_uaudio(4) doesn't provide
information about the device's description and the driver it's attached
to. A side-effect of this is that applications such as mixer(8), that
fetch these strings through the OSS API's SNDCTL_CARDINFO ioctl will
show a USB audio device as:

pcm0:mixer: <USB Audio> at ? kld snd_uaudio

This patch replaces the generic "USB Audio" description with the
device's actual manufacturer and product strings, and the "at ?" string
with the driver it's attached to:

pcm0:mixer: <Focusrite Scarlett Solo USB> at uaudio0 kld snd_uaudio

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D43347
2024-01-16 18:46:49 +02:00
rilysh e2e956828c bhyve: return ENOMEM instead of EFAULT and call free() after being used
1. In basl_load() function, when allocation fails,
it returns an EFAULT instead of ENOMEM. An EFAULT
can mislead in some scenarios, whereas an ENOMEM
for an allocation function makes much more sense.

2. Call free() on addr, as it's not being used
anymore after the basl_table_append_bytes()
function.

Signed-off-by: rilysh <nightquick@proton.me>

MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1016
2024-01-16 09:39:25 -05:00
Ricardo Branco 9b20849bc5 md5: Enter capability mode earlier
Reviewed by:	markj
MFC after:	1 month
Pull Request:	https://github.com/freebsd/freebsd-src/pull/988
2024-01-16 09:38:53 -05:00
Kristof Provost d086b9f77c pf tests: test per-rule pflow
Test that we can enable pflow on a per-rule basis.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-01-16 09:45:55 +01:00
Kristof Provost c4d97a9487 pf tests: test pflow NAT state information
pflow(4) now also exports NAT session creation/destruction information.
Test that this works as expected.

While here improve the parsing of ipfix (i.e. pflowproto 10) a bit, and
check more information for the existing state information exports.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43117
2024-01-16 09:45:55 +01:00
Kristof Provost 2be6f75707 pflow: Turn `pflowstats' statistics counters into per-CPU counters to make them mpsafe.
The weird interactions around `pflow_flows' and `sc_gcounter' replaced
by simple `pflow_flows' increment. Since the flow sequence is the 32
bits integer, the `sc_gcounter' type replaced by the type of uint32_t.

Obtained from:	OpenBSD
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43116
2024-01-16 09:45:55 +01:00
Kristof Provost 34276498fa pf tests: verify pflow over IPv6
Test that we can send netflow information over IPv6.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43115
2024-01-16 09:45:55 +01:00
Kristof Provost fc6e506996 pflow: add RFC8158 NAT support
Extend pflow(4) to send NAT44 Session Create and Delete events.
This applies only to IPFIX (i.e. proto version 10), and requires no
user configuration.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43114
2024-01-16 09:45:55 +01:00
Kristof Provost 85b71dcfc9 pflow: allow observation domain to be configured
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43113
2024-01-16 09:45:54 +01:00
Kristof Provost 0493260115 pf: store state creation/expiration timestamps with milisecond precision
The primary beneficiary is pflow(4), which expects milisecond precision
in timestamps.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43112
2024-01-16 09:45:54 +01:00
Kristof Provost 6bd36d1cf4 pf tests: pflow functionality test
Test that we actually send netflow messages when configured to do so.
We do not yet inspect the generated netflow messages.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43111
2024-01-16 09:45:54 +01:00
Kristof Provost 7ec34ebe18 pfctl tests: basic pflow parser test
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43110
2024-01-16 09:45:54 +01:00
Kristof Provost fb0c74685f pf tests: initial pflow test case
Basic creation, validation and cleanup test for the new pflow interface.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43109
2024-01-16 09:45:54 +01:00
Kristof Provost baf9b6d042 pf: allow pflow to be activated per rule
Only generate ipfix/netflow reports (through pflow) for the rules where
this is enabled. Reports can also be enabled globally through 'set
state-default pflow'.

Obtained from:	OpenBSD
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43108
2024-01-16 09:45:54 +01:00
Kristof Provost 5dea523bd2 pflow: netstat statistics
Expose pflow counters via netstat.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43107
2024-01-16 09:45:53 +01:00
Kristof Provost f92d9b1aad pflow: import from OpenBSD
pflow is a pseudo device to export flow accounting data over UDP.
It's compatible with netflow version 5 and IPFIX (10).

The data is extracted from the pf state table. States are exported once
they are removed.

Reviewed by:	melifaro
Obtained from:	OpenBSD
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43106
2024-01-16 09:45:53 +01:00
Warner Losh 393f2dca36 mount: Add a note that userquota and groupquota aren't printed with -p
The quota options are pseudo options and not passed to the mount system
call when a filesystem is mounted. They are not part of the info
returned from getmntinfo(3), so can't be printed. Add a note to this
effect.
2024-01-15 21:38:26 -07:00
Kyle Evans 30189156d3 kern: pts: do not special case closed slave side
This would previously return 1 if the slave side of the pts was closed
to force an application to read() from it and observe the EOF, but it's
not clear why and this is inconsistent both with how we handle devices
with similar mechanics (like pipes) and also with other kernels, such as
OpenBSD/NetBSD and Linux.

PR:             239604
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D43457
2024-01-15 20:55:59 -06:00
Kyle Evans 522083ffbd kern: tty: recanonicalize the buffer on ICANON/VEOF/VEOL changes
Before this change, we would canonicalize any partial input if the new
local mode is not ICANON, but that's about it.  If we were switching
from -ICANON -> ICANON, or if VEOF/VEOL changes, then our internal canon
accounting would be wrong.

The main consequence of this is that in ICANON mode, we would
potentially hang a read(2) longer if the new VEOF/VEOL appears later in
the buffer, and FIONREAD would be similarly wrong as a result.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D43456
2024-01-15 20:55:59 -06:00
Kyle Evans d51dac5f13 kern: tty: fix EOF handling for canonical reads
If the read(2) buffer is one byte short of an EOF, then we'll end up
reading the line into the buffer, then re-entering and seeing an EOF at
the beginning of the inq, assuming it's a zero-length line.

Fix this corner-case by searching one more byte than we have available
for an EOF.  If we found it, then we'll trim it here; otherwise, we'll
limit our read to just the space we have in the out buffer and the next
read(2) will (potentially) read the remainder of the line.

Fix FIONREAD while we're here to match what an application can expect
read(2) to return -- scan for the first break character in the part of
the input that's been canonicalized, we'll never return more than that.

PR:	276220
Reviewed by:	cy, imp (both previous version), kib
Differential Revision:	https://reviews.freebsd.org/D43378
2024-01-15 20:55:58 -06:00
Kyle Evans 09a43b8790 kern: tty: fix ttyinq_read_uio assertion
It's clear from later context that `rlen` was always expected to include
`flen`, as we'll trim `flen` bytes from the end of the read.  Relax our
initial assertion to only require the total size less trimmed bytes to
lie within the out buffer size.

While we're here, I note that if we have to read more than one block and
we're trimming from the end then we'll do the wrong thing and omit
`flen` bytes from every block, rather than just the end.  Add an
assertion to make sure we're not doing that, but the only caller that
specifies a non-zero `flen` today will only really be doing so if rlen
is entirely within a single buffer.

Reviewed by:	cy, imp
Differential Revision:	https://reviews.freebsd.org/D43377
2024-01-15 20:55:58 -06:00
Jose Luis Duran 08efe9bef4 GitHub: style: Add the synchronize activity type
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1064
2024-01-15 17:58:31 -07:00
Warner Losh 57623b3b74 checkstyle9.pl: Soften the single line braces requirement
We inherited the error for single line statements needing braces from
the original script. Style(9) allow that, and could be read to encourage
that, but does not require that.

Sponsored by:		Netflix
2024-01-15 17:57:28 -07:00
Pete Zaitcev 11500481c8 mptable: improve error reporting for invalid commands
mptable ignores arguments with matching first letters, report errors
when it gets garbate.

PR: 38727
Reviewed by: imp
2024-01-15 17:57:28 -07:00
Alan Somers daf26f9350 fusefs: more consistent operand ordering in io.cc
MFC after:	2 weeks
2024-01-15 16:16:40 -07:00
Alan Somers 1c909c300b fusefs: fix an interaction between copy_file_range and mmap
If a copy_file_range operation tries to read from a page that was
previously written via mmap, that page must be flushed first.

MFC after:	2 weeks
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D43451
2024-01-15 14:57:15 -07:00
Mark Johnston 2524b7dfb0 crashinfo: Print stack traces for all on-CPU threads
Add a python script which implements the bulk of this functionality.
Over time, this would ideally evolve into a library of python routines
which can be used to inspect kernel data structures and automate some
debugging tasks, similar to jhb's out-of-tree scripts, but written in a
somewhat nicer language and with better integration into the kgdb
command prompt.

Note that kgdb currently won't auto-load scripts in this directory.
This should perhaps change in the future.  It probably also makes more
sense to have a crashinfo.py which provides all the kgdb output that we
want to include in core.txt, rather than having crashinfo.sh pipe in
several commands.

Reviewed by:	avg, imp
Discussed with:	jhb
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33817
2024-01-15 16:36:40 -05:00
Mike Karels b9e8ae1d8a route: error on IPv4 network routes with incorrect destination
Route destinations like 10/8 are most likely intended as a shorthand
for 10.0.0.0/8, but instead it means 0.0.0.10/8, which includes
only bits in the host part of the mask, and hence adds a route to
0.0.0.0/8.  In 12.x, there was code to "do what I mean", which was
removed as part of a cleanup of old network class remnants.  Given
that we have gone this long without that code, do not restore that
behavior.  Instead, detect the issue and produce an error.
Specifically, if there are no dots in a numeric IPv4 address, the
mask is specified with CIDR notation (using a slash), and there are
bits set in the host part, produce an error like this for 10/8:

    route: malformed address, bits set after mask; 10 means 0.0.0.10

PR:		258874
MFC after:	1 week
Reviewed by:	melifaro, emaste
Differential Revision:	https://reviews.freebsd.org/D43384
2024-01-15 15:14:54 -06:00
Ricardo Branco 2a121b97e9 find: Allow '/' to be used with -perm for GNU compatibility
In 2005, Gnu find deprecated '+' as the leading character for the -perm
argument, instead preferring '/' with the same meaning. Implement that
behavior here, and document it in the man page.

Reviewed by: imp, emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/1060
2024-01-15 11:47:24 -07:00
Mohamed Akram ec13a838e6 man: avoid unportable use of utilities
echo -e is not portable. It can be replaced by printf %b (it works
only with the /bin/sh built-in echo, not /bin/echo anyway).
head -# is not portable, but head -n # is.

Replace these two things in three places total.

Signed-off-by: Mohamed Akram <mohd.akram@outlook.com>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1062
2024-01-15 11:30:37 -07:00
Mark Johnston a5ef95cd22 condvar: Fix a user-after-free in _cv_wait() when ktrace is enabled
When a thread wakes up after sleeping on a CV, it must not dereference
the CV structure, as it may already have been freed.  At least ZFS
relies on this invariant, see commit
c636f94bd2 for example.

Thus, when logging context-switch events, copy the wmesg into a stack
buffer while it is still safe to do so, and log that after waking up.

While here, move the initial ktrcsw() call later, after assertions and
the SCHEDULER_STOPPED_TD() condition are checked.

Reported by:	syzkaller
Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D43450
2024-01-15 12:29:02 -05:00
Mark Johnston 61b0092be7 condvar: Clean up condvar.h a bit
- Remove a typedef that has been unused for a long time.
- Remove a LOCORE guard.  MI headers like condvar.h don't need such a
  guard in general.
- Move a forward declaration into the _KERNEL block.
- Add a types.h include to make the file self-contained.

Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D43449
2024-01-15 12:27:11 -05:00
Konstantin Belousov 503f72a828 ncl_bioread(): check for vp->v_object before accessing it
Reported by:	cy
Reviewed by:	rmacklem
Fixes:	70dc6b2ce3
MFC after:	3 days
2024-01-15 17:19:58 +02:00
Mike Karels 6137b5f7b8 Increase the size of riscv GENERICSD images to 6 GB
The stable/13 snapshot this week failed to build the riscv GENERICSD
image because it ran out of space.  Checking main and stable/14
snapshots, they are also low on space, around 100% or more of
capacity.  Increase them all from 5 GB to 6 GB.  Note, this is the
only riscv image configuration.

Discussed with:	cperciva
2024-01-15 07:28:53 -06:00
Kristof Provost 3f9a6e0b85 pf tests: dummynet + nat fragmentation test
Ensure that we do the right thing when we reassemble fragmented packet
and send it through a dummynet pipe.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-01-15 14:02:02 +01:00
Kristof Provost 24c0058a9b pf tests: test reassembly with dummynet
Ensure that if we pass packets through a dummynet pipe we still
reassemble as expected.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-01-15 14:02:02 +01:00