]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agonfscl: Fix a deadlock related to the NFSv4 clientID lock
Rick Macklem [Tue, 12 Oct 2021 04:58:24 +0000 (21:58 -0700)]
nfscl: Fix a deadlock related to the NFSv4 clientID lock

Without this patch, it is possible for a process doing an NFSv4
Open/create of a file to block to allow another process
to acquire the exclusive lock on the clientID when holding
a shared lock on the clientID.  As such, both processes
deadlock, with one wanting the exclusive lock, while the
other holds the shared lock.  This deadlock is unlikely to occur
unless delegations are in use on the NFSv4 mount.

This patch fixes the problem by not deferring to the process
waiting for the exclusive lock when a shared lock (reference cnt)
is already held by the process.

This problem was detected during a recent NFSv4 interoperability
testing event held by the IETF working group.

MFC after: 1 week

2 years agoSkip sys.net.if_lagg_test.status_stress in CI
Li-Wen Hsu [Mon, 11 Oct 2021 21:40:24 +0000 (05:40 +0800)]
Skip sys.net.if_lagg_test.status_stress in CI

This case panics the machine fairly often and we should run
stress tests separately.

Sponsored by: The FreeBSD Foundation

2 years agoforward declare struct thread
Warner Losh [Mon, 11 Oct 2021 18:59:39 +0000 (12:59 -0600)]
forward declare struct thread

sys/sysctl.h moved struct thread forward declaration under #ifdef
_KERNEL and so this header fails when included from userland. Add a
forward declaration here.

Fixes:       99eefc727eba
Sponsored by: Netflix

2 years agoRevert "bootstrap: No need to disable shared libraries for bootstrap tools"
Warner Losh [Mon, 11 Oct 2021 17:49:48 +0000 (11:49 -0600)]
Revert "bootstrap: No need to disable shared libraries for bootstrap tools"

This reverts commit e8f26e5dc859a8fbc663e108421f657325ca3054.

