]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agolibsa: Fix a typo in source code comments
Gordon Bergling [Sun, 29 Aug 2021 08:09:58 +0000 (10:09 +0200)]
libsa: Fix a typo in source code comments

- s/mininum/minimum/

MFC after: 3 days

2 years agoisci(4): Fix a common typo in src comments
Gordon Bergling [Sun, 29 Aug 2021 07:55:10 +0000 (09:55 +0200)]
isci(4): Fix a common typo in src comments

- s/exlusive/exclusive/

MFC after: 3 days

2 years agostress2: Added new msdosfs rename() tests
Peter Holm [Sun, 29 Aug 2021 06:37:54 +0000 (08:37 +0200)]
stress2: Added new msdosfs rename() tests

2 years agoldd: Remove non-functional -v option
Konstantin Belousov [Sat, 28 Aug 2021 17:28:54 +0000 (20:28 +0300)]
ldd: Remove non-functional -v option

It seems -v only worked for a.out.  Remove it, not even keeping the current
nop for compat.  Also remove more mentions of a.out format from the man
page.

Reviewed by: dim, emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31708

2 years agoStyle
Konstantin Belousov [Fri, 27 Aug 2021 14:28:19 +0000 (17:28 +0300)]
Style

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agofsetown: Avoid process group lock recursion
Mark Johnston [Sat, 28 Aug 2021 19:50:44 +0000 (15:50 -0400)]
fsetown: Avoid process group lock recursion

Restore the pre-1d874ba4f8ba behaviour of disassociating the current
SIGIO recipient before looking up the specified process or process
group.  This avoids a lock recursion in the scenario where a process
group is configured to receive SIGIO for an fd when it has already been
so configured.

Reported by: pho
Tested by: pho
Reviewed by: kib
MFC after: 3 days

2 years agoExplicitly link zfsd with libspl to avoid undefined references
Dimitry Andric [Sat, 28 Aug 2021 18:23:15 +0000 (20:23 +0200)]
Explicitly link zfsd with libspl to avoid undefined references

Because lld 13.0.0 is more strict about undefined references when
linking to shared libraries, it produces the following errors for zfsd:

ld: error: /home/dim/obj/home/dim/src/llvm-13-update/amd64.amd64/tmp/usr/lib/libzfs_core.so: undefined reference to libspl_assertf [--no-allow-shlib-undefined]
ld: error: /home/dim/obj/home/dim/src/llvm-13-update/amd64.amd64/tmp/usr/lib/libnvpair.so: undefined reference to libspl_assertf [--no-allow-shlib-undefined]
ld: error: /home/dim/obj/home/dim/src/llvm-13-update/amd64.amd64/tmp/usr/lib/libavl.so: undefined reference to libspl_assertf [--no-allow-shlib-undefined]
*** [zfsd.full] Error code 1

Fix this by adding libspl (where libspl_assertf lives) to zfsd's LIBADD.

MFC after: 3 days

2 years agoFix a common typo in man pages and src comments
Gordon Bergling [Sat, 28 Aug 2021 17:24:27 +0000 (19:24 +0200)]
Fix a common typo in man pages and src comments

- s/desciptor/descriptor/

MFC after: 5 days

2 years agoFix some common typos in source code comments
Gordon Bergling [Sat, 28 Aug 2021 16:57:23 +0000 (18:57 +0200)]
Fix some common typos in source code comments

- s/priviledged/privileged/
- s/funtion/function/
- s/doens't/doesn't/
- s/sychronization/synchronization/

MFC after: 3 days

2 years agoinet6(4): Fix a few common typos in source code comments
Gordon Bergling [Sat, 28 Aug 2021 16:53:59 +0000 (18:53 +0200)]
inet6(4): Fix a few common typos in source code comments

- s/reshedule/reschedule/

MFC after: 3 days

2 years agoinet(3): Fix a few common typos in source code comments
Gordon Bergling [Sat, 28 Aug 2021 16:53:02 +0000 (18:53 +0200)]
inet(3): Fix a few common typos in source code comments

- s/funtion/function/

MFC after: 3 days

2 years agoocs_fs(4): Fix some common typos in source code comments
Gordon Bergling [Sat, 28 Aug 2021 16:24:08 +0000 (18:24 +0200)]
ocs_fs(4): Fix some common typos in source code comments

- s/transfered/transferred/
- s/associted/associated/

MFC after: 3 days

2 years agosh: improve emacs mode
Baptiste Daroussin [Sat, 28 Aug 2021 12:59:53 +0000 (14:59 +0200)]
sh: improve emacs mode

in emacs mode ^W should delete the previous word by default
Note that upstreaming this change directly into libedit is in process.

Reported by: manu
Reviewed by: jills, pstef, manu
Differential Revision: https://reviews.freebsd.org/D29493

2 years agoSilence unused parameter warnings in fspacectl(2) bootstrap stub
Dimitry Andric [Sat, 28 Aug 2021 13:37:24 +0000 (15:37 +0200)]
Silence unused parameter warnings in fspacectl(2) bootstrap stub

While here, replace spaces with tabs and add a newline at EOF.

Fixes: 5425ba8332571e57f9fe623346cb9d83293264d4
MFC after: 3 days

2 years agonfscl: Add a VOP_DEALLOCATE() for the NFSv4.2 client
Rick Macklem [Sat, 28 Aug 2021 01:31:36 +0000 (18:31 -0700)]
nfscl: Add a VOP_DEALLOCATE() for the NFSv4.2 client

This patch adds a VOP_DEALLOCATE() to the NFS client.
For NFSv4.2 servers that support the Deallocate operation,
it is used. Otherwise, it falls back on calling
vop_stddeallocate().

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

