]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
19 months agopkgbase: report type for duplicated METALOG entries
Ed Maste [Thu, 17 Nov 2022 14:15:20 +0000 (09:15 -0500)]
pkgbase: report type for duplicated METALOG entries

Duplicate METALOG file entries are more of a concern than duplicate
directories.  The metalog check tool previously did not include the
entry type in the warnings, making it hard to find the ones of concern.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit b751fc75bb989ea737c9f1c440d2601e1ed95092)

19 months agopkgbase: examine METALOG files relative to stage root directory
Ed Maste [Wed, 16 Nov 2022 19:53:42 +0000 (14:53 -0500)]
pkgbase: examine METALOG files relative to stage root directory

Previously we stripped the '.' from the beginning of each METALOG entry
to determine the path to stat.  This meant that we examined files on the
build host, not the staged files.

Instead, strip off the last part of the specified METALOG pathname to
find the stage root directory, and stat files relative to that.

Reviewed by: bapt
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37412

(cherry picked from commit bca4d27052bf5735725449cd0be51bd58cf0cb80)

19 months agobuild: Use `rm -fv` for BATCH_DELETE_OLD_FILES
Ed Maste [Mon, 24 Oct 2022 18:06:41 +0000 (14:06 -0400)]
build: Use `rm -fv` for BATCH_DELETE_OLD_FILES

It's possible to have files with odd permissions in the tmproot (or
sysroot), causing rm to prompt for each one during e.g. buildworld.
Add -f to forcibly delete these.

Reviewed by: brooks
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37111

(cherry picked from commit 470fb726f3d242fed42592bc59263c9d49226073)

19 months agosshd: sync tracing disable with upstream
Ed Maste [Mon, 7 Nov 2022 17:17:15 +0000 (12:17 -0500)]
sshd: sync tracing disable with upstream

Old versions of FreeBSD do not support using id 0 to refer to the
current pid for procctl, so pass getpid() explicitly.

Although this is not required in current FreeBSD branches I am merging
it to reduce differences with upstream.

Obtained from: OpenSSH commit 0f7e1eba5525

(cherry picked from commit 4232f36eda60406642fc6cfef605b6d38fc0a7c0)
(cherry picked from commit 733bf3b108f8b69295778bab5f7d680b9a8e6dba)

19 months agognu diff3: apply patch to committed src, rather than at build time
Ed Maste [Fri, 11 Nov 2022 19:48:40 +0000 (14:48 -0500)]
gnu diff3: apply patch to committed src, rather than at build time

This appears to be a leftover from the time we used a less-capable VCS.

Reviewed by: delphij
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D37368

(cherry picked from commit 3a13b5ac83a100ebb5a0da0579e418f19b3b630b)

19 months agobhyve nvme: Check return value of mapped memory
Chuck Tuffli [Sun, 14 Aug 2022 14:45:21 +0000 (07:45 -0700)]
bhyve nvme: Check return value of mapped memory

Fuzzing of bhyve using hyfuzz discovered a way to cause a segmentation
fault in the NVMe emulation. If a guest specifies a physical address in
either the PRP1 or PRP2 field of a command that cannot be mapped from
guest to host, the function paddr_guest2host() returns a NULL pointer.
The NVMe emulation did not check for this error case, which allowed for
the segmentation fault to occur.

Fix is to check for a return value of NULL and indicate an error back to
the guest (Data Transfer error). While in the area, slightly refactor
the write/read blockif function to use a common error exit path.

PR: 256317,256319,256320,256321,256322

(cherry picked from commit 3d3678627c3112c94d174a8c51d8c058d02befb3)

19 months agobhyve nvme: Switch to POSIX standard functions
Chuck Tuffli [Wed, 17 Aug 2022 00:16:06 +0000 (17:16 -0700)]
bhyve nvme: Switch to POSIX standard functions

Switch bzero to memset and bcopy to memcpy

(cherry picked from commit 6391be30894460c03a70e0321e99b2bdcda8eebf)

19 months agobhyve nvme: Support minimal Controller list
Chuck Tuffli [Tue, 16 Aug 2022 16:15:53 +0000 (09:15 -0700)]
bhyve nvme: Support minimal Controller list

Controllers must support the Identify Controller list if they support
Namespace Management. But the UNH NVMe tests use this command regardless
of whether the device under test supports Namespace Management.

This implementation returns an empty Controller list (i.e., Number of
Identifiers is zero).

Fixes UNH Test 1.1.2

(cherry picked from commit 715f82e4f5c51c04314904dee8090c8abbbe2156)