Although the change worked locally, it's breaking something in the CI
build for the riscv64 build (which makes no sense it would only break
that since we're building host tools to bootstrap at that point).

Sponsored by: Netflix

2 years agosysctl.h: Less namespace pollution
Warner Losh [Mon, 11 Oct 2021 17:15:08 +0000 (11:15 -0600)]
sysctl.h: Less namespace pollution

Remove unused struct ctlname. It is unused. Move struct thread to
inside #if _KERNEL.

Sponsored by: Netflix
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D32457

2 years agosysctl: make sys/sysctl.h self contained
Warner Losh [Mon, 11 Oct 2021 17:14:51 +0000 (11:14 -0600)]
sysctl: make sys/sysctl.h self contained

sys/sysctl.h only needs u_int and size_t from sys/types.h. When the
sysctl interface was designed, having one more more prerequisites
(especially sys/types.h) was the norm. Times have changed, and to make
things more portable, make sys/types.h optional. We do this by including
sys/_types.h, defining size_t if needed, and changing u_int to 'unsigned
int' in a prototype for userland builds. For kernel builds, sys/types.h
is still required.

Sponsored by: Netflix
Reviewed by: kib, jhb
Differential Revision: https://reviews.freebsd.org/D31827

2 years agobootstrap: No need to disable shared libraries for bootstrap tools
Warner Losh [Mon, 11 Oct 2021 17:13:39 +0000 (11:13 -0600)]
bootstrap: No need to disable shared libraries for bootstrap tools

There's no need to disable shared libraries when building the bootstrap
tools. This was added on 2000 (commit ad879ce9552c) when the perl
bootstrap was added (libperl and miniperl) and saved a fair amount of
time (perl took a long time to build on 2000-era hardware).

For many years now, however, we rarely build any libraries when
bootstrapping. Even when we do, the optimization saves at most a few
seconds when upgrading since the libraries built have been small. Shared
libraries are more robust accross versions that static libraries due to
creaping dependencies (we aren't crossing versions of share libraries,
though, just using what's on the host). In addition, linux and macos
have been building like this for some time because static binaries on
those systems are difficult to impossible.

Sponsored by: Netflix
Reviewed by: arichardson, bapt
Differential Revision: https://reviews.freebsd.org/D32443

2 years agoO_PATH: allow vfs_extattr syscalls
Greg V [Sun, 10 Oct 2021 12:45:31 +0000 (15:45 +0300)]
O_PATH: allow vfs_extattr syscalls

These calls do operate on vnodes only, not file contents.
This is useful for e.g. the xdg-document-portal fuse filesystem.

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

2 years agolast: improve non-UTF8 locale output after libxo support was added
Piotr Pawel Stefaniak [Sun, 10 Oct 2021 07:16:59 +0000 (09:16 +0200)]
last: improve non-UTF8 locale output after libxo support was added

Some strftime(3) conversion specifications will generate strings encoded
with the current locale, not necessarily UTF8. As per xo_format.5, use
the h string modifier so that libxo interprets it appropriately.

Reviewed by: eugen, philip
Differential Revision: https://reviews.freebsd.org/D32437

2 years agoRevert "last(1): unbreak for 8-bit locales"
Piotr Pawel Stefaniak [Sun, 10 Oct 2021 06:37:36 +0000 (08:37 +0200)]
Revert "last(1): unbreak for 8-bit locales"

This reverts commits 8e67c427b5 (unbreak for 8-bit locales), 0ca58ca151
(correction after r351413), and f424ec1b80 (fix style after r351459).

A simpler fix can be done by using the h modifier for strings that are
encoded with the current locale.

Reviewed by: eugen, philip
Differential Revision: https://reviews.freebsd.org/D32437

2 years agonanosleep.2: use appropriate macros
Piotr Pawel Stefaniak [Sat, 9 Oct 2021 16:00:01 +0000 (18:00 +0200)]
nanosleep.2: use appropriate macros

Reported by: kib
Fixes: bf8f6ffcb66a

2 years agovfs: remove thread argument from VOP_STAT
Mateusz Guzik [Fri, 1 Oct 2021 22:25:39 +0000 (00:25 +0200)]
vfs: remove thread argument from VOP_STAT

and fo_stat.

2 years agovfs: remove cn_thread
Mateusz Guzik [Fri, 1 Oct 2021 21:16:54 +0000 (23:16 +0200)]
vfs: remove cn_thread

It is always curthread.

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

2 years agoAdd missing const after 6c4f95161d6e
Alex Richardson [Mon, 11 Oct 2021 12:20:36 +0000 (13:20 +0100)]
Add missing const after 6c4f95161d6e

I accidentally didn't include hunk in the committed patch.

Fixes: 6c4f95161d6e ("virtio: make the write_config buffer argument const")

2 years agocross-build: fix some redeclaration warnings during bootstrap
Alex Richardson [Mon, 13 Sep 2021 09:11:47 +0000 (10:11 +0100)]
cross-build: fix some redeclaration warnings during bootstrap

MFC after: 3 days

2 years agovirtio: make the write_config buffer argument const
Alex Richardson [Mon, 11 Oct 2021 10:52:17 +0000 (11:52 +0100)]
virtio: make the write_config buffer argument const

No functional change intended, but noticed that we could add const here
while adding linuxkpi support for virtio.

Reviewed By: bryanv, imp
Differential Revision: https://reviews.freebsd.org/D32370

2 years agolinuxkpi: implement ida_alloc()
Alex Richardson [Fri, 8 Oct 2021 08:36:30 +0000 (09:36 +0100)]
linuxkpi: implement ida_alloc()

Needed for the virtio-gpu driver.

Reviewed By: #linuxkpi, manu, bz, hselasky
Differential Revision: https://reviews.freebsd.org/D32366

2 years agolinuxkpi: Allow BUILD_BUG_ON in if statements without braces
Alex Richardson [Fri, 8 Oct 2021 08:35:31 +0000 (09:35 +0100)]
linuxkpi: Allow BUILD_BUG_ON in if statements without braces

I got a compilation failure in virtio-gpu without this change.

Reviewed By: #linuxkpi, manu, bz, hselasky
Differential Revision: https://reviews.freebsd.org/D32366

2 years agolinuxkpi: add PAGE_ALIGNED macro
Alex Richardson [Fri, 8 Oct 2021 08:33:21 +0000 (09:33 +0100)]
linuxkpi: add PAGE_ALIGNED macro

Needed for the virtio-gpu driver.

Reviewed By: #linuxkpi, manu, bz, hselasky
Differential Revision: https://reviews.freebsd.org/D32366

2 years agolinuxkpi: Add sg_init_one
Alex Richardson [Fri, 8 Oct 2021 08:32:46 +0000 (09:32 +0100)]
linuxkpi: Add sg_init_one

Needed for the virtio-gpu driver.

Reviewed By: #linuxkpi, manu, bz, hselasky
Differential Revision: https://reviews.freebsd.org/D32366

2 years agoUpdate OptionalObsoleteFiles.inc after 021385aba562
Alex Richardson [Mon, 11 Oct 2021 10:46:30 +0000 (11:46 +0100)]
Update OptionalObsoleteFiles.inc after 021385aba562

I forgot to update this file so make delete-old would incorrectly remove
the newly-installed LLVM binutils. While touching the file also update
for 8e1c989abbd1 since ObsoleteFiles.inc now inludes the tablegen binaries.

Reported by: Herbert J. Skuhra <herbert@gojira.at>
Reviewed By: emaste, imp

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

2 years agoTeach the readelf about arm64 gnu properties
Andrew Turner [Fri, 17 Sep 2021 15:54:31 +0000 (15:54 +0000)]
Teach the readelf about arm64 gnu properties

On arm64 binaries can be tagged as using BTI or PAC. Add support to
decode these to the elftoolchain readelf.

To simplify the code use a table based method to find the flag
description table.

Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32315

2 years agoAllocate arm64 per-CPU data in the correct domain
Andrew Turner [Wed, 6 Oct 2021 15:08:04 +0000 (15:08 +0000)]
Allocate arm64 per-CPU data in the correct domain

To minimise NUMA traffic allocate the pcpu, dpcpu, and boot stacks in
the correct domain when possible.

Submitted by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32338

2 years agoOnly demote when needed in the arm64 pmap_change_props_locked
Andrew Turner [Wed, 6 Oct 2021 16:38:22 +0000 (17:38 +0100)]
Only demote when needed in the arm64 pmap_change_props_locked

When changing page table properties there is no need to demote a
level 1 or level 2 block if we are changing the entire memory range the
block is mapping. In this case just change the block directly.

Reported by: alc, kib, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32339

2 years agoAdd pmap_change_prot on arm64
Andrew Turner [Mon, 20 Sep 2021 16:49:18 +0000 (16:49 +0000)]
Add pmap_change_prot on arm64

Support changing the protection of preloaded kernel modules by
implementing pmap_change_prot on arm64 and calling it from
preload_protect.

Reviewed by: alc (previous version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32026

2 years agonfsd: Disable the NFSv4.2 Allocate operation by default
Rick Macklem [Mon, 11 Oct 2021 01:46:02 +0000 (18:46 -0700)]
nfsd: Disable the NFSv4.2 Allocate operation by default

Some exported file systems, such as ZFS ones, cannot do VOP_ALLOCATE().
Since an NFSv4.2 server must either support the Allocate operation for
all file systems or not support it at all, define a sysctl called
vfs.nfsd.enable_v42allocate to enable the Allocate operation.
This sysctl is false by default and can only be set true if all
exported file systems (or all DSs for a pNFS server) can perform
VOP_ALLOCATE().

Unfortunately, there is no way to know if a ZFS file system will
be exported once the nfsd is operational, even if there are none
exported when the nfsd is started up, so enabling Allocate must
be done manually for a server configuration.

This problem was detected during a recent NFSv4 interoperability
testing event held by the IETF working group.

MFC after: 2 weeks

2 years agonfscl: Fix NFS VOP_ALLOCATE for mounts without Allocate support
Rick Macklem [Sun, 10 Oct 2021 21:27:52 +0000 (14:27 -0700)]
nfscl: Fix NFS VOP_ALLOCATE for mounts without Allocate support

Without this patch, nfs_allocate() fell back on using vop_stdallocate()
for NFS mounts without Allocate operation support.  This was incorrect,
since some file systems, such as ZFS, cannot do allocate via
vop_stdallocate(), which uses writes to try and allocate blocks.

Also, fix nfs_allocate() to return EINVAL when mounts cannot do Allocate,
since that is the correct error for posix_fallocate(2).
Note that Allocate is only supported by some NFSv4.2 servers.

MFC after: 2 weeks

2 years agoEnable PPS_SYNC on amd64, arm64 and armv7
Konstantin Belousov [Sun, 10 Oct 2021 12:20:45 +0000 (15:20 +0300)]
Enable PPS_SYNC on amd64, arm64 and armv7

Remove the option from NOTES/LINT, and add to NOTES for powerpc and
riscv.

PR: 259036
Requested by: John Hay <john@sanren.ac.za>
Discussed with: ian, imp
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

2 years agovfs: add predicts to getvnode and getvnode_path
Mateusz Guzik [Sun, 10 Oct 2021 18:17:50 +0000 (18:17 +0000)]
vfs: add predicts to getvnode and getvnode_path

2 years agoRetire code added to support CloudABI
Mateusz Guzik [Wed, 28 Apr 2021 20:55:03 +0000 (22:55 +0200)]
Retire code added to support CloudABI

CloudABI was removed in cf0ee8738e31aa9e6fbf4dca4dac56d89226a71a

2 years agocross-build: Remove redundant lines.
Warner Losh [Sun, 10 Oct 2021 16:21:49 +0000 (10:21 -0600)]
cross-build: Remove redundant lines.

There's two identical gid_from_group lines in a row. We only need one.
Ditto for uid_from_user().

Sponsored by: Netflix
Reviewed by: bapt, jrtc27
Differential Revision: https://reviews.freebsd.org/D32442

2 years agoncurses: fix typo in makefile
Baptiste Daroussin [Sun, 10 Oct 2021 16:52:21 +0000 (18:52 +0200)]
ncurses: fix typo in makefile

2 years agoObsoleteFiles.inc: stop removing pthread_mutexattr_get/setpshared.3
Konstantin Belousov [Sun, 10 Oct 2021 14:38:20 +0000 (17:38 +0300)]
ObsoleteFiles.inc: stop removing pthread_mutexattr_get/setpshared.3

The man pages were added by 6bda192013fc8e (as symlinks).

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agounzip: Fix segmentation fault if a zip file contains buggy filename.
Yoshihiro Takahashi [Sun, 10 Oct 2021 11:49:19 +0000 (20:49 +0900)]
unzip: Fix segmentation fault if a zip file contains buggy filename.

PR:             259011
Reported by:    Robert Morris
Submitted by:   ak
MFC after::     1 week

2 years agorescue: fix after with to a ldscript of libncursesw.a
Baptiste Daroussin [Sun, 10 Oct 2021 06:53:41 +0000 (08:53 +0200)]
rescue: fix after with to a ldscript of libncursesw.a

2 years agoncurses: convert libncursesw.a into a static ldscript
Baptiste Daroussin [Sun, 10 Oct 2021 05:37:26 +0000 (07:37 +0200)]
ncurses: convert libncursesw.a into a static ldscript

Introduce the notion of static linker scripts to allow libncursesw.a to
track its dependency on libtinfow.a

this allows the build of older freebsd source tree to happen and make
static linking in part with dynamic linking which already provides a
ldscript

This fixes a bootstrapping FreeBSD 12 or 13 on recent FreeBSD 14

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

2 years agovmci: fix panic due to freeing unallocated resources
Mark Peek [Sat, 9 Oct 2021 21:21:16 +0000 (14:21 -0700)]
vmci: fix panic due to freeing unallocated resources

Summary:
An error mapping PCI resources results in a panic due to unallocated
resources being freed up. This change puts the appropriate checks in
place to prevent the panic.

PR: 252445
Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
Tested by: marcus
MFC after: 1 week
Sponsored by: VMware

Test Plan:
Along with user testing, also simulated error by inserting a ENXIO
return in vmci_map_bars().

Reviewed by: marcus
Subscribers: imp
Differential Revision: https://reviews.freebsd.org/D32016

2 years agoreadlinkat(2): allow O_PATH fd
Konstantin Belousov [Sat, 9 Oct 2021 05:12:05 +0000 (08:12 +0300)]
readlinkat(2): allow O_PATH fd

PR: 258856
Reported by: ashish
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32390

2 years agotimecounter: Let kern.timecounter.stepwarnings be set as a tunable
Mark Johnston [Sat, 9 Oct 2021 16:34:06 +0000 (12:34 -0400)]
timecounter: Let kern.timecounter.stepwarnings be set as a tunable

MFC after: 1 week

2 years agobhyve: Map the MSI-X table unconditionally for passthrough
Mark Johnston [Sat, 9 Oct 2021 15:36:19 +0000 (11:36 -0400)]
bhyve: Map the MSI-X table unconditionally for passthrough

It is possible for the PBA to reside in the same page as the MSI-X
table.  And, while devices are not supposed to do this, at least some
Intel wifi devices place registers in a page shared with the MSI-X
table.  To handle the first case we currently map the PBA page using
/dev/mem, and the second case is not handled.

Kill two birds with one stone: map the MSI-X table BAR using the
PCIOCBARMMAP ioctl instead of /dev/mem, and map the entire table so that
accesses beyond the bounds of the table can be emulated.  Regions of the
BAR not containing the table are left unmapped.

Reviewed by: bz, grehan, jhb
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32359

2 years agosbin/mount_fusefs/mount_fusefs.8: Fix typos
Elyes HAOUAS [Fri, 8 Oct 2021 16:44:48 +0000 (18:44 +0200)]
sbin/mount_fusefs/mount_fusefs.8: Fix typos

"expicitly" --> "explicitly"
"uknown" --> "unknown"

Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
MFC after: 3 days
Pull Request: https://github.com/freebsd/freebsd-src/pull/552

2 years ago[fib_algo][dxr] Retire counters which are no longer used
Marko Zec [Sat, 9 Oct 2021 11:47:10 +0000 (13:47 +0200)]
[fib_algo][dxr] Retire counters which are no longer used

The number of chunks can still be tracked via vmstat -z|fgrep dxr.

MFC after: 3 days

2 years ago[fib_algo][dxr] Improve incremental updating strategy
Marko Zec [Sat, 9 Oct 2021 11:22:27 +0000 (13:22 +0200)]
[fib_algo][dxr] Improve incremental updating strategy

Tracking the number of unused holes in the trie and the range table
was a bad metric based on which full trie and / or range rebuilds
were triggered, which would happen in vain by far too frequently,
particularly with live BGP feeds.

Instead, track the total unused space inside the trie and range table
structures, and trigger rebuilds if the percentage of unused space
exceeds a sysctl-tunable threshold.

MFC after: 3 days
PR: 257965

2 years agoBelatedly track private lib renaming for OptionalObsoleteFiles.inc
Ed Maste [Sat, 9 Oct 2021 00:15:43 +0000 (20:15 -0400)]
Belatedly track private lib renaming for OptionalObsoleteFiles.inc

Reviewed by: kevans
Fixes: 5551c573554e ("Rework PRIVATELIB")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32384

2 years agoOpenSSH: cherry-pick "need initgroups() before setresgid()"
Ed Maste [Sat, 9 Oct 2021 01:28:53 +0000 (21:28 -0400)]
OpenSSH: cherry-pick "need initgroups() before setresgid()"

From openssh-portable commits f3cbe43e28fe and bf944e3794ef.

2 years agobsdconfig: Comments
Devin Teske [Fri, 8 Oct 2021 23:26:21 +0000 (16:26 -0700)]
bsdconfig: Comments

My current style is to copy C for "/* NOTREACHED */" instead of spelling
out "Not reached". Make this one nominal change in this one file and the
others later.

While here, word-smith "Preload" into "Pre-load" as I believe that to
be more grammatically correct in this instance.

Also while here, fix a comment capitalization error.

Lastly, bump copyright for above changes.

2 years agobsd.cpu.mk: Minor formatting for armv6 vs armv7
Warner Losh [Mon, 27 Sep 2021 17:33:05 +0000 (11:33 -0600)]
bsd.cpu.mk: Minor formatting for armv6 vs armv7

Separate out the arch/cpu options for armv6 from the armv7 ones. This is
less confusing.

Sponsored by: Netflix

2 years agoarm, arm64, riscv: adjust top-level nexus comment
Mitchell Horne [Thu, 7 Oct 2021 18:02:02 +0000 (15:02 -0300)]
arm, arm64, riscv: adjust top-level nexus comment

These platforms don't manage resources for DMA request lines or I/O
ports, this is specific to x86. Remove the references from the comments.

Reviewed by: imp, jhb
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32358

2 years agoMention kern.timecounter.alloweddeviation in nanosleep.1
Piotr Pawel Stefaniak [Thu, 7 Oct 2021 19:14:27 +0000 (21:14 +0200)]
Mention kern.timecounter.alloweddeviation in nanosleep.1

PR: 224837
Reported by: Aleksander Derevianko

2 years agopf: do not copy anchor_wildcard / anchor_relative from userspace
Kristof Provost [Fri, 8 Oct 2021 13:13:21 +0000 (15:13 +0200)]
pf: do not copy anchor_wildcard / anchor_relative from userspace

We overwrite these fields again in pf_kanchor_setup() anyway.

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agonet80211: fix build for 526370fb85db4b659cff4625eb2f379acaa4a1a8
Bjoern A. Zeeb [Fri, 8 Oct 2021 11:21:44 +0000 (11:21 +0000)]
net80211: fix build for 526370fb85db4b659cff4625eb2f379acaa4a1a8

In 526370fb85db4b659cff4625eb2f379acaa4a1a8 "net80211: proper ssid
length check in setmlme_assoc_adhoc()" we are checking the
sizeof on an array function parameter which leads to a warning that
it will resturn the size of the type of the array rather than the
array size itself.  Use the defined length used both in the ioctl
and the sizing of the array function parameter instead.

Reported by: CI
MFC after: 3 days
X-MFC with: 526370fb85db4b659cff4625eb2f379acaa4a1a8

2 years agoUSB: adjust the Generic XHCI ACPI probe return value
Bjoern A. Zeeb [Fri, 1 Oct 2021 13:37:01 +0000 (13:37 +0000)]
USB: adjust the Generic XHCI ACPI probe return value

Change the probe return value from BUS_PROBE_DEFAULT to BUS_PROBE_GENERIC
given this is the "generic" attach method.  This allows individual
drivers using XHCI generic but needing their own intialisation to
gain priority for attaching over the generic implementation.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D32257

2 years agonet80211: correct length check in ieee80211_ies_expand()
Bjoern A. Zeeb [Wed, 6 Oct 2021 18:09:39 +0000 (18:09 +0000)]
net80211: correct length check in ieee80211_ies_expand()

In ieee80211_ies_expand() we are looping over Elements
(also known as Information Elements or IEs).
The comment suggests that we assume well-formedness of
the IEs themselves.
Checking the buffer length being least 2 (1 byte Element ID and
1 byte Length fields) rather than just 1 before accessing ie[1]
is still good practise and can prevent and out-of-bounds read in
case the input is not behaving according to the comment.

Reported by: (coypu sdf.org)
admbugs: 857
MFC after: 3 days
Reviewed by: adrian, markj
Differential Revision: https://reviews.freebsd.org/D32340

2 years agonet80211: proper ssid length check in setmlme_assoc_adhoc()
Bjoern A. Zeeb [Wed, 6 Oct 2021 18:41:37 +0000 (18:41 +0000)]
net80211: proper ssid length check in setmlme_assoc_adhoc()

A user supplied SSID length is used without proper checks in
setmlme_assoc_adhoc() which can lead to copies beyond the end
of the user supplied buffer.
The ssid is a fixed size array for the ioctl and the argument
to setmlme_assoc_adhoc().
In addition to an ssid_len check of 0 also error in case the
ssid_len is larger than the size of the ssid array to prevent
problems.

PR: 254737
Reported by: Tommaso (cutesmilee.research protonmail.com)
MFC after: 3 days
Reviewed by: emaste, adrian
Differential Revision: https://reviews.freebsd.org/D32341

2 years agosctp: improve KASSERT messages
Michael Tuexen [Fri, 8 Oct 2021 09:32:55 +0000 (11:32 +0200)]
sctp: improve KASSERT messages

MFC after: 1 week

2 years agovm_fault: do not trigger OOM too early
Konstantin Belousov [Mon, 4 Oct 2021 06:36:02 +0000 (09:36 +0300)]
vm_fault: do not trigger OOM too early

Wakeup in vm_waitpfault() does not mean that the thread would get the
page on the next vm_page_alloc() call, other thread might steal the free
page we were waiting for. On the other hand, this wakeup might come much
earlier than just vm_pfault_oom_wait seconds, if the rate of the page
reclamation is high enough.

If wakeups come fast and we loose the allocation race enough times, OOM
could be undeservably triggered much earlier than vm_pfault_oom_attempts
x vm_pfault_oom_wait seconds.  Fix it by not counting the number of sleeps,
but measuring the time to th first allocation failure, and triggering OOM
when it was older than oom_attempts x oom_wait seconds.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D32287

2 years agorouting: Use the same index space for both nexthop and nexthop groups.
Alexander V. Chernikov [Wed, 6 Oct 2021 19:07:54 +0000 (19:07 +0000)]
routing: Use the same index space for both nexthop and nexthop groups.

This simplifies userland object handling along with kernel-level
 nexthop handling in fib algo framework.

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D32342

2 years agodwmmc: Calculate the maximum transaction length correctly.
Michal Meloun [Thu, 7 Oct 2021 18:42:56 +0000 (20:42 +0200)]
dwmmc: Calculate the maximum transaction length correctly.

We should reserve two descriptors (not MMC_SECTORS) for potentially
unaligned (so bounced) buffer fragments, one for the starting fragment
and one for the ending fragment.

Submitted by: kjopek@gmail.com
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30387

2 years agostress2: Added a regression test
Peter Holm [Fri, 8 Oct 2021 06:38:17 +0000 (06:38 +0000)]
stress2: Added a regression test

2 years agostress2: exclude known problem test
Peter Holm [Fri, 8 Oct 2021 06:35:17 +0000 (06:35 +0000)]
stress2: exclude known problem test

2 years agoprometheus_sysctl_exporter(8): filter output using a regex
Robert Wing [Fri, 8 Oct 2021 01:00:27 +0000 (17:00 -0800)]
prometheus_sysctl_exporter(8): filter output using a regex

Add two options, -i and -e, for filtering prometheus metrics.

Each option takes a regular expression as an argument. The provided
regex will be tested against the prometheus metric name.

The -i option includes metrics matching the given regex.
The -e option excludes metrics matching the given regex.

Sponsored by:   Modirum MDPay
Sponsored by:   Klara Inc.
Reviewed by: 0mp, debdrup
Differential Revision: https://reviews.freebsd.org/D32269

2 years agoMake core dump writes interruptible with SIGKILL
Konstantin Belousov [Tue, 5 Oct 2021 05:11:32 +0000 (08:11 +0300)]
Make core dump writes interruptible with SIGKILL

This can be disabled by sysctl kern.core_dump_can_intr

Reported and tested by: pho
Reviewed by: imp, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32313

2 years agocore(5): explicitly mention the core file size limit name
Konstantin Belousov [Tue, 5 Oct 2021 14:52:44 +0000 (17:52 +0300)]
core(5): explicitly mention the core file size limit name

Reviewed by: imp, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32313

2 years agoAdd curproc_sigkilled()
Konstantin Belousov [Tue, 5 Oct 2021 05:08:51 +0000 (08:08 +0300)]
Add curproc_sigkilled()

Function returns an indicator that the process was killed with SIGKILL

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

2 years agosys/proc.h: remove dead prototype
Konstantin Belousov [Tue, 5 Oct 2021 05:07:27 +0000 (08:07 +0300)]
sys/proc.h: remove dead prototype

Reviewed by: imp, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32313

2 years agokern_sig.c: Remove unused SIGPROP_CANTMASK
Konstantin Belousov [Tue, 5 Oct 2021 04:55:54 +0000 (07:55 +0300)]
kern_sig.c: Remove unused SIGPROP_CANTMASK

Reviewed by: imp, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32313

2 years agoriscv: move signal delivery code to exec_machdep.c
Konstantin Belousov [Mon, 4 Oct 2021 15:15:17 +0000 (18:15 +0300)]
riscv: move signal delivery code to exec_machdep.c

Reviewed by: emaste, imp
Discussed with: jrtc27
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32310

2 years agoarm: move signal delivery code to exec_machdep.c
Konstantin Belousov [Mon, 4 Oct 2021 11:39:11 +0000 (14:39 +0300)]
arm: move signal delivery code to exec_machdep.c

Reviewed by: emaste, imp
Discussed with: jrtc27
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32310

2 years agoarm64: move signal delivery code to exec_machdep.c
Konstantin Belousov [Mon, 4 Oct 2021 06:55:51 +0000 (09:55 +0300)]
arm64: move signal delivery code to exec_machdep.c

also move ptrace-related helpers to ptrace_machdep.c.

Reviewed by: emaste, imp
Discussed with: jrtc27
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32310

2 years agoi386: move signal delivery code to exec_machdep.c
Konstantin Belousov [Mon, 4 Oct 2021 01:29:26 +0000 (04:29 +0300)]
i386: move signal delivery code to exec_machdep.c

also move ptrace-related helpers to ptrace_machdep.c
Apply some style. Use ANSI C function definitions.
Remove MPSAFE annotations.

Reviewed by: emaste, imp
Discussed with: jrtc27
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32310

2 years agoAvoid lost buffers in fsck_ffs.
Kirk McKusick [Thu, 7 Oct 2021 22:51:56 +0000 (15:51 -0700)]
Avoid lost buffers in fsck_ffs.

The ino_blkatoff() and indir_blkatoff() functions failed to release
the buffers holding second and third level indirect blocks. This
commit ensures that these buffers are now properly released.

MFC after:    1 week
Sponsored by: Netflix

2 years agoriscv: fix VM_MAXUSER_ADDRESS checks in asm routines
Mitchell Horne [Thu, 7 Oct 2021 21:12:30 +0000 (18:12 -0300)]
riscv: fix VM_MAXUSER_ADDRESS checks in asm routines

There are two issues with the checks against VM_MAXUSER_ADDRESS. First,
the comparison should consider the values as unsigned, otherwise
addresses with the high bit set will fail to branch. Second, the value
of VM_MAXUSER_ADDRESS is, by convention, one larger than the maximum
mappable user address and invalid itself. Thus, use the bgeu instruction
for these comparisons.

Add a regression test case for copyin(9).

PR: 257193
Reported by: Robert Morris <rtm@lcs.mit.edu>
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D31209

2 years agoriscv: handle page faults in the unmappable region
Mitchell Horne [Thu, 7 Oct 2021 21:05:38 +0000 (18:05 -0300)]
riscv: handle page faults in the unmappable region

When handling a kernel page fault, check explicitly that stval resides
in either the user or kernel address spaces, and make the page fault
fatal if not. Otherwise, a properly crafted address may appear to
pmap_fault() as a valid and present page in the kernel map, causing the
page fault to be retried continuously. This is mainly due to the fact
that the upper bits of virtual addresses are not validated by most of
the pmap code.

Faults of this nature should only occur due to some kind of bug in the
kernel, but it is best to handle them gracefully when they do.

Handle user page faults in the same way, sending a SIGSEGV immediately
when a malformed address is encountered.

Add an assertion to pmap_l1(), which should help catch other bugs of
this kind that make it this far.

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

2 years agopf: remove unused field from pf_kanchor
Kristof Provost [Mon, 4 Oct 2021 08:58:27 +0000 (10:58 +0200)]
pf: remove unused field from pf_kanchor

The 'match' field is only used in the userspace version of the struct
(pf_anchor).

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agopfctl: Remove unused variable
Kristof Provost [Thu, 30 Sep 2021 15:25:45 +0000 (17:25 +0200)]
pfctl: Remove unused variable

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agodiff: consider two files with same inodes as identical
Mariusz Zaborski [Thu, 7 Oct 2021 15:07:00 +0000 (17:07 +0200)]
diff: consider two files with same inodes as identical

Obtained from: OpenBSD
MFC after: 1 week

2 years agoi2c(8): fix option handling
Martin Birgmeier [Thu, 7 Oct 2021 05:20:56 +0000 (21:20 -0800)]
i2c(8): fix option handling

Recognize the '-o' option when processing command line arguments.

Fixes: 9c10d00bf8cd ("i2c(8): Add interpreted mode for batch/scripted...")
PR:     258572

2 years agobuild: slap a libtinfo dependency on libncurses
Kyle Evans [Thu, 7 Oct 2021 03:01:05 +0000 (22:01 -0500)]
build: slap a libtinfo dependency on libncurses

This mirrors the SUBDIR_DEPEND in lib/ncurses/Makefile.

Reported by: jenkins (e.g., riscv64 build #23984)
Fixes: 396851c20aeb ("ncurses: split libtinfo from libncurses")

2 years agoixgbe: Update shared code catchup
Kevin Bowling [Thu, 7 Oct 2021 01:43:27 +0000 (18:43 -0700)]
ixgbe: Update shared code catchup

Leftovers from DPDK sync

Reviewed by: grehan
Obtained from: DPDK
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D31621

2 years agolibfido2: Address CHERI compatibility
Jessica Clarke [Sat, 2 Oct 2021 15:51:38 +0000 (16:51 +0100)]
libfido2: Address CHERI compatibility

Cherry-picked from libfido2 upstream f20a735c0a6f:

iso7816: Avoid storing pointers in a packed structure

On CHERI, and thus Arm's experimental Morello prototype architecture,
pointers are represented as capabilities, which are unforgeable bounded
pointers, providing always-on fine-grained spatial memory safety. The
unforgeability is enforced through the use of tagged memory, with one
validity tag bit per capability-sized-and-aligned word in memory. This
means that storing a pointer to an unaligned location, which is not
guaranteed to work per the C standard, either traps or results in the
capability losing its tag (and thus never being dereferenceable again),
depending on how exactly the store is done (specifically, whether a
capability store or memcpy is used).

However, iso7816 itself does not need to be packed, and doing so likely
causes inefficiencies on existing architectures. The iso7816_header_t
member is packed, and the flexible payload array is a uint8_t (which by
definition has no padding bits and is exactly 8 bits in size and, since
CHAR_BITS must be at least 8, its existence implies that it has the same
representation as unsigned char, and that it has size and alignment 1)
so there will never be any padding inserted between header and payload
(but payload may overlap with padding at the end of the struct due to
how flexible arrays work, which means we need to be careful about our
calculations).

Co-authored-by: pedro martelletto <pedro@yubico.com>
2 years agoImport libfido2 at 'contrib/libfido2/'
Ed Maste [Thu, 7 Oct 2021 01:27:02 +0000 (21:27 -0400)]
Import libfido2 at 'contrib/libfido2/'

git-subtree-dir: contrib/libfido2
git-subtree-mainline: d586c978b9b4216869e589daa5bbcc33225a0e35
git-subtree-split: a58dee945a5da64d0e97f35a508928e0d17c9cc7

2 years agostand: fix build after recent opencrypto changes
Kyle Evans [Thu, 7 Oct 2021 01:19:47 +0000 (20:19 -0500)]
stand: fix build after recent opencrypto changes

Pass the ivlen along through, and just drop this KASSERT() if we're
building _STANDALONE for the time being.

Fixes: 1833d6042c9a ("crypto: Permit variable-sized IVs ...")

2 years agoImport libcbor at 'contrib/libcbor/'
Ed Maste [Thu, 7 Oct 2021 00:26:10 +0000 (20:26 -0400)]
Import libcbor at 'contrib/libcbor/'

git-subtree-dir: contrib/libcbor
git-subtree-mainline: 293663f4da9e8b8aeb106ce3b73a8ed2aa2a8a90
git-subtree-split: 5b2defbd2a1aa991bd0a2855eef8e15107572747

2 years agoe1000: print EEPROM/NVM/OROM versions
Kevin Bowling [Wed, 6 Oct 2021 23:25:03 +0000 (16:25 -0700)]
e1000: print EEPROM/NVM/OROM versions

This is useful for diagnosing problems. In particular, the errata
sheets identify the EEPROM version for many fixes.

Reviewed by: gallatin
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D32333

2 years agoe1000: Lock nvm print sysctl
Kevin Bowling [Wed, 6 Oct 2021 23:20:26 +0000 (16:20 -0700)]
e1000: Lock nvm print sysctl

Otherwise results in KASSERT with debug kernels because we rely on the
iflib CTX lock to implement the software serialization to the NVM model

Reviewed by: gallatin
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D32333

2 years agocontrib/bc: update to version 5.1.1
Stefan Eßer [Wed, 6 Oct 2021 21:30:59 +0000 (23:30 +0200)]
contrib/bc: update to version 5.1.1

Merge commit '6f49f5cdde1c62c4e5a743e895f3afe592b5c0e5'

2 years agovendor/bc: update to version 5.1.1
Stefan Eßer [Wed, 6 Oct 2021 21:27:16 +0000 (23:27 +0200)]
vendor/bc: update to version 5.1.1

This update fixes a parser issue, which in special situations could
reject syntactically correct if statements.

2 years agoBump __FreeBSD_version for OCF changes to support variable nonce lengths.
John Baldwin [Wed, 6 Oct 2021 21:09:18 +0000 (14:09 -0700)]
Bump __FreeBSD_version for OCF changes to support variable nonce lengths.

Sponsored by: The FreeBSD Foundation

2 years agocrypto: Support Chacha20-Poly1305 with a nonce size of 8 bytes.
John Baldwin [Wed, 6 Oct 2021 21:08:49 +0000 (14:08 -0700)]
crypto: Support Chacha20-Poly1305 with a nonce size of 8 bytes.

This is useful for WireGuard which uses a nonce of 8 bytes rather
than the 12 bytes used for IPsec and TLS.

Note that this also fixes a (should be) harmless bug in ossl(4) where
the counter was incorrectly treated as a 64-bit counter instead of a
32-bit counter in terms of wrapping when using a 12 byte nonce.
However, this required a single message (TLS record) longer than 64 *
(2^32 - 1) bytes (about 256 GB) to trigger.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32122

2 years agocrypto: Test all of the AES-CCM KAT vectors.
John Baldwin [Wed, 6 Oct 2021 21:08:48 +0000 (14:08 -0700)]
crypto: Test all of the AES-CCM KAT vectors.

Previously, only test vectors which used the default nonce and tag
sizes (12 and 16, respectively) were tested.  This now tests all of
the vectors.  This exposed some additional issues around requests with
an empty payload (which wasn't supported) and an empty AAD (which
falls back to CIOCCRYPT instead of CIOCCRYPTAEAD).

- Make use of the 'ivlen' and 'maclen' fields for CIOGSESSION2 to
  test AES-CCM vectors with non-default nonce and tag lengths.

- Permit requests with an empty payload.

- Permit an input MAC for requests without AAD.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32121

2 years agocryptosoft: Fix support for variable tag lengths in AES-CCM.
John Baldwin [Wed, 6 Oct 2021 21:08:48 +0000 (14:08 -0700)]
cryptosoft: Fix support for variable tag lengths in AES-CCM.

The tag length is included as one of the values in the flags byte of
block 0 passed to CBC_MAC, so merely copying the first N bytes is
insufficient.

To avoid adding more sideband data to the CBC MAC software context,
pull the generation of block 0, the AAD length, and AAD padding out of
cbc_mac.c and into cryptosoft.c.  This matches how GCM/GMAC are
handled where the length block is constructed in cryptosoft.c and
passed as an input to the Update callback.  As a result, the CBC MAC
Update() routine is now much simpler and simply performs the
XOR-and-encrypt step on each input block.

While here, avoid a copy to the staging block in the Update routine
when one or more full blocks are passed as input to the Update
callback.

Reviewed by: sef
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32120

2 years agosafexcel: Support truncated tags for AES-CCM.
John Baldwin [Wed, 6 Oct 2021 21:08:48 +0000 (14:08 -0700)]
safexcel: Support truncated tags for AES-CCM.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32119

2 years agosafexcel: Support multiple nonce lengths for AES-CCM.
John Baldwin [Wed, 6 Oct 2021 21:08:48 +0000 (14:08 -0700)]
safexcel: Support multiple nonce lengths for AES-CCM.

Reviewed by: markj
Sponsored by: Chelsio Communications, The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32118

2 years agoccr: Support AES-CCM requests with truncated tags.
John Baldwin [Wed, 6 Oct 2021 21:08:48 +0000 (14:08 -0700)]
ccr: Support AES-CCM requests with truncated tags.

Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D32117

2 years agoccr: Support multiple nonce lengths for AES-CCM.
John Baldwin [Wed, 6 Oct 2021 21:08:48 +0000 (14:08 -0700)]
ccr: Support multiple nonce lengths for AES-CCM.

Sponsored by: Chelsio Communications, The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32116

2 years agoaesni: Support AES-CCM requests with a truncated tag.
John Baldwin [Wed, 6 Oct 2021 21:08:48 +0000 (14:08 -0700)]
aesni: Support AES-CCM requests with a truncated tag.

Reviewed by: sef
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32115

2 years agoaesni: Permit AES-CCM requests with neither payload nor AAD.
John Baldwin [Wed, 6 Oct 2021 21:08:47 +0000 (14:08 -0700)]
aesni: Permit AES-CCM requests with neither payload nor AAD.

Reviewed by: sef
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32114

2 years agoaesni: Handle requests with an empty payload.
John Baldwin [Wed, 6 Oct 2021 21:08:47 +0000 (14:08 -0700)]
aesni: Handle requests with an empty payload.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32113

2 years agoaesni: Support multiple nonce lengths for AES-CCM.
John Baldwin [Wed, 6 Oct 2021 21:08:47 +0000 (14:08 -0700)]
aesni: Support multiple nonce lengths for AES-CCM.

Reviewed by: sef
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32112

2 years agocrypto: Support multiple nonce lengths for AES-CCM.
John Baldwin [Wed, 6 Oct 2021 21:08:47 +0000 (14:08 -0700)]
crypto: Support multiple nonce lengths for AES-CCM.

Permit nonces of lengths 7 through 13 in the OCF framework and the
cryptosoft driver.  A helper function (ccm_max_payload_length) can be
used in OCF drivers to reject CCM requests which are too large for the
specified nonce length.

Reviewed by: sef
Sponsored by: Chelsio Communications, The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32111