2 years agovfs_default: Change vop_stddeallocate() from static to global
Rick Macklem [Sat, 28 Aug 2021 01:25:44 +0000 (18:25 -0700)]
vfs_default: Change vop_stddeallocate() from static to global

A future commit to the NFS client uses vop_stddeallocate() for
cases where the NFS server does not support a Deallocate operation.
Change vop_stddeallocate() from static to global so that it can
be called by the NFS client.

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

2 years agoSilence more gtest warnings, now in fusefs tests
Dimitry Andric [Fri, 27 Aug 2021 21:39:23 +0000 (23:39 +0200)]
Silence more gtest warnings, now in fusefs tests

Follow-up d396c67f26b0 by also silencing warnings about deprecated
implicit copy constructors in the fusefs tests, which use googletest.

Fixes: d396c67f26b0
MFC after: 3 days

2 years agoAdd a regression test for ggatec remote code execution
Alan Somers [Fri, 27 Aug 2021 20:40:05 +0000 (14:40 -0600)]
Add a regression test for ggatec remote code execution

Tests that ggatec appropriately handles unsupported BIO operations,
rather than overflowing a buffer.

Submitted by: Johannes Bruelltuete <johannes@jo-t.de>
PR: 213479
Reviewed by: asomers
Differential Revision: https://reviews.freebsd.org/D31318

2 years agoFix null pointer subtraction in mergesort()
Dimitry Andric [Fri, 27 Aug 2021 17:45:43 +0000 (19:45 +0200)]
Fix null pointer subtraction in mergesort()

Clang 13 produces the following warning for this function:

lib/libc/stdlib/merge.c:137:41: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
        if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE))
                                               ^ ~~~~~~~~~

This is meant to check whether the size and base parameters are aligned
to the size of an int, so use our __is_aligned() macro instead.

Also remove the comment that indicated this "stupid subtraction" was
done to pacify some ancient and unknown Cray compiler, and which has
been there since the BSD 4.4 Lite Lib Sources were imported.

MFC after: 3 days

2 years agoAdd SDT probes virtqueue::enqueue_segments:{entry,return}
Stephen J. Kiernan [Fri, 27 Aug 2021 17:08:59 +0000 (13:08 -0400)]
Add SDT probes virtqueue::enqueue_segments:{entry,return}

This allows one to be able to map the sglist entries passed into the
vq_ring_enqueue_segments() function to the segment indexes used in
the virtqueue.

This function normally gets inlined and may not available via FBT
probes.

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

2 years agoefi loader: disallow user to configure staging area size less than default
Konstantin Belousov [Thu, 26 Aug 2021 21:46:48 +0000 (00:46 +0300)]
efi loader: disallow user to configure staging area size less than default

We need to round it up to 2M, for instance.  Having staging area too small
might cause the first resize to use negative size for memmove()/memcpy(),
which kills loader.

Tested by: Harry Schmalzbauer <freebsd@omnilan.de>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

2 years agoRestore the definition of EFI_STAGING_SIZE
Konstantin Belousov [Thu, 26 Aug 2021 19:32:42 +0000 (22:32 +0300)]
Restore the definition of EFI_STAGING_SIZE

The definition can be overridden by users, and before f75caed644a5c it
was in MBs.  Make the symbol' unit MB, to be compatible with users
customizations.

Reported and tested by: Harry Schmalzbauer <freebsd@omnilan.de>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

2 years agovfs_hash_rehash(): require the vnode to be exclusively locked
Konstantin Belousov [Wed, 18 Aug 2021 11:14:42 +0000 (14:14 +0300)]
vfs_hash_rehash(): require the vnode to be exclusively locked

Rehash updates v_hash.  Also, rehash moves the vnode to different hash
bucket, which should be noticed in vfs_hash_get() after sleeping for
the vnode lock.

Reviewed by: mckusick, rmacklem
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31464

2 years agovfs_hash_insert: ensure that predicate is true
Konstantin Belousov [Tue, 17 Aug 2021 13:47:25 +0000 (16:47 +0300)]
vfs_hash_insert: ensure that predicate is true

After vnode lock, recheck v_hash. When vfs_hash_insert() is used with
a predicate, recheck it after the selected vnode is locked. Since
vfs_hash_lock is dropped, vnode could be rehashed during the sleep for
the vnode lock, which could go unnoticed there.

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

2 years agomsdosfs: drop now unused DE_RENAME
Konstantin Belousov [Sat, 7 Aug 2021 20:21:27 +0000 (23:21 +0300)]
msdosfs: drop now unused DE_RENAME

Submitted by: trasz
Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31464

2 years agomsdosfs: add doscheckpath lock
Konstantin Belousov [Sat, 7 Aug 2021 20:18:26 +0000 (23:18 +0300)]
msdosfs: add doscheckpath lock

Similar to the UFS revision 8df4bc48c89a130207

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31464

2 years agomsdosfs: fix rename
Konstantin Belousov [Sun, 1 Aug 2021 17:46:59 +0000 (20:46 +0300)]
msdosfs: fix rename

Use the same locking algorithm for msdosfs_rename() as used by ufs_rename().
Convert doscheckpath() to non-sleeping version.

Reported by: trasz
PR: 257522
In collaboration with: pho
Reviewed by: mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31464

2 years agomsdosfs deget(): add locking flags argument
Konstantin Belousov [Sun, 1 Aug 2021 17:53:12 +0000 (20:53 +0300)]
msdosfs deget(): add locking flags argument

LK_EXCLUSIVE must be passed always, some consumers need the ability to
specify LK_NOWAIT

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31464

2 years agomsdosfs: unstaticise msdosfs_lookup_
Konstantin Belousov [Sun, 1 Aug 2021 17:11:40 +0000 (20:11 +0300)]
msdosfs: unstaticise msdosfs_lookup_