19 months agobhyve nvme: Fix reported SANICAP value
Chuck Tuffli [Tue, 16 Aug 2022 16:14:43 +0000 (09:14 -0700)]
bhyve nvme: Fix reported SANICAP value

The NVMe specification only allows Controllers compliant with the
revision 1.3 and earlier specification to report a value of 0x0 in the
No-Deallocate Modifies Media After Sanitize (NODMMAS) field.

For our revision 1.4 Controller, report that media is not modified after
Sanitize as the implementation does not implement Sanitize.

Fixes UNH Test 1.1.2

(cherry picked from commit ec0efe34dd486359d57bc1e792a0e4f9280f66d7)

19 months agobhyve nvme: Fix firmware read only initialization
Wanpeng Qian [Sun, 14 Aug 2022 15:30:06 +0000 (08:30 -0700)]
bhyve nvme: Fix firmware read only initialization

Summary:
Code was using the mask value without the shift.

Test Plan: Within FreeBSD/Linux guest, Identify NVMe controller to check the result.

(cherry picked from commit 9f678cfcb42d1d0ce3898b0e38bb147a3e14834a)

19 months agobhyve: Fix Number of Power States Supported value
WanpengQian [Sun, 14 Aug 2022 15:26:42 +0000 (08:26 -0700)]
bhyve: Fix Number of Power States Supported value

Summary:
Set Number of Power States Supported to indicate 1 power state. Keep the
Power State Descriptor data structures as zero to indicate "Not
reported".

Test Plan:
Within FreeBSD/Linux guests, list the number of power states and check
the Max Power value.

(cherry picked from commit eae0210cdd2e22c2eb9bc652f2136b3386a663a4)

19 months agobhyve nvme: Fix out-of-bound IOV array access
Chuck Tuffli [Thu, 9 Jun 2022 18:19:32 +0000 (11:19 -0700)]
bhyve nvme: Fix out-of-bound IOV array access

Summary:
NVMe operations indicate the memory region(s) associated with a command
via physical region pages (PRPs). Since each PRP has a fixed size,
contiguous memory regions larger than the PRP size require multiple PRP
entries.

Instead of issuing a blockif call for each PRP, the NVMe emulation
concatenates multiple contiguous PRP entries into a single blockif
request. The test for contiguous regions has a bug such that it
mistakenly treats an initial PRP address of zero as a contiguous range
and concatenates it with the previous. But because there is no previous
IOV, the concatenation code corrupts the IO request structure and leads
to a segmentation fault when the blockif request completes.

Fix is to test for the existence of a previous range before trying to
concatenate the current range with the previous one.

While in the area, rename pci_nvme_append_iov_req()'s lba parameter to
offset to match its usage.

PR:             264177

(cherry picked from commit 88951aaaee73b87121b0f121224fe188a5b5e6e3)

19 months agowait for device mounts in zpool and dumpon
Chuck Tuffli [Fri, 5 Mar 2021 16:13:23 +0000 (08:13 -0800)]
wait for device mounts in zpool and dumpon

If the root file system is composed from multiple devices, wait for
devices to be ready before running zpool and dumpon rc scripts.

An example of this is if the bulk of the root file system exists on a
fast device (e.g. NVMe) but the /var directory comes from a ZFS dataset
on a slower device (e.g. SATA). In this case, it is possible that the
zpool import may run before the slower device has finished being probed,
leaving the system in an intermediate state.

Fix is to add root_hold_wait to the zpool and dumpon (which has a
similar issue) rc scripts.

PR: 242189

(cherry picked from commit f30f11f878fe2aa535cd286810d31c92793a3d95)

19 months agobhyve: Define an accessor for net backend private data
Mark Johnston [Fri, 11 Nov 2022 15:01:40 +0000 (10:01 -0500)]
bhyve: Define an accessor for net backend private data

Use it to silence warnings about potential unaligned accesses.  No
functional change intended.

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

(cherry picked from commit 0ced97acb05197cb2ef30932786eab0512f77e07)

19 months agoFix to b999366aab4e for compilation on i386.
Kirk McKusick [Fri, 18 Nov 2022 05:03:01 +0000 (21:03 -0800)]
Fix to b999366aab4e for compilation on i386.

Reported by: jenkins, Philip Paeps

19 months agoOpenSSL: Regen assembly file for OpenSSSL 1.1.1s
Jung-uk Kim [Tue, 1 Nov 2022 23:12:09 +0000 (19:12 -0400)]
OpenSSL: Regen assembly file for OpenSSSL 1.1.1s

(cherry picked from commit f443d0802a21279387596ec2c9644d3e91ca0431)

19 months agoOpenSSL: Regen manual pages for OpenSSL 1.1.1s
Jung-uk Kim [Tue, 1 Nov 2022 23:38:40 +0000 (19:38 -0400)]
OpenSSL: Regen manual pages for OpenSSL 1.1.1s

(cherry picked from commit 93381ae06bb043a85d6b26459b511ccacc2045e2)

19 months agoOpenSSL: Merge OpenSSL 1.1.1s
Jung-uk Kim [Tue, 1 Nov 2022 22:58:59 +0000 (18:58 -0400)]
OpenSSL: Merge OpenSSL 1.1.1s

(cherry picked from commit cfc39718e9cc18943a6f8428c560b02c6f590b16)

19 months agortld: add support for the $LIB token
Konstantin Belousov [Thu, 10 Nov 2022 16:35:00 +0000 (18:35 +0200)]
rtld: add support for the $LIB token

MFC note: the arm soft case is not handled, it is probably worth
expanding $LIB to libsoft there.

(cherry picked from commit 8cc44a1e59f648eb5bea5afe6d9aa1d7f927c9d7)

19 months agostand: Compile out the extensive superblock diagnostic messages for BIOS loader
Warner Losh [Fri, 12 Aug 2022 17:08:36 +0000 (11:08 -0600)]
stand: Compile out the extensive superblock diagnostic messages for BIOS loader

The BIOS loader operates in a very constrained environment. The messages
for the super block integrity tests take up about 12k of space. Compile
them out for the BIOS loader, while leaving it intact for all other
loaders that aren't space constrained. These aren't used in the 'super
tiny' *boot* programs, so no adjustment is needed there.

We reply on the fact that (a) i386 doesn't support 32-bit UEFI booting
and (b) LIBSA_CPUARCH is "i386" when building on both i386 and when
we're building the 32-bit libsa32 library.

This saves about 12k of space for this constrained envrionment and will
take a bit of the pressure off some machines where the loader has grown
too big for their BIOS (see comments in i386/loader/Makefile for
details).

Sponsored by: Netflix
Reviewed by: mckusick
Differential Revision: https://reviews.freebsd.org/D36175

(cherry picked from commit 148211300870b3bd558bf70dc3bf7d7f78c657aa)

19 months agoDo comprehensive UFS/FFS superblock integrity checks when reading a superblock.
Kirk McKusick [Fri, 27 May 2022 19:21:11 +0000 (12:21 -0700)]
Do comprehensive UFS/FFS superblock integrity checks when reading a superblock.

Historically only minimal checks were made of a superblock when it
was read in as it was assumed that fsck would have been run to
correct any errors before attempting to use the filesystem. Recently
several bug reports have been submitted reporting kernel panics
that can be triggered by deliberately corrupting filesystem superblocks,
see Bug 263979 - [meta] UFS / FFS / GEOM crash (panic) tracking
which is tracking the reported corruption bugs.

This change upgrades the checks that are performed. These additional
checks should prevent panics from a corrupted superblock. Although
it appears in only one place, the new code will apply to the kernel
modules and (through libufs) user applications that read in superblocks.

Reported by:  Robert Morris and Neeraj
Reviewed by:  kib
Tested by:    Peter Holm
PR:           263979
Differential Revision: https://reviews.freebsd.org/D35219

(cherry picked from commit 076002f24d35962f0d21f44bfddd34ee4d7f015d)
(cherry picked from commit bc218d89200faa021def77732f3d9fde4f4dee13)
(cherry picked from commit 800a53b445e7eb113ba193b1ac98631299178529)
(cherry picked from commit 50dc4c7df4156863148e6a9609c03e852e2aeb35)
(cherry picked from commit f3f5368dfbef4514686ba2d67f01f314b275227e)
(cherry picked from commit 9e1f44d044a58fcd2caaca3f57e69cf6180db3dc)
(cherry picked from commit 5bc926af9fd1c47f74356734f731c68145e31c6f)
(cherry picked from commit 904347a00c1f9a29f3b17e6e676805036d2494f1)
(cherry picked from commit 36e08b0127f97928a2f2c062feed8df9087b2b35)
(cherry picked from commit 548045bf57c46cb2f4d43d3d7fa5d8ad37ec7f9a)
(cherry picked from commit 3e40d2cc61a00a7d69e99b0fda4040cd1df04c57)
(cherry picked from commit 184e3118c1057a97e16230baf0f0433adeeed723)
(cherry picked from commit f0be378a66a75ebf335e9388ef0d319a70064d94)
(cherry picked from commit 9dee5da7450e8530c9fec51c9a16ecd42da78e55)
(cherry picked from commit 82ee4e1c42d70345cbaa1f6dd1874ae98a004910)
(cherry picked from commit dcdba3460dd779a0180ec7769ab8cd47c932799e)
(cherry picked from commit 017367c1146a69baca6a1a0bea10b0cb02c72d85)
(cherry picked from commit 8435a9b20684ba8bcda3df31d06b4d5eac9431a7)

19 months agoheimdal: Fix: Too large time skew, client time 1970-01-01T01:00:00
Cy Schubert [Thu, 17 Nov 2022 15:43:29 +0000 (07:43 -0800)]
heimdal: Fix: Too large time skew, client time 1970-01-01T01:00:00

Part of ed549cb0c53f zeroed out a data structure in the resulting code-file
when a TUTCTime type was freed. This part of the patch applies to Heimdal
7.1+ and not our Heimdal 1.5.2.

PR: 267827
Reported by: Peter Much <pmc@citylink.dinoex.sub.org>
Tested by: Peter Much <pmc@citylink.dinoex.sub.org>
Fixes: ed549cb0c53f

(cherry picked from commit f556a05c49261af3d373c599d05fa250f3563b59)

19 months agoipfilter: Document count_mask_bits() arguments
Cy Schubert [Mon, 14 Nov 2022 23:58:02 +0000 (15:58 -0800)]
ipfilter: Document count_mask_bits() arguments

Document arguments input to count_mask_bits().

(cherry picked from commit 1ffab636dac8e52d4b3d5a2cb40c93a229404ffd)

19 months agoixgbe: workaround errata about UDP frames with zero checksum
Andrey V. Elsukov [Thu, 10 Nov 2022 09:34:40 +0000 (12:34 +0300)]
ixgbe: workaround errata about UDP frames with zero checksum

Intel 82599 has errata related to IPv4 UDP frames with zero checksum.
It reports such datagrams with L4 integrity errors in IXGBE_XEC
register. And after afb1aa4e6df2 commit such errors are reported
via IFCOUNTER_IERRORS. This confuses users, since actually all frames
are handled correctly by the system.
To workaround the problem, let's ignore the XEC register value for
82599 cards for now.

PR: 266048
Discussed with: erj
Sponsored by: Yandex LLC

(cherry picked from commit 8526120ad41ca47367b43f8f4459e0fa61285571)

19 months agonfsd: Make the pNFS server update Change for Setxattr/Rmxattr
Rick Macklem [Tue, 18 Oct 2022 22:47:07 +0000 (15:47 -0700)]
nfsd: Make the pNFS server update Change for Setxattr/Rmxattr

When the NFS server does the Setxattr or Rmxattr operation,
the Change attribute (va_filerev) needs to be updated.

Without this patch, that was not happening for the
pNFS server configuration.  This patch does a Setattr
against the DS file to make the Change attribute
change.

This bug was discovered during a recent IETF NFSv4 testing
event, where the Change attribute wasn't changed in the
operation reply.

(cherry picked from commit ae7816576e44412a8ae9daa92c210a6ba4f269dc)

19 months agonfsd: Make Setxattr/Removexattr NFSv4.2 ops IO_SYNC
Rick Macklem [Sun, 16 Oct 2022 20:27:32 +0000 (13:27 -0700)]
nfsd: Make Setxattr/Removexattr NFSv4.2 ops IO_SYNC

When the NFS server does Setxattr or Removexattr, the
operations must be done IO_SYNC. If a server
crashes/reboots immediately after replying it must
have the extended attribute changes.

Since UFS does extended attributes asynchronously
by default and there is no "ioflag" argument in
the VOP calls, follow the VOP calls with VOP_FSYNC(),
to ensure the operation has been done synchronously.

This was found by inspection while investigating a
bug discovered during a recent IETF NFSv4 testing
event, where the Change attribute wasn't changed
in the operation reply.

This bug will take further work for ZFS and the
pNFS server configuration, but is now fixed for
a non-pNFS UFS exported file system.

(cherry picked from commit 8063dc03202fad7d6bdf34976bc8556fa3f23fa1)

19 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)

19 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)

19 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)

19 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>

19 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)

19 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)

19 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)

19 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>

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

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

(cherry picked from commit aaf998056ed46c0dfb429e3e5cfe624c8aa4dec8)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)