]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
19 months agoatrtc: Correct name of tunable in man page
Michael Gmelin [Mon, 17 Oct 2022 10:09:42 +0000 (12:09 +0200)]
atrtc: Correct name of tunable in man page

Not reviewed, but I took the liberty to commit it
since it's so obvious.

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

19 months agoroute: allow RTM_CHANGE notifications in rt_routemsg().
Alexander V. Chernikov [Thu, 15 Dec 2022 10:39:06 +0000 (10:39 +0000)]
route: allow RTM_CHANGE notifications in rt_routemsg().

MFC after: 2 weeks

19 months agojail: fix a NULL pointer derefence in parsing ip6.addr settings.
Jamie Gritton [Thu, 15 Dec 2022 00:47:55 +0000 (16:47 -0800)]
jail: fix a NULL pointer derefence in parsing ip6.addr settings.

This is the counterpart to bd24e861b4ef, which did the same for ip4.
PR: 268377
Reported by: ahkithaama at proton.me

19 months agoUnbreak the build when MAC is not defined
Andrew Gallatin [Wed, 14 Dec 2022 22:33:30 +0000 (17:33 -0500)]
Unbreak the build when MAC is not defined

7a2c93b86ef7 removed the use of "error" when MAC was not
defined, resulting in an unused variable error.

Sponsored by: Netflix
Reviewed by: jhb

19 months agoOpps take out a stray left behind printf that was
Randall Stewart [Wed, 14 Dec 2022 21:11:39 +0000 (16:11 -0500)]
Opps take out a stray left behind printf that was
for debugging.. Sorry.

19 months agoRack cannot be loaded without cc_newreno compiled into the kernel.
Randall Stewart [Wed, 14 Dec 2022 20:37:48 +0000 (15:37 -0500)]
Rack cannot be loaded without cc_newreno compiled into the kernel.

Right now rack will fail to load due to its hack in accessing symbol names
in cc_newreno. This was fine when newreno was always compiled into the
kernel but now ... not so much. Instead lets fix up rack to use the socket
option queries to get the information it wants and set the parameters. We
also fix the CC parameter so they are always settable.

Reviewed by: tuexen
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D37622

19 months agonetlink: improve interface handling
Alexander V. Chernikov [Wed, 14 Dec 2022 19:45:01 +0000 (19:45 +0000)]
netlink: improve interface handling

* Separate interface creation from interface modification code
* Support setting some interface attributes (ifdescr, mtu, up/down, promisc)
* Improve interaction with the cloners requiring to parse/write custom
 interface attributes
* Add bitmask-based way of checking if the attribute is present in the
message
* Don't use multipart RTM_GETLINK replies when searching for the
specific interface names
* Use ENODEV instead of ENOENT in case of failed RTM_GETLINK search
* Add python netlink test helpers
* Add some netlink interface tests

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

19 months agovm: reduce lock contention when processing vm batchqueues
Andrew Gallatin [Wed, 14 Dec 2022 19:34:07 +0000 (14:34 -0500)]
vm: reduce lock contention when processing vm batchqueues

Rather than waiting until the batchqueue is full to acquire the lock &
process the queue, we now start trying to acquire the lock using trylocks
when the batchqueue is 1/2 full. This removes almost all contention on the
vm pagequeue mutex for for our busy sendfile() based web workload.
It also greadly reduces the amount of time a network driver ithread
remains blocked on a mutex, and eliminates some packet drops under
heavy load.

So that the system does not loose the benefit of processing large
batchqueues, I've doubled the size of the batchqueues. This way, when
there is no contention, we process the same batch size as before.

This has been run for several months on a busy Netflix server, as well
as on my personal desktop.

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

19 months agoallocate inpcb aligned to cachelines
Andrew Gallatin [Wed, 14 Dec 2022 19:19:35 +0000 (14:19 -0500)]
allocate inpcb aligned to cachelines

The inpcb struct is one of the most heavily utilized in the kernel
on a busy network server.  By aligning it to a cacheline
boundary, we can ensure that closely related fields in the inpcb
and tcbcb can be predictably located on the same cacheline.  rrs
has already done a lot of this work to put related fields on the
same line for the tcbcb.

In combination with a forthcoming patch to align the start of the tcpcb,
we see a roughly 3% reduction in CPU use on a busy web server serving
traffic over roughly 50,000 TCP connections.

Reviewed by: glebius, markj, tuexen
Differential Revision: https://reviews.freebsd.org/D37687
Sponsored by: Netflix

19 months agosockets: provide sousrsend() that does socket specific error handling
Gleb Smirnoff [Wed, 14 Dec 2022 18:02:44 +0000 (10:02 -0800)]
sockets: provide sousrsend() that does socket specific error handling

Sockets have special handling for EPIPE on a write, that was spread out
into several places.  Treating transient errors is also special - if
protocol is atomic, than we should ignore any changes to uio_resid, a
transient error means the write had completely failed (see d2b3a0ed31e).

- Provide sousrsend() that expects a valid uio, and leave sosend() for
  kernel consumers only.  Do all special error handling right here.
- In dofilewrite() don't do special handling of error for DTYPE_SOCKET.
- For send(2), write(2) and aio_write(2) call into sousrsend() and remove
  error handling for kern_sendit(), soo_write() and soaio_process_job().

PR: 265087
Reported by:            rz-rpi03 at h-ka.de
Reviewed by:            markj
Differential revision: https://reviews.freebsd.org/D35863