and rename it to msdosfs_lookup_ino(), similarly to UFS

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31464

2 years agopmap_extract.9: Fix pmap_extract_and_hold()'s function type
Ka Ho Ng [Fri, 27 Aug 2021 13:42:49 +0000 (21:42 +0800)]
pmap_extract.9: Fix pmap_extract_and_hold()'s function type

pmap_extract_and_hold() returns a vm_page_t instead of a physical page
address.

Sponsored by: The FreeBSD Foundation
Reviewed by: alc
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D31691

2 years agoconnect: Use soconnectat() unconditionally in kern_connect()
Mark Johnston [Fri, 27 Aug 2021 12:32:07 +0000 (08:32 -0400)]
connect: Use soconnectat() unconditionally in kern_connect()

soconnect(...) is equivalent to soconnectat(AT_FDCWD, ...), so rely on
this to save a branch.  No functional change intended.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agotcp: Remove unused v6 state definitions
Mark Johnston [Fri, 27 Aug 2021 12:31:32 +0000 (08:31 -0400)]
tcp: Remove unused v6 state definitions

These are supposedly for compatibility with KAME, but they are
completely unused in our tree and don't exist in OpenBSD or NetBSD.

Reviewed by: kbowling, bz, gnn
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31700

2 years agollvm/powerpc64*: fix broken binaries generated by clang12
Alfredo Dal'Ava Junior [Fri, 27 Aug 2021 14:47:11 +0000 (11:47 -0300)]
llvm/powerpc64*: fix broken binaries generated by clang12

Amends LLVM commit 2518433f861fcb877d0a7bdd9aec1aec1f77505a that
was pointed as the source of regression on LLVM12.

This affects powerpc64*, making binaries crash with segmentation fault
due to bad code generation around "__stack_chk_guard"

Root cause and/or proper fix is under investigation by:
    https://bugs.llvm.org/show_bug.cgi?id=51590

Reviewed by:    dim
MFC after:      2 days
Sponsored by:   Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:  https://reviews.freebsd.org/D31698

2 years agolibarchive: import bugfix from upstream
Martin Matuska [Fri, 27 Aug 2021 10:51:01 +0000 (12:51 +0200)]
libarchive: import bugfix from upstream

Reworked bugfix for upstream issue #1566:
  Do not follow symlinks when processing the fixup list

MFC after: 2 weeks

2 years agovendor/libarchive: cherry-pick 8a1bd5c18 from upstream
Martin Matuska [Fri, 27 Aug 2021 10:36:49 +0000 (12:36 +0200)]
vendor/libarchive: cherry-pick 8a1bd5c18 from upstream

Reworked fix for upstream issue #1566:
  Processing fixup entries may follow symbolic links

Obtained from: libarchive
Libarchive commit: 8a1bd5c18e896f0411a991240ce0d772bb02c840

2 years agolibc/posix1e: Add acl_extended_file_np() function.
Gleb Popov [Fri, 12 Mar 2021 08:52:58 +0000 (11:52 +0300)]
libc/posix1e: Add acl_extended_file_np() function.

Reviewed by: kib, debdrup, gbe
Approved by: kib
Differential Revision: https://reviews.freebsd.org/D28255

2 years agotests/sys/acl: Add ATF C test for newly added acl_* functions.
Gleb Popov [Sat, 23 Jan 2021 10:00:47 +0000 (14:00 +0400)]
tests/sys/acl: Add ATF C test for newly added acl_* functions.

Reviewed by: kib, debdrup, gbe
Approved by: kib
Differential Revision: https://reviews.freebsd.org/D28255

2 years agoFix build of bin/getfacl after libc changes.
Gleb Popov [Wed, 20 Jan 2021 09:47:44 +0000 (13:47 +0400)]
Fix build of bin/getfacl after libc changes.

Reviewed by: kib, debdrup, gbe
Approved by: kib
Differential Revision: https://reviews.freebsd.org/D28255

2 years agolibc/posix1e: Add acl_equiv_mode_np() function.
Gleb Popov [Tue, 19 Jan 2021 18:05:57 +0000 (22:05 +0400)]
libc/posix1e: Add acl_equiv_mode_np() function.

Reviewed by: kib, debdrup, gbe
Approved by: kib
Differential Revision: https://reviews.freebsd.org/D28255

2 years agolibc/posix1e: Add acl_cmp_np() function.
Gleb Popov [Tue, 19 Jan 2021 15:26:19 +0000 (19:26 +0400)]
libc/posix1e: Add acl_cmp_np() function.

Reviewed by: kib, debdrup, gbe
Approved by: kib
Differential Revision: https://reviews.freebsd.org/D28255

2 years agolibc/posix1e: Add acl_from_mode_np() function.
Gleb Popov [Tue, 19 Jan 2021 15:25:07 +0000 (19:25 +0400)]
libc/posix1e: Add acl_from_mode_np() function.

Reviewed by: kib, debdrup, gbe
Approved by: kib
Differential Revision: https://reviews.freebsd.org/D28255

2 years agoinet6(4): add a missing IPPROTO_ETHERIP entry
Hiroki Sato [Fri, 27 Aug 2021 08:14:35 +0000 (17:14 +0900)]
inet6(4): add a missing IPPROTO_ETHERIP entry

bridge(4) + gif(4) did not work when the outer protocol was IPv6.

Submitted by: Masahiro Kozuka
PR: 256820
MFC after: 3 days

2 years agonfsd: Add support for the NFSv4.2 Deallocate operation
Rick Macklem [Fri, 27 Aug 2021 01:14:11 +0000 (18:14 -0700)]
nfsd: Add support for the NFSv4.2 Deallocate operation

