]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
18 months agoheimdal: Fix multiple security vulnerabilities
Cy Schubert [Tue, 8 Nov 2022 08:53:29 +0000 (00:53 -0800)]
heimdal: Fix multiple security vulnerabilities

The following issues are patched:

 - CVE-2022-42898 PAC parse integer overflows
 - CVE-2022-3437 Overflows and non-constant time leaks in DES{,3} and arcfour
 - CVE-2021-44758 NULL dereference DoS in SPNEGO acceptors
 - CVE-2022-44640 Heimdal KDC: invalid free in ASN.1 codec

    Note that CVE-2022-44640 is a severe vulnerability, possibly a 10.0
    on the Common Vulnerability Scoring System (CVSS) v3, as we believe
    it should be possible to get an RCE on a KDC, which means that
    credentials can be compromised that can be used to impersonate
    anyone in a realm or forest of realms.

    Heimdal's ASN.1 compiler generates code that allows specially
    crafted DER encodings of CHOICEs to invoke the wrong free function
    on the decoded structure upon decode error.  This is known to impact
    the Heimdal KDC, leading to an invalid free() of an address partly
    or wholly under the control of the attacker, in turn leading to a
    potential remote code execution (RCE) vulnerability.

    This error affects the DER codec for all extensible CHOICE types
    used in Heimdal, though not all cases will be exploitable.  We have
    not completed a thorough analysis of all the Heimdal components
    affected, thus the Kerberos client, the X.509 library, and other
    parts, may be affected as well.

    This bug has been in Heimdal's ASN.1 compiler since 2005, but it may
    only affect Heimdal 1.6 and up.  It was first reported by Douglas
    Bagnall, though it had been found independently by the Heimdal
    maintainers via fuzzing a few weeks earlier.

    While no zero-day exploit is known, such an exploit will likely be
    available soon after public disclosure.

 - CVE-2019-14870: Validate client attributes in protocol-transition
 - CVE-2019-14870: Apply forwardable policy in protocol-transition
 - CVE-2019-14870: Always lookup impersonate client in DB

Sponsored by: so (philip)
Obtained from: so (philip)
Tested by: philip, cy

(cherry picked from commit ed549cb0c53f8438c52593ce811f6fcc812248e9)

18 months agoascii.7: Add full names of the control character set
Gordon Bergling [Sat, 12 Nov 2022 11:22:22 +0000 (12:22 +0100)]
ascii.7: Add full names of the control character set

Extent the manual page by the full names of the
control character set.

Obtained from: NetBSD

(cherry picked from commit b6d1ac7f01f35ff3c44f65d197414f92356e932b)

18 months agovipw.8: Add a FILES section
Gordon Bergling [Sat, 12 Nov 2022 11:56:29 +0000 (12:56 +0100)]
vipw.8: Add a FILES section

Mention passwd related files in the FILES section
of vipw(8).

Obtained from: OpenBSD

(cherry picked from commit 30a6c8a3a8a65074e531010f4adc8c1559f954ac)

18 months ago<crypto/chacha20_poly1305>: Fix operations with 8 byte nonce.
John Baldwin [Tue, 15 Nov 2022 01:24:56 +0000 (17:24 -0800)]
<crypto/chacha20_poly1305>: Fix operations with 8 byte nonce.

In head, the inline ChaCha20+Poly1305 API is implemented using the
software implementation backing OCF, but that requires API changes
that can't be MFC'd.  As a result, this API in stable/13 uses
libsodium directly.

However, libsodium's version of ChaCha20+Poly1305 with an 8 byte nonce
uses a different construction for the Poly1305 hash than is used for
the standard IETF AEAD cipher used for TLS and IPsec.  WireGuard's use
of an 8 byte nonce also uses the more standard construction.

Since the verison in stable/13 was using libsodium directly for the 8
byte nonce case, it was generating incorrect MACs for if_wg(4).  As a
workaround, change the direct API to always use the IETF API from
libsodium which uses 12 byte nonces.  This can be done by
zero-extending the provided 8 byte nonce to 12 bytes so long as the
passed in buffers are sufficiently small to not overflow a 4 byte
counter.

This fixes key negotiation for if_wg(4) on stable/13.  This is also
a direct commit to stable/13.

Reported by: Marek Zarychta <mzar@bpine64.dom.potoki.eu>

18 months agoatomic: Intercept atomic_(load|store)_bool for kernel sanitizers
Mark Johnston [Sat, 29 Oct 2022 15:02:02 +0000 (11:02 -0400)]
atomic: Intercept atomic_(load|store)_bool for kernel sanitizers

Fixes: 2bed73739aac ("atomic: Add plain atomic_load/store_bool()")

(cherry picked from commit 1f6b6cf1774c4f173df1cde3e5cff459f340c95f)

18 months agoOnly define sanitizer wrappers for atomic fences once.
John Baldwin [Wed, 15 Sep 2021 16:03:17 +0000 (09:03 -0700)]
Only define sanitizer wrappers for atomic fences once.

Previously, this was defining duplicate definitions for each type.

This fixes a redundat definition warning from GCC.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D31965

(cherry picked from commit 45cb7671133efa52b63f301e8439a71259abe478)

18 months agoSimplify kernel sanitizer interceptors
Mark Johnston [Mon, 19 Jul 2021 20:09:42 +0000 (16:09 -0400)]
Simplify kernel sanitizer interceptors

KASAN and KCSAN implement interceptors for various primitive operations
that are not instrumented by the compiler.  KMSAN requires them as well.
Rather than adding new cases for each sanitizer which requires
interceptors, implement the following protocol:
- When interceptor definitions are required, define
  SAN_NEEDS_INTERCEPTORS and SANITIZER_INTERCEPTOR_PREFIX.
- In headers that declare functions which need to be intercepted by a
  sanitizer runtime, use SANITIZER_INTERCEPTOR_PREFIX to provide
  declarations.
- When SAN_RUNTIME is defined, do not redefine the names of intercepted
  functions.  This is typically the case in files which implement
  sanitizer runtimes but is also needed in, for example, files which
  define ifunc selectors for intercepted operations.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

(cherry picked from commit a90d053b84223a4e5cb65852a9b6193570ab1c7d)

18 months agowg: Fix build without VIMAGE.
John Baldwin [Mon, 14 Nov 2022 19:02:26 +0000 (11:02 -0800)]
wg: Fix build without VIMAGE.

This is a direct commit to stable/13.

Reported by: Helge Oldach <freebsd@oldach.net>

18 months agoddb: don't limit pindex output in 'show vmopag'
Mitchell Horne [Fri, 11 Nov 2022 18:23:11 +0000 (14:23 -0400)]
ddb: don't limit pindex output in 'show vmopag'

This command already prints a tremendous amount of output, and properly
obeys the pager. It no longer makes sense to arbitrarily limit the pages
that are printed, as the reader will not be aware that this has
happened.

Reviewed by: markj
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D37361

(cherry picked from commit 03d6764b384e64c0e812c1a1b9b19c0e0d45cde2)

