]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agomn: bump deprecation version to 14 in man page as well
Ed Maste [Thu, 25 Mar 2021 02:37:33 +0000 (22:37 -0400)]
mn: bump deprecation version to 14 in man page as well

Fixes: 66e75d9e2ddd ("mn: report that this driver is removed in 14, not 13")
3 years agomn: report that this driver is removed in 14, not 13
Ed Maste [Thu, 25 Mar 2021 02:35:38 +0000 (22:35 -0400)]
mn: report that this driver is removed in 14, not 13

3 years agoarm64: implement COMPAT_FREEBSD32 fill/set dbregs/fpregs
Ed Maste [Wed, 17 Mar 2021 14:10:41 +0000 (10:10 -0400)]
arm64: implement COMPAT_FREEBSD32 fill/set dbregs/fpregs

On FreeBSD/arm fill_fpregs, fill_dbregs are stubs that zero the reg
struct and return success. set_fpregs and set_dbregs do nothing and
return success.

Provide the same implementation for arm64 COMPAT_FREEBSD32.

Reviewed by: andrew
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29314

(cherry picked from commit 5be27cbf16c85ce95d21db57349f61494f851821)

3 years agortsold: Fix validation of RDNSS options
Mark Johnston [Sun, 21 Mar 2021 18:18:10 +0000 (14:18 -0400)]
rtsold: Fix validation of RDNSS options

The header specifies the size of the option in multiples of eight bytes.
The option consists of an eight-byte header followed by one or more IPv6
addresses, so the option is invalid if the size is not equal to 1+2n for
some n>0.  Check this.

The bug can cause random stack data to be formatted as an IPv6 address
and passed to resolvconf(8), but a host able to trigger the bug may also
specify arbitrary addresses this way.

Reported by: Q C <cq674350529@gmail.com>
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 1af332a7d8f86b6fcc1f0f575fe5b06021b54f4c)

3 years agoMFC eeb26cf52c4c51e1571253d57684c442aa79a98d:
Cy Schubert [Wed, 17 Mar 2021 00:06:17 +0000 (17:06 -0700)]
MFC eeb26cf52c4c51e1571253d57684c442aa79a98d:

wpa: import fix for P2P provision discovery processing vulnerability

Latest version available from: https://w1.fi/security/2021-1/

Vulnerability

A vulnerability was discovered in how wpa_supplicant processes P2P
(Wi-Fi Direct) provision discovery requests. Under a corner case
condition, an invalid Provision Discovery Request frame could end up
reaching a state where the oldest peer entry needs to be removed. With
a suitably constructed invalid frame, this could result in use
(read+write) of freed memory. This can result in an attacker within
radio range of the device running P2P discovery being able to cause
unexpected behavior, including termination of the wpa_supplicant process
and potentially code execution.

Vulnerable versions/configurations

wpa_supplicant v1.0-v2.9 with CONFIG_P2P build option enabled

An attacker (or a system controlled by the attacker) needs to be within
radio range of the vulnerable system to send a set of suitably
constructed management frames that trigger the corner case to be reached
in the management of the P2P peer table.

Note: FreeBSD base does not enable P2P.
(cherry picked from commit eeb26cf52c4c51e1571253d57684c442aa79a98d)

3 years agoMFC 1acf24a044aa:
Hans Petter Selasky [Tue, 16 Mar 2021 15:06:42 +0000 (16:06 +0100)]
MFC 1acf24a044aa:
Implement pci_get_relaxed_ordering_enabled() helper function.

Discussed with: kib@
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 1acf24a044aaa0391c61af4abe7e018c3bf8a37c)

3 years agonvme: Replace potentially long DELAY() with pause().
Alexander Motin [Wed, 17 Mar 2021 14:30:40 +0000 (10:30 -0400)]
nvme: Replace potentially long DELAY() with pause().

In some cases like broken hardware nvme(4) may wait minutes for
controller response before timeout.  Doing so in a tight spin loop
made whole system unresponsive.

Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29309
Sponsored by: iXsystems, Inc.

(cherry picked from commit 4fbbe523653b6d2a0186aca38224efcab941deaa)

3 years agoMFC: Fix post-start check when unbound.conf has moved.
Dag-Erling Smørgrav [Wed, 10 Mar 2021 14:18:59 +0000 (14:18 +0000)]
MFC: Fix post-start check when unbound.conf has moved.

On behalf of: des
Reported by: phk@
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 409388cfac49a312034e9397c870e3f81ff90734)

3 years agoMFC: Fix local-unbound setup for some IPv6 deployments.
Dag-Erling Smørgrav [Wed, 10 Mar 2021 14:01:38 +0000 (14:01 +0000)]
MFC: Fix local-unbound setup for some IPv6 deployments.

On behalf of: des
PR: 250984

(cherry picked from commit e5f02c140bf1e519a95bd6331382e8a2a1b6219f)

3 years agonetmap: fix issues in nm_os_extmem_create()
Vincenzo Maffione [Sat, 20 Mar 2021 17:15:50 +0000 (17:15 +0000)]
netmap: fix issues in nm_os_extmem_create()

- Call vm_object_reference() before vm_map_lookup_done().
- Use vm_mmap_to_errno() to convert vm_map_* return values to errno.
- Fix memory leak of e->obj.

Reported by: markj
Reviewed by: markj
MFC after: 1 week

(cherry picked from commit ee7ffaa2e6e08b63efb4673610875d40964d5058)

3 years agoFix scripted installs on EFI systems after default mounting of the ESP.
Nathan Whitehorn [Tue, 23 Mar 2021 13:19:42 +0000 (09:19 -0400)]
Fix scripted installs on EFI systems after default mounting of the ESP.

Because the ESP mount point (/boot/efi) is in mtree, tar will attempt to
extract a directory at that point post-mount when the system is installed.
Normally, this is fine, since tar can happily set whatever properties it
wants. For FAT32 file systems, however, like the ESP, tar will attempt to
set mtime on the root directory, which FAT does not support, and tar will
interpret this as a fatal error, breaking the install (see
https://github.com/libarchive/libarchive/issues/1516). This issue would
also break scripted installs on bare-metal POWER8, POWER9, and PS3
systems, as well as some ARM systems.

This patch solves the problem in two ways:
- If stdout is a TTY, use the distextract stage instead of tar, as in
  interactive installs. distextract solves this problem internally and
  provides a nicer UI to boot, but requires a TTY.
- If stdout is not a TTY, use tar but, as a stopgap for 13.0, exclude
  boot/efi from tarball extraction and then add it by hand. This is a
  hack, and better solutions (as in the libarchive ticket above) will
  obsolete it, but it solves the most common case, leaving only
  unattended TTY-less installs on a few tier-2 platforms broken.

In addition, fix a bug with fstab generation uncovered once the tar issue
is fixed that umount(8) can depend on the ordering of lines in fstab in a
way that mount(8) does not. The partition editor now writes out fstab in
mount order, making sure umount (run at the end of scripted, but not
interactive, installs) succeeds.

PR: 254395
Approved by: re (gjb)
Reviewed by: gjb, imp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D29380

(cherry picked from commit c2f16c595eb51c6e0cb6ece3f6f078d738019059)

3 years agopf: pool/kpool conversion code
Kristof Provost [Thu, 11 Mar 2021 10:37:05 +0000 (11:37 +0100)]
pf: pool/kpool conversion code

stuct pf_pool and struct pf_kpool are different. We should not simply
bcopy() them.

Happily it turns out that their differences were all pointers, and the
userspace provided pointers were overwritten by the kernel, so this did
actually work correctly, but we should fix it anyway.

Reviewed by: glebius
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29216

(cherry picked from commit 15b82e00a1640d1b9a1d720c95f65e580be30187)

3 years agopchtherm: fix a wrong bit and a wrong register use
Michal Vanco [Fri, 5 Mar 2021 08:55:30 +0000 (10:55 +0200)]
pchtherm: fix a wrong bit and a wrong register use

Probably just copy-paste errors that slipped in.

(cherry picked from commit 5084dde5f087264cf9a826569d1152c65d88a0fe)

PR: 253915
Reported by: Michal Vanco <michal.vanco@gmail.com>

3 years agoMFC dfb33cb0ef48:
Hans Petter Selasky [Wed, 10 Mar 2021 12:26:09 +0000 (13:26 +0100)]
MFC dfb33cb0ef48:
Allocating the LinuxKPI current structure from a software interrupt thread
must be done using the M_NOWAIT flag after 1ae20f7c70ea .

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit dfb33cb0ef48084da84072244e8ca486dfcf3a96)