The recently added VOP_DEALLOCATE(9) VOP call allows
implementation of the Deallocate NFSv4.2 operation.

Since the Deallocate operation is a single succeed/fail
operation, the call to VOP_DEALLOCATE(9) loops so long
as progress is being made.  It calls maybe_yield()
between loop iterations to allow other processes
to preempt it.

Where RFC 7862 underspecifies behaviour, the code
is written to be Linux NFSv4.2 server compatible.

Reviewed by: khng
Differential Revision: https://reviews.freebsd.org/D31624

2 years agoAdd support for recording EC2 AMI Ids in SSM
Colin Percival [Fri, 27 Aug 2021 00:54:53 +0000 (17:54 -0700)]
Add support for recording EC2 AMI Ids in SSM

If SSMPREFIX is specified, AMI Ids will be recorded in the SSM
Parameter Store under the name
  ${SSMPREFIX}/${ARCH}/${FLAVOUR}/${ROOTFS}/${REVISION}/${BRANCH}
where ARCH is "amd64" or "arm64", FLAVOUR is "base" (but may have
other options in the future), ROOTFS is "ufs" (but may have other
options in the future), and REVISION and BRANCH have their normal
meanings.

FreeBSD will be using the public prefix "/aws/service/freebsd",
resulting in SSM Parameter names which look like
  /aws/service/freebsd/amd64/base/ufs/14.0/CURRENT

Relnotes: yes
Sponsored by: https://patreon.com/cperciva
MFC after: 2 weeks

2 years agopcib(4): Write window registers after resource adjustment
Alexander Motin [Fri, 27 Aug 2021 00:21:56 +0000 (20:21 -0400)]
pcib(4): Write window registers after resource adjustment

When adjusting resources we should write updated window base/limit into
the registers.  Without this newly added address range won't be routed
through the bridge properly.

Use MIN()/MAX() against current window base/limit to not shrink it on
the other side if the window is shared by several resources.

Align passed resource start/end to the set window granularity to keep
it properly aligned.  Currently this is mostly called by other bridges
having the same window alignment, but it may be change one day.

Reviewed by: jrtc27, jhb
MFC after: 1 week
Sponsored by: iXsystems, Inc.
Differential Revision:  https://reviews.freebsd.org/D31693

2 years agogoogletest: Silence warnings about deprecated implicit copy constructors
Dimitry Andric [Thu, 26 Aug 2021 20:06:49 +0000 (22:06 +0200)]
googletest: Silence warnings about deprecated implicit copy constructors

Our copy of googletest is rather stale, and causes a number of -Werror
warnings about implicit copy constructor definitions being deprecated,
because several classes have user-declared copy assignment operators.
Silence the warnings until we either upgrade or remove googletest.

MFC after: 3 days

2 years agoCleanup compiler warning flags in lib/libefivar/Makefile
Dimitry Andric [Thu, 26 Aug 2021 18:53:18 +0000 (20:53 +0200)]
Cleanup compiler warning flags in lib/libefivar/Makefile

There is no need to set -Wno-unused-parameter twice, and instead of
appending to CFLAGS, append to CWARNFLAGS instead. While here, add
-Wno-unused-but-set-variable for the sake of clang 13.0.0.

MFC after: 3 days

2 years agovfs: drop dedicated sysinit for mountlist_mtx
Mateusz Guzik [Thu, 26 Aug 2021 12:53:10 +0000 (14:53 +0200)]
vfs: drop dedicated sysinit for mountlist_mtx

Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agonetinet: prevent NULL pointer dereference in in_aifaddr_ioctl()
Artem Khramov [Tue, 24 Aug 2021 14:26:35 +0000 (17:26 +0300)]
netinet: prevent NULL pointer dereference in in_aifaddr_ioctl()

It appears that maliciously crafted ifaliasreq can lead to NULL
pointer dereference in in_aifaddr_ioctl(). In order to replicate
that, one needs to

1. Ensure that carp(4) is not loaded

2. Issue SIOCAIFADDR call setting ifra_vhid field of the request
   to a negative value.

A repro code would look like this.

int main() {
    struct ifaliasreq req;
    struct sockaddr_in sin, mask;
    int fd, error;

    bzero(&sin, sizeof(struct sockaddr_in));
    bzero(&mask, sizeof(struct sockaddr_in));

    sin.sin_len = sizeof(struct sockaddr_in);
    sin.sin_family = AF_INET;
    sin.sin_addr.s_addr = inet_addr("192.168.88.2");

    mask.sin_len = sizeof(struct sockaddr_in);
    mask.sin_family = AF_INET;
    mask.sin_addr.s_addr = inet_addr("255.255.255.0");

    fd = socket(AF_INET, SOCK_DGRAM, 0);
    if (fd < 0)
        return (-1);

    memset(&req, 0, sizeof(struct ifaliasreq));
    strlcpy(req.ifra_name, "lo0", sizeof(req.ifra_name));
    memcpy(&req.ifra_addr, &sin, sin.sin_len);
    memcpy(&req.ifra_mask, &mask, mask.sin_len);
    req.ifra_vhid = -1;

    return ioctl(fd, SIOCAIFADDR, (char *)&req);
}

To fix, discard both positive and negative vhid values in
in_aifaddr_ioctl, if carp(4) is not loaded. This prevents NULL pointer
dereference and kernel panic.

Reviewed by: imp@
Pull Request: https://github.com/freebsd/freebsd-src/pull/530

2 years agoHyper-V: hn: Enter network epoch when required
Michael Tuexen [Thu, 26 Aug 2021 17:27:04 +0000 (19:27 +0200)]
Hyper-V: hn: Enter network epoch when required

PR: 254695