18 months agonetgdb(4): update list of required kernel options
Mitchell Horne [Fri, 11 Nov 2022 18:20:31 +0000 (14:20 -0400)]
netgdb(4): update list of required kernel options

The man page claims that netgdb will be enabled automatically with the
presence of the DDB, GDB, and INET options. Based on the logic in
conf/files, this is not the case. Update the manpage to list all
of the options required to include netgdb.

Reviewed by: pauamma, markj
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D37330

(cherry picked from commit d5f3e80f5a0b64ccde9ab6856766fc565e795393)

18 months agonetdump(4): document all kernel options required
Mitchell Horne [Fri, 11 Nov 2022 18:20:58 +0000 (14:20 -0400)]
netdump(4): document all kernel options required

This means INET and DEBUGNET in addition to NETDUMP.

Reviewed by: pauamma, markj
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D37331

(cherry picked from commit b0832b5074840bce6f52842888b8c5279528fefa)

18 months agoREADME.md: link to the list of supported platforms
Mitchell Horne [Tue, 1 Nov 2022 15:20:01 +0000 (12:20 -0300)]
README.md: link to the list of supported platforms

It answers a question that someone might have when faced with the source
tree for the first time, and improves discoverability of the platforms
page.

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

(cherry picked from commit c34ffd6c8b2859ef46873e6c3d6b3655da6db8c0)

18 months agolibc: Don't warn about RRSIG replies.
Dag-Erling Smørgrav [Mon, 7 Nov 2022 15:48:11 +0000 (16:48 +0100)]
libc: Don't warn about RRSIG replies.

PR: 213178
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D37303

(cherry picked from commit 817f1f3064db25f821032c8fffb131183206bba1)

18 months agogetty: code cleanup, part 1
Dag-Erling Smørgrav [Fri, 4 Nov 2022 13:23:33 +0000 (14:23 +0100)]
getty: code cleanup, part 1

* Avoid unnecessary use of `unsigned char *`
* Use explicit casts when assigning `unsigned char *` to `char *` or vice versa
* Drop unused global variables (and fix memory leak in `gettable()`)
* Use `snprintf()` instead of `strcpy()` + `strcat()`
* Drop spurious braces in switch

Sponsored by: Klara, Inc.
Obtained from: Apple OSS Distributions (in part)
Differential Revision: https://reviews.freebsd.org/D37263

(cherry picked from commit 8ad7a14ab49b93240676e15f404354775be931f4)

getty: code cleanup, part 2

* Clean up whitespace
* Reindent

Sponsored by: Klara, Inc.

(cherry picked from commit f285f41498ebe0bfc1dbe47d67af12ec2d131521)

getty: Avoid NULL deref if stdin is not a tty.

Sponsored by: Klara, Inc.
Obtained from: Apple OSS Distributions
Differential Revision: https://reviews.freebsd.org/D37265

(cherry picked from commit eb4d86d529e2523a19fd7454976923319954a49d)

18 months agolinux(4): Fix get_robust_list() syscall return value.
Alex S [Tue, 8 Nov 2022 21:17:17 +0000 (00:17 +0300)]
linux(4): Fix get_robust_list() syscall return value.

The system call returns the head of the robust futex list. The list head is stored
in the location pointed to by the head argument. When copying data between address
spaces use proper head storage size as it depends on an emulated ABI.

PR: 267616
MFC after: 3 days

(cherry picked from commit 9f7bf94ee2a88a702cef9fdb67166404c275afaf)

18 months agoRemove references to timed(8)
Ceri Davies [Thu, 13 May 2021 07:53:08 +0000 (09:53 +0200)]
Remove references to timed(8)

There are still references to timed(8) and timedc(8) in the base system,
which were removed in 2018.

PR: 255425
Reported by: Ceri Davies <ceri at submonkey dot net>
Reviewed by: ygy, gbe
Differential Revision: https://reviews.freebsd.org/D30232

(cherry picked from commit 1760799b4c612b98c0e5c1abeb03814e24c33cf6)

18 months agobhyve: initial PowerCycles value
Wanpeng Qian [Fri, 4 Nov 2022 07:48:00 +0000 (08:48 +0100)]
bhyve: initial PowerCycles value

Currently PowerCycles field of Log Page is 0 and it is an invalid value.
This patch will initial the PowerCycles data to 1.

MFC after: 1 week
Approved by: manu (mentor)
Reviewed By: grehan (older version), chuck, corvink
Differential Revision: https://reviews.freebsd.org/D32558

(cherry picked from commit b631954ff07989b83378bf5cd1af5fad7162c9f9)

18 months agobhyve nvme: Fix Active Firmware Info
WanpengQian [Sun, 14 Aug 2022 15:28:05 +0000 (08:28 -0700)]
bhyve nvme: Fix Active Firmware Info

Summary:
Currently Active Firmware Info is not initialized.

Fix is to initialize the Active Firmware Info to Slot 1.

Test Plan: Within FreeBSD/Linux guests, show the Firmware Logpage to confirm.

Reviewed By: chuck
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D32658

(cherry picked from commit 3cae10048d27f805d7fc909b123ddee34be0268e)

18 months agoresolver.5: Add an EXAMPLES section
Gordon Bergling [Mon, 7 Nov 2022 11:09:43 +0000 (12:09 +0100)]
resolver.5: Add an EXAMPLES section

In case local-unbound(8) fails for some reason, it could be useful
to have a basic resolv.conf(5) example in the manual page.

Reviewed by: karels, pauamma
Differential Revision: https://reviews.freebsd.org/D37183

(cherry picked from commit 4d00d772e9aa995f93da41883a1fea5e2e43f818)

18 months agoshutdown.8: Add a note about needed priviledges to run the command
Gordon Bergling [Mon, 7 Nov 2022 11:00:11 +0000 (12:00 +0100)]
shutdown.8: Add a note about needed priviledges to run the command

In order to use the shutdown command, the user must
have root privileges or be a member of the operator group.

PR: 266525
Reported by: Zsolt Udvari <uzsolt at uzsolt hu>
Reviewed by: pauamma
Differential Revision: https://reviews.freebsd.org/D36688

(cherry picked from commit e0dfa1c4c45ec1b787020c99310c36aec9d9007b)

18 months agoUpdate HISTORY and AUTHORS sections for cut(1) and paste(1)
Gordon Bergling [Mon, 7 Nov 2022 10:23:33 +0000 (11:23 +0100)]
Update HISTORY and AUTHORS sections for cut(1) and paste(1)

In an e-mail Brian Walden wrote that:

"GWRL stands for Gottfried W. R. Luderer, the author of cut(1) and
paste(1), probably around 1978. Those came either from PWB or USG,
as he worked with, or for, Berkley Tague. Thus they made their way
into AT&T commercial UNIX, first into System III and the into System
V, and that's why they are missing from early BSD releases as they
didn't get into Research UNIX until the 8th Edition."

So update the HISTORY and AUTHORS sections for cut(1) and paste(1).

[1] https://minnie.tuhs.org/pipermail/tuhs/2020-January/019955.html

Reviewed by: pauamma, imp
Obtained from: OpenBSD (in partial)
Differential Revision: https://reviews.freebsd.org/D36048

(cherry picked from commit 9bdb5158d6016798187e4d7eb943791a64809194)

18 months agologger: fix builds without casper
Mariusz Zaborski [Wed, 19 Oct 2022 14:00:07 +0000 (16:00 +0200)]
logger: fix builds without casper

We can enter capability mode only when Casper is available in
the system.

Reported by: mjg@

(cherry picked from commit af3297898720af2f2ed18d18d45ea6bf50d55ef1)

18 months agoinclude: put includes into -dev packages
Kyle Evans [Thu, 10 Nov 2022 04:20:34 +0000 (22:20 -0600)]
include: put includes into -dev packages

The includes build is kind of funky, as we support either copying or
symlinking files into /usr/include.  For `copies`, we were supplying
the include/ ${TAG_ARGS}, which puts packages into `FreeBSD-runtime`,
without any consideration to the fact that we're installing headers.

Let's copy the approach that the `symlinks` target uses for now, and
add ",dev" to the TAG_ARGS so that headers at least end up in
FreeBSD-runtime-dev, which is more appropriate.  Some of these includes
are actually technically supposed to be in *other* packages and their
INCSGROUP's PACKAGE setting is actually correct, but this is less
trivial to solve.  This is a bandaid to fix the immediate problem of
some headers ending up in two different packages.

PR: 267526
Reviewed by: dfr, manu
Differential Revision: https://reviews.freebsd.org/D37256

(cherry picked from commit 8b8babf044ca8e8f0d49894c3a41d429146ffc5a)

18 months agomktemp: don't double up on trailing slashes for -t paths
Kyle Evans [Wed, 2 Nov 2022 20:29:16 +0000 (15:29 -0500)]
mktemp: don't double up on trailing slashes for -t paths

This is a minor cosmetic change; re-organize slightly to set tmpdir to
_PATH_TMP if we didn't otherwise have a tmpdir candidate, then check the
trailing char before appending another slash.

While we're here, remove some bogus whitespace and add a test case for
this change.

Obtained from: https://github.com/apple-oss-distributions/shell_cmds
Sponsored by: Klara, Inc.

(cherry picked from commit a6346c02f646c6b74f007c64a9b546deb06182ae)

18 months agomktemp: add -p/--tmpdir argument
Kyle Evans [Mon, 31 Oct 2022 03:55:46 +0000 (22:55 -0500)]
mktemp: add -p/--tmpdir argument

This matches other mktemp implementations, including OpenBSD and GNU.
The -p option can be used to provide a tmpdir prefix for specified
templates.  Precedence works out like so:

-t flag:
- $TMPDIR
- -p directory
- /tmp

Implied -t flag (no arguments or only -d flag):
- -p directory
- $TMPDIR
- /tmp

Some tests have been added for mktemp(1) in the process.

Reviewed by: imp (earlier version), wosch
Sponsored by: Klara, Inc.

(cherry picked from commit ac6f924e1cd1ebd9832227e906ebc03e3ba5eede)
(cherry picked from commit d22f03636be1c012951f744f414b0d410970808e)

18 months agomktemp: add some GNU-compatible long options
Kyle Evans [Mon, 31 Oct 2022 03:55:46 +0000 (22:55 -0500)]
mktemp: add some GNU-compatible long options

GNU maketemp has long options for -d, -q, and -u, so let's add these
now for compatibility.

Reviewed by: emaste, imp, wosch
Sponsored by: Klara, Inc.

(cherry picked from commit cfc57d7dbe5bff175ef6d508fecd6779c0a0d656)

18 months agowg: drop -Wno-cast-qual from CFLAGS
Kyle Evans [Sat, 5 Nov 2022 03:45:36 +0000 (22:45 -0500)]
wg: drop -Wno-cast-qual from CFLAGS

The latest update fixes the warning by applying const to the correct
part of the pointer.

(cherry picked from commit a28989483e9d4b3488b3b232139fc47b522a6786)

18 months agoMerge commit '93bf91b4012a28610672d2266366dfa0a663b70f' into HEAD
Kyle Evans [Sat, 5 Nov 2022 03:46:21 +0000 (22:46 -0500)]
Merge commit '93bf91b4012a28610672d2266366dfa0a663b70f' into HEAD

This fixes a warning in wireguard-tools, as well as two issues pointed out by
FreeBSD's Coverity instance.

CID: 15004051500421
(cherry picked from commit 2cb43631ab122ee0b2a3a101003b73415a9bf963)

18 months agousr.bin: hook wg(8) up to the build
Kyle Evans [Sat, 29 Oct 2022 03:04:56 +0000 (22:04 -0500)]
usr.bin: hook wg(8) up to the build

wg(8) is used to manage WireGuard interfaces; see wg(4) and wg(8) both
for more details and usage examples.

(cherry picked from commit 0283826706706c598fff86e16c42604841c1a05a)

18 months agoAdd 'contrib/wireguard-tools/' from commit '7e00bf8773b93a2a3ee28dba2710d2ae443989f1'
Kyle Evans [Sat, 29 Oct 2022 03:05:14 +0000 (22:05 -0500)]
Add 'contrib/wireguard-tools/' from commit '7e00bf8773b93a2a3ee28dba2710d2ae443989f1'

git-subtree-dir: contrib/wireguard-tools
git-subtree-mainline: 9142a2a37b2fe65d46ace08a098ad26b8ff81541
git-subtree-split: 7e00bf8773b93a2a3ee28dba2710d2ae443989f1
(cherry picked from commit adf376485712c8fffbf3be330d505a969647f479)

18 months agoRemove README in favor of README.md
Warner Losh [Fri, 12 Mar 2021 00:11:28 +0000 (17:11 -0700)]
Remove README in favor of README.md

Complete the transition to README.md I started 3 years ago. Remove the
now-redundant README file. It's currently just README.md w/o the light markup
and adds no real value. This also allows us to use additional MarkDown
markup as we see fit w/o worrying about keeping things in sync.

(cherry picked from commit 8a157722e947191a63e9108cbfb60ee2605858b4)

18 months agoWhitespace cleanup
Li-Wen Hsu [Fri, 12 Mar 2021 11:57:30 +0000 (19:57 +0800)]
Whitespace cleanup

(cherry picked from commit aaf998056ed46c0dfb429e3e5cfe624c8aa4dec8)

18 months agoUpdate doc links in README
Li-Wen Hsu [Fri, 12 Mar 2021 11:55:56 +0000 (19:55 +0800)]
Update doc links in README

(cherry picked from commit cada2b74b8d670741643dca8e3d40c39d8fc7105)

18 months agoreadme: Link to COPYRIGHT file
Warner Losh [Fri, 12 Mar 2021 00:55:16 +0000 (17:55 -0700)]
readme: Link to COPYRIGHT file

(cherry picked from commit e75eac2cb81c510389f527da14cec4a16123e673)

18 months agoFix arch rendering
Warner Losh [Fri, 12 Mar 2021 00:52:13 +0000 (17:52 -0700)]
Fix arch rendering

(cherry picked from commit dbd92cc2a4915a2070c93cff423314f43edfc841)

18 months agoreadme: update style
Warner Losh [Fri, 12 Mar 2021 00:21:16 +0000 (17:21 -0700)]
readme: update style

Update the style to one sentence per line, as is currently used in the FreeBSD
document project. Make the links to the handbook clickable.

(cherry picked from commit 2918e9fdb82ffe5e95cab90a754bc6c2b6dd16a2)

18 months agouslcom(4): Clear stall at every open.
Hans Petter Selasky [Wed, 5 Oct 2022 14:45:21 +0000 (16:45 +0200)]
uslcom(4): Clear stall at every open.

To avoid data loss, make sure both the receive and transmit data toggles
get reset, before trying to read or write any data.

Sponsored by: NVIDIA Networking

(cherry picked from commit 9e0edafe92ad9fc6745ee4c4c58e45a49b9e7ed1)

18 months agoxhci(4): Fix spelling in manual page.
Hans Petter Selasky [Fri, 21 Oct 2022 05:47:54 +0000 (07:47 +0200)]
xhci(4): Fix spelling in manual page.

Noted by: Gary Jennejohn <garyj@gmx.de>
Sponsored by: NVIDIA Networking

(cherry picked from commit a2d60916d0dd4073d8da15bad65f301e9f8085fa)

18 months agoxhci(4): Update list of quirks in manual page.
Hans Petter Selasky [Thu, 20 Oct 2022 17:22:41 +0000 (19:22 +0200)]
xhci(4): Update list of quirks in manual page.

Sponsored by: NVIDIA Networking

(cherry picked from commit 30e555de804f67afb27385ee0521f94784dbbfbf)

18 months agoxhci(4): Don't allocate an IRQ vector if hw.usb.xhci.use_polling=1 is set.
Hans Petter Selasky [Thu, 20 Oct 2022 17:21:53 +0000 (19:21 +0200)]
xhci(4): Don't allocate an IRQ vector if hw.usb.xhci.use_polling=1 is set.

This is useful for debugging purposes.

Sponsored by: NVIDIA Networking

(cherry picked from commit 3346ae0d24c072ef0e26ace3aae21bfef93d80aa)

18 months agosound(4): Fix memory map of /dev/dsp devices when buffer size is not a multiple of...
Florian Walpen [Fri, 4 Nov 2022 18:04:26 +0000 (19:04 +0100)]
sound(4): Fix memory map of /dev/dsp devices when buffer size is not a multiple of PAGE_SIZE.

By using sndbuf_getallocsize() instead of sndbuf_getsize() in dsp_mmap_single().

PR: 267555
Sponsored by: NVIDIA Networking

(cherry picked from commit ad370f7658ba59811d02c04032ac33ef787f752f)

18 months agotime(3): Fix spelling.
Hans Petter Selasky [Sun, 23 Oct 2022 16:41:28 +0000 (18:41 +0200)]
time(3): Fix spelling.

Noted by: Gary Jennejohn <garyj@gmx.de>
Sponsored by: NVIDIA Networking

(cherry picked from commit fdd95483332bf7fab36e2562d570a9a914a19769)

18 months agotime(3): Optimize tvtohz() function.
Hans Petter Selasky [Thu, 20 Oct 2022 16:49:51 +0000 (18:49 +0200)]
time(3): Optimize tvtohz() function.

List of changes:
- Use integer multiplication instead of long multiplication, because the result is an integer.
- Remove multiple if-statements and predict new if-statements.
- Rename local variable name, "ticks" into "retval" to avoid shadowing
the system "ticks" global variable.

Reviewed by: kib@ and imp@
Sponsored by: NVIDIA Networking
Differential Revision:  https://reviews.freebsd.org/D36859

(cherry picked from commit 35a33d14b593ba93feb8fed8d0689bc8e0edd15b)

18 months agotime(3): Declare the minimum and maximum hz values supported.
Hans Petter Selasky [Mon, 3 Oct 2022 09:08:53 +0000 (11:08 +0200)]
time(3): Declare the minimum and maximum hz values supported.

Reviewed by: kib@ and imp@
Sponsored by:   NVIDIA Networking
Differential Revision: https://reviews.freebsd.org/D37072

(cherry picked from commit ee29897fc3d66ba7006c9ee3f524bf2e8cf30a4f)

18 months agotime(3): Align fast clock times to avoid firing multiple timers.
Hans Petter Selasky [Mon, 3 Oct 2022 08:54:40 +0000 (10:54 +0200)]
time(3): Align fast clock times to avoid firing multiple timers.

In non-periodic mode absolute timers fire at exactly the time given.
When specifying a fast clock, align the firing time so that less
timer interrupt events are needed.

Reviewed by: rrs @
Sponsored by: NVIDIA Networking
Differential Revision: https://reviews.freebsd.org/D36858

(cherry picked from commit 0def80f1a5c8f7a02b92c823e5c71f9f746c3e6b)

18 months agoFix umtxq_sleep() regression caused by 56070dd2e4d.
Alexander Motin [Mon, 21 Mar 2022 23:43:39 +0000 (19:43 -0400)]
Fix umtxq_sleep() regression caused by 56070dd2e4d.

umtxq_requeue() moves the queue to a different hash chain and different
lock, so we can't rely on msleep_sbt() reacquiring the same old lock.
We have to use PDROP and update the queue chain and so lock pointer.

PR: 262587

(cherry picked from commit fd6ca665d206b74970e7c01d06ae06fed71500fc)

18 months agoImprove timeout precision of pthread_cond_timedwait().
Alexander Motin [Fri, 4 Mar 2022 03:03:09 +0000 (22:03 -0500)]
Improve timeout precision of pthread_cond_timedwait().

This code was not touched when all other user-space sleep functions were
switched to sbintime_t and decoupled from hardclock.  When it is possible,
convert supplied times into sbinuptime to supply directly to msleep_sbt()
with C_ABSOLUTE.  This provides the timeout resolution of few microseconds
instead of 2 milliseconds, plus avoids few clock reads and conversions.

Reviewed by: vangyzen
Differential Revision: https://reviews.freebsd.org/D34163

(cherry picked from commit 56070dd2e4df70e4de2a10c7ace684ceb8b0f0bd)

18 months agowg.4: Update the SPDX License Identifier
Gordon Bergling [Sun, 30 Oct 2022 18:05:30 +0000 (19:05 +0100)]
wg.4: Update the SPDX License Identifier

The following License Identifier
'BSD-2-Clause-FreeBSD' is not allowed
for new code so use the correct on.

Reported by: imp

(cherry picked from commit c72854c06aaed11971a29bc2e302e72577bc21e0)

18 months agowg.4: Add some enhancements
Gordon Bergling [Sun, 30 Oct 2022 12:59:37 +0000 (13:59 +0100)]
wg.4: Add some enhancements

- add a SPDX-License-Identifier
- rename the title of the man page
- use better grammar in some places
- reword 'IPs' to 'IP addresses'
- add a missing word in the AUTHORS section
- use '.An -nosplit' in the AUTHORS section
- Xr ipsec and ovpn

Reviewed by: pauamma, mhorne
Differential Revision: https://reviews.freebsd.org/D37205

(cherry picked from commit 19c03f4ab0d68788a561b91278fd13c760227a31)

18 months agowg: Trim compat shims for versions older than current stable/13.
John Baldwin [Fri, 28 Oct 2022 20:36:13 +0000 (13:36 -0700)]
wg: Trim compat shims for versions older than current stable/13.

Reviewed by: kevans, markj, emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36913

(cherry picked from commit 854d066251a9e1731993416b1934e2002a29d395)

18 months agowg: Retire now unused support.h.
John Baldwin [Fri, 28 Oct 2022 20:36:13 +0000 (13:36 -0700)]
wg: Retire now unused support.h.

Reviewed by: kevans, markj, emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36912

(cherry picked from commit c640d1af2c8ade5bcad6ffcfe92ba946146e565f)

18 months agowg: Use zfree.
John Baldwin [Fri, 28 Oct 2022 20:36:13 +0000 (13:36 -0700)]
wg: Use zfree.

Reviewed by: kevans, markj, emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36911

(cherry picked from commit dcf581bb49bedcf9c18d6cccc80a9fbd68516d23)

18 months agowg: Use atomic(9) instead of concurrency-kit atomics.
John Baldwin [Fri, 28 Oct 2022 20:36:13 +0000 (13:36 -0700)]
wg: Use atomic(9) instead of concurrency-kit atomics.

Kernel sanitizers only support atomic(9) operations.

Reviewed by: kevans, markj, emaste
Reported by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36910

(cherry picked from commit e32e1a160e01a5a0ca9e0b76ace37e58dc1379b5)

18 months agoImport the WireGuard driver from zx2c4.com.
John Baldwin [Fri, 28 Oct 2022 20:36:12 +0000 (13:36 -0700)]
Import the WireGuard driver from zx2c4.com.

This commit brings back the driver from FreeBSD commit
f187d6dfbf633665ba6740fe22742aec60ce02a2 plus subsequent fixes from
upstream.

Relative to upstream this commit includes a few other small fixes such
as additional INET and INET6 #ifdef's, #include cleanups, and updates
for recent API changes in main.

Reviewed by: pauamma, gbe, kevans, emaste
Obtained from: git@git.zx2c4.com:wireguard-freebsd @ 3cc22b2
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36909

(cherry picked from commit 744bfb213144c63cbaf38d91a1c4f7aebb9b9fbc)

18 months agoSplit netinet shell tests into one per line.
John Baldwin [Fri, 28 Oct 2022 20:36:12 +0000 (13:36 -0700)]
Split netinet shell tests into one per line.

This makes diffs when adding or removing tests easier to read.

While here, sort the list of tests.

Reviewed by: kevans, melifaro, asomers, markj, emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36908

(cherry picked from commit 9e0aaedd704ee8a040ecb1d1aadf0bd75ed4dc09)

18 months agoktrace.2: Document KTRFAC_STRUCT_ARRAY.
John Baldwin [Wed, 2 Nov 2022 17:35:26 +0000 (10:35 -0700)]
ktrace.2: Document KTRFAC_STRUCT_ARRAY.

Sponsored by: DARPA

(cherry picked from commit c9c9057c772f8fc8a0c768383597f4b92db0cd74)

18 months agors: Fix some pointer arith UB.
John Baldwin [Wed, 5 Oct 2022 23:48:05 +0000 (16:48 -0700)]
rs: Fix some pointer arith UB.

If the next column was blank, then the length of the following entry
was computed as the end of the following entry minus a global variable
"blank" which is not in the same string or allocation.  Instead, save
the start value of 'p' explicitly instead of abusing '*ep'.  Possibly
we should just increment p before saving it in sp in the 'blank' case,
but at worst that would just mean maxlen might be one char too large
which should be harmless.

Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D36832

(cherry picked from commit ba86cffb2840e12b5d72453d7c574850a76001d8)

18 months agors: Fix a use after free.
John Baldwin [Wed, 5 Oct 2022 23:47:40 +0000 (16:47 -0700)]
rs: Fix a use after free.

Using a pointer passed to realloc() after realloc() even for pointer
arithmetic is UB.  It also breaks in practice on CHERI systems as
the updated value of 'sp' in this case would have had the bounds from
the old allocation.

This would be much cleaner if elem were a std::vector<char *>.

Reviewed by: brooks, emaste
Reported by: GCC -Wuse-after-free
Differential Revision: https://reviews.freebsd.org/D36831

(cherry picked from commit e5f2d5b35e79ddf995a8a5c782a7940ca2e05fdf)

18 months agors: Fix various harmless warnings.
John Baldwin [Wed, 5 Oct 2022 23:47:21 +0000 (16:47 -0700)]
rs: Fix various harmless warnings.

- Add /* FALLTHROUGH */ comments for intentional fall throughs in
  getargs().

- Remove id strings to quiet -Wunused-const-variable warnings from
  GCC.

- While here, remove __FBSDID.

Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D36830

(cherry picked from commit bb31e1bbf2ade7abd38eb29391e1ba0718723480)

18 months agomsk: Use a void cast to mark values of dummy reads as unused.
John Baldwin [Wed, 5 Oct 2022 23:46:01 +0000 (16:46 -0700)]
msk: Use a void cast to mark values of dummy reads as unused.

Note that this required adding missing ()'s around the outermost level
of MSK_READ_MIB*.  Otherwise, the void cast was only applied to the
first register read.  This also meant that MSK_READ_MIB64 was pretty
broken as the uint64_t cast only applied to the first 16-bit register
read in each MSK_READ_MIB32 invocation and the 32-bit shift was only
applied to the second register read of the pair.

Reviewed by: imp, emaste
Reported by: GCC -Wunused-value
Differential Revision: https://reviews.freebsd.org/D36777

(cherry picked from commit ae70e8838c6673850098530f23ce1521328f983c)

18 months agomsk: Don't bother reading spare stats registers.
John Baldwin [Wed, 5 Oct 2022 23:45:43 +0000 (16:45 -0700)]
msk: Don't bother reading spare stats registers.

msk_stats_update reads stats registers named "spare" whose values are
discarded.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D36871

(cherry picked from commit aabbe26939be63615e371a91f87eeea8b177f728)

18 months agomsk: Remove write only variables, but leave hardware reads in place
Warner Losh [Wed, 6 Apr 2022 02:01:47 +0000 (20:01 -0600)]
msk: Remove write only variables, but leave hardware reads in place

Sponsored by: Netflix

(cherry picked from commit 7e5c042cced9f2fba00133af25ea0ee96f435f5d)

18 months agoqsort_b_test: Only build on clang.
John Baldwin [Mon, 3 Oct 2022 23:14:39 +0000 (16:14 -0700)]
qsort_b_test: Only build on clang.

GCC doesn't support -fblocks.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D36809

(cherry picked from commit ab9293239c7def9b93e3892f60ec3e7212b29bab)

18 months agobhyve: Don't free an invalid pointer.
John Baldwin [Mon, 3 Oct 2022 23:10:44 +0000 (16:10 -0700)]
bhyve: Don't free an invalid pointer.

The netmap-specific data stored at be->opaque is freed by the caller
on error as part of freeing be.

Reviewed by: markj
Reported by: GCC -Wfree-nonheap-object
Differential Revision: https://reviews.freebsd.org/D36828

(cherry picked from commit 2fb81691b02f27fa938f311835a8c6704c5cf80f)

18 months agonvmecontrol wdc: Don't pass a bogus pointer to free().
John Baldwin [Mon, 3 Oct 2022 23:10:44 +0000 (16:10 -0700)]
nvmecontrol wdc: Don't pass a bogus pointer to free().

wdc_get_dui_log_size allocates a buffer and then advances the
returned pointer.  Passing this advanced pointer to free() is UB,
so save the original pointer to pass to free() instead.

Reviewed by: imp
Reported by: GCC 12 -Wfree-nonheap-object
Differential Revision: https://reviews.freebsd.org/D36827

(cherry picked from commit 1187e46d1b3833b9b54867a5587904c451369515)

18 months agolibbegemot: Disable -Wuse-after-free.
John Baldwin [Mon, 3 Oct 2022 23:10:43 +0000 (16:10 -0700)]
libbegemot: Disable -Wuse-after-free.

The _xrealloc() function prints pointer values for internal assertion
failures and in one case does so after it has freed the pointer.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D36819

(cherry picked from commit 996ee965976379f0455c5f59b1cf9c82bc2e5e1b)

18 months agolibiconv VIQR: Fix a use after free.
John Baldwin [Mon, 3 Oct 2022 23:10:43 +0000 (16:10 -0700)]
libiconv VIQR: Fix a use after free.

Use TAILQ_FOREACH_SAFE to walk to list of children mnemonics to free
them instead of TAILQ_FOREACH.

Reviewed by: emaste
Reported by: GCC 12 -Wuse-after-free
Differential Revision: https://reviews.freebsd.org/D36821

(cherry picked from commit 8f27c9d14a559f33aa7fc3245f841f7ce52fadd5)

18 months agolibedit: Disable -Wuse-after-free for chartype.c.
John Baldwin [Mon, 3 Oct 2022 23:10:43 +0000 (16:10 -0700)]
libedit: Disable -Wuse-after-free for chartype.c.

GCC 12 thinks ct_visual_string can reuse a pointer after it has been
reallocated, but in this case the warning appears false.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D36820

(cherry picked from commit 7973f26ad6f98e6da3e2bb07a1015270c0d16c43)

18 months agolibfetch: Use memcpy in place of an odd strncpy.
John Baldwin [Mon, 3 Oct 2022 23:10:43 +0000 (16:10 -0700)]
libfetch: Use memcpy in place of an odd strncpy.

The length passed to strncpy is the length of the source string, not
the destination buffer.  This triggers a non-fatal warning in GCC 12.
Hoewver, the code is also odd.  It is really just a memcpy of the
string without its nul terminator.  For that use case, memcpy is
clearer.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D36824

(cherry picked from commit 611cf392672cf7aa52a593412fb2537546a7d6a4)

18 months agodiff: Fix a use after free as well as a memory leak in change().
John Baldwin [Mon, 3 Oct 2022 23:10:43 +0000 (16:10 -0700)]
diff: Fix a use after free as well as a memory leak in change().

When -B or -I are used, change() evaluates the lines in a hunk to
determine if it is a hunk that should be ignored.  It does this by
reading each candidate line into a mallocated buffer via preadline()
and then calling ignoreline().  Previously the buffer was freed as a
side effect of ignoreline_pattern() called from ignoreline().
However, if only -B was specified, then ignoreline_pattern() was not
called and the lines were leaked.  If both options were specified,
then ignoreline_pattern() was called before checking for a blank line
so that the second check was a use after free.

To fix, pull the free() out of ignoreline_pattern() and instead do it
up in change() so that is paired with preadline().

While here, simplify ignoreline() by checking for the -B and -I cases
individually without a separate clause for when both are set.  Also,
do the cheaper check (-B) first, and remove a false comment (this
function is only called if at least one of -I or -B are specified).

Reviewed by: emaste
Reported by: GCC 12 -Wuse-after-free
Differential Revision: https://reviews.freebsd.org/D36822

(cherry picked from commit 3736b2dd327050d2e6c925964b210eccbaac51ab)

18 months agofortune: Unindent a debug printf in get_fort().
John Baldwin [Mon, 3 Oct 2022 23:10:42 +0000 (16:10 -0700)]
fortune: Unindent a debug printf in get_fort().

The debug printf is intended to execute after the loop has ended to
log the selected file.

Reviewed by: imp, emaste
Reported by: GCC
Differential Revision: https://reviews.freebsd.org/D36815

(cherry picked from commit db695788fc3d1eb3ff4cb258710f874953324208)

18 months agonvmecontrol wdc: Remove unused but set variable.
John Baldwin [Mon, 3 Oct 2022 23:10:42 +0000 (16:10 -0700)]
nvmecontrol wdc: Remove unused but set variable.

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

(cherry picked from commit d81082a7ad25f26309a1466b9ad565f507bed275)

18 months agotail: Fix misleading indentation in ARG() macro.
John Baldwin [Mon, 3 Oct 2022 23:10:42 +0000 (16:10 -0700)]
tail: Fix misleading indentation in ARG() macro.

Reviewed by: imp, emaste
Reported by: GCC
Differential Revision: https://reviews.freebsd.org/D36810

(cherry picked from commit c2e561a38f739a4801d652f4b662cdc1903244f0)

18 months agobsd.sys.mk: Add NO_WUSE_AFTER_FREE helper variable.
John Baldwin [Mon, 3 Oct 2022 23:10:42 +0000 (16:10 -0700)]
bsd.sys.mk: Add NO_WUSE_AFTER_FREE helper variable.

This variable expands to -Wno-use-after-free on GCC 12+.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D36817

(cherry picked from commit 67b0751249183749c302f37e114481f8b9550032)

18 months agorpc.lockd: Explicitly cast enum nlm_stats values to enum nlm4_stats.
John Baldwin [Mon, 3 Oct 2022 23:10:42 +0000 (16:10 -0700)]
rpc.lockd: Explicitly cast enum nlm_stats values to enum nlm4_stats.

NLM 4 status values are a superset of the older NLM protocol so these
casts are safe while pacifying -Wenum-conversion warnings from GCC.

Reviewed by: rmacklem
Differential Revision: https://reviews.freebsd.org/D36816

(cherry picked from commit 3b887005b4bb215e0e052ae81fe31c2c0d5f4f35)

18 months agopowerpc_nvram: Fix a bug in the adler32 checksum.
John Baldwin [Mon, 3 Oct 2022 23:10:41 +0000 (16:10 -0700)]
powerpc_nvram: Fix a bug in the adler32 checksum.

The Adler32 digest consists of two 16-bit words whose values are
calculated modulo 65521 (largest prime < 2^16).  To avoid two division
instructions per byte, this version copies an optimization found in
zlib which defers the modulus until close to the point that the
intermediate sums can overflow 2^32.  (zlib uses NMAX == 5552 for
this, this version uses 5000)

The bug is that in the deferred modulus case, the modulus was
only applied to the high word (and twice at that) but not to
the low word.  The fix is to apply it to both words.

Reviewed by: jhibbits
Reported by: Miod Vallat <miod@openbsd.org>
Differential Revision: https://reviews.freebsd.org/D36798

(cherry picked from commit e0df0dce71d86796195502b923243bb6bacdcdc2)

18 months agopfctl: Fix mismatch in array bounds for pfr_next_token().
John Baldwin [Mon, 3 Oct 2022 23:10:41 +0000 (16:10 -0700)]
pfctl: Fix mismatch in array bounds for pfr_next_token().

Reviewed by: kp, emaste
Differential Revision: https://reviews.freebsd.org/D36806

(cherry picked from commit d74024a490c877c6b5c7a2de7a69dcfa9486162f)

18 months agoypldap: Fix mismatch in array bounds for ldapclient().
John Baldwin [Mon, 3 Oct 2022 23:10:41 +0000 (16:10 -0700)]
ypldap: Fix mismatch in array bounds for ldapclient().

Reviewed by: emaste
Reported by: GCC -Warray-parameter
Differential Revision: https://reviews.freebsd.org/D36807

(cherry picked from commit c41b161812101300570d48b1fdd17600765992dc)

18 months agoFix various places which cast a pointer to a vm_paddr_t or vice versa.
John Baldwin [Mon, 3 Oct 2022 23:10:41 +0000 (16:10 -0700)]
Fix various places which cast a pointer to a vm_paddr_t or vice versa.

GCC warns about the mismatched sizes on i386 where vm_paddr_t is 64
bits.

Reviewed by: imp, markj
Differential Revision: https://reviews.freebsd.org/D36750

(cherry picked from commit a9fca3b987bcfa16d457b15cba2de46000f6bb86)

18 months agolinux32: binutils as requires %eflags instead of %flags for CFI.
John Baldwin [Thu, 29 Sep 2022 22:06:01 +0000 (15:06 -0700)]
linux32: binutils as requires %eflags instead of %flags for CFI.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D36781

(cherry picked from commit a35572b16e38420f5f7573b13bfe2c3b07a79d19)

18 months agonewkey: Fix mismatch in array bounds in for adjust().
John Baldwin [Wed, 28 Sep 2022 21:06:16 +0000 (14:06 -0700)]
newkey: Fix mismatch in array bounds in for adjust().

Reviewed by: emaste
Reported by: GCC -Warray-parameter
Differential Revision: https://reviews.freebsd.org/D36762

(cherry picked from commit 536f7d84cd061bd5667a4d93fed3f41772197c79)

18 months agomail: Fix mismatch in array bounds for isign().
John Baldwin [Wed, 28 Sep 2022 21:05:42 +0000 (14:05 -0700)]
mail: Fix mismatch in array bounds for isign().

Reviewed by: imp, emaste
Reported by: GCC -Warray-parameter
Differential Revision: https://reviews.freebsd.org/D36761

(cherry picked from commit 157436dcbf86a5e51723f222e524e9970066e7c5)

18 months agosh: Fix mismatch in array bounds for vforkexecshell().
John Baldwin [Wed, 28 Sep 2022 21:04:08 +0000 (14:04 -0700)]
sh: Fix mismatch in array bounds for vforkexecshell().

Reviewed by: imp, jilles, emaste
Reported by: GCC -Warray-parameter
Differential Revision: https://reviews.freebsd.org/D36760

(cherry picked from commit 10297a9ed488a9fff159ae495b61185e6f50e22a)

18 months agopam_unix: Fix mismatch in array bounds for make_salt().
John Baldwin [Wed, 28 Sep 2022 21:02:59 +0000 (14:02 -0700)]
pam_unix: Fix mismatch in array bounds for make_salt().

Reviewed by: imp, emaste
Reported by: GCC -Warray-parameter
Differential Revision: https://reviews.freebsd.org/D36759

(cherry picked from commit 5ceec6c1054e6bde3b72672f33705a044fc0eb86)

18 months agoldns: Disable -Warray-parameter warnings from GCC 12 on sha2.c.
John Baldwin [Wed, 28 Sep 2022 21:02:30 +0000 (14:02 -0700)]
ldns: Disable -Warray-parameter warnings from GCC 12 on sha2.c.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D36758

(cherry picked from commit 5d27845e5a8b7324b91d6a6c2a63db2635671205)

18 months agolibc rpc: Fix mismatches in prototypes for array bounds.
John Baldwin [Wed, 28 Sep 2022 21:01:36 +0000 (14:01 -0700)]
libc rpc: Fix mismatches in prototypes for array bounds.

Various RPC functions used a bare pointer in function prototypes to
describe fixed-length buffer arguments but used a fixed-length array
in the function definition.  The manual page for these functions
describes the parameters as being fixed-length buffers, so update
the prototypes to match the definitions.

Reviewed by: imp, emaste
Reported by: GCC -Warray-parameter
Differential Revision: https://reviews.freebsd.org/D36757

(cherry picked from commit a2e41a585b3a8a54e09831ea476ccaa56142c1ae)

18 months agobsd.sys.mk: Add NO_WARRAY_PARAMETER helper variable.
John Baldwin [Wed, 28 Sep 2022 21:01:04 +0000 (14:01 -0700)]
bsd.sys.mk: Add NO_WARRAY_PARAMETER helper variable.

This variable expands to -Wno-array-parameter on GCC 11+.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D36756

(cherry picked from commit 409dae262ffce0647ceb196193a34ad11e1e1edd)

18 months agozlib crc32: Add prototypes for recently-added static functions.
John Baldwin [Wed, 28 Sep 2022 21:00:27 +0000 (14:00 -0700)]
zlib crc32: Add prototypes for recently-added static functions.

This appeases -Wstrict-prototypes with GCC.  Using a separate
prototype using the OF macro seems to be consistent with the rest of
this file which still supports pre-ANSI C.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D36755

(cherry picked from commit 7550e242ab4c118ba48171577ccadf81ba739847)

18 months agoipfilter: Cast uintmax_t values to size_t when adding to a pointer.
John Baldwin [Wed, 28 Sep 2022 20:58:34 +0000 (13:58 -0700)]
ipfilter: Cast uintmax_t values to size_t when adding to a pointer.

GCC warns about the mismatched sizes on 32-bit platforms where
uintmax_t is larger in size than a pointer.

Reviewed by: imp, cy
Differential Revision: https://reviews.freebsd.org/D36753

(cherry picked from commit 9c4f7e82348b656aef9660f859b76d6e894590aa)

18 months agontb: Use uintmax_t casts and %j to print physical addresses.
John Baldwin [Wed, 28 Sep 2022 20:56:31 +0000 (13:56 -0700)]
ntb: Use uintmax_t casts and %j to print physical addresses.

This fixes -Wint-to-pointer-cast errors with GCC when compiling on
i386 where physical addresses are not the same size as pointers.

Reviewed by: mav, imp
Differential Revision: https://reviews.freebsd.org/D36751

(cherry picked from commit 124e46735e07037afafbf0caa097faafb09c7329)

18 months agosplit: reset errno prior to getline()
Math Ieu [Thu, 27 Oct 2022 17:01:57 +0000 (12:01 -0500)]
split: reset errno prior to getline()

Something else may have set errno, breaking the post-getline() logic
that tries to detect the getline() error.  This was initially noted in
a jail on a system that has HPET, in a jail that does not expose
/dev/hpet0 -- we see an earlier error in libc's vdso bits.

Fixes: 5c053aa3c5e90 ("split: switch to getline() [...]")
(cherry picked from commit 172be8642d93851b0c083d0db240cf35fd56ab0e)

18 months agosplit: add word order fix
Kyle Evans [Tue, 25 Oct 2022 21:51:21 +0000 (16:51 -0500)]
split: add word order fix

This was meant to note that both pattern and line matching were
previously restricted, but words are difficult.  +line and rearrange.

Sponsored by: Klara, Inc.

(cherry picked from commit 7aaa50c6b58319ec948e8048fb165958bc47a356)

18 months agosplit: add some tests
Kyle Evans [Tue, 23 Aug 2022 02:08:03 +0000 (21:08 -0500)]
split: add some tests

This should cover all of the basic functionality, as well as the recent
enhancement to use a dynamic buffer size rather than limiting patterns
and lines to MAXBSIZE.

Reviewed by: bapt
Sponsored by: Klara, Inc.

(cherry picked from commit 75c3ca1ebf81224919f2b7a9edf2921ce76ea290)

18 months agosplit: switch to getline() for line/pattern matching
Kyle Evans [Tue, 23 Aug 2022 02:05:58 +0000 (21:05 -0500)]
split: switch to getline() for line/pattern matching

Get rid of split's home-grown logic for growing the buffer; arbitrarily
breaking at LONG_MAX bytes instead of 65536 bytes gives us much more
wiggle room.  Additionally, we'll actually fail out entirely if we can't
fit a line, which makes noticing this class of problem much easier.

Reviewed by: bapt, emaste, pauamma
Sponsored by: Klara, Inc.

(cherry picked from commit 5c053aa3c5e907bdd1ac466ce9b58611781c2c20)

18 months agotcp_bbr(4): Fix a typo in a source code comment
Gordon Bergling [Tue, 8 Nov 2022 13:59:56 +0000 (14:59 +0100)]
tcp_bbr(4): Fix a typo in a source code comment

- s/retranmitted/retransmitted/

(cherry picked from commit bcf8fb7f033a940d2ee403bcfbd03bdd2874012d)

18 months agopnfs.4: Fix a typo
Gordon Bergling [Tue, 8 Nov 2022 13:57:06 +0000 (14:57 +0100)]
pnfs.4: Fix a typo

- s/attrbute/attribute/

(cherry picked from commit 40b245af0f496f75a0396a88747474ced909fef5)

18 months agonfs: Fix common typos in source code comments
Gordon Bergling [Tue, 8 Nov 2022 13:58:32 +0000 (14:58 +0100)]
nfs: Fix common typos in source code comments

- s/attrbute/attribute/

(cherry picked from commit bf312482870fb663fac4446955ca6c3090d1e7f3)

18 months agovmm: Cherry pick illumos commit '13361 bhyve should mask RDT cpuid info'
Vitaliy Gusev [Thu, 30 Jun 2022 17:27:27 +0000 (10:27 -0700)]
vmm: Cherry pick illumos commit '13361 bhyve should mask RDT cpuid info'

Summary:
    commit  1a5f1879be09d3de900b2510692dd12003784d84
    Author: Patrick Mooney <pmooney@pfmooney.com>
    Date:   2020-12-16T20:02:23.000Z

        13361 bhyve should mask RDT cpuid info
        Reviewed by: Andy Fiddaman <andy@omnios.org>
        Reviewed by: Toomas Soome <tsoome@me.com>
        Approved by: Robert Mustacchi <rm@fingolfin.org>

    https://github.com/illumos/illumos-gate/commit/1a5f1879be09d3de900b2510692dd12003784d8

----

We saw similar warning of GP (on Intel Xeon CPU E5-2630 v4 and VM with Ubuntu 20.04 5.4.0-113-generic)  until this commit is applied:

```
[    1.658880] kernel: unchecked MSR access error: WRMSR to 0xc8f (tried to write 0x0000000000000000) at rIP: 0xffffffffacc735b4 (native_write_msr+0x4/0x30)
[    1.662734] kernel: Call Trace:
[    1.663885] kernel:  ? clear_closid_rmid.isra.0+0x36/0x40
[    1.665501] kernel:  resctrl_online_cpu+0xdc/0x3f0
[    1.666952] kernel:  ? __switch_to_asm+0x40/0x70
[    1.668358] kernel:  ? __switch_to+0x7f/0x480
[    1.669693] kernel:  ? cat_wrmsr+0x70/0x70
[    1.670970] kernel:  cpuhp_invoke_callback+0x9b/0x580
[    1.672541] kernel:  ? __schedule+0x2eb/0x740
[    1.673893] kernel:  cpuhp_thread_fun+0xb8/0x120
[    1.675304] kernel:  smpboot_thread_fn+0xd0/0x170
[    1.676685] kernel:  kthread+0x104/0x140
[    1.677948] kernel:  ? sort_range+0x30/0x30
[    1.679299] kernel:  ? kthread_park+0x90/0x90
[    1.680570] kernel:  ret_from_fork+0x35/0x40
[    1.682000] kernel: *** VALIDATE rdt ***
[    1.683454] kernel: resctrl: L3 monitoring detected
```

Reviewed by: markj, jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D35442

(cherry picked from commit 5afcca138f6b1f9d6413de586a0cf2baf16da764)

18 months agocxgbe: Use secq(9) to manage the timestamp generations.
John Baldwin [Mon, 26 Sep 2022 21:58:06 +0000 (14:58 -0700)]
cxgbe: Use secq(9) to manage the timestamp generations.

This is mostly cosmetic, but it also doesn't leave a gap of time where
no structures are valid.  Instead, we permit the ISR to continue to
use the previous structure if the write to update cal_current isn't
yet visible.

Reviewed by: gallatin
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D36669

(cherry picked from commit cee4fc7cada8244f375a6542f03d1f255c719bf1)

18 months agocxgbe: Compute timestamps via sbintime_t.
John Baldwin [Mon, 26 Sep 2022 21:57:26 +0000 (14:57 -0700)]
cxgbe: Compute timestamps via sbintime_t.

This uses fixed-point math already used elsewhere in the kernel for
sub-second time values.  To avoid overflows this does require updating
the calibration once a second rather than once every 30 seconds.  Note
that the cxgbe driver already queries multiple registers once a second
for the statistics timers.  This version also uses fewer instructions
with no branches (for the math portion) in the per-packet fast path.

Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D36663

(cherry picked from commit 2c74c9dac3a6e74a2c33d519cdcf1de145e7664c)