3 years agoMFC d1cbe7908986:
Hans Petter Selasky [Wed, 10 Mar 2021 09:50:01 +0000 (10:50 +0100)]
MFC d1cbe7908986:
Allocating the LinuxKPI current structure from an interrupt thread must be
done using the M_NOWAIT flag after 1ae20f7c70ea .

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit d1cbe79089868226625c12ef49f51214d79aa427)

3 years agoMFC 6eb60f5b7f7d:
Hans Petter Selasky [Wed, 10 Mar 2021 11:21:01 +0000 (12:21 +0100)]
MFC 6eb60f5b7f7d:
Use the word "LinuxKPI" instead of "Linux compatibility", to not confuse with
user-space Linux compatibility support. No functional change.

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 6eb60f5b7f7df1a59de139260aebfa0aa5f6d79e)

3 years agoMFC ebe5cf355dca:
Hans Petter Selasky [Fri, 5 Mar 2021 11:44:06 +0000 (12:44 +0100)]
MFC ebe5cf355dca:
Implement basic support for allocating memory from a specific numa node
in the LinuxKPI.

Differential Revision: https://reviews.freebsd.org/D29077
Reviewed by: markj@ and kib@
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit ebe5cf355dca1d7827a70b99a9d9c4f97f78691d)

3 years agoMFC c743a6bd4fc0:
Hans Petter Selasky [Sat, 6 Mar 2021 10:25:12 +0000 (11:25 +0100)]
MFC c743a6bd4fc0:
Implement mallocarray_domainset(9) variant of mallocarray(9).

Reviewed by: kib @
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit c743a6bd4fc0d1be30f9bc9996333ac0ba079563)

3 years agostand: Load INIT_ARRAY and FINI_ARRAY sections
Mark Johnston [Tue, 16 Mar 2021 19:01:41 +0000 (15:01 -0400)]
stand: Load INIT_ARRAY and FINI_ARRAY sections

This is required for preloading modules into a KASAN-configured kernel.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7b1b5aad95df671aba3192f1669a8d96da481939)

3 years agonlmrsa: Mark deprecated for 14.
John Baldwin [Tue, 16 Mar 2021 21:34:58 +0000 (14:34 -0700)]
nlmrsa: Mark deprecated for 14.

This is the only in-tree driver for the asymmetric crypto support in
OCF that is already marked deprecated for 14.

Sponsored by: Chelsio Communications

(cherry picked from commit 096a84721670d388e432a1f7399251e4b20714f1)

3 years agoiscsi: Mark iSCSI CAM sims as non-pollable.
John Baldwin [Thu, 11 Feb 2021 21:51:20 +0000 (13:51 -0800)]
iscsi: Mark iSCSI CAM sims as non-pollable.

Previously, iscsi_poll() just panicked.  This meant if you got a panic
on a box when using the iSCSI initiator, the attempt to shutdown would
trigger a nested panic and never write out a core.  Now, CCB's sent to
iSCSI devices (such as the sychronize-cache request in dashutdown())
just fail with a timeout during a panic shutdown.

Sponsored by: Chelsio

(cherry picked from commit 47769bc5573fc5d2263f9e20cb06f6c12d0a82e7)

3 years agocam: Don't permit crashdumps on non-pollable devices.
John Baldwin [Thu, 11 Feb 2021 21:51:01 +0000 (13:51 -0800)]
cam: Don't permit crashdumps on non-pollable devices.

If a disk's SIM doesn't support polling, then it can't be used to
store crashdumps.  Leave d_dump NULL in that case so that dumpon(8)
fails gracefully rather than having dumps fail at crash time.

Sponsored by: Chelsio

(cherry picked from commit e07ac3f2fd7336e04178d116033989a6c099fec4)

3 years agocam: Permit non-pollable sims.
John Baldwin [Thu, 11 Feb 2021 21:49:43 +0000 (13:49 -0800)]
cam: Permit non-pollable sims.

Some CAM sim drivers do not support polling (notably iscsi(4)).
Rather than using a no-op poll routine that always times out requests,
permit a SIM to set a NULL poll callback.  cam_periph_runccb() will
fail polled requests non-pollable sims immediately as if they had
timed out.

Sponsored by: Chelsio

(cherry picked from commit 447b3557a9cc5f00a301be8404339f21a9a0faa8)
(cherry picked from commit e6405c8c37335a42a187a9d2470025b57347b1b5)

3 years agoarmv8crypto: note derivation in armv8_crypto_wrap.c
Mitchell Horne [Mon, 15 Mar 2021 13:46:03 +0000 (10:46 -0300)]
armv8crypto: note derivation in armv8_crypto_wrap.c

This file inherits some boilerplate and structure from the analogous
file in aesni(4), aesni_wrap.c. Note the derivation and the copyright
holders of that file.

For example, the AES-XTS bits added in 4979620ece984 were ported from
aesni(4).

Requested by: jmg
Reviewed by: imp, gnn

(cherry picked from commit da45b462664148ff6f8adbe59847c6c06f295391)

3 years agoiflib: Make if_shared_ctx_t a pointer to const
Mark Johnston [Mon, 8 Mar 2021 17:39:06 +0000 (12:39 -0500)]
iflib: Make if_shared_ctx_t a pointer to const

This structure is shared among multiple instances of a driver, so we
should ensure that it doesn't somehow get treated as if there's a
separate instance per interface.  This is especially important for
software-only drivers like wg.

DEVICE_REGISTER() still returns a void * and so the per-driver sctx
structures are not yet defined with the const qualifier.

Reviewed by: gallatin, erj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29102

(cherry picked from commit ffe3def903a5f239c319e5fe12450659658974a5)

3 years agoofwfb: fix boot on LE
Leandro Lupori [Tue, 9 Mar 2021 15:11:58 +0000 (12:11 -0300)]
ofwfb: fix boot on LE

Some framebuffer properties obtained from the device tree were not being
properly converted to host endian.
Replace OF_getprop calls by OF_getencprop where needed to fix this.

This fixes boot on PowerPC64 LE, when using ofwfb as the system console.

Reviewed by:    bdragon
Sponsored by:   Eldorado Research Institute (eldorado.org.br)
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D27475

(cherry picked from commit 043577b721ec4e5c2ab7571e6c05cfd54e49473c)

3 years agoInclude ccompile.h after opt_global.h.
Alexander Motin [Mon, 15 Mar 2021 17:48:50 +0000 (13:48 -0400)]
Include ccompile.h after opt_global.h.

This restores INVARIANTS enabling ZFS_DEBUG when built as module.

Discussed with: freqlabs
MFC after: 1 week

(cherry picked from commit 8ea35c45d5206ad57945ba160484f04450c88b75)

3 years agogenet: Fix problem with forwarding some TCP/IPv6 packets
Mike Karels [Thu, 18 Mar 2021 00:19:24 +0000 (19:19 -0500)]
genet: Fix problem with forwarding some TCP/IPv6 packets