2 years agoamd64: remove lfence after swapgs on syscall entry
Konstantin Belousov [Wed, 25 Aug 2021 19:28:57 +0000 (22:28 +0300)]
amd64: remove lfence after swapgs on syscall entry

According to the description of SBSS issue at
https://software.intel.com/content/www/us/en/develop/articles/software-security-guidance/technical-documentation/speculative-behavior-swapgs-and-segment-registers.html
lfence after swapgs is needed only for the case when swapgs could be
speculatively executed.  Since syscall entry, unlike exception and
interrupt entries, executes swapgs unconditionally, there is no
opportunity for speculation.

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

2 years agosound(4): Fix some common typos in comments
Gordon Bergling [Thu, 26 Aug 2021 15:15:55 +0000 (17:15 +0200)]
sound(4): Fix some common typos in comments

- s/doens't/doesn't/
- s/apropriate/appropriate/
- s/intepretation/interpretation/

MFC after: 5 days

2 years agovfs: refactor kern_unmount
Mateusz Guzik [Thu, 26 Aug 2021 11:49:41 +0000 (13:49 +0200)]
vfs: refactor kern_unmount

Split unmounting by path and id in preparation for other changes.

Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agovfs: stop open-coding vfs_getvfs in kern_unmount
Mateusz Guzik [Thu, 26 Aug 2021 08:29:47 +0000 (10:29 +0200)]
vfs: stop open-coding vfs_getvfs in kern_unmount

Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agoipfw_nat64: fix direct output mode
Andrey V. Elsukov [Thu, 26 Aug 2021 10:48:23 +0000 (13:48 +0300)]
ipfw_nat64: fix direct output mode

In nat64_find_route[46] handle NHF_GATEWAY flag and use destination
address from next hop to do link layer address lookup.

PR: 255928
Reviewed by: melifaro
Obtained from: Yandex LLC
MFC after: 1 week
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D31680

2 years agoichwd: add Lewisburg Super SKUs, Cannon and Comet Lake support
Paweł Anikiel [Fri, 30 Jul 2021 08:57:28 +0000 (10:57 +0200)]
ichwd: add Lewisburg Super SKUs, Cannon and Comet Lake support

Cannon and Comet Lake PCHs have their PMC hidden, so when reading
the ACPI Base Address fails, we assume a default value.

Obtained from: Semihalf
Sponsored by: Stormshield

2 years agopf tests: Test ALTQ on top of if_bridge
Kristof Provost [Wed, 25 Aug 2021 09:08:38 +0000 (11:08 +0200)]
pf tests: Test ALTQ on top of if_bridge

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

2 years agoif_bridge: add ALTQ support
Luiz Otavio O Souza [Wed, 25 Aug 2021 09:07:44 +0000 (11:07 +0200)]
if_bridge: add ALTQ support

Similar to the recent addition of ALTQ support to if_vlan.

Reviewed by: donner
Obtained from: pfsense
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31675

2 years agopf tests: ALTQ priority test
Kristof Provost [Thu, 26 Aug 2021 08:25:57 +0000 (10:25 +0200)]
pf tests: ALTQ priority test

Test that ALTQ can prioritise one type of traffic over another. Do this
by establishing a slow link and saturating it with ICMP echos.
When prioritised TCP connections reliably go through. When not
prioritised TCP connections reliably fail.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agoAdd support for Lewisburg GPIO through P2SB
Arnaud Ysmal [Tue, 29 Jun 2021 13:54:07 +0000 (15:54 +0200)]
Add support for Lewisburg GPIO through P2SB

Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D31269

2 years agopxeboot: improve and simplify rx handling
Kyle Evans [Thu, 12 Aug 2021 02:49:17 +0000 (21:49 -0500)]
pxeboot: improve and simplify rx handling

This pushes the bulk of the rx servicing into a single loop that's only
slightly convoluted, and it addresses a problem with rx handling in the
process.  If we hit a tx interrupt while we're processing, we'd
previously drop the frame on the floor completely and ultimately
timeout, increasing boot time on particularly busy hosts as we keep
having to backoff and resend.

After this patch, we don't seem to hit timeouts at all on zoo anymore
though loading a 27M kernel is still relatively slow (~1m20s).

Reviewed by: tsoome
Triage by: Ash Gokhale <ashfixit gmail com>
Sponsored By: National Bureau of Economic Research
Sponsored by: Klara, Inc.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31512

2 years agotmpfs: Implement VOP_DEALLOCATE
Ka Ho Ng [Wed, 25 Aug 2021 21:34:35 +0000 (05:34 +0800)]
tmpfs: Implement VOP_DEALLOCATE

Implementing VOP_DEALLOCATE to allow hole-punching in the same manner as
POSIX shared memory's fspacectl(SPACECTL_DEALLOC) support.

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

2 years agotmpfs: Move partial page invalidation to a separate helper
Ka Ho Ng [Wed, 25 Aug 2021 21:30:53 +0000 (05:30 +0800)]
tmpfs: Move partial page invalidation to a separate helper

The partial page invalidation code is factored out to be a separate
helper from tmpfs_reg_resize().

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

2 years agofsetown: Simplify error handling
Mark Johnston [Wed, 25 Aug 2021 20:20:07 +0000 (16:20 -0400)]
fsetown: Simplify error handling

No functional change intended.

Suggested by: kib
Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31671

2 years agofsetown: Fix process lookup bugs
Mark Johnston [Wed, 25 Aug 2021 20:18:10 +0000 (16:18 -0400)]
fsetown: Fix process lookup bugs

- pget()/pfind() will acquire the PID hash bucket locks, which are
  sleepable sx locks, but this means that the sigio mutex cannot be held
  while calling these functions.  Instead, use pget() to hold the
  process, after which we lock the sigio and proc locks, respectively.