19 months agotcp: retire TCPDEBUG
Gleb Smirnoff [Wed, 14 Dec 2022 17:54:06 +0000 (09:54 -0800)]
tcp: retire TCPDEBUG

This subsystem is superseded by modern debugging facilities,
e.g. DTrace probes and TCP black box logging.

We intentionally leave SO_DEBUG in place, as many utilities may
set it on a socket.  Also the tcp::debug DTrace probes look at
this flag on a socket.

Reviewed by: gnn, tuexen
Discussed with: rscheff, rrs, jtl
Differential revision: https://reviews.freebsd.org/D37694

19 months agosys/conf: Remove an unneeded flag variable
Mark Johnston [Wed, 14 Dec 2022 14:32:17 +0000 (09:32 -0500)]
sys/conf: Remove an unneeded flag variable

After commit fac6dee9eb58 ("Remove tests for obsolete compilers in the
build system"), we always set -fdebug-prefix-map, so there's no point in
defining and testing _MAP_DEBUG_PREFIX.  No functional change intended.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

19 months agopf: Fix definitions of pf_pfil_*_hooked
Mark Johnston [Wed, 14 Dec 2022 14:29:59 +0000 (09:29 -0500)]
pf: Fix definitions of pf_pfil_*_hooked

This use of "volatile" in the vnet definitions doesn't have any effect.
VNET_DEFINE_STATE(volatile int, ...) should work, but let's avoid using
"volatile" altogether and convert to atomic_load/atomic_store.  Also
convert to bool while here.

Reviewed by: kp, mjg
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37684

19 months agoif_ovpn: fix LINT-NOIP build
Kristof Provost [Wed, 14 Dec 2022 09:53:03 +0000 (10:53 +0100)]
if_ovpn: fix LINT-NOIP build

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

19 months agopf tests: check that we clean up unused kifs
Kristof Provost [Wed, 30 Nov 2022 14:20:41 +0000 (15:20 +0100)]
pf tests: check that we clean up unused kifs

The previous commit fixed a memory leak, where we'd fail to clean up
removed groups (and interfaces).
Check that we now clean those up as expected.

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D37570

19 months agopf: fix pfi_ifnet leak on interface removal
Nick Reilly [Wed, 30 Nov 2022 14:19:44 +0000 (15:19 +0100)]
pf: fix pfi_ifnet leak on interface removal

The detach of the interface and group were leaving pfi_ifnet memory
behind. Check if the kif still has references, and clean it up if it
doesn't

On interface detach, the group deletion was notified first and then a
change notification was sent. This would recreate the group in the kif
layer. Reorder the change to before the delete.

PR: 257218
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D37569

19 months agotcp: whack the stale declaration of rack_timer_stop
Mateusz Guzik [Wed, 14 Dec 2022 08:48:52 +0000 (08:48 +0000)]
tcp: whack the stale declaration of rack_timer_stop

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

19 months agoif_ovpn: cleanup offsetof() use
Kristof Provost [Mon, 5 Dec 2022 13:14:49 +0000 (14:14 +0100)]
if_ovpn: cleanup offsetof() use

Move the use of the `offsetof(struct ovpn_counters, fieldname) /
sizeof(uint64_t)` construct into a macro.
This removes a fair bit of code duplication and should make things a
little easier to read.

Reviewed by: zlei
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D37607

19 months agoif_ovpn: include peer counters in a OVPN_NOTIF_DEL_PEER message
Kristof Provost [Fri, 2 Dec 2022 15:59:38 +0000 (16:59 +0100)]
if_ovpn: include peer counters in a OVPN_NOTIF_DEL_PEER message

When we remove a peer userspace can no longer retrieve its counters. To
ensure that userspace can get a full count of the entire session we now
include the counters in the deletion message.

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D37606

19 months agoif_ovpn: allow peer lookup by vpn4/vpn6 address
Kristof Provost [Tue, 29 Nov 2022 11:06:32 +0000 (12:06 +0100)]
if_ovpn: allow peer lookup by vpn4/vpn6 address

Introduce two more RB_TREEs so that we can look up peers by their peer
id (already present) or vpn4 or vpn6 address.
This removes the last linear scan of the peer list.

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D37605

19 months agoif_ovpn: implement OVPN_GET_PEER_STATS
Kristof Provost [Sun, 27 Nov 2022 11:58:40 +0000 (12:58 +0100)]
if_ovpn: implement OVPN_GET_PEER_STATS

Allow userspace to retrieve per-peer traffic stats.

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D37604

19 months agoif_ovpn: start tracking per-peer packets/bytes in/out
Kristof Provost [Sat, 26 Nov 2022 13:22:23 +0000 (14:22 +0100)]
if_ovpn: start tracking per-peer packets/bytes in/out

OpenVPN will introduce a mechanism to retrieve per-peer statistics.
Start tracking those so we can return them to userspace when queried.

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D37603

19 months agoif_ovpn: remove OVPN_SEND_PKT
Kristof Provost [Sat, 26 Nov 2022 12:52:40 +0000 (13:52 +0100)]
if_ovpn: remove OVPN_SEND_PKT

OpenVPN userspace no longer uses the ioctl interface to send control
packets. It instead uses the socket directly.
The use of OVPN_SEND_PKT was never released, so we can remove this
without worrying about compatibility.

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D37602

19 months agosizeof(7): miscellaneous edits
Konstantin Belousov [Tue, 13 Dec 2022 14:07:32 +0000 (16:07 +0200)]
sizeof(7): miscellaneous edits

Suggested by: pstef
Reviewed by: imp, pstef (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D37683

19 months agosizeof(7): remove "All rights reserved"
Jan Schaumann [Wed, 14 Dec 2022 04:58:23 +0000 (06:58 +0200)]
sizeof(7): remove "All rights reserved"

Requested by: pstef
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D37674

19 months agotcp: remove a 4.4BSD relic
Gleb Smirnoff [Wed, 14 Dec 2022 04:21:45 +0000 (20:21 -0800)]
tcp: remove a 4.4BSD relic

The actual code to modify this counter was disabled in 2c37256e5a59
and later removed in d0390e0570c.

19 months agoComplete retire cp(4)
Li-Wen Hsu [Wed, 14 Dec 2022 03:42:36 +0000 (11:42 +0800)]
Complete retire cp(4)

Sponsored by: The FreeBSD Foundation

19 months agoComplete retire cp(4)
Li-Wen Hsu [Wed, 14 Dec 2022 03:38:55 +0000 (11:38 +0800)]
Complete retire cp(4)

And fix the LINT build.

Sponsored by: The FreeBSD Foundation

Fixes: 895992bb66d214f34c76a2b9da1133d457b2dee1

19 months agotcp: fix counter leak for SYN_RCVD state when syncache_socket() fails
Gleb Smirnoff [Wed, 14 Dec 2022 03:31:05 +0000 (19:31 -0800)]
tcp: fix counter leak for SYN_RCVD state when syncache_socket() fails

The SYN_RCVD state count is tricky here due to default code path and TFO
being so different.  In the default case the count is incremented when a
syncache entry is added to the the database in syncache_insert().  Later
when connection transitions from syncache entry to a socket in
syncache_expand(), this counter is inherited by the tcpcb.  If socket or
tcpcb allocation failed in syncache_socket() failed the syncache_expand()
is responsible for decrement.  In the TFO case the syncache entry is not
inserted into database and count of SYN_RCVD is first incremented in the
syncache_tfo_expand() after successful socket allocation.  Thus, inside
syncache_socket() we can't tell whether we need to decrement in a case of
a failure or not.  The caller is responsible for this book keeping.

Fixes: 07285bb4c22c026a50f69149d5dae03169b15fe4
Differential revision: https://reviews.freebsd.org/D37610

19 months agodiff: restyle loop a bit
Kyle Evans [Wed, 14 Dec 2022 01:31:21 +0000 (19:31 -0600)]
diff: restyle loop a bit

This is a bit more readable, and this loop is probably unlikely to gain
any `continue` or `break`s.

Suggested by: pstef
Differential Revision: https://reviews.freebsd.org/D37676

19 months agodiff: fix side-by-side output with tabbed input
Kyle Evans [Wed, 14 Dec 2022 01:31:21 +0000 (19:31 -0600)]
diff: fix side-by-side output with tabbed input

The previous logic conflated some things... in this block:
- j: input characters rendered so far
- nc: number of characters in the line
- col: columns rendered so far
- hw: column width ((h)ard (w)idth?)

Comparing j to hw or col to nc are naturally wrong, as col and hw are
limits on their respective counters and nc is already brought down to hw
if the input line should be truncated to start with.

Right now, we end up easily truncating lines with tabs in them as we
count each tab for $tabwidth lines in the input line, but we really
should only be accounting for them in the column count.  The problem is
most easily demonstrated by the two input files added for the tests,
the two tabbed lines lose at least a word or two even though there's
plenty of space left in the row for each side.

Reviewed by: bapt, pstef
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37676

19 months agoptrace_test: Remove another MIPS remnant.
John Baldwin [Tue, 13 Dec 2022 22:51:52 +0000 (14:51 -0800)]
ptrace_test: Remove another MIPS remnant.

19 months agokref: switch internal type to atomic_t and bring back const to kref_read
Mateusz Guzik [Tue, 13 Dec 2022 20:42:32 +0000 (20:42 +0000)]
kref: switch internal type to atomic_t and bring back const to kref_read

This unbreak drm-kmod build.

the const is part of Linux API

Unfortunately drm-kmod uses hand-rolled refcount* calls on a kref
object. For now go the easy route of keeping it operational by casting
stuff internally.

The general goal here is to make FreeBSD refcount API use an opaque
type, hence the ongoing removal of hand-rolled accesses.

Reported by: emaste

19 months agoretire sconfig(8) ce(4)/cp(4) configuration tool
Ed Maste [Tue, 13 Dec 2022 20:07:46 +0000 (15:07 -0500)]
retire sconfig(8) ce(4)/cp(4) configuration tool

The ce(4) and cp(4) drivers have been retired.

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

19 months agoretire cp(4) driver
Ed Maste [Thu, 24 Sep 2020 14:08:02 +0000 (10:08 -0400)]
retire cp(4) driver

Sync serial (e.g. T1/T1/G.703) interfaces are obsolete, this driver
includes obfuscated source, and has reported potential security issues.

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

19 months agoretire ce(4) driver
Ed Maste [Sun, 2 Feb 2020 18:27:37 +0000 (13:27 -0500)]
retire ce(4) driver

Sync serial (e.g. T1/T1/G.703) interfaces are obsolete, this driver
includes obfuscated source, and has reported potential security issues.

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

19 months agoAdd deprecation notices to ce,cp sync serial drivers
Ed Maste [Mon, 2 Mar 2020 17:31:52 +0000 (12:31 -0500)]
Add deprecation notices to ce,cp sync serial drivers

And the related sconfig utility.  Sync serial (e.g. E1/T1) interfaces
are obsolete, and nobody responded to several inquires on the mailing
lists about use of these drivers.

Relnotes: Yes
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23928

19 months agoFix rcorder example to match the keyword in the description
Jose Luis Duran [Tue, 13 Dec 2022 19:49:52 +0000 (19:49 +0000)]
Fix rcorder example to match the keyword in the description

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

19 months agosysctl.8: grammar nit
Ceri Davies [Tue, 13 Dec 2022 19:48:25 +0000 (19:48 +0000)]
sysctl.8: grammar nit

19 months agolibarchive: merge from vendor branch
Martin Matuska [Tue, 13 Dec 2022 19:21:13 +0000 (20:21 +0100)]
libarchive: merge from vendor branch

Libarchive 3.6.2

Important bug fixes:
  rar5 reader: fix possible garbled output with bsdtar -O (#1745)
  mtree reader: support reading mtree files with tabs (#1783)
  various small fixes for issues found by CodeQL

MFC after: 2 weeks
PR: 286306 (exp-run)

19 months agoRELNOTES: Add mention of growfs addition of swap partition.
Mike Karels [Tue, 13 Dec 2022 14:54:43 +0000 (08:54 -0600)]
RELNOTES: Add mention of growfs addition of swap partition.

As documented in growfs(7).

19 months agossh: describe two additional changes present in base system ssh
Ed Maste [Tue, 13 Dec 2022 14:43:04 +0000 (09:43 -0500)]
ssh: describe two additional changes present in base system ssh

Sponsored by: The FreeBSD Foundation

19 months agostress2: Add problem found
Peter Holm [Tue, 13 Dec 2022 11:00:01 +0000 (12:00 +0100)]
stress2: Add problem found

19 months agokref: replace hand-rolled atomic ops with refcount API
Mateusz Guzik [Mon, 5 Dec 2022 17:38:45 +0000 (17:38 +0000)]
kref: replace hand-rolled atomic ops with refcount API

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D37608

19 months agoAdd driver for Motorcomm YT8511 GbE PHY
Søren Schmidt [Tue, 13 Dec 2022 05:58:51 +0000 (05:58 +0000)]
Add driver for Motorcomm YT8511 GbE PHY

Partially from: https://reviews.freebsd.org/D36093

19 months agostand: Make ioctl declaration consistent
Warner Losh [Tue, 13 Dec 2022 04:46:05 +0000 (21:46 -0700)]
stand: Make ioctl declaration consistent

It typically had two args with an optional third from the userland
declaration in sys/ioccom.h. However, the funciton definition used a
non-optional char * argument. This mismatch is UB behavior (but worked
due to the calling convetions of all our machines).

Instead, add a declaration for ioctl to stand.h, make the third arg
'void *' which is a better match to the ... declaration before. This
prevents the convert int * -> char * errors as well. Make the ioctl
user-space declaration truly user-space specific (omit it in the
stand-alone build).

No functional change intended.

Sponsored by: Netflix
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37680

19 months agoAdd sizeof(7) manual page
Jan Schaumann [Tue, 13 Dec 2022 04:35:11 +0000 (06:35 +0200)]
Add sizeof(7) manual page

PR: 268310
Reviewed by: kib
Discussed with: brooks, pauamma
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D37674

19 months agogeom: minor man page updates suggested by igor(1)
Ed Maste [Mon, 12 Dec 2022 21:26:00 +0000 (16:26 -0500)]
geom: minor man page updates suggested by igor(1)

Reviewed by: pauamma
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37681

19 months agossh: remove note about local change to [Use]PrivilegeSeparation
Ed Maste [Mon, 12 Dec 2022 22:00:13 +0000 (17:00 -0500)]
ssh: remove note about local change to [Use]PrivilegeSeparation

We documented "[Use]PrivilegeSeparation defaults to sandbox" as one of
our modifications to ssh's server-side defaults, but this is not (any
longer) a difference from upstream.

Sponsored by: The FreeBSD Foundation

19 months agogeom: add vinum as a recognized class
Ed Maste [Mon, 12 Dec 2022 17:13:58 +0000 (12:13 -0500)]
geom: add vinum as a recognized class

And note that it is deprecated.

PR: 236569
Reported by: bcran
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37678

19 months agoRELNTOES: Add note for llvm-objdump as objdump
Ed Maste [Mon, 12 Dec 2022 16:29:20 +0000 (11:29 -0500)]
RELNTOES: Add note for llvm-objdump as objdump

19 months agopmap: standardize promotion conditions between amd64 and arm64
Alan Cox [Sat, 8 Oct 2022 07:20:25 +0000 (02:20 -0500)]
pmap: standardize promotion conditions between amd64 and arm64

On amd64, don't abort promotion due to a missing accessed bit in a
mapping before possibly write protecting that mapping.  Previously,
in some cases, we might not repromote after madvise(MADV_FREE) because
there was no write fault to trigger the repromotion.  Conversely, on
arm64, don't pointlessly, yet harmlessly, write protect physical pages
that aren't part of the physical superpage.

Don't count aborted promotions due to explicit promotion prohibition
(arm64) or hardware errata (amd64) as ordinary promotion failures.

Reviewed by: kib, markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D36916

19 months agorestore: fix restore of NFS4 ACLs
Chuck Silvers [Mon, 12 Dec 2022 16:14:17 +0000 (08:14 -0800)]
restore: fix restore of NFS4 ACLs

Changing the mode bits on a file with an NFS4 ACL results in the
NFS4 ACL being replaced by one matching the new mode bits being set,
so when restoring a file with an NFS4 ACL, set the owner/group/mode first
and then set the NFS4 ACL, so that setting the mode does not throw away
the ACL that we just set.

Reviewed by: mckusick
Differential Revision:  https://reviews.freebsd.org/D37618

19 months agoAlways install llvm-objdump as objdump
Ed Maste [Fri, 18 Nov 2022 20:47:13 +0000 (15:47 -0500)]
Always install llvm-objdump as objdump

Instead of providing no /usr/bin/objdump when LLVM_BINUTILS is false.

PR: 267854 [exp-run]
Reviewed by: dim
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37445

19 months agoRevert "uname: switch machine to HW_MACHINE_ARCH"
Piotr Kubaj [Mon, 12 Dec 2022 14:39:12 +0000 (15:39 +0100)]
Revert "uname: switch machine to HW_MACHINE_ARCH"

Reverting because of issue in Makefile.inc1 during native builds:
make[1]: â€œ.../freebsd/Makefile.inc1" line 163: Unknown target aarch64:aarch64.

Since I only tested this patch with make universe on amd64, this issue wasn't caught.

This reverts commit 83bf6ab568293e325f437342cdb87a626353e27c.

19 months agoAdd driver for Rockchip One Time Programmable (OTP) device.
Søren Schmidt [Mon, 12 Dec 2022 14:34:18 +0000 (14:34 +0000)]
Add driver for Rockchip One Time Programmable (OTP) device.
This driver created the possibility to assign fixed MAC adresses to eqos devices.

19 months agobridge: Fix a potential memory leak in bridge_enqueue()
Mark Johnston [Sun, 11 Dec 2022 16:40:12 +0000 (11:40 -0500)]
bridge: Fix a potential memory leak in bridge_enqueue()

A comment at the beginning of the function notes that we may be
transmitting multiple fragments as distinct packets.  So, the function
loops over all fragments, transmitting each mbuf chain.  If if_transmit
fails, we need to free all of the fragments, but m_freem() only frees an
mbuf chain - it doesn't follow m_nextpkt.

Change the error handler to free each untransmitted packet fragment, and
count each fragment as a separate error since we increment OPACKETS once
per fragment when transmission is successful.

Reviewed by: zlei, kp
MFC after: 1 week
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37635

19 months agolibdtrace: Change the binding of USDT probe symbols to STB_WEAK
Mark Johnston [Sun, 11 Dec 2022 16:27:22 +0000 (11:27 -0500)]
libdtrace: Change the binding of USDT probe symbols to STB_WEAK

Otherwise, if multiple object files contain references to the same
probe, newish lld will refuse to link them by default, raising a
duplicate global symbol definition error.  Previously, duplicate global
symbols with identical absolute st_values were permitted by both lld and
GNU ld.

Since dtrace has no use for probe function symbols after the relocation
performed by dtrace -G, make the symbols weak as well, following a
suggestion from MaskRay.

Reported by: dim
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

19 months agouname: switch machine to HW_MACHINE_ARCH
Piotr Kubaj [Sun, 11 Dec 2022 03:01:44 +0000 (04:01 +0100)]
uname: switch machine to HW_MACHINE_ARCH

On powerpc64, powerpc64le and riscv64 some software wrongly assumes that
it runs on powerpc or riscv (32-bit).

Differential revision: https://reviews.freebsd.org/D35962
Approved by: alfredo, imp

19 months agonullfs: adopt VV_CROSSLOCK
Jason A. Harmening [Sun, 20 Nov 2022 18:33:34 +0000 (12:33 -0600)]
nullfs: adopt VV_CROSSLOCK

When the lower filesystem directory hierarchy is the same as the nullfs
mount point (admittedly not likely to be a useful situation in
practice), nullfs is subject to the exact deadlock between the busy
count drain and the covered vnode lock that VV_CROSSLOCK is intended
to address.

Reviewed by: kib
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D37458

19 months agounionfs: allow recursion on covered vnode lock during mount/unmount
Jason A. Harmening [Sun, 20 Nov 2022 18:25:46 +0000 (12:25 -0600)]
unionfs: allow recursion on covered vnode lock during mount/unmount

When taking the covered vnode lock during mount and unmount operations,
specify LK_CANRECURSE as the existing lock state of the covered vnode
is not guaranteed (AFAIK) either by assertion or documentation for
these code paths.

For the mount path, this is done only for completeness as the covered
vnode lock is not currently held when VFS_MOUNT() is called.
For the unmount path, the covered vnode is currently held across
VFS_UNMOUNT(), and the existing code only happens to work when unionfs
is mounted atop FFS because FFS sets LO_RECURSABLE on its vnode locks.

This of course doesn't cover a hypothetical case in which the covered
vnode may be held shared, but for the mount and unmount paths such a
scenario seems unlikely to materialize.

Reviewed by: kib
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D37458

19 months agoGeneralize the VV_CROSSLOCK logic in vfs_lookup()
Jason A. Harmening [Wed, 26 Oct 2022 22:25:20 +0000 (17:25 -0500)]
Generalize the VV_CROSSLOCK logic in vfs_lookup()

When VV_CROSSLOCK is present, the lock for the vnode at the current
stage of lookup must be held across the VFS_ROOT() call for the
filesystem mounted at the vnode.  Since VV_CROSSLOCK implies that
the root vnode reuses the already-held lock, the possibility for
recursion should be made clear in the flags passed to VFS_ROOT().

For cases in which the lock is held exclusive, this means passing
LK_CANRECURSE.  For cases in which the lock is held shared, it
means clearing LK_NODDLKTREAT to allow VFS_ROOT() to potentially
recurse on the shared lock even in the presence of an exclusive
waiter.

That the existing code works for unionfs is due to a coincidence
of the current unionfs implementation.

Reviewed by: kib
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D37458

19 months agomtx: retire PARTIAL_PICKUP_GIANT
Mateusz Guzik [Sun, 11 Dec 2022 03:26:23 +0000 (03:26 +0000)]
mtx: retire PARTIAL_PICKUP_GIANT

It does not appear to have ever been used.

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

19 months agouipc: remove accept_mtx
Mateusz Guzik [Sun, 11 Dec 2022 02:47:07 +0000 (02:47 +0000)]
uipc: remove accept_mtx

It is unused since 779f106aa169256b ("Listening sockets improvements.")

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

19 months agogrowfs(7): document addition of swap partition and growfs_fstab script
Mike Karels [Sat, 10 Dec 2022 19:40:55 +0000 (13:40 -0600)]
growfs(7): document addition of swap partition and growfs_fstab script

Add documentation of the growfs script's new ability to add a swap
partition, expanding on the previous functionality as well.  Add the
growfs_fstab helper script, which runs separately.  Add a description
of how to expand a file system a second time if swap had been added.
While here, fix a typo.

Reviewed by: pauamma
Differential Revision: https://reviews.freebsd.org/D37465

19 months agodefault rc.conf: Add new growfs_swap_size variable
Mike Karels [Sat, 10 Dec 2022 19:40:33 +0000 (13:40 -0600)]
default rc.conf: Add new growfs_swap_size variable

Add new growfs_swap_size variable with a default value of the empty
string, along with comments on other settings.  Used by the growfs
script.

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

19 months agogrowfs_fstab: add new /etc/rc.d script to add swap to fstab
Mike Karels [Sat, 10 Dec 2022 19:39:59 +0000 (13:39 -0600)]
growfs_fstab: add new /etc/rc.d script to add swap to fstab

The growfs_fstab script is a helper for the growfs script to add any
new swap partition to /etc/fstab on first boot.  If growfs adds a
swap partition, it sets growfs_swap_pdev in the kenv.   In this case,
after the root file system is read/write, if there is no swap partition
in the fstab, growfs_fstab adds growfs_swap as a swap partition to the
fstab.  Also, it runs dumpon to add the swap partition  (as this
happened earlier in the startup sequence).

Discussed with: cperciva
Differential Revision: https://reviews.freebsd.org/D37463

19 months agogrowfs script: add swap partition as well as growing root
Mike Karels [Sat, 10 Dec 2022 19:38:36 +0000 (13:38 -0600)]
growfs script: add swap partition as well as growing root

Add the ability to create a swap partition in the course of growing
the root file system on first boot, enabling by default.  The default
rules are: add swap if the disk is at least 15 GB (decimal), and the
existing root is less than 40% of the disk.  The default size is 10%
of the disk, but is limited by the memory size.  The limit is twice
memory size up to 4 GB, 8 GB up to 8 GB memory, and memory size over
8 GB memory. Swap size is clamped at vm.swap_maxpages/2 as well.
The new swap partition is labeled as "growfs_swap".

The default behavior can be overridden by setting growfs_swap_size in
/etc/rc.conf or in the kernel environment, with kenv taking priority.
A value of 0 inhibits the addition of swap, an empty value specifies
the default, and other values indicate a swap size in bytes.

By default, addition of swap is inhibited if a swap partition is found
in the output of the sysctl kern.geom.conftxt before the current root
partition, usually meaning that there is another disk present.
Swap space is not added if one is already present in /etc/fstab.

The root partition is read-only when growfs runs, so /etc/fstab can
not be modified.  That step is handled by a new growfs_fstab script,
added in a separate commit.  Set the value "growfs_swap_pdev" in kenv
to indicate that this should be done, as well as for internal use.

There is optional verbose output meant for debugging; it can only be
enabled by modifying the script (in two places, for sh and awk).
This should be removed before release, after testing on -current.

Discussed with: cperciva
Reviewed by: imp (previous version)
Differential Revision: https://reviews.freebsd.org/D37462

19 months agobhyve: Remove the unused vcpu argument from all of the I/O port handlers.
John Baldwin [Fri, 9 Dec 2022 18:35:44 +0000 (10:35 -0800)]
bhyve: Remove the unused vcpu argument from all of the I/O port handlers.

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

19 months agobhyve: Remove unused vcpu argument from PCI read/write methods.
John Baldwin [Fri, 9 Dec 2022 18:35:28 +0000 (10:35 -0800)]
bhyve: Remove unused vcpu argument from PCI read/write methods.

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

19 months agobhyve: Pass a vCPU ID of 0 to vm_setup_pptdev_msi*.
John Baldwin [Fri, 9 Dec 2022 18:28:11 +0000 (10:28 -0800)]
bhyve: Pass a vCPU ID of 0 to vm_setup_pptdev_msi*.

These ioctls are not vCPU-specific and the ioctl now ignores the vCPU
ID.  0 is used instead of -1 to provide limited forwards
compatibility.

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

19 months agobhyve: Remove unused argument from pci_nvme_handle_doorbell.
John Baldwin [Fri, 9 Dec 2022 18:27:36 +0000 (10:27 -0800)]
bhyve: Remove unused argument from pci_nvme_handle_doorbell.

Reviewed by: corvink, chuck, markj
Differential Revision: https://reviews.freebsd.org/D37650

19 months agovmm: Free vCPUs when destroying them.
John Baldwin [Fri, 9 Dec 2022 18:27:05 +0000 (10:27 -0800)]
vmm: Free vCPUs when destroying them.

Reported by: andrew
Reviewed by: corvink, andrew, markj
Differential Revision: https://reviews.freebsd.org/D37649

19 months agovmm: Avoid infinite loop in vcpu_lock_all error case.
John Baldwin [Fri, 9 Dec 2022 18:26:49 +0000 (10:26 -0800)]
vmm: Avoid infinite loop in vcpu_lock_all error case.

Reported by: Coverity (CIDs 1501060,1501071)
Reviewed by: corvink, markj, emaste
Differential Revision: https://reviews.freebsd.org/D37648

19 months agovmm: Don't lock a vCPU for VM_PPTDEV_MSI[X].
John Baldwin [Fri, 9 Dec 2022 18:26:23 +0000 (10:26 -0800)]
vmm: Don't lock a vCPU for VM_PPTDEV_MSI[X].

These are manipulating state in a ppt(4) device none of which is
vCPU-specific.  Mark the vcpu fields in the relevant ioctl structures
as unused, but don't remove them for now.

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

19 months agovmm: VM_GET/SET_KERNEMU_DEV should run with the vCPU locked.
John Baldwin [Fri, 9 Dec 2022 18:25:30 +0000 (10:25 -0800)]
vmm: VM_GET/SET_KERNEMU_DEV should run with the vCPU locked.

Reviewed by: corvink, kib, markj
Differential Revision: https://reviews.freebsd.org/D37638

19 months agoUpdate vendor/libarchive to libarchive/libarchive@ba80276cc
Martin Matuska [Fri, 9 Dec 2022 16:26:30 +0000 (17:26 +0100)]
Update vendor/libarchive to libarchive/libarchive@ba80276cc

Important Bugfixes:
  rar5 reader: fix possible garbled output with bsdtar -O (#1745)
  mtree reader: support reading mtree files with tabs (#1783)
  various small fixes for issues found by CodeQL

Obtained from: libarchive
Libarchive commit: ba80276ccc3c941c4918ec6e2460059f0c525c43
Libarcive tag: v3.6.2

19 months agoProvide consistent prototype for swp_pager_meta_free()
Konstantin Belousov [Fri, 9 Dec 2022 15:21:16 +0000 (17:21 +0200)]
Provide consistent prototype for swp_pager_meta_free()

This should fix 32bit build breakage.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

19 months agokboot: Use (void) instead of () for functiosn with no args
Warner Losh [Fri, 9 Dec 2022 14:55:42 +0000 (07:55 -0700)]
kboot: Use (void) instead of () for functiosn with no args

`int foo();` means 'a function that takes any number of arguments.`
not `a function that takes no arguemnts`, that's spelled `int foo(void);`
Adopt the latter.

Sponsored by: Netflix

19 months agoheimdal: kadm5_c_get_principal() should check return code
Cy Schubert [Fri, 9 Dec 2022 14:06:04 +0000 (06:06 -0800)]
heimdal: kadm5_c_get_principal() should check return code

kadm5_c_get_principal() should check the return code from
kadm5_ret_principal_ent(). As it doesn't it assumes success when
there is none and can lead to potential vulnerability. Fix this.

Reported by: rtm@csail.mit.edu
MFC after: 3 days

19 months agoheimdal: Properly ix bus fault when zero-length request received
Cy Schubert [Thu, 8 Dec 2022 23:22:43 +0000 (15:22 -0800)]
heimdal: Properly ix bus fault when zero-length request received

Zero length client requests result in a bus fault when attempting to
free malloc()ed pointers within the requests softc. Return an error
when the request is zero length.

This properly fixes PR/268062 without regressions.

PR: 268062
Reported by: Robert Morris <rtm@lcs.mit.edu>
MFC after: 3 days

19 months agoRevert "heimdal: Fix bus fault when zero-length request received"
Cy Schubert [Thu, 8 Dec 2022 16:08:50 +0000 (08:08 -0800)]
Revert "heimdal: Fix bus fault when zero-length request received"

This is the wrong fix for PR/268062.

MFC after: immediately

This reverts commit 6742ff42ab3b6e65239f975314060b1393e22d62.

19 months agoposixshm_test: add naive page accounting test
Konstantin Belousov [Sat, 3 Dec 2022 22:54:36 +0000 (00:54 +0200)]
posixshm_test: add naive page accounting test

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

19 months agoposixshm_test: small style fixes
Konstantin Belousov [Sat, 3 Dec 2022 22:54:13 +0000 (00:54 +0200)]
posixshm_test: small style fixes

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

19 months agoposixshmcontrol(1): for regular shmfd, report used pages number
Konstantin Belousov [Wed, 23 Nov 2022 22:01:05 +0000 (00:01 +0200)]
posixshmcontrol(1): for regular shmfd, report used pages number

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

19 months agoshmfd: account for the actually allocated pages
Konstantin Belousov [Wed, 23 Nov 2022 21:26:38 +0000 (23:26 +0200)]
shmfd: account for the actually allocated pages

Return the value as stat(2) st_blocks.

Suggested and reviewed by: markj (previous version)
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D37097

19 months agotmpfs: for used pages, account really allocated pages, instead of file sizes
Konstantin Belousov [Thu, 20 Oct 2022 13:17:43 +0000 (16:17 +0300)]
tmpfs: for used pages, account really allocated pages, instead of file sizes

This makes tmpfs size accounting correct for the sparce files. Also
correct report st_blocks/va_bytes. Previously the reported value did not
accounted for the swapped out pages.

PR: 223015
Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D37097

19 months agovm_pager_allocate(): override resulting object type
Konstantin Belousov [Sun, 4 Dec 2022 00:37:28 +0000 (02:37 +0200)]
vm_pager_allocate(): override resulting object type

For dynamically allocated pager type, which inherits the parent's alloc
method, type of the returned object is set to the parent's type
otherwise.

Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D37097

19 months agovm_pager: add method to veto page allocation
Konstantin Belousov [Thu, 20 Oct 2022 13:15:46 +0000 (16:15 +0300)]
vm_pager: add method to veto page allocation

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

19 months agovm_pager: add methods for page insertion and removal notifications
Konstantin Belousov [Thu, 20 Oct 2022 12:55:38 +0000 (15:55 +0300)]
vm_pager: add methods for page insertion and removal notifications

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

19 months agotmpfs: make vm_object point to the tmpfs node instead of vnode
Konstantin Belousov [Thu, 20 Oct 2022 12:00:21 +0000 (15:00 +0300)]
tmpfs: make vm_object point to the tmpfs node instead of vnode

The vnode could be reclaimed and allocated again during the lifecycle of
the node, but the node cannot.  Also, referencing the node would allow
to reach it and tmpfs mount data from the object, regardless of the
state of the possibly absent vnode.

Still use swp_tmpfs for back-pointer, instead of using handle. Use of
named swap objects would incur taking the sw_alloc_sx on node allocation
and deallocation.

swp_tmpfs is renamed to swp_priv to remove the last bit of tmpfs in vm/.

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

19 months agoMake swap_pager_freespace() global
Konstantin Belousov [Wed, 26 Oct 2022 22:13:27 +0000 (01:13 +0300)]
Make swap_pager_freespace() global

also make it return the count of the swap pages freed, which are not
simultaneously resident in the object.

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

19 months agoAdd 'show tmpfs' ddb command
Konstantin Belousov [Thu, 20 Oct 2022 14:30:00 +0000 (17:30 +0300)]
Add 'show tmpfs' ddb command

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

19 months agotmpfs: minor style
Konstantin Belousov [Mon, 24 Oct 2022 13:30:38 +0000 (16:30 +0300)]
tmpfs: minor style

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

19 months agouiomove_object: hide diagnostic under bootverbose
Konstantin Belousov [Sun, 23 Oct 2022 11:36:17 +0000 (14:36 +0300)]
uiomove_object: hide diagnostic under bootverbose

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

19 months agonetlink: add interface notification on link status / flags change.
Alexander V. Chernikov [Sat, 3 Dec 2022 17:10:50 +0000 (17:10 +0000)]
netlink: add interface notification on link status / flags change.

* Add link-state change notifications by subscribing to ifnet_link_event.
 In the Linux netlink model, link state is reported in 2 places: first is
 the IFLA_OPERSTATE, which stores state per RFC2863.
 The second is an IFF_LOWER_UP interface flag. As many applications rely
 on the latter, reserve 1 bit from if_flags, named as IFF_NETLINK_1.
 This flag is mapped to IFF_LOWER_UP in the netlink headers. This is done
 to avoid making applications think this flag is actually
 supported / presented in non-netlink outputs.
* Add flag change notifications, by hooking into rt_ifmsg().
 In the netlink model, notification should include the bitmask for the
 change flags. Update rt_ifmsg() to include such bitmask.

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

19 months agoMFV: xz 5.2.9
Xin LI [Fri, 9 Dec 2022 07:46:09 +0000 (23:46 -0800)]
MFV: xz 5.2.9

MFC after: 2 weeks

19 months agoVendor import of xz 5.2.9 (trimmed)
Xin LI [Fri, 9 Dec 2022 07:45:12 +0000 (23:45 -0800)]
Vendor import of xz 5.2.9 (trimmed)

19 months agokboot: Allow loading fdt from different sources
Warner Losh [Fri, 9 Dec 2022 05:07:52 +0000 (22:07 -0700)]
kboot: Allow loading fdt from different sources

Linux has /sys/firmware/fdt and /proc/device-tree to publish the dtb for
the system. The former has it all in one file, while the latter breaks
it out. Prefer the former since it's the more modern interface, but
retain both since I don't have a PS3 to test to see if its kernel is new
enough for /sys/firmware or not.

In addition, do the proper fixup.

Sponsored by: Netflix

19 months agokboot: Need to find the ACPI tables
Warner Losh [Fri, 9 Dec 2022 04:56:06 +0000 (21:56 -0700)]
kboot: Need to find the ACPI tables

We need to pass the ACPI tables to the laucnhed kernel (at least for x86
and aarch64). Find it using the Linux standard way.

Sponsored by: Netflix