TCP/IPv6 packets to be forwarded can be laid out with only the Ethernet
header in the first mbuf, and these packets are lost.  There was a
previous hack to pullup ICMPv6 packets with such a layout for the
same reason.  Generalize, and pullup any IPv6 packets with only the
Ethernet header in the first mbuf.  Possibly this should also include
IPv4, but that situation has not been observed to fail.

PR: 254060
Reported by: denis at h3q.com
MFC after: 3 days

(cherry picked from commit 2bdcf6237744b2d9d9707d623660d33931daeb52)

3 years agoVendor import of bc 3.3.4
Stefan Eßer [Fri, 19 Mar 2021 08:39:56 +0000 (09:39 +0100)]
Vendor import of bc 3.3.4

This update performs an implicit flush of the output when a script
calls read() in case a prompt is to be displayed in line-buffered
output mode.

(cherry picked from commit 893ecb52db5ed47d6c1e8698334d34e0df651612)

3 years agoMerge tcsh 6.22.03-ceccc7f
Dmitry Chagin [Sun, 14 Mar 2021 16:33:13 +0000 (19:33 +0300)]
Merge tcsh 6.22.03-ceccc7f

PR: 252663

(cherry picked from commit 5224c2a3bc95b431f729f3692f264395248d8acc)

3 years agoSpeed up geom_stats_resync in the presence of many devices
Alan Somers [Sat, 27 Feb 2021 15:59:40 +0000 (08:59 -0700)]
Speed up geom_stats_resync in the presence of many devices

The old code had a O(n) loop, where n is the size of /dev/devstat.
Multiply that by another O(n) loop in devstat_mmap for a total of
O(n^2).

This change adds DIOCGMEDIASIZE support to /dev/devstat so userland can
quickly determine the right amount of memory to map, eliminating the
O(n) loop in userland.

This change decreases the time to run "gstat -bI0.001" with 16,384 md
devices from 29.7s to 4.2s.

Also, fix a memory leak first reported as PR 203097.

Sponsored by: Axcient
Reviewed by: mav, imp
Differential Revision: https://reviews.freebsd.org/D28968

(cherry picked from commit ab63da3564e8ab0907f9d8eb565774848ffdadeb)

3 years agofortune: add a tip about gstat
Alan Somers [Fri, 26 Feb 2021 15:06:07 +0000 (08:06 -0700)]
fortune: add a tip about gstat

(cherry picked from commit 60a632f047cdb6e5314711f593a4d3b1f1d8dde9)

3 years agofusefs: set d_off during VOP_READDIR
Alan Somers [Fri, 12 Feb 2021 01:01:10 +0000 (18:01 -0700)]
fusefs: set d_off during VOP_READDIR

This allows d_off to be used with lseek to position the file so that
getdirentries(2) will return the next entry.  It is not used by
readdir(3).

PR: 253411
Reported by: John Millikin <jmillikin@gmail.com>
Reviewed by: cem
Differential Revision: https://reviews.freebsd.org/D28605

(cherry picked from commit 71befc35061b3c9d8cc07e34c5dce622c848fcdb)

3 years agopf tests: Test tos/dscp matching
Kristof Provost [Wed, 3 Mar 2021 20:15:39 +0000 (21:15 +0100)]
pf tests: Test tos/dscp matching

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

(cherry picked from commit 9d3b2bcf761041bbe79da3de25f2e4142d90b46a)

3 years agopfctl: Add missing 'va' code point name
Kristof Provost [Thu, 4 Mar 2021 12:50:28 +0000 (13:50 +0100)]
pfctl: Add missing 'va' code point name

Add the 'va' (voice-admit, RFC5865) symbolic name.

Reviewed by: rgrimes, gbe (man page)
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29069

(cherry picked from commit b4e3f3c2de6e6dc614f99615e50d0d87f3367ca0)

3 years agofind(1): Refine the HISTORY within the manual page.
Gordon Bergling [Sat, 13 Mar 2021 18:28:26 +0000 (19:28 +0100)]
find(1): Refine the HISTORY within the manual page.

A simple find command appeared in Version 1 AT&T UNIX and was removed in
Version 3 AT&T UNIX. It was rewritten for Version 5 AT&T UNIX and later
be enhanced for the Programmer's Workbench (PWB). These changes were
later incorporated in AT&T UNIX v7.

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

(cherry picked from commit a9275d996c229a30879baa42a6d02d24663ac43b)

3 years agofind(1): Mark -not as an extensions to POSIX
Daniel Ebdrup Jensen [Tue, 23 Feb 2021 15:23:09 +0000 (16:23 +0100)]
find(1): Mark -not as an extensions to POSIX

While here, change mdoc macro from Ic to Fl.

PR: 253499
Reported by: Michael Siegel <bugcounterism at malbolge.net>

(cherry picked from commit 75e6f664c469927ca73ecd7b16a8058bc292a451)

3 years agonet80211: Fix a typo in a comment
Gordon Bergling [Sat, 13 Mar 2021 14:51:30 +0000 (15:51 +0100)]
net80211: Fix a typo in a comment

- destionation -> destination
- while here, fix some whitespace issues

(cherry picked from commit d197bf2b20e7efc6ffef520bf96d5f642e26a015)

3 years agoFix a few typos in comments
Gordon Bergling [Sat, 13 Mar 2021 15:37:28 +0000 (16:37 +0100)]
Fix a few typos in comments

- trough -> through

MFC after: 1 week

(cherry picked from commit 183502d1625fbcc3600fbe1d196758b946749569)

3 years agoarm64: Add support for bcm2838 RNG
Gordon Bergling [Sat, 6 Mar 2021 11:28:35 +0000 (12:28 +0100)]
arm64: Add support for bcm2838 RNG

The hardware random number generator of the RPi4 differs slightly
from the version found on the RPi3.

This commit extends the existing bcm2835_rng driver to function on the RPi4.

Submitted by: James Mintram <me at jamesrm dot com>
Reviewed by: markm, cem, delphij
Approved by: csprng(cem, markm)
Differential Revision: https://reviews.freebsd.org/D22493

(cherry picked from commit e797dc58bd29c5bc0873fc620fc11d5332f90e7f)

3 years agoi386: Fix a few typos
Gordon Bergling [Sat, 13 Mar 2021 15:10:01 +0000 (16:10 +0100)]
i386: Fix a few typos

- wheter -> whether
- while here, fix some whitespace issues

(cherry picked from commit 564a3ac63abe166c6174ed3a58e78859a738ee58)

3 years agopf: Fully remove interrupt events on vnet cleanup
Kristof Provost [Wed, 10 Mar 2021 21:56:11 +0000 (22:56 +0100)]
pf: Fully remove interrupt events on vnet cleanup

swi_remove() removes the software interrupt handler but does not remove
the associated interrupt event.
This is visible when creating and remove a vnet jail in `procstat -t
12`.

We can remove it manually with intr_event_destroy().

PR: 254171
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29211

(cherry picked from commit cecfaf9bede9665d6a10f1e575cd5d575450cff7)

3 years agopf: Simplify cleanup
Kristof Provost [Wed, 10 Mar 2021 14:15:16 +0000 (15:15 +0100)]
pf: Simplify cleanup

We can now counter_u64_free(NULL), so remove the checks.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29190

(cherry picked from commit 28dc2c954f5096ae594ed5cd7a83d66ce4bf1ded)

3 years agoDocument that uma_zfree_pcpu() allows NULL now
Kristof Provost [Thu, 11 Mar 2021 08:32:01 +0000 (09:32 +0100)]
Document that uma_zfree_pcpu() allows NULL now