- funsetownlst() assumes that processes cannot be registered for SIGIO
  once they have P_WEXIT set.  However, pfind() will happily return
  exiting processes, breaking the invariant.  Add an explicit check for
  P_WEXIT in fsetown() to fix this. [1]

Fixes: f52979098d3c ("Fix a pair of races in SIGIO registration")
Reported by: syzkaller [1]
Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31661

2 years agoamd64 UEFI loader: enable automatic disable of staging area copying
Konstantin Belousov [Tue, 10 Aug 2021 01:38:55 +0000 (04:38 +0300)]
amd64 UEFI loader: enable automatic disable of staging area copying

Discussed with: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 month

2 years agodiff3: document and test -T
Piotr Pawel Stefaniak [Mon, 23 Aug 2021 19:33:27 +0000 (21:33 +0200)]
diff3: document and test -T

Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D31650

2 years agoparam: Bump __FreeBSD_version to 1400032
Ka Ho Ng [Wed, 25 Aug 2021 16:02:43 +0000 (00:02 +0800)]
param: Bump __FreeBSD_version to 1400032

Commit 9e202d036dd6 introduces incompatible changes to
fspacectl(2), vn_deallocate(9) and VOP_DEALLOCATE(9)'s
rmsr.r_offset/*offset return value.

Sponsored by: The FreeBSD Foundation

2 years agofspacectl(2): Changes on rmsr.r_offset's minimum value returned
Ka Ho Ng [Wed, 25 Aug 2021 16:02:27 +0000 (00:02 +0800)]
fspacectl(2): Changes on rmsr.r_offset's minimum value returned

rmsr.r_offset now is set to rqsr.r_offset plus the number of bytes
zeroed before hitting the end-of-file. After this change rmsr.r_offset
no longer contains the EOF when the requested operation range is
completely beyond the end-of-file. Instead in such case rmsr.r_offset is
equal to rqsr.r_offset.  Callers can obtain the number of bytes zeroed
by subtracting rqsr.r_offset from rmsr.r_offset.

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

2 years agotcp: make network epoch expectations of LRO explicit
Michael Tuexen [Wed, 25 Aug 2021 15:09:25 +0000 (17:09 +0200)]
tcp: make network epoch expectations of LRO explicit

Reviewed by: gallatin, hselasky
MFC after: 3 days
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D31648

2 years agopf tests: test ALTQ CBQ on top of if_vlan
Kristof Provost [Mon, 23 Aug 2021 14:58:50 +0000 (16:58 +0200)]
pf tests: test ALTQ CBQ on top of if_vlan

The main purpose of this test is to verify that we can use ALTQ on top
of if_vlan, but while we're here we also exercise the CBQ code. There's
already a basis test for HFSC, so it makes sense to test another
algorithm while we test if_vlan.

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

2 years agoif_vlan: add the ALTQ support to if_vlan.
Luiz Otavio O Souza [Sat, 21 Aug 2021 09:41:03 +0000 (11:41 +0200)]
if_vlan: add the ALTQ support to if_vlan.

Inspired by the iflib implementation, allow ALTQ to be used with if_vlan
interfaces.

Reviewed by: donner
Obtained from: pfsense
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31647

2 years agoddb: do not assume that ffs is mounted with softdep
Keith Owens [Wed, 25 Aug 2021 01:59:31 +0000 (20:59 -0500)]
ddb: do not assume that ffs is mounted with softdep

Avoid a panic when debugging with "show ffs" in ddb.

Reviewed By: kib, markj, mckusick
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D31622

2 years agowsp(4): Add evdev support.
Vladimir Kondratyev [Tue, 24 Aug 2021 23:01:42 +0000 (02:01 +0300)]
wsp(4): Add evdev support.

Reviewed by: hselasky
Tested by: Greg V, Constantin Furst<constantin_AT_fuersten_DOT_info>
MFC after: 2 weeks
PR: 252236
Differential revision: https://reviews.freebsd.org/D31653

2 years agowsp(4): Compact parameter structure.
Vladimir Kondratyev [Tue, 24 Aug 2021 22:59:48 +0000 (01:59 +0300)]
wsp(4): Compact parameter structure.

MFC after: 2 weeks

2 years agoatp(4), wsp(4): Return correct priority from probe() method;
Vladimir Kondratyev [Tue, 24 Aug 2021 22:59:17 +0000 (01:59 +0300)]
atp(4), wsp(4): Return correct priority from probe() method;

MFC after: 2 weeks

2 years agoevdev: Add support for automatic MT protocol type A to type B conversion.
Vladimir Kondratyev [Tue, 24 Aug 2021 22:53:56 +0000 (01:53 +0300)]
evdev: Add support for automatic MT protocol type A to type B conversion.

MFC after: 2 weeks

2 years agoevdev: Add implicit mode for touch tracking.
Vladimir Kondratyev [Tue, 24 Aug 2021 22:52:37 +0000 (01:52 +0300)]
evdev: Add implicit mode for touch tracking.

In implicit mode assignment of slot number and tracking id is performed
automatically on each synchronization requested by device driver.

This is done with creation of intermediate buffer for multitouch events.
This buffer holds untracked events until synchronization is requested by
device driver. It is needed as touch assigment requires
knowledges of all touch positions pushed in current and previous reports.

MFC after: 2 weeks

2 years agoevdev: Import support for touch-tracking.
Vladimir Kondratyev [Tue, 24 Aug 2021 22:50:53 +0000 (01:50 +0300)]
evdev: Import support for touch-tracking.

Touch tracking is a process of assignment of unique trackingID to each
initiated contact on the surface.  Keeping the trackingIDs persistent
across multitouch reports requires solving of so called Euclidian
Bipartite Matching problem.

This commit imports EBM-solver implementation based on Dinitz-Kronrod
algorithm to find minimum cost matching between contacts listed in two
consecutive reports.

Obtained from: OpenBSD
MFC after: 2 weeks

2 years agoevdev: Make MT tracking IDs monotonically increasing sequence.
Vladimir Kondratyev [Tue, 24 Aug 2021 22:48:33 +0000 (01:48 +0300)]
evdev: Make MT tracking IDs monotonically increasing sequence.

MFC after: 2 weeks

2 years agoevdev: Give short aliases to items of evdev_mt_slot array
Vladimir Kondratyev [Tue, 24 Aug 2021 22:47:34 +0000 (01:47 +0300)]
evdev: Give short aliases to items of evdev_mt_slot array

with using of unioned anonymous structure.

Access to the same data by using different members of union generally
works despite it is not supported by C specs.

Also add helper function to report entire slot state.

MFC after: 2 weeks

2 years agoevdev: Normalize width and pressure of single touch compat events
Vladimir Kondratyev [Tue, 24 Aug 2021 22:46:49 +0000 (01:46 +0300)]
evdev: Normalize width and pressure of single touch compat events

to match Synaptics touchpad reporting range.

MFC after: 2 weeks

2 years agoevdev: force no fuzz for autogenerated single touch compat events.
Vladimir Kondratyev [Tue, 24 Aug 2021 22:45:50 +0000 (01:45 +0300)]
evdev: force no fuzz for autogenerated single touch compat events.

As fuzz has already been applied on multitouch event processing.
This allows to remove existing workaround for double fuzz procesing.

MFC after: 2 weeks

2 years agoevdev: Send first active rather than 0-th slot state as ST report
Vladimir Kondratyev [Tue, 24 Aug 2021 22:45:16 +0000 (01:45 +0300)]
evdev: Send first active rather than 0-th slot state as ST report

MFC after: 2 weeks

2 years agoevdev: Use bitsets to track active touches and slots changed in current report
Vladimir Kondratyev [Tue, 24 Aug 2021 22:44:36 +0000 (01:44 +0300)]
evdev: Use bitsets to track active touches and slots changed in current report

Obtained from: OpenBSD

MFC after:  2 weeks

2 years agoevdev: Multitouch code style changes.
Vladimir Kondratyev [Tue, 24 Aug 2021 22:43:41 +0000 (01:43 +0300)]
evdev: Multitouch code style changes.

1. Move touch count reporting helpers to utils. They are not multitouch.
2. Use evdev_mt prefix for private multitouch support routines.
3. Use int instead of int32_t where fixed size is not required.
4. Export some internal functions.

This change should be no-op.

MFC after: 2 weeks

2 years agoiscsi: Validate DataSN values in Data-In PDUs in the initiator.
John Baldwin [Tue, 24 Aug 2021 21:58:34 +0000 (14:58 -0700)]
iscsi: Validate DataSN values in Data-In PDUs in the initiator.

As is done in the target, require that DataSN values are consecutive
and in-order.  If an out of order Data-In PDU is received, force a
session reconnect.  In addition, when a SCSI Response PDU is received,
verify that the ExpDataSN field matches the count of Data-In PDUs
received for this command.  If not, force a session reconnect.

Reviewed by: mav
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D31594

2 years agobhyve: Fix vq_getchain() error handling bugs in various device models
Mark Johnston [Tue, 24 Aug 2021 18:10:08 +0000 (14:10 -0400)]
bhyve: Fix vq_getchain() error handling bugs in various device models

Reviewed by: grehan, khng
Approved by: so
Security: CVE-2021-29631
Security: FreeBSD-SA-21:13.bhyve

2 years agoFix multiple OpenSSL vulnerabilities.
Gordon Tetlow [Tue, 24 Aug 2021 18:03:46 +0000 (11:03 -0700)]
Fix multiple OpenSSL vulnerabilities.

Approved by: so
Security: SA-21:16.openssl
Security: CVE-2021-3711
Security: CVE-2021-3712

2 years agoFix libfetch out of bounds read.
Gordon Tetlow [Tue, 24 Aug 2021 17:59:01 +0000 (10:59 -0700)]
Fix libfetch out of bounds read.

Approved by: so
Security: SA-21:15.libfetch
Security: CVE-2021-36159

2 years agoFix remote code execution in ggatec(8).
Gordon Tetlow [Tue, 24 Aug 2021 17:40:49 +0000 (10:40 -0700)]
Fix remote code execution in ggatec(8).

Approved by:    so
Security:       SA-21:14.ggatec
Security:       CVE-2021-29630

2 years agotmpfs: Fix error being cleared after commit c12118f6cec0
Ka Ho Ng [Tue, 24 Aug 2021 16:35:29 +0000 (00:35 +0800)]
tmpfs: Fix error being cleared after commit c12118f6cec0

In tmpfs_link() error was erroneously cleared in commit c12118f6cec0.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
MFC with: c12118f6cec0

2 years agouipc_shm: Handle offset on shm_size as if it is beyond shm_size
Ka Ho Ng [Tue, 24 Aug 2021 14:39:43 +0000 (22:39 +0800)]
uipc_shm: Handle offset on shm_size as if it is beyond shm_size

This avoids any unnecessary works in such case.

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

2 years agotmpfs: Fix styles
Ka Ho Ng [Tue, 24 Aug 2021 13:09:21 +0000 (21:09 +0800)]
tmpfs: Fix styles

A lot of return statements were in the wrong style before this commit.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agoarm: export actlr as sysctl hw.cpu.quirks.actlr_value
Mateusz Guzik [Tue, 24 Aug 2021 14:20:13 +0000 (14:20 +0000)]
arm: export actlr as sysctl hw.cpu.quirks.actlr_value

Reviewed by: cognet
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agoRevert "Mark LLDB/CLANG_BOOTSTRAP/LLD_BOOTSTRAP as broken on non-FreeBSD for now"
Jessica Clarke [Tue, 24 Aug 2021 14:00:06 +0000 (15:00 +0100)]
Revert "Mark LLDB/CLANG_BOOTSTRAP/LLD_BOOTSTRAP as broken on non-FreeBSD for now"

The fixes for this have now been committed so we can re-enable these.

This reverts commit d9f25575a29ff7c83f226349a10a37b9aaf75ad5.

MFC after: 1 week

2 years agoclang: Build with -fno-strict-aliasing when using GCC
Jessica Clarke [Tue, 24 Aug 2021 13:59:36 +0000 (14:59 +0100)]
clang: Build with -fno-strict-aliasing when using GCC

Somewhat ironically, there are strict aliasing violations in Clang,
which can result in the following assertion failure:

  Assertion `*(NamedDecl **)&Data == ND && "PointerUnion mangles the NamedDecl pointer!"' failed.

Upstream's clang/CMakeLists.txt specifically (not LLVM as a whole)
passes -fno-strict-aliasing if the compiler is not Clang, and this fixes
the above issue.

This was seen when cross-building from Linux using a bootstrap
compiler, but likely also affects worlds built with a new enough
external GCC toolchain.

MFC after: 1 week
Reviewed by: dim
Differential Revision: https://reviews.freebsd.org/D31533

2 years agoclang: Support building with GCC and DEBUG_FILES disabled
Jessica Clarke [Tue, 24 Aug 2021 13:59:18 +0000 (14:59 +0100)]
clang: Support building with GCC and DEBUG_FILES disabled

If MK_DEBUG_FILES=no then the Clang link rule has clang as .TARGET,
rather than clang.full, causing the implicit ${CFLAGS.${.TARGET:T}} to
be CFLAGS.clang, and thus pull in flags intended for when your compiler
is Clang, not when linking Clang itself. This doesn't matter if your
compiler is in fact Clang, but it breaks using GCC as, for example,
bsd.sys.mk adds -Qunused-arguments to CFLAGS.clang. This is seen when
trying to build a bootstrap toolchain on Linux where GCC is the system
compiler.

Thus, introduce a new internal NO_TARGET_FLAGS variable that is set by
Clang to disable the addition of these implicit flags. This is a bigger
hammer than necessary, as flags for .o files would be safe, but that is
not needed for Clang.

Note that the same problem does not arise for LDFLAGS when building LLD
with BFD, since our build produces a program called ld.lld, not plain
lld (unlike upstream, where ld.lld is a symlink to lld so they can
support multiple different flavours in one binary).

Suggested by: sjg
Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux")
MFC after: 1 week
Reviewed by: dim, imp, emaste
Differential Revision: https://reviews.freebsd.org/D31532

2 years agoFix bootstrapping to actually build lldb-tblgen for later use
Jessica Clarke [Tue, 24 Aug 2021 13:59:04 +0000 (14:59 +0100)]
Fix bootstrapping to actually build lldb-tblgen for later use

Because MK_LLDB=no is in BSARGS, the bootstrap-tools recursive make does
not add lldb-tblgen to _clang_tblgen, causing it to not be built. This
means that the build currently always uses the host's lldb-tblgen
(which, whilst currently it appears to work, could in future break if
TableGen backends are added or altered) and, if it doesn't exist (either
because the current FreeBSD system was built with it disabled, or you're
building on macOS/Linux), fails. Linux and macOS cross-builds used to
work simply because LLDB was previously in BROKEN_OPTIONS when building
on non-FreeBSD.

Instead, move MK_LLDB=no from BSARGS to XMAKE. This ensures that the
lib/clang build in cross-tools continues to not build LLDB parts for the
bootstrap toolchain (both to save time/space on FreeBSD, and because our
vendored LLDB does not include the macOS and Linux host files so those
would fail to build).

The DIRDEPS target is updated to move MK_LLDB=no from the BSARGS block
that mirrors Makefile.inc1 to the line that disables additional
toolchain components. The DIRDEPS build likely suffers from the same
issue currently, but having never used it and not being familiar with
how it works I am leaving that as-is. If it does suffer from the same
issue it should be easily reproducible by renaming /usr/bin/lldb-tblgen
or moving it to a directory not in PATH.

Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux")
MFC after: 1 week
Reviewed by: dim, emaste, imp
Differential Revision: https://reviews.freebsd.org/D31531

2 years agoMakefile.inc1: Make sure sub-makes see MK_CLANG_BOOTSTRAP=no when XCC is a path
Jessica Clarke [Tue, 24 Aug 2021 13:55:31 +0000 (14:55 +0100)]
Makefile.inc1: Make sure sub-makes see MK_CLANG_BOOTSTRAP=no when XCC is a path

Currently we override MK_CLANG_BOOTSTRAP to no so we don't build a
bootstrap compiler, but subdirectories don't see that and so the hack in
bsd.sys.mk to prefer our includes over Clang's resource dir for external
toolchains is not enabled unless you use -DWITHOUT_CLANG_BOOTSTRAP
explicitly on top of XCC (which tools/build/make.py does not do),
causing duplicate definition errors when building rtld-elf due to the
use of -ffreestanding (Clang's stdint.h will use the system one when
hosted, but its own when freestanding, and only has glibc's preprocessor
guards, not FreeBSD's).

This broke when dropping CLANG_BOOTSTRAP from BROKEN_OPTIONS.

Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux")
MFC after: 1 week
Reviewed by: imp, arichardson
Differential Revision: https://reviews.freebsd.org/D31529