Commit graph

272293 commits

Author SHA1 Message Date
Kyle Evans
cd1ebf9c7e 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 0283826706)
2022-11-12 23:37:05 -06:00
Kyle Evans
919fc568b6 Add 'contrib/wireguard-tools/' from commit '7e00bf8773b93a2a3ee28dba2710d2ae443989f1'
git-subtree-dir: contrib/wireguard-tools
git-subtree-mainline: 9142a2a37b
git-subtree-split: 7e00bf8773
(cherry picked from commit adf3764857)
2022-11-12 23:37:05 -06:00
Warner Losh
94884840d4 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 8a157722e9)
2022-11-12 15:07:21 -04:00
Li-Wen Hsu
bfbe15ca51 Whitespace cleanup
(cherry picked from commit aaf998056e)
2022-11-12 15:07:14 -04:00
Li-Wen Hsu
47740fd2c5 Update doc links in README
(cherry picked from commit cada2b74b8)
2022-11-12 15:07:14 -04:00
Warner Losh
2292caf6cd readme: Link to COPYRIGHT file
(cherry picked from commit e75eac2cb8)
2022-11-12 15:07:14 -04:00
Warner Losh
ad2fe88979 Fix arch rendering
(cherry picked from commit dbd92cc2a4)
2022-11-12 15:07:14 -04:00
Warner Losh
7d9207ce56 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 2918e9fdb8)
2022-11-12 15:07:14 -04:00
Hans Petter Selasky
a41a9e01c3 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 9e0edafe92)
2022-11-12 13:00:16 +01:00
Hans Petter Selasky
46fb3402ee xhci(4): Fix spelling in manual page.
Noted by:	Gary Jennejohn <garyj@gmx.de>
Sponsored by:	NVIDIA Networking

(cherry picked from commit a2d60916d0)
2022-11-12 13:00:12 +01:00
Hans Petter Selasky
bfa2c25c92 xhci(4): Update list of quirks in manual page.
Sponsored by:	NVIDIA Networking

(cherry picked from commit 30e555de80)
2022-11-12 13:00:09 +01:00
Hans Petter Selasky
d68c00757d 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 3346ae0d24)
2022-11-12 13:00:06 +01:00
Florian Walpen
f0a3d2341d 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 ad370f7658)
2022-11-12 13:00:01 +01:00
Hans Petter Selasky
3cfb2d365f time(3): Fix spelling.
Noted by:	Gary Jennejohn <garyj@gmx.de>
Sponsored by:	NVIDIA Networking

(cherry picked from commit fdd9548333)
2022-11-12 12:59:57 +01:00
Hans Petter Selasky
9408dc3cc4 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 35a33d14b5)
2022-11-12 12:59:47 +01:00
Hans Petter Selasky
98be2ec6df 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 ee29897fc3)
2022-11-12 12:59:40 +01:00
Hans Petter Selasky
eb9766b37c 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 0def80f1a5)
2022-11-12 12:59:32 +01:00
Alexander Motin
62e1bb4245 Fix umtxq_sleep() regression caused by 56070dd2e4.
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 fd6ca665d2)
2022-11-12 12:59:27 +01:00
Alexander Motin
e21c77f80c 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 56070dd2e4)
2022-11-12 12:59:18 +01:00
Gordon Bergling
21f35c3699 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 c72854c06a)
2022-11-11 23:55:51 +01:00
Gordon Bergling
78d36c8602 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 19c03f4ab0)
2022-11-11 23:55:16 +01:00
John Baldwin
dfbbcea39b 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 854d066251)
2022-11-11 13:50:09 -08:00
John Baldwin
fa7b4b9294 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 c640d1af2c)
2022-11-11 13:49:57 -08:00
John Baldwin
4c6b5076b7 wg: Use zfree.
Reviewed by:	kevans, markj, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36911

(cherry picked from commit dcf581bb49)
2022-11-11 13:49:44 -08:00
John Baldwin
0d10367122 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 e32e1a160e)
2022-11-11 13:48:50 -08:00
John Baldwin
5ae69e2f10 Import the WireGuard driver from zx2c4.com.
This commit brings back the driver from FreeBSD commit
f187d6dfbf 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 744bfb2131)
2022-11-11 13:44:11 -08:00
John Baldwin
980c7b0a54 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 9e0aaedd70)
2022-11-11 13:44:11 -08:00
John Baldwin
5762f69640 ktrace.2: Document KTRFAC_STRUCT_ARRAY.
Sponsored by:	DARPA

(cherry picked from commit c9c9057c77)
2022-11-11 10:18:54 -08:00
John Baldwin
593cb2e370 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 ba86cffb28)
2022-11-11 10:18:54 -08:00
John Baldwin
59c1904fc2 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 e5f2d5b35e)
2022-11-11 10:18:54 -08:00
John Baldwin
068c9d3de7 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 bb31e1bbf2)
2022-11-11 10:18:54 -08:00
John Baldwin
587ab8e019 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 ae70e8838c)
2022-11-11 10:18:54 -08:00
John Baldwin
d77e67e9d5 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 aabbe26939)
2022-11-11 10:18:54 -08:00
Warner Losh
2498e94fb6 msk: Remove write only variables, but leave hardware reads in place
Sponsored by:		Netflix

(cherry picked from commit 7e5c042cce)
2022-11-11 10:18:54 -08:00
John Baldwin
9da0029889 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 ab9293239c)
2022-11-11 10:18:54 -08:00
John Baldwin
6728d270e1 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 2fb81691b0)
2022-11-11 10:18:54 -08:00
John Baldwin
7597246911 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 1187e46d1b)
2022-11-11 10:18:54 -08:00
John Baldwin
65e28bfeaa 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 996ee96597)
2022-11-11 10:18:54 -08:00
John Baldwin
61abd47a09 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 8f27c9d14a)
2022-11-11 10:18:54 -08:00
John Baldwin
fb61949706 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 7973f26ad6)
2022-11-11 10:18:54 -08:00
John Baldwin
7cefb4bc4b 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 611cf39267)
2022-11-11 10:18:54 -08:00
John Baldwin
1f9f319919 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 3736b2dd32)
2022-11-11 10:18:53 -08:00
John Baldwin
78a211c5eb 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 db695788fc)
2022-11-11 10:18:53 -08:00
John Baldwin
ec5c52b7a3 nvmecontrol wdc: Remove unused but set variable.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D36812

(cherry picked from commit d81082a7ad)
2022-11-11 10:18:53 -08:00
John Baldwin
cf668c1697 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 c2e561a38f)
2022-11-11 10:18:53 -08:00
John Baldwin
f49af51ccb 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 67b0751249)
2022-11-11 10:18:53 -08:00
John Baldwin
598fbd36f1 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 3b887005b4)
2022-11-11 10:18:53 -08:00
John Baldwin
44c1914ee6 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 e0df0dce71)
2022-11-11 10:18:53 -08:00
John Baldwin
991603548e 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 d74024a490)
2022-11-11 10:18:53 -08:00
John Baldwin
caaa27df7b 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 c41b161812)
2022-11-11 10:18:53 -08:00