While here also document that for counter_u64_free().

Reviewed by: rpokala@
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29215

(cherry picked from commit 51dc8e7f688867e73eb7edc6bc65fdc77c9d5fff)

3 years agouma: allow uma_zfree_pcu(..., NULL)
Kristof Provost [Wed, 10 Mar 2021 14:11:59 +0000 (15:11 +0100)]
uma: allow uma_zfree_pcu(..., NULL)

We already allow free(NULL) and uma_zfree(..., NULL). Make
uma_zfree_pcpu(..., NULL) work as well.
This also means that counter_u64_free(NULL) will work.

These make cleanup code simpler.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29189

(cherry picked from commit b8f7267d499c8ef8e70b021879d3e9e087ecc32d)

3 years agopf: Remove redundant kif != NULL checks
Kristof Provost [Wed, 10 Mar 2021 14:50:42 +0000 (15:50 +0100)]
pf: Remove redundant kif != NULL checks

pf_kkif_free() already checks for NULL, so we don't have to check before
we call it.

Reviewed by: melifaro@
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29195

(cherry picked from commit 913e7dc3e0eb7df78ec0e7ecc7dd160a316a3ac6)

3 years agoaltq: Increase maximum number of CBQ and HFSC classes
Kristof Provost [Wed, 3 Mar 2021 10:06:49 +0000 (11:06 +0100)]
altq: Increase maximum number of CBQ and HFSC classes

In some configurations we need more classes than ALTQ supports by
default.  Increase the maximum number of classes we allow.
This will only cost us a comparatively trivial amount of memory, so
there's little reason not to do so.

If ever we find we want even more we may want to consider turning these
defines into a tunable, but for now do the easy thing.

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

(cherry picked from commit 448732b8e2d9bf4e2656a2e5a9e88cc58b88d4f4)

3 years agopf: Retrieve DSCP value from the IPv6 header
Kristof Provost [Wed, 3 Mar 2021 20:33:42 +0000 (21:33 +0100)]
pf: Retrieve DSCP value from the IPv6 header

Teach pf to read the DSCP value from the IPv6 header so that we can
match on them.

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

(cherry picked from commit f19323847ca894af8a58839f6a2a41691a8e2245)

3 years agopf: Factor out pf_krule_free()
Kristof Provost [Wed, 10 Mar 2021 10:10:04 +0000 (11:10 +0100)]
pf: Factor out pf_krule_free()

Reviewed by: melifaro@
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29194

(cherry picked from commit 5e9dae8e149ae8848f52148b665f3a0d031ca40f)

3 years agolinux: make timerfd_settime(2) set expirations count to zero
shu [Wed, 3 Feb 2021 16:51:45 +0000 (16:51 +0000)]
linux: make timerfd_settime(2) set expirations count to zero

On Linux, read(2) from a timerfd file descriptor returns an unsigned
8-byte integer (uint64_t) containing the number of expirations
that have occurred, if the timer has already expired one or more
times since its settings were last modified using timerfd_settime(),
or since the last successful read(2).  That's to say, once we do
a read or call timerfd_settime(), timer fd's expiration count should
be zero.  Some Linux applications create timerfd and add it to epoll
with LT mode, when event comes, they do timerfd_settime instead
of read to stop event source from trigger.  On FreeBSD,
timerfd_settime(2) didn't set the count to zero, which caused high
CPU utilization.

Submitted by: ankohuu_outlook.com (Shunchao Hu)
Differential Revision: https://reviews.freebsd.org/D28231

(cherry picked from commit ae71b794cbed19e5e25effc3438720ad452ab87c)

3 years agosbin/ifconfig: Get media status with libifconfig
Ryan Moeller [Sun, 28 Feb 2021 20:27:28 +0000 (20:27 +0000)]
sbin/ifconfig: Get media status with libifconfig

Code deduplication.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D29030

(cherry picked from commit 2803fa471e77dc8f227fe00bbf075de7feb10022)

3 years agolibifconfig: Overhaul ifconfig_media_* interfaces
Ryan Moeller [Tue, 2 Mar 2021 10:29:17 +0000 (10:29 +0000)]
libifconfig: Overhaul ifconfig_media_* interfaces

Define an ifmedia_t type to use for ifmedia words.

Add ifconfig_media_lookup_* functions to lookup ifmedia words by name.

Get media options as an array of option names rather than formatting it
as a comma-delimited list into a buffer.

Sprinkle const on static the static description tables for peace of
mind.

Don't need to zero memory allocated by calloc.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D29029

(cherry picked from commit c4ba4aa547184ab401204096cdad9def4ab37964)

3 years agozfs: bring back possibility to rewind the checkpoint from
Mariusz Zaborski [Sat, 13 Mar 2021 11:56:17 +0000 (12:56 +0100)]
zfs: bring back possibility to rewind the checkpoint from

Add parsing of the rewind options.

When I was upstreaming the change [1], I omitted the part where we
detect that the pool should be rewind. When the FreeBSD repo has
synced with the OpenZFS, this part of the code was removed.

[1] FreeBSD repo: 277f38abffc6a8160b5044128b5b2c620fbb970c
[2] OpenZFS repo: f2c027bd6a003ec5793f8716e6189c389c60f47a

Originally reviewed by: tsoome, allanjude
Originally reviewed by: kevans (ok from high-level overview)

Signed-off-by: Mariusz Zaborski <oshogbo@vexillium.org>
PR: 254152
Reported by: Zhenlei Huang <zlei.huang at gmail.com>
Obtained from: https://github.com/openzfs/zfs/pull/11730

(cherry picked from commit 653ed678c70376b15cdc42daafa7b4554570cea2)

3 years agovtnet: fix TSO for TCP/IPv6
Michael Tuexen [Thu, 18 Mar 2021 20:25:47 +0000 (21:25 +0100)]
vtnet: fix TSO for TCP/IPv6

The decision whether a TCP packet is sent over IPv4 or IPv6 was
based on ethertype, which works correctly. In D27926 the criteria
was changed to checking if the CSUM_IP_TSO flag is set in the
csum-flags and then considering it to be TCP/IPv4.
However, the TCP stack sets the flag to CSUM_TSO for IPv4 and IPv6,
where CSUM_TSO is defined as CSUM_IP_TSO|CSUM_IP6_TSO.
Therefore TCP/IPv6 packets gets mis-classified as TCP/IPv4,
which breaks TSO for TCP/IPv6.
This patch bases the check again on the ethertype.
This fix is instantly MFCed.

Approved by: re(gjb)
PR: 254366
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D29331

(cherry picked from commit d4697a6b56168876fc0ffec1a0bb1b24d25b198e)

3 years agotail: fix "tail -F" file rotation detection
Chuck Silvers [Tue, 2 Feb 2021 00:21:14 +0000 (16:21 -0800)]
tail: fix "tail -F" file rotation detection

When checking if the newly opened file is the same as the old one,
we need to fstat() the new file descriptor, not the old one again.

Reviewed by: glebius
Sponsored by: Netflix

(cherry picked from commit 7787e7eed9d2a43fb6eb66666040f1b495995a2f)

3 years agonetmap: fix memory leak in NETMAP_REQ_PORT_INFO_GET
Vincenzo Maffione [Mon, 15 Mar 2021 17:39:18 +0000 (17:39 +0000)]
netmap: fix memory leak in NETMAP_REQ_PORT_INFO_GET

The netmap_ioctl() function has a reference counting bug in case of
NETMAP_REQ_PORT_INFO_GET command. When `hdr->nr_name[0] == '\0'`,
the function does not decrease the refcount of "nmd", which is
increased by netmap_mem_find(), causing a refcount leak.

Reported by: Xiyu Yang <sherllyyang00@gmail.com>
Submitted by: Carl Smith <carl.smith@alliedtelesis.co.nz>
MFC after: 3 days
PR: 254311

(cherry picked from commit 0ab5902e8ad93d0a9341dcce386b6c571ee02173)

3 years agovfs: fix vnlru marker handling for filtered/unfiltered cases
Mateusz Guzik [Wed, 17 Mar 2021 21:33:47 +0000 (22:33 +0100)]
vfs: fix vnlru marker handling for filtered/unfiltered cases

The global list has a marker with an invariant that free vnodes are
placed somewhere past that. A caller which performs filtering (like ZFS)
can move said marker all the way to the end, across free vnodes which
don't match. Then a caller which does not perform filtering will fail to
find them. This makes vn_alloc_hard sleep for 1 second instead of
reclaiming, resulting in significant stalls.

Fix the problem by requiring an explicit marker by callers which do
filtering.

As a temporary measure extend vnlru_free to restart if it fails to
reclaim anything.

Big thanks go to the reporter for testing several iterations of the
patch.

Reported by: Yamagi <lists yamagi.org>
Tested by: Yamagi <lists yamagi.org>
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D29324

(cherry picked from commit e9272225e6bed840b00eef1c817b188c172338ee)

3 years ago base: remove if_wg(4) and associated utilities, manpage
Scott Long [Thu, 18 Mar 2021 07:07:56 +0000 (07:07 +0000)]
   base: remove if_wg(4) and associated utilities, manpage

   After length decisions, we've decided that the if_wg(4) driver and
   related work is not yet ready to live in the tree.  This driver has
   larger security implications than many, and thus will be held to
   more scrutiny than other drivers.

Requested by: secteam
Approved by: re

3 years agolink_elf_obj: Add a case missing from 5e6989ba4f26
Mark Johnston [Tue, 16 Mar 2021 19:01:41 +0000 (15:01 -0400)]
link_elf_obj: Add a case missing from 5e6989ba4f26

Fixes: 5e6989ba4f26
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4aa157dd5b4e72b85dd07ce3c106b742ca371bca)

3 years agolink_elf_obj: Handle init_array sections in KLDs
Mark Johnston [Thu, 4 Mar 2021 15:02:47 +0000 (10:02 -0500)]
link_elf_obj: Handle init_array sections in KLDs

Reuse existing handling for .ctors, print a warning if multiple
constructor sections are present.   Destructors are not handled as of
yet.

This is required for KASAN.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29049

(cherry picked from commit 5e6989ba4f26acafc77baa6055c0a9e7fe683514)

3 years agogmirror: Pre-allocate the timeout event structure
Mark Johnston [Thu, 11 Mar 2021 20:43:04 +0000 (15:43 -0500)]
gmirror: Pre-allocate the timeout event structure

We can't call malloc(M_WAITOK) in a callout handler.

Reviewed by: imp
Reported by: pho
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29223

(cherry picked from commit 2f1cfb7f63ca744e7a143896347bdc8606c291d6)

3 years agosbin/ifconfig: Use a global libifconfig handle
Ryan Moeller [Sun, 28 Feb 2021 10:30:09 +0000 (10:30 +0000)]
sbin/ifconfig: Use a global libifconfig handle

This should eventually replace the socket passed to the various
handlers. In the meantime, making it global avoids repeatedly opening
and closing handles.

Reported by: kp
Reviewed by: kp (earlier version)
Differential Revision: https://reviews.freebsd.org/D28990

(cherry picked from commit 8b22242550c98d0a59b6589f2be0beb1dc2eac13)

3 years agotests/sys/netgraph/ng_macfilter_test: Fix invalid TAP output
Alex Richardson [Fri, 12 Mar 2021 17:35:24 +0000 (17:35 +0000)]
tests/sys/netgraph/ng_macfilter_test: Fix invalid TAP output

This should allow the test to pass in Jenkins. Testing it locally now
reports "passed" instead of "invalid TAP data".

While touching this file also fix some shellcheck warnings that were
pointed out by my IDE.

Reviewed By: lwhsu, afedorov
Differential Revision: https://reviews.freebsd.org/D29054

(cherry picked from commit 65f4ff4e68afc3867781dfc8cd4faf2a8be1c74f)

3 years agocapsicum-test: Update for O_BENEATH removal
Alex Richardson [Fri, 12 Mar 2021 17:12:10 +0000 (17:12 +0000)]
capsicum-test: Update for O_BENEATH removal

Update the tests to check O_RESOLVE_BENEATH instead.
If this looks reasonable, I'll try to upstream this change.
This keeps a compat fallback for O_BENEATH since the Linux port still
has/had O_BENEATH with "no .., no absolute paths" semantics.

Test Plan: `/usr/tests/sys/capsicum/capsicum-test -u 977` passes and
runs the O_RESOLVE_BENEATH tests.
Reviewed By: markj
Differential Revision: https://reviews.freebsd.org/D29016

(cherry picked from commit 8cf5812af4b7f4933983822ff8e1e9185818fbef)

3 years agotests/sys/cddl: correctly quote atf_set "require.progs"
Alex Richardson [Mon, 8 Mar 2021 09:38:24 +0000 (09:38 +0000)]
tests/sys/cddl: correctly quote atf_set "require.progs"

The argument has to be a single whitespace-separate value. While touching
all these lines also add ksh93, since `atf_set "require.progs"` overrides
the default value specified in the Kyuafile. This then results in tests
being executed despite ksh93 not being installed.

Reviewed By: asomers
Differential Revision: https://reviews.freebsd.org/D29066

(cherry picked from commit 0b86424c31ece31190c94d55feb5d190be4de5df)

3 years agoRemove unnecessary semicolon from CRITICAL_ASSERT()
Alex Richardson [Thu, 4 Mar 2021 15:06:32 +0000 (15:06 +0000)]
Remove unnecessary semicolon from CRITICAL_ASSERT()

This fixes off-by-default "empty statement" compiler warnings.

(cherry picked from commit b2c8cbf992cb0b51118beae9c304580705ae00c9)

3 years agoFix capsicum-test build with GCC
Alex Richardson [Wed, 3 Mar 2021 13:53:30 +0000 (13:53 +0000)]
Fix capsicum-test build with GCC

Apparently GCC defines NULL to 0 in C++11 mode (instead of nullptr), so
this causes the following error:
```
In file included from capsicum-test.h:15,
                 from capsicum-test.cc:1:
gtest-1.10.0/include/gtest/gtest.h: In instantiation of 'testing::AssertionResult testing::internal::CmpHelperNE(const char*, const char*, const T1&, const T2&) [with T1 = long int; T2 = procstat*]':
capsicum-test.cc:75:3:   required from here
gtest-1.10.0/include/gtest/gtest.h:1621:28: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
 1609 |   if (val1 op val2) {\
      |       ~~~~~~~~~~~~
......
 1621 | GTEST_IMPL_CMP_HELPER_(NE, !=);
gtest-1.10.0/include/gtest/gtest.h:1609:12: note: in definition of macro 'GTEST_IMPL_CMP_HELPER_'
 1609 |   if (val1 op val2) {\
      |            ^~
```

Fix this by using nullptr directly.

Submitted upstream as https://github.com/google/capsicum-test/pull/56

Reported by: Jenkins CI

(cherry picked from commit 47ceb65f3c213904642f4859a53a3139e9cb287d)

3 years agoSimplify the capsicum-test wrapper script
Alex Richardson [Tue, 2 Mar 2021 18:27:34 +0000 (18:27 +0000)]
Simplify the capsicum-test wrapper script

Instead of running tests one-by-one with the shell wrapper we now run
the full gtest testsuite twice (once as root, once as non root). This
significantly speeds up running tests despite running them twice.
This change also passes the missing -u flag to capsicum-test that caused
test failures (https://bugs.freebsd.org/250178)

Previously, running the testsuite with the wrapper script took ~3s per
test on aarch64 QEMU, i.e. a total of almost 5 minutes.
Now it takes 6 seconds to run all tests twice.

Before:
root@freebsd-aarch64:/usr/tests/sys/capsicum # /usr/bin/time kyua test functional
94/96 passed (2 failed)
      309.97 real        58.46 user       244.31 sys

After:
root@freebsd-aarch64:/usr/tests/sys/capsicum # /usr/bin/time kyua test functional
functional:test_root  ->  passed  [2.659s]
functional:test_unprivileged  ->  passed  [2.391s]
2/2 passed (0 failed)
        5.48 real         1.06 user         2.52 sys

This overhead is caused by kyua + atf-sh spawning lots of additional
processes and can be avoided by just running the googletest test binary.
syscall                     seconds   calls  errors
fork                   39.810229456    1275       0
sigprocmask            13.546928736     572       0

i.e. 1275 processes spawned to run a single test.

Test Plan: All tests pass with D28907.
PR: 250178
Reviewed By: lwhsu
Differential Revision: https://reviews.freebsd.org/D29014

(cherry picked from commit 53a535c1d80a2e5ea33a4e8807647e600402b1d8)

3 years agoUpdate capsicum-test to git commit f4d97414d48b8f8356b971ab9f45dc5c70d53c40
Alex Richardson [Tue, 2 Mar 2021 16:28:26 +0000 (16:28 +0000)]
Update capsicum-test to git commit f4d97414d48b8f8356b971ab9f45dc5c70d53c40

This includes various fixes that I submitted recently such as updating the
pdkill() tests for the actual implemented behaviour
(https://github.com/google/capsicum-test/pull/53) and lots of changes to
avoid calling sleep() and replacing it with reliable synchronization
(pull requests 49,51,52,53,54). This should make the testsuite more reliable
when running on Jenkins. Additionally, process status is now retrieved using
libprocstat instead of running `ps` and parsing the output
(https://github.com/google/capsicum-test/pull/50). This fixes one previously
failing test and speeds up execution.

Overall, this update reduces the total runtime from ~60s to about 4-5 seconds.

(cherry picked from commit 955a3f9ad586f38395e66127f9f2f4afbf3d5a94)

3 years agoUpdate capsicum-test to git commit 7707222b46abe52d18fd4fbb76115ffdb3e6f74b
Alex Richardson [Tue, 16 Feb 2021 14:35:12 +0000 (14:35 +0000)]
Update capsicum-test to git commit 7707222b46abe52d18fd4fbb76115ffdb3e6f74b

This includes changes to use GTEST_SKIP() instead of the local hand-rolled
mechanism as well as a few minor cleanups.

(cherry picked from commit 2d936e6c99ad1c4fb01f6c99a96dcc924ee44b9d)

3 years agotests/sys/netgraph: Tell kyua that perl is required
Alex Richardson [Tue, 23 Feb 2021 17:02:31 +0000 (17:02 +0000)]
tests/sys/netgraph: Tell kyua that perl is required

Otherwise these tests fail with incomprehensible error messages.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D28894

(cherry picked from commit 3775ddcf5a12c8e23970e94b7b165bf23c92aeba)

3 years agotests/sys/netpfil/pf: Add missing python3 requirements
Alex Richardson [Tue, 23 Feb 2021 19:04:01 +0000 (19:04 +0000)]
tests/sys/netpfil/pf: Add missing python3 requirements

This also fixes a typo in the dup test that caused the head function to
not be called. On my test system without python3 the tests are now
skipped instead of failing.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D28903

(cherry picked from commit 98202829d1b3727a8706f45d052fc9e9507b562b)

3 years agoSilence a macro-redefined warning when crossbuilding
Alex Richardson [Mon, 1 Mar 2021 14:11:20 +0000 (14:11 +0000)]
Silence a macro-redefined warning when crossbuilding

This is already defined by the ncurses headers, so just undef it before
defining it again.

(cherry picked from commit 10f2a0c2e8766e9878ad4181f555d8dda84da34e)

3 years agotests/sys/audit: add missing comma delimiter between fields
Alex Richardson [Tue, 2 Mar 2021 18:34:42 +0000 (18:34 +0000)]
tests/sys/audit: add missing comma delimiter between fields

This makes the `kyua report --verbose` output a lot easier to parse when
looking at failed tests. It also fixes the closefrom() test since I
tested my changes with this commit but forgot to push it together with
fa32350347b4e351a144b5423f0fb2ca9d67f4ca.

Fixes: fa32350347b4 ("close_range: add audit support")
(cherry picked from commit c97304110a02f9c41b515e7b94d53229ab8f61af)

3 years agoclose_range: add audit support
Alex Richardson [Tue, 23 Feb 2021 17:47:07 +0000 (17:47 +0000)]
close_range: add audit support

This fixes the closefrom test in sys/audit.

Includes cherry-picks of the following commits from openbsm:

https://github.com/openbsm/openbsm/commit/4dfc628aafe589d68848f7033f3d3488c4d979e0
https://github.com/openbsm/openbsm/commit/99ff6fe32aebc5a4b8d40d60062b8574697df557
https://github.com/openbsm/openbsm/commit/da48a0399e95448693d3fa2be48454ca564c1be8

Reviewed By: kevans
Differential Revision: https://reviews.freebsd.org/D28388

(cherry picked from commit fa32350347b4e351a144b5423f0fb2ca9d67f4ca)

3 years agotests/sys/audit: Avoid race caused by starting auditd(8) for testing
Alex Richardson [Thu, 18 Feb 2021 10:14:27 +0000 (10:14 +0000)]
tests/sys/audit: Avoid race caused by starting auditd(8) for testing

In the CheriBSD CI we reproducibly see the first test in sys/audit
(administrative:acct_failure) fail due to a missing startup message.
It appears this is caused by a race condition when starting auditd:
`service auditd onestart` returns as soon as the initial auditd() parent
exits (after the daemon(3) call).
We can avoid this problem by setting up the auditd infrastructure
in-process: libauditd contains audit_quick_{start,stop}() functions that
look like they are ideally suited to this task.
This patch also avoids forking lots of shell processes for each of the 418
tests by using `auditon(A_SENDTRIGGER, &trigger, sizeof(trigger))` to check
for a running auditd(8) instead of using `service auditd onestatus`.

With these two changes (and D28388 to fix the XFAIL'd test) I can now
boot and run `cd /usr/tests/sys/audit && kyua test` without any failures
in a single-core QEMU instance. Before there would always be at least one
failed test.

Besides making the tests more reliable in CI, a nice side-effect of this
change is that it also significantly speeds up running them by avoiding
lots of fork()/execve() caused by shell scripts:
Running kyua test on an AArch64 QEMU took 315s before and now takes 68s,
so it's roughly 3.5 times faster. This effect is even larger when running
on a CHERI-RISC-V QEMU since emulating CHERI instructions on an x86 host
is noticeably slower than emulating AArch64.

Test Plan: aarch64+amd64 QEMU no longer fail.

Reviewed By: asomers
Differential Revision: https://reviews.freebsd.org/D28451

(cherry picked from commit df093aa9463b2121d8307fb91c4ba7cf17f4ea64)

3 years agofix panic when rescue retransmission and FIN overlap
Richard Scheffenegger [Wed, 17 Mar 2021 15:44:29 +0000 (16:44 +0100)]
fix panic when rescue retransmission and FIN overlap

PR:           254244
PR:           254309
Reviewed By:  #transport, hselasky, tuexen
Approved by:  re (cperciva)
MFC after:    immediately
Sponsored By: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29315

(cherry picked from commit e9f029831fa5747ae1b405f5716c52cb4ebf1e04)

3 years agoFix GCC build of ptrace_test after 96a9e50e63bfc
Alex Richardson [Wed, 3 Mar 2021 11:21:04 +0000 (11:21 +0000)]
Fix GCC build of ptrace_test after 96a9e50e63bfc

It seems like GCC's -Wsign-compare is stricter and also warns for
constants. Appease GCC by adding the required casts.

Fixes: 96a9e50e63bfc ("ptrace_test: Add more debug output on test failures")
Reported by: Jenkins CI

(cherry picked from commit 1fcbddec14dd693acf6a4be579f8d9e10b6a06a4)

3 years agoFix ptrace_test:ptrace__syscall_args after ATF upgrade
Alex Richardson [Tue, 23 Feb 2021 12:51:35 +0000 (12:51 +0000)]
Fix ptrace_test:ptrace__syscall_args after ATF upgrade

ATF now opens the results file (without CLOEXEC), so the child actually
has a valid file descriptor 3. To fix this simply use a large number that
will definitely not be a valid file descriptor.

Reviewed by: jhb, cem, lwhsu
Differential Revision: https://reviews.freebsd.org/D28889

(cherry picked from commit 17cc20092cd7a45adb6d772e0f449617007a82d9)

3 years agoRemove atf_tc_skip calls from ptrace_test
Alex Richardson [Mon, 1 Mar 2021 18:51:02 +0000 (18:51 +0000)]
Remove atf_tc_skip calls from ptrace_test

I've run these tests many times in a loop on multiple architectures and
it works reliably for me, maybe it's time to retire these skips?
This also adds an additional waitpid to one of the tests to avoid
a potential race condition (suggested by markj@).

PR: 239397, 244056, 239425, 240510, 220841, 243605
Reviewed By: markj
Differential Revision: https://reviews.freebsd.org/D28888

(cherry picked from commit 1032131464f1196ad674b30c14a9e611789a1061)

3 years agoptrace_test: Add more debug output on test failures
Alex Richardson [Mon, 1 Mar 2021 18:49:31 +0000 (18:49 +0000)]
ptrace_test: Add more debug output on test failures

Mostly automatic, using
`CHILD_REQUIRE\(([^|&\n]*) ==` -> `CHILD_REQUIRE_EQ_INT($1,`
`ATF_REQUIRE\(([^|&\n]*) ==` -> `REQUIRE_EQ_INT($1,` followed by
git-clang-format -f and then manually checking ones that contain ||/&&.

Test Plan:
Still getting the same failure but now it prints
`psr.sr_error (0) == EBADF (9) not met` instead of just failing
without printing the values.

PR: 243605
Reviewed By: jhb
Differential Revision: https://reviews.freebsd.org/D28887

(cherry picked from commit 96a9e50e63bfcbca7309c012c2c7a477c8826824)

3 years agoatf: Fix ATF_BUILD_* values when not using the bootstrap compiler
Alex Richardson [Wed, 3 Feb 2021 09:32:16 +0000 (09:32 +0000)]
atf: Fix ATF_BUILD_* values when not using the bootstrap compiler

Currently, we encode the full path and compile flags for the build
compiler in libatf. However, these values are not correct when
cross-compiling: For example, when I build on macOS, CC is set to the
host path /usr/local/Cellar/llvm/11.0.0_1/bin/clang-11. This path will
not exist on the target system.
Simplify this logic and use cc/cpp/c++ since those binaries will exist
on the target system unless the compiler was explicitly disabled.
I'm not convinced ATF needs to encode these values, but this is a
minimal fix for these tests when using a non-bootstrapped compiler.

Reviewed By: ngie, brooks
Differential Revision: https://reviews.freebsd.org/D28414

(cherry picked from commit 9b131f1e51a00c8bbbda32672fb5db88010400f6)

3 years agolibc: Fix t_spawn_fileactions test after ATF update
Alex Richardson [Thu, 18 Feb 2021 10:07:51 +0000 (10:07 +0000)]
libc: Fix t_spawn_fileactions test after ATF update

Since https://github.com/freebsd/atf/commit/4581cefc1e3811dd3c926b5dd4b15fd63d2e19da
ATF opens the results file on startup. This fixes problems like
capsicumized tests not being able to open the file on exit.

However, this test closes all file descriptors above 3 to get a
deterministic fd table allocation for the child. Instead of using closefrom
(which will close the ATF output file FD) I've changed this test use
the lowest available fd and pass that to the helper program as a string.

We could also try to re-open the results file in ATF if we get a EBADF
error, but that will fail when running under Capsicum.

Reviewed By: cem
Differential Revision: https://reviews.freebsd.org/D28684

(cherry picked from commit 2aa3ef285a23d802f0bd6c7281612e16834e9b68)

3 years agoFix two failing tests after ATF update
Alex Richardson [Mon, 15 Feb 2021 22:11:30 +0000 (22:11 +0000)]
Fix two failing tests after ATF update

Since https://github.com/freebsd/atf/commit/4581cefc1e3811dd3c926b5dd4b15fd63d2e19da
ATF opens the results file on startup. This fixes problems like
capsicumized tests not being able to open the file on exit.

However, this test closes all file descriptors just to check that
socketpair returns fd 3+4 and thereby also closes the ATF results file.
This then results in an EBADF when writing the result so the test is
reported as broken.

While system calls that create new file descriptors (must?) use the lowest
available file descriptor number, it does not seem useful to test this
property here. Drop the check for FD==3/4 to unbreak the testsuite.

We could also try to re-open the results file in ATF if we get a EBADF
error, but that will fail when running under Capsicum.

Reviewed By: cem
Differential Revision: https://reviews.freebsd.org/D28683

(cherry picked from commit 10fc4c3218381fef7189a5b8d46a757cd1989dff)

3 years agotests/sys/vfs/lookup_cap_dotdot: No longer aborts after ATF update
Alex Richardson [Thu, 4 Feb 2021 17:48:29 +0000 (17:48 +0000)]
tests/sys/vfs/lookup_cap_dotdot: No longer aborts after ATF update

It appears this test no longer fails after c203bd70b5957f85616424b6fa374479372d06e3.

PR: 215690
(cherry picked from commit 1eec5861d52e074bc20d08aef051af59cc70040e)

3 years agoImport atf 0.22 snapshot ca73d08c3fc1ecffc1f1c97458c31ab82c12bb01
Alex Richardson [Thu, 4 Feb 2021 14:48:10 +0000 (14:48 +0000)]
Import atf 0.22 snapshot ca73d08c3fc1ecffc1f1c97458c31ab82c12bb01

This includes improvements to the atf-sh helper functions that
significantly reduce the number of spawned processes for each test
and therefore speeds up running the testsuite noticeably.

(cherry picked from commit c203bd70b5957f85616424b6fa374479372d06e3)

3 years agoFix bootstrap tools build on macOS after 02af91c52e71e8a0f47251e637c9687f35d45dd9
Alex Richardson [Wed, 17 Feb 2021 16:03:11 +0000 (16:03 +0000)]
Fix bootstrap tools build on macOS after 02af91c52e71e8a0f47251e637c9687f35d45dd9

After changing the namespace.h header we need to provide _err on macOS, too.
Previously we used the system libc err*/warn*, but that does not provide
_err/_warn (which is used by other bootstrapped files from libc).
To fix this problem bootstrap err.c on macOS as well.

Fixes: 02af91c52 (Fix crossbuild bootstrap tools build with Clang 12)
(cherry picked from commit 962a3814d4c838d21a67a4b704c64be843cb2b51)

3 years agoFix crossbuild bootstrap tools build with Clang 12
Alex Richardson [Wed, 10 Feb 2021 11:05:02 +0000 (11:05 +0000)]
Fix crossbuild bootstrap tools build with Clang 12

Clang 12 no longer allows re-defining a weak symbol as non-weak. This
happed here because we compile err.c with _err defined to err. To fix
this, use the same approach as the libc namespace.h

(cherry picked from commit 02af91c52e71e8a0f47251e637c9687f35d45dd9)

3 years agobin/pkill: Fix {pgrep,pkill}-j_test.sh
Alex Richardson [Sat, 13 Feb 2021 13:53:50 +0000 (13:53 +0000)]
bin/pkill: Fix {pgrep,pkill}-j_test.sh

The POSIX sh case statement does not allow for pattern matching using the
regex + qualifier so this case statement never matches. Instead just check
for a string starting with a digit followed by any character.

While touching these files also fix various shellcheck warnings.

`kyua -v parallelism=4 test` failed before, succeeds now.

Reviewed By: imp
Differential Revision: https://reviews.freebsd.org/D28480

(cherry picked from commit 5ff2e55e0071dabbf18cdbe13a1230822d1270d4)

3 years agolib/libc/tests/rpc: Correctly set timeout
Alex Richardson [Sat, 13 Feb 2021 13:52:59 +0000 (13:52 +0000)]
lib/libc/tests/rpc: Correctly set timeout

The rpc_control() API does not accept the CLCR_SET_RPCB_TIMEOUT command,
it only accepts RPC_SVC_CONNMAXREC_GET/RPC_SVC_CONNMAXREC_SET, so it was
not doing anything.
Instead of incorrectly calling this API, use clnt_create_timed() instead.

I noticed this because the test was timing out after 120s in the CheriBSD CI.

Reviewed By: ngie
Differential Revision: https://reviews.freebsd.org/D28478

(cherry picked from commit 90b5fc95832da64a5f56295e687379732c33718f)

3 years agousr.bin/jail: Fix tests when using kyua -v parallelism=N
Alex Richardson [Thu, 4 Feb 2021 17:56:54 +0000 (17:56 +0000)]
usr.bin/jail: Fix tests when using kyua -v parallelism=N

These tests create jails with the same name, so they cannot be run in
parallel.

Reviewed By: lwhsu
Differential Revision: https://reviews.freebsd.org/D28482

(cherry picked from commit 72692dfdfe7b4ffd894afd67959651ca1b01a105)

3 years agosbin/pfctl: fix tests after recent output changes
Alex Richardson [Thu, 4 Feb 2021 17:56:26 +0000 (17:56 +0000)]
sbin/pfctl: fix tests after recent output changes

The output now contains http-alt instead of 8080 and personal-agent
instead of 5555.
This was probably caused by 228e2087a32847fa51168f3f0c58f931cb2cb0f8.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D28481

(cherry picked from commit 58de61b9967b36f5fbd34e8b51ece7b4b772f104)

3 years agotools/build/make.py: -DNO_CLEAN -> -DWITHOUT_CLEAN
Alex Richardson [Wed, 3 Feb 2021 15:56:03 +0000 (15:56 +0000)]
tools/build/make.py: -DNO_CLEAN -> -DWITHOUT_CLEAN

(cherry picked from commit 43e083be8103685e65582e002d33e861f7d5c794)

3 years agousr.sbin/praudit: Fix tests after 5619d49e07
Alex Richardson [Wed, 3 Feb 2021 15:26:19 +0000 (15:26 +0000)]
usr.sbin/praudit: Fix tests after 5619d49e07

Commit 5619d49e07 made the getgrgid() call inside bsm work as
intended so we now print "wheel" instead of a numeric 0 in the rgid field.

Reviewed By: markj
Differential Revision: https://reviews.freebsd.org/D28462

(cherry picked from commit 7791ecf04b48a0c365b003447f479ec890115dfc)

3 years agotests/sys/audit: Skip extattr tests if extattrs are not supported
Alex Richardson [Tue, 2 Feb 2021 09:55:18 +0000 (09:55 +0000)]
tests/sys/audit: Skip extattr tests if extattrs are not supported

In the CheriBSD CI, we run the testsuite with /tmp as tmpfs. This causes
the extattr audit tests to fail since tmpfs does not (yet) support
extattrs. Skip those tests if the target path is on a file system that
does not support extended file attributes.

While touching these two files also convert the ATF_REQUIRE_EQ(-1, ...)
checks to use ATF_REQURIE_ERRNO().

Reviewed By: asomers
Differential Revision: https://reviews.freebsd.org/D28392

(cherry picked from commit 40407d3998d1a12cbe929721f4dbe72b4be478a6)

3 years agoUpdate comment missed in 83ff5d5d98cbcf9b66dccd70022358aec8918a14
Alex Richardson [Fri, 29 Jan 2021 09:19:27 +0000 (09:19 +0000)]
Update comment missed in 83ff5d5d98cbcf9b66dccd70022358aec8918a14

Reported by: jrtc27

(cherry picked from commit d4a6843bb1207d71234099ded81cee75d3ae8864)

3 years agotests/sys/audit: fix timeout calculation
Alex Richardson [Thu, 28 Jan 2021 17:23:27 +0000 (17:23 +0000)]
tests/sys/audit: fix timeout calculation

This changes the behaviour to a 30s total timeout (needed when running
on slow emulated uniprocessor systems) and timing out after 10s without
any input. This also uses timespecsub() instead of ignoring the
nanoseconds field.

After this change the tests runs more reliably on QEMU and time out less
frequently.

Reviewed By: asomers
Differential Revision: https://reviews.freebsd.org/D28391

(cherry picked from commit 869cc06480b75b4caea0d049e0cf7f82bb5aeed1)

3 years agoUn-XFAIL two tests with Clang > 10
Alex Richardson [Thu, 28 Jan 2021 17:17:49 +0000 (17:17 +0000)]
Un-XFAIL two tests with Clang > 10

SVN r343917 fixed this for in-tree clang, but when building with a newer
out-of-tree clang the test was still marked as XFAIL.

Reviewed By: dim
Differential Revision: https://reviews.freebsd.org/D28390

(cherry picked from commit 83ff5d5d98cbcf9b66dccd70022358aec8918a14)

3 years agoDon't include libarchive fuzz tests by default
Alex Richardson [Mon, 25 Jan 2021 14:03:17 +0000 (14:03 +0000)]
Don't include libarchive fuzz tests by default

These tests are basic fuzz tests that permute input to trigger crashes
rather than regression or unit tests. Additionally, some of them take a
rather long time to run and should probably be run on a dedicated fuzzing
job instead. Moreover, these simple tests use rand() instead of a real
fuzzing tool that generates interesting inputs (e.g. LLVM libFuzzer) so are
unlikely to find anything interesting when run in CI.

This allows removing one BROKEN_TESTS case due to timeouts and speeds up
running tests on emulated platforms such as QEMU.

Reviewed By: lwhsu, mm
Differential Revision: https://reviews.freebsd.org/D27153

(cherry picked from commit 3454fa118c41a588e2dad20614325297c989c60b)

3 years agorc.d/auditd: set pidfile
Alex Richardson [Thu, 28 Jan 2021 17:17:07 +0000 (17:17 +0000)]
rc.d/auditd: set pidfile

auditd creates a pidfile so we should use it for status checks.
This also seems to speed up the frequent onestatus checks used in
tests/sys/audit.

Reviewed By: asomers
Differential Revision: https://reviews.freebsd.org/D28389

(cherry picked from commit bcc5b2445674e4691853d7533e4873a6712f67ee)