]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoMFV d60fa10fd872db7e3d8cb1e161cfdae026c43b14:
Cy Schubert [Wed, 10 Feb 2021 04:25:05 +0000 (20:25 -0800)]
MFV d60fa10fd872db7e3d8cb1e161cfdae026c43b14:

Update unbound 1.13.0 --> 1.13.1.

Includes numerous bugfixes documented at:
https://www.nlnetlabs.nl/projects/unbound/download/#unbound-1-13-1

MFC after: 1 month

3 years agoFix non-IPv6 build post 57785538c6e0d7e8ca0f161ab95bae10fd304047.
Cy Schubert [Wed, 10 Feb 2021 01:13:01 +0000 (17:13 -0800)]
Fix non-IPv6 build post 57785538c6e0d7e8ca0f161ab95bae10fd304047.

57785538c6e0d7e8ca0f161ab95bae10fd304047 change the test for FreeBSD
from __FreeBSD_version to __FreeBSD__. However this test was performed
before sys/param.h was included, therefore __FreeBSD_version was never
defined. As the test was never true opt_random_ip_id.h was never included.

Submitted by: bdragon
Reported by: bdragon
MFC after: 1 week
X-MFC with: 57785538c6e0d7e8ca0f161ab95bae10fd304047

3 years agolibsysdecode: fix decoding of TCP_NOPUSH and TCP_MD5SIG
Michael Tuexen [Tue, 9 Feb 2021 22:35:55 +0000 (23:35 +0100)]
libsysdecode: fix decoding of TCP_NOPUSH and TCP_MD5SIG

TCP_FASTOPEN_MIN_COOKIE_LEN was incorrectly registered as a name of
a IPPROTO_TCP level socket option, which overwrote TCP_NOPUSH.
TCP_FASTOPEN_PSK_LEN was incorrectly registered as a name of an
IPPROTO_TCP level socket option, which overwrote TCP_MD5SIG.

MFC after: 3 days
Sponsored by: Netflix, Inc.

3 years agoAdd test case for 93fc67896550 (incorrect powf(3) result)
Dimitry Andric [Tue, 9 Feb 2021 22:37:08 +0000 (23:37 +0100)]
Add test case for 93fc67896550 (incorrect powf(3) result)

This adds the test case to contrib/netbsd-tests/lib/libm/t_pow.c, as it
is currently the only place testing pow(3) and friends.

MFC after: 1 week

3 years agobsd.compiler.mk: Detect distribution-provided GCC when executed as cc
Jessica Clarke [Tue, 9 Feb 2021 21:40:24 +0000 (21:40 +0000)]
bsd.compiler.mk: Detect distribution-provided GCC when executed as cc

Clang always prints "clang $VERSION" regardless of the name used to
execute it, whereas GCC prints "$progname $VERSION", meaning if CC is
set to cc and cc is GCC it will print "cc $VERSION". We are able to
detect some of those cases since it then prints "($PKGVERSION)", where
the default is "GCC", but many distributions override that to print
their name and the package version number (e.g. "Debian 10.2.1-6"), so
nothing tells us it's GCC other than the fact that it's not Clang (and
that there's an FSF copyright disclaimer).

However, GCC's -v option will always print "gcc version $VERSION", so
fall back on using that to detect GCC. Whilst Clang also supports this
option, we should never get here, so Clang handling is not added.

Reviewed by: brooks, emaste, arichardson
Differential Revision: https://reviews.freebsd.org/D28315

3 years agoFix lib/msun's ctrig_test/test_inf_inputs test case with clang >= 10
Dimitry Andric [Tue, 9 Feb 2021 21:06:51 +0000 (22:06 +0100)]
Fix lib/msun's ctrig_test/test_inf_inputs test case with clang >= 10

This sprinkles a few strategic volatiles in an attempt to defeat clang's
optimization interfering with the expected floating-point exception
flags.

Reported by: lwhsu
PR: 244732
MFC after: 3 days

3 years agoVendor import of Unbound 1.13.1.
Cy Schubert [Tue, 9 Feb 2021 20:59:02 +0000 (12:59 -0800)]
Vendor import of Unbound 1.13.1.

Includes numerous bugfixes documented at:
https://www.nlnetlabs.nl/projects/unbound/download/#unbound-1-13-1

3 years agonetgraph/ng_bridge: Document staleness in multithreaded operation
Lutz Donnerhacke [Tue, 9 Feb 2021 11:32:46 +0000 (12:32 +0100)]
netgraph/ng_bridge: Document staleness in multithreaded operation

In the data path of ng_bridge(4), the only value of the host struct,
which needs to be modified, is the staleness, which is reset every
time a frame is received.  It's save to leave the code as it is.

This patch is part of a series to make ng_bridge(4) multithreaded.

Reviewed by: kp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28546

3 years agonetgraph/ng_bridge: Merge internal structures
Lutz Donnerhacke [Mon, 8 Feb 2021 21:36:46 +0000 (22:36 +0100)]
netgraph/ng_bridge: Merge internal structures

In a earlier version of ng_bridge(4) the exernal visible host entry
structure was a strict subset of the internal one.  So internal view
was a direct annotation of the external structure.  This strict
inheritance was lost many versions ago.  There is no need to
encapsulate a part of the internal represntation as a separate
structure.

This patch is a preparation to make the internal structure read only
in the data path in order to make ng_bridge(4) multithreaded.

Reviewed by: kp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28545

3 years agoSet file mode during zfs_write
Antonio Russo [Mon, 8 Feb 2021 17:15:05 +0000 (10:15 -0700)]
Set file mode during zfs_write

Apply https://github.com/openzfs/zfs/pull/11576

Direct commit from upstream openzfs. Full commit message below:

Set file mode during zfs_write

3d40b65 refactored zfs_vnops.c, which shared much code verbatim between
Linux and BSD.  After a successful write, the suid/sgid bits are reset,
and the mode to be written is stored in newmode.  On Linux, this was
propagated to both the in-memory inode and znode, which is then updated
with sa_update.

3d40b65 accidentally removed the initialization of newmode, which
happened to occur on the same line as the inode update (which has been
moved out of the function).

The uninitialized newmode can be saved to disk, leading to a crash on
stat() of that file, in addition to a merely incorrect file mode.

Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Antonio Russo <aerusso@aerusso.net>
Closes #11474
Closes #11576

Obtained from: openzfs/zfs@f8ce8aed0
MFC after: 0 days
Sponsored by: iXsystems, Inc.

3 years agousr.bin/grep: Fix Address OOB read error
Alex Richardson [Tue, 19 Jan 2021 11:35:07 +0000 (11:35 +0000)]
usr.bin/grep: Fix Address OOB read error

I found this when compiling all the bootstrap tools with -fsanitize=addres:

==65590==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62d000008400 at pc 0x000000473053 bp 0x7ffc1c7dd910 sp 0x7ffc1c7dd0b8
READ of size 32769 at 0x62d000008400 thread T0
    #0 0x473052 in regexec (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x473052)
    #1 0x4c9cf3 in procline /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:539:8
    #2 0x4c8687 in procfile /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:379:18
    #3 0x4c6596 in main /local/scratch/alr48/cheri/freebsd/usr.bin/grep/grep.c:714:8

0x62d000008400 is located 0 bytes to the right of 32768-byte region [0x62d000000400,0x62d000008400)
allocated by thread T0 here:
    #0 0x493d5d in malloc (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x493d5d)
    #1 0x4cad75 in grep_malloc /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:656:13
    #2 0x4c8129 in procfile /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c
    #3 0x4c6596 in main /local/scratch/alr48/cheri/freebsd/usr.bin/grep/grep.c:714:8

SUMMARY: AddressSanitizer: heap-buffer-overflow (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x473052) in regexec

Reviewed By: kevans
MFC after: 1 week

3 years agocache: assorted comment fixups
Mateusz Guzik [Tue, 9 Feb 2021 16:06:27 +0000 (17:06 +0100)]
cache: assorted comment fixups

3 years agoRevert "amd64: implement strlen in assembly"
Mateusz Guzik [Tue, 9 Feb 2021 15:18:58 +0000 (16:18 +0100)]
Revert "amd64: implement strlen in assembly"

This reverts commit af366d353b84bdc4e730f0fc563853abc338271c.

Trips over '\xa4' byte and terminates early, as found in
lib/libc/gen/setdomainname_test:setdomainname_basic testcase

However, keep moving libkern/strlen.c out of conf/files.

Reported by: lwhsu

3 years agoarm32: Align arguments of sync_icache() syscall to cacheline size.
Michal Meloun [Tue, 9 Feb 2021 10:36:36 +0000 (11:36 +0100)]
arm32: Align arguments of sync_icache() syscall to cacheline size.

Otherwise, we may miss synchronization of the last cacheline.
MFC after: 3 days

3 years agoloader: do not autoselect smaller font than 8x16 with high res display
Toomas Soome [Mon, 8 Feb 2021 22:34:47 +0000 (00:34 +0200)]
loader: do not autoselect smaller font than 8x16 with high res display

The VT screen buffer size is calculated based on our default
built in (8x16) font.

With high-resolution display, we want to use at least 8x16 font,
or we will have large unused areas on screen.

MFC after: 1 week

3 years agoloader: remove BORDER_PIXELS
Toomas Soome [Mon, 8 Feb 2021 18:49:09 +0000 (20:49 +0200)]
loader: remove BORDER_PIXELS

BORDER_PIXELS is left over from picking up the source from illumos
port. Since FreeBSD VT does not use border in terminal size
calculation, there is no reason why should loader use it.

MFC after: 1 week

3 years agokern: sonewconn: set so_options before pru_attach()
Kyle Evans [Wed, 20 Jan 2021 17:53:05 +0000 (11:53 -0600)]
kern: sonewconn: set so_options before pru_attach()

Protocol attachment has historically been able to observe and modify
so->so_options as needed, and it still can for newly created sockets.
779f106aa169 moved this to after pru_attach() when we re-acquire the
lock on the listening socket.

Restore the historical behavior so that pru_attach implementations can
consistently use it. Note that some pru_attach() do currently rely on
this, though that may change in the future. D28265 contains a change to
remove the use in TCP and IB/SDP bits, as resetting the requested linger
time on incoming connections seems questionable at best.

This does move the assignment out from under the head's listen lock, but
glebius notes that head won't be going away and applications cannot
assume any specific ordering with a race between a connection coming in
and the application changing socket options anyways.

Discussed-with: glebius
MFC-after: 1 week

3 years agodevfs: fix use count leak when using TIOCSCTTY
Mateusz Guzik [Mon, 8 Feb 2021 22:10:57 +0000 (23:10 +0100)]
devfs: fix use count leak when using TIOCSCTTY

by matching devfs_ctty_ref

Fixes: 3b44443626603f65 ("devfs: rework si_usecount to track opens")
3 years agoSimplify the FreeBSD check using __FreeBSD__ compiler macro.
Cy Schubert [Sun, 7 Feb 2021 03:22:52 +0000 (19:22 -0800)]
Simplify the FreeBSD check using __FreeBSD__ compiler macro.

Rather than rely on __FreeBSD_version, defined in sys/param.h, use
__FreeBSD__ defined by the compiler.

Reported by: emaste
MFC after: 1 week

3 years agoSimply FreeBSD check using __FreeBSD__ and remove OpenBSD
Cy Schubert [Sun, 7 Feb 2021 03:15:27 +0000 (19:15 -0800)]
Simply FreeBSD check using __FreeBSD__ and remove OpenBSD

MFC after: 1 week

3 years agoZFS: fix assertions with INVARIANTS
Alan Somers [Wed, 20 Jan 2021 15:55:36 +0000 (08:55 -0700)]
ZFS: fix assertions with INVARIANTS

AFAICT, this was an oversight from
9e5787d2284e187abb5b654d924394a65772e004 (svn r364746).  That revision
inadvertently disabled assertions unconditionally.

Reviewed by: freqlabs
MFC after: 3 days
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D28256

3 years agoRevert "SO_RERROR indicates that receive buffer overflows should be handled as errors."
Alexander V. Chernikov [Mon, 8 Feb 2021 22:30:39 +0000 (22:30 +0000)]
Revert "SO_RERROR indicates that receive buffer overflows should be handled as errors."
Wrong version of the change was pushed inadvertenly.

This reverts commit 4a01b854ca5c2e5124958363b3326708b913af71.

3 years agohid: bump HID_ITEM_MAXUSAGES to 8
Warner Losh [Mon, 8 Feb 2021 19:29:20 +0000 (12:29 -0700)]
hid: bump HID_ITEM_MAXUSAGES to 8

My YOGA requires a minimum of 7 to parse w/o an error. Since the memory savings
are trivial and the yoga a popular system, bump the default up to 8. There's no
API/ABI issues in doing this. This hid_item struct isn't exported to userland
and the one libusbhid has is different and only shares a name...

MFC After: 3 days
Reviewed by: wulf@
Differential Revision: https://reviews.freebsd.org/D28543

3 years agoDon't check compat.linux.emul_path before loading linux(4)
Edward Tomasz Napierala [Mon, 8 Feb 2021 21:52:31 +0000 (21:52 +0000)]
Don't check compat.linux.emul_path before loading linux(4)

Fix e40787f900f to make libexec/rc/rc.d/linux retrieve the sysctl
after loading the kernel module which provides it, not before.

Reported By: jkim
Sponsored By: The FreeBSD Foundation

3 years agoacpi: limit the AMDI0020/AMDI0010 workaround to an option
Warner Losh [Mon, 8 Feb 2021 21:43:25 +0000 (14:43 -0700)]
acpi: limit the AMDI0020/AMDI0010 workaround to an option

It appears that production versions of EPYC firmware get the _STA method right
for these nodes. In fact, this workaround breaks on production hardware by
including too many uart nodes. This work around was for pre-release hardware
that wound up not having a large deployment. Move this work around to a kernel
option since the machines that needed it have been powered off and are difficult
to resurrect. Should there be a more significant deployment than is understood,
we can restrict it based on smbios strings.

Discussed with: mmacy@, seanc@, jhb@
MFC After: 3 days

3 years agoTurn off forgotten multipath debug messages
Alexander V. Chernikov [Mon, 8 Feb 2021 20:11:38 +0000 (20:11 +0000)]
Turn off forgotten multipath debug messages

Reported by: mike tancsa<mike at sentex.net>
MFC after: 3 days

3 years agoSO_RERROR indicates that receive buffer overflows should be handled as errors.
Alexander V. Chernikov [Sun, 7 Feb 2021 17:21:18 +0000 (17:21 +0000)]
SO_RERROR indicates that receive buffer overflows should be handled as errors.
Historically receive buffer overflows have been ignored and programs
could not tell if they missed messages or messages had been truncated
because of overflows. Since programs historically do not expect to get
receive overflow errors, this behavior is not the default.

This is really really important for programs that use route(4) to keep in sync
with the system. If we loose a message then we need to reload the full system
state, otherwise the behaviour from that point is undefined and can lead
to chasing bogus bug reports.

3 years agowsp: Add sysctl tunable for Z-Axis inversion
Vladimir Kondratyev [Mon, 8 Feb 2021 21:26:42 +0000 (00:26 +0300)]
wsp: Add sysctl tunable for Z-Axis inversion

This adds a new sysctl to Wellspring Touchpad driver for controlling
Z-Axis (2-finger vertical scroll) direction "hw.usb.wsp.z_invert".

Submitted by: James Wright <james.wright_AT_digital-chaos_DOT_com>
Reviewed by: wulf
PR: 253321
Differential revision: https://reviews.freebsd.org/D28521

3 years agonvme: Make nvme_ctrlr_hw_reset static
Warner Losh [Mon, 8 Feb 2021 20:28:18 +0000 (13:28 -0700)]
nvme: Make nvme_ctrlr_hw_reset static

nvme_ctrlr_hw_reset is no longer used outside of nvme_ctrlr.c, so
make it static. If we need to change this in the future we can.

3 years agoktls(4): Mention WITH_OPENSSL_KTLS in the ktls(4) manual page
Gordon Bergling [Mon, 8 Feb 2021 20:21:26 +0000 (21:21 +0100)]
ktls(4): Mention WITH_OPENSSL_KTLS in the ktls(4) manual page

Since we ship a ktls(4) enabled OpenSSL version, mention
the src.conf(5) option WITH_OPENSSL_KTLS in the manual page.

Reviewed by: jhb
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D28435

3 years agonvme: use NVME_GONE rather than hard-coded 0xffffffff
Warner Losh [Mon, 8 Feb 2021 20:08:48 +0000 (13:08 -0700)]
nvme: use NVME_GONE rather than hard-coded 0xffffffff

Make it clearer that the value 0xfffffff is being used to detect the device is
gone. We use it other places in the driver for other meanings.

3 years agoFix incorrect powf(3) result with x near 1 and |y| much larger than 1
Steve Kargl [Mon, 8 Feb 2021 19:45:30 +0000 (20:45 +0100)]
Fix incorrect powf(3) result with x near 1 and |y| much larger than 1

This adjusts the check to trigger overflow/underflow to a slightly lower
value.

Before: powf(9.999995e-01, -1.342177e+08) -> inf
After:  powf(9.999995e-01, -1.342177e+08) -> 1.858724e+31

MFC after: 1 week

3 years agomca: Handle inconsistent CMCI capability reporting
Mark Johnston [Mon, 8 Feb 2021 19:42:54 +0000 (14:42 -0500)]
mca: Handle inconsistent CMCI capability reporting

A BIOS bug may apparently cause the BSP to report that it does not
implement CMCI, with some APs reporting that they do.  In this scenario,
avoid a NULL pointer dereference that occurs in cmci_monitor() because
cmc_state was not allocated by the BSP.

PR: 253272
Reported by: asomers, mmacy
Reviewed by: kib (previous version)
MFC after: 1 week

3 years agoamd64: fix up a braino in strlen comment
Mateusz Guzik [Mon, 8 Feb 2021 19:24:26 +0000 (19:24 +0000)]
amd64: fix up a braino in strlen comment

3 years agoprepare-commit-msg: Remove blank character
Daniel Ebdrup Jensen [Mon, 8 Feb 2021 19:15:34 +0000 (20:15 +0100)]
prepare-commit-msg: Remove blank character

Approved by: emaste@ (maintainer)

3 years agoamd64: implement strlen in assembly
Mateusz Guzik [Mon, 8 Feb 2021 17:01:48 +0000 (18:01 +0100)]
amd64: implement strlen in assembly

The C variant in libkern performs excessive branching to find the
non-zero byte instead of using the bsfq instruction. The same code
patched to use it is still slower than the routine implemented here
as the compiler keeps neglecting to perform certain optimizations
(like using leaq).

On top of that the routine can is a starting point for copyinstr
which operates on words instead of bytes.

Tested with glibc test suite.

Sample results (calls/s):

Haswell:
$(perl -e "print 'A' x 3"):
stock: 211198039
patched:338626619
asm: 465609618

$(perl -e "print 'A' x 100"):
stock:  83151997
patched: 98285919
asm: 120719888

AMD EPYC 7R32:
$(perl -e "print 'A' x 3"):
stock: 282523617
asm: 491498172

$(perl -e "print 'A' x 100"):
stock: 114857172
asm: 112082057

3 years agoRestore the augmented strlen commentary
Mateusz Guzik [Sun, 7 Feb 2021 19:53:34 +0000 (19:53 +0000)]
Restore the augmented strlen commentary

... lost in revert

3 years agolibkern: use compiler builtins for strcpy, strcmp and strlen
Mateusz Guzik [Sun, 7 Feb 2021 19:50:25 +0000 (19:50 +0000)]
libkern: use compiler builtins for strcpy, strcmp and strlen

3 years agogrep: fix -A handling in conjunction with -m match limitation
Kyle Evans [Mon, 8 Feb 2021 18:31:17 +0000 (12:31 -0600)]
grep: fix -A handling in conjunction with -m match limitation

The basic issue here is that grep, when given -m 1, would stop all
line processing once it hit the match count and exit immediately.  The
problem with exiting immediately is that -A processing only happens when
subsequent lines are processed and do not match.

The fix here is relatively easy; when bsdgrep matches a line, it resets
the 'tail' of the matching context to the value supplied to -A and
dumps anything that's been queued up for -B. After the current line has
been printed and tail is reset, we check our mcount and do what's
needed. Therefore, at the time that we decide we're doing nothing, we
know that 'tail' of the context is correct and we can simply continue
on if there's still more to pick up.

With this change, we still bail out immediately if there's been no -A
flag. If -A was supplied, we signal that we should continue on. However,
subsequent lines will not even bothere to try and process the line.  We
have reached the match count, so even if the next line would match then
we must process it if it hadn't. Thus, the loop in procfile() can
short-circuit and just process the line as a non-match until
procmatches() indicates that it's safe to stop.

A test has been added to reflect both that we should be picking up the
next line and that the next line should be considered a non-match even
if it should have been.

PR: 253350
MFC-after: 3 days

3 years agovt: terminal size can grow too big with small font
Toomas Soome [Thu, 21 Jan 2021 22:18:56 +0000 (00:18 +0200)]
vt: terminal size can grow too big with small font

vt is using static buffers for on screen data, the buffer size is
calculated based on maximum supported screen size and 8x16 font.

When using hi-res graphics and very smaller than 8x16 font, we
need to be careful not to overflow static buffers in vt.

Testing: I did test by building smaller buffers than vt currently is using,
royger was testing on actual 4k capable hardware.

MFC after: 1 week
Tested by: royger

3 years agobinmiscctl: Avoid segfault with "binmiscctl add" and no extra params
Mark Johnston [Mon, 8 Feb 2021 14:20:38 +0000 (09:20 -0500)]
binmiscctl: Avoid segfault with "binmiscctl add" and no extra params

MFC after: 1 week

3 years agoktls: Avoid wakeups and locking for synchronous callbacks
Mark Johnston [Mon, 8 Feb 2021 14:19:27 +0000 (09:19 -0500)]
ktls: Avoid wakeups and locking for synchronous callbacks

When performing encryption in software, the KTLS crypto callback always
locks the session to deliver a wakeup.  But, if we're handling the
operation synchronously this is wasted effort and can result in
sleepqueue lock contention on large systems.

Use CRYPTO_SESS_SYNC() to determine whether the operation will be
completed asynchronously or not, and select a callback appropriately.
Avoid locking the session to check for completion if the session handles
requests synchronously.

Reviewed by: jhb
Sponsored by: Ampere Computing
Submitted by: Klara, Inc.
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28195

3 years agoopencrypto: Introduce crypto_dispatch_async()
Mark Johnston [Mon, 8 Feb 2021 14:19:19 +0000 (09:19 -0500)]
opencrypto: Introduce crypto_dispatch_async()

Currently, OpenCrypto consumers can request asynchronous dispatch by
setting a flag in the cryptop.  (Currently only IPSec may do this.)   I
think this is a bit confusing: we (conditionally) set cryptop flags to
request async dispatch, and then crypto_dispatch() immediately examines
those flags to see if the consumer wants async dispatch. The flag names
are also confusing since they don't specify what "async" applies to:
dispatch or completion.

Add a new KPI, crypto_dispatch_async(), rather than encoding the
requested dispatch type in each cryptop. crypto_dispatch_async() falls
back to crypto_dispatch() if the session's driver provides asynchronous
dispatch. Get rid of CRYPTOP_ASYNC() and CRYPTOP_ASYNC_KEEPORDER().

Similarly, add crypto_dispatch_batch() to request processing of a tailq
of cryptops, rather than encoding the scheduling policy using cryptop
flags.  Convert GELI, the only user of this interface (disabled by
default) to use the new interface.

Add CRYPTO_SESS_SYNC(), which can be used by consumers to determine
whether crypto requests will be dispatched synchronously. This is just
a helper macro. Use it instead of looking at cap flags directly.

Fix style in crypto_done(). Also get rid of CRYPTO_RETW_EMPTY() and
just check the relevant queues directly. This could result in some
unnecessary wakeups but I think it's very uncommon to be using more than
one queue per worker in a given workload, so checking all three queues
is a waste of cycles.

Reviewed by: jhb
Sponsored by: Ampere Computing
Submitted by: Klara, Inc.
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28194

3 years agoarmv8crypto: Extract GCM state into a structure
Mark Johnston [Mon, 8 Feb 2021 14:19:10 +0000 (09:19 -0500)]
armv8crypto: Extract GCM state into a structure

This makes it easier to refactor the GCM code to operate on
crypto_buffer_cursors rather than plain contiguous buffers, with the aim
of minimizing the amount of copying and zeroing done today.

No functional change intended.

Reviewed by: jhb
MFC after: 1 week
Sponsored by: Ampere Computing
Submitted by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D28500

3 years agoarmv8crypto: Fix some edge cases in the AES-GCM implementation
Mark Johnston [Mon, 8 Feb 2021 14:19:07 +0000 (09:19 -0500)]
armv8crypto: Fix some edge cases in the AES-GCM implementation

- We were only hashing up to the first 16 bytes of the AAD.
- When computing the digest during decryption, handle the case where
  len == trailer, i.e., len < AES_BLOCK_LEN, properly.

While here:

- trailer is always smaller than AES_BLOCK_LEN, so remove a pair of
  unnecessary modulus operations.
- Replace some byte-by-byte loops with memcpy() and memset() calls.
  In particular, zero the full block before copying a partial block into
  it since we do that elsewhere and it means that the memset() length is
  known at compile time.

Reviewed by: jhb
Sponsored by: Ampere Computing
Submitted by: Klara, Inc.
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D28501

3 years agoktls: Make configuration sysctls available as tunables
Mark Johnston [Mon, 8 Feb 2021 14:19:02 +0000 (09:19 -0500)]
ktls: Make configuration sysctls available as tunables

Reviewed by: gallatin, jhb
Sponsored by: Ampere Computing
Submitted by: Klara, Inc.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28499

3 years agoktls: Use COUNTER_U64_DEFINE_EARLY
Mark Johnston [Mon, 8 Feb 2021 14:18:51 +0000 (09:18 -0500)]
ktls: Use COUNTER_U64_DEFINE_EARLY

This makes it a bit more straightforward to add new counters when
debugging.  No functional change intended.

Reviewed by: jhb
Sponsored by: Ampere Computing
Submitted by: Klara, Inc.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28498

3 years agonetgraph/ng_base: Allow larger BINARY2ASCII conversions
Lutz Donnerhacke [Sun, 7 Feb 2021 21:07:34 +0000 (22:07 +0100)]
netgraph/ng_base: Allow larger BINARY2ASCII conversions

Allocate the necessary memory for the conversion dynamically starting
with a value which is sufficient for almost all normal cases.

PR: 187835
Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D23840

3 years agoarm64: optimize set_syscall_retval()
Edward Tomasz Napierala [Mon, 8 Feb 2021 10:46:29 +0000 (10:46 +0000)]
arm64: optimize set_syscall_retval()

Microoptimize set_syscall_retval() for arm64 by predicting
the return value to be zero.  This is similar to what has
been done for other architectures

Reviewed By: emaste, mhorne
Differential Revision: https://reviews.freebsd.org/D26991

3 years agokldload(8): Add note about using kld_list in rc.conf(5)
Daniel Ebdrup Jensen [Mon, 8 Feb 2021 06:49:32 +0000 (07:49 +0100)]
kldload(8): Add note about using kld_list in rc.conf(5)

While here, also recommend that loader.conf(5) should only be used in
order to get to mountroot, as rc(8) is less fragile, faster, and is
easier to fix by booting to single-user mode instead of having to
blacklist modules in the loader.

MFH: 2 weeks

3 years agoepoll: Store epoll_event udata member in ext member of kevent.
Vladimir Kondratyev [Sun, 7 Feb 2021 23:46:14 +0000 (02:46 +0300)]
epoll: Store epoll_event udata member in ext member of kevent.

Current epoll implementation stores udata fields of epoll_event
structure in special dynamically-sized table rather than in udata field
of backing kevent structure because of 2 reasons:
1. Kevent's udata size is smaller than epoll's on 32-bit archs.
2. Kevent's udata can be clobbered on execution EPOLL_CTL_ADD as kqueue
   modifies existing event while epoll returns error in this case.

After r320043 has introduced four new 64bit user data members (ext[]),
we can store epoll udata in one of them and drop aforementioned table.
According to kqueue_register() source code ext members are not updated
when existing kevent is modified that fixes p.2.

As a side effect the patch fixes PR/252582.

Reviewed by: trasz
MFC after: 1 month
Differential revision: https://reviews.freebsd.org/D28169

3 years agopowerpc64: Fix boot on virtual-mode OF (PowerMac G5)
Brandon Bergren [Sun, 7 Feb 2021 22:05:41 +0000 (16:05 -0600)]
powerpc64: Fix boot on virtual-mode OF (PowerMac G5)

In 78599c32efed3247d165302a1fbe8d9203e38974, CFI endproc decoration was
added to locore64.S. However, it missed the subtle detail that
__restartkernel_virtual() falls through to __restartkernel(). This was
causing boot failure on PowerMac G5, as it tried to execute the
epilogue as code.

Fix this by branching to __restartkernel() instead of intentionally
running off the end of the function.

While here, add some additional notes on how the virtual mode restart
works.

MFC after: 3 days

3 years agolinux: add support for SO_PEERSEC getsockopt
Edward Tomasz Napierala [Sun, 7 Feb 2021 20:28:35 +0000 (20:28 +0000)]
linux: add support for SO_PEERSEC getsockopt

It returns "unconfined", like Linux without SELinux would.

Sponsored By: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28164

3 years agonetgraph/ng_bridge: Make simple internal functions read-only
Lutz Donnerhacke [Wed, 13 Jan 2021 22:18:55 +0000 (23:18 +0100)]
netgraph/ng_bridge: Make simple internal functions read-only

The data path in netgraph is designed to work on an read only state of
the whole netgraph network.  Currently this is achived by convention,
there is no technical enforcment.  In the case of NETGRAPH_DEBUG all
nodes can be annotated for debugging purposes, so the strict
enforcment needs to be lifted for this purpose.

This patch is part of a series to make ng_bridge multithreaded, which
is done by rewrite the data path to operate on const.

Reviewed By: kp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28141

3 years agoRevert "netgraph/ng_bridge: Make simple internal functions read-only"
Lutz Donnerhacke [Sun, 7 Feb 2021 16:39:35 +0000 (17:39 +0100)]
Revert "netgraph/ng_bridge: Make simple internal functions read-only"

Patch mass breaks LINT kernels.

This reverts commit bb67e52db143b699bdac1830717930b26a7b5766.

3 years agonetgraph/ng_bridge: Make simple internal functions read-only
Lutz Donnerhacke [Wed, 13 Jan 2021 22:18:55 +0000 (23:18 +0100)]
netgraph/ng_bridge: Make simple internal functions read-only

The data path in netgraph is designed to work on an read only state of
the whole netgraph network.  Currently this is achived by convetion,
there is no technical enforcment.  This patch is part of a series to
make ng_brigde multithreaded, which is done by rewrite the data path
to const handling.

Reviewed By: kp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28141

3 years agonetgraph/ng_bridge: Remove old table ABI
Lutz Donnerhacke [Sat, 6 Feb 2021 22:09:52 +0000 (23:09 +0100)]
netgraph/ng_bridge: Remove old table ABI

This was announced to happen after the 12 relases.
Remove a depeciated ABI.

The complete removal is for HEAD only. I'll remove the #define in
stable/13 as MFC, so the code will still exist in 13.x, but will not
included by default. Earlier versions will not be affected.

Reviewed by: kp
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D28518

3 years agoUpdate Mentor and Mentee Information (eduardo)
Nuno Eduardo Simões Leal Teixeira [Sun, 7 Feb 2021 13:46:13 +0000 (13:46 +0000)]
Update Mentor and Mentee Information (eduardo)

3 years agolinux: fix handling of flags for 32 bit send(2) syscall
Edward Tomasz Napierala [Fri, 5 Feb 2021 17:24:23 +0000 (17:24 +0000)]
linux: fix handling of flags for 32 bit send(2) syscall

Previously the flags were passed as-is, which could resulted
in spurious EAGAIN returned for non-blocking sockets, which
broke some Steam games.

PR: 248065
Reported By: Alex S <iwtcex@gmail.com>
Tested By: Alex S <iwtcex@gmail.com>
Reviewed By: emaste
MFC After: 3 days
Sponsored By: The FreeBSD Foundation

3 years agolastcomm(1): Only install if MK_ACCT is on
Emmanuel Vadot [Sat, 6 Feb 2021 19:41:39 +0000 (20:41 +0100)]
lastcomm(1): Only install if MK_ACCT is on

MFC after: 3 days

3 years agonetgraph/ng_bridge: switch stats to counter framework
Lutz Donnerhacke [Wed, 13 Jan 2021 06:16:34 +0000 (07:16 +0100)]
netgraph/ng_bridge: switch stats to counter framework

This is the first patch of a series of necessary steps
to make ng_bridge(4) multithreaded.

Reviewed by: melifaro (network), afedorov
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D28125

3 years agonetgraph/ng_bridge: Derive forwarding mode from first attached hook
Lutz Donnerhacke [Sat, 6 Feb 2021 10:25:04 +0000 (11:25 +0100)]
netgraph/ng_bridge: Derive forwarding mode from first attached hook

Handling of unknown MACs on an bridge with incomplete learning
capabilites (aka uplink ports) can be defined in different ways.

The classical approach is to broadcast unicast frames send to an
unknown MAC, because the unknown devices can be everywhere. This mode
is default for ng_bridge(4).

In the case of dedicated uplink ports, which prohibit learning of MAC
addresses in order to save memory and CPU cycles, the broadcast
approach is dangerous. All traffic to the uplink port is broadcasted
to every downlink port, too. In this case, it's better to restrict the
distribution of frames to unknown MAC to the uplink ports only.

In order to keep the chance small and the handling as natural as
possible, the first attached link is used to determine the behaviour
of the bridge: If it is an "uplink" port, then the bridge switch from
classical mode to restricted mode.

Reviewed By: kp
Approved by: kp (mentor)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28487

3 years agong_bridge.4: Use more suitable mandoc macros
Lutz Donnerhacke [Fri, 5 Feb 2021 21:24:06 +0000 (22:24 +0100)]
ng_bridge.4: Use more suitable mandoc macros

yuripv@ suggested to replace inapprobriate macros by better ones.

Reviewed by: philip
Approved by: philip (mentor)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28510

3 years agonetgraph/ng_bridge: Introduce "uplink" ports without MAC learning
Lutz Donnerhacke [Sat, 6 Feb 2021 10:08:24 +0000 (11:08 +0100)]
netgraph/ng_bridge: Introduce "uplink" ports without MAC learning

The ng_bridge(4) node is designed to work in moderately small
environments. Connecting such a node to a larger network rapidly fills
the MAC table for no reason. It even become complicated to obtain data
from the gettable message, because the result is too large to
transmit.

This patch introduces, two new functionality bits on the hooks:
  - Allow or disallow MAC address learning for incoming patckets.
  - Allow or disallow sending unknown MACs through this hook.

Uplinks are characterized by denied learing while sending out
unknowns. Normal links are charaterized by allowed learning and
sending out unknowns.

Reviewed by: kp
Approved by: kp (mentor)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D23963

3 years agoipfilter: Use the softn (NAT softc) host map size in ip_nat6 calculation.
Cy Schubert [Fri, 5 Feb 2021 14:26:04 +0000 (06:26 -0800)]
ipfilter: Use the softn (NAT softc) host map size in ip_nat6 calculation.

The ipfilter NAT table host map size is a tunable that defaults to
a macro value defined at build time. HOSTMAP_SIZE is saved in softn
(the ipnat softc) at initialization. It can be tuned (changed) at runtime
using the ipf -T command. If the hostmap_size tunable is adjusted the
calculation to determine where to put new entries in the table was
incorrect. Use the tunable in the NAT softc instead of the static build
time value.

MFC after: 1 week

3 years agoSimplify FreeBSD check.
Cy Schubert [Wed, 3 Feb 2021 03:24:05 +0000 (19:24 -0800)]
Simplify FreeBSD check.

MFC after: 1 week

3 years agoSimplify BSD macro tests.
Cy Schubert [Wed, 3 Feb 2021 03:18:48 +0000 (19:18 -0800)]
Simplify BSD macro tests.

All FreeBSD and NetBSD are BSD >= 199306 and have been for a long time.

MFC after: 1 week

3 years agopowerpc64le: readd COMPAT_FREEBSD11 and COMPAT_FREEBSD12
Piotr Kubaj [Sat, 6 Feb 2021 02:21:55 +0000 (03:21 +0100)]
powerpc64le: readd COMPAT_FREEBSD11 and COMPAT_FREEBSD12

lang/rust needs COMPAT_FREEBSD11 to build, even though powerpc64le itself is supported only since 13.0.
I also corrected a comment, because if we ever have lib32 for powerpc64le, it will be for powerpcle.

Reviewed by: bdragon (on IRC)

3 years agocache: remove the largely obsolete general description
Mateusz Guzik [Fri, 5 Feb 2021 23:16:55 +0000 (00:16 +0100)]
cache: remove the largely obsolete general description

Examples of inconsistencies with the current state:
- references LRU of all entries, removed years ago
- references a non-existent lock (neglist)
- claims negative entries have a NULL target

It will be replaced with a more accurate and more informative
description.

In the meantime take it out so it stops misleading.

3 years agocache: fix vfs:namecache:lookup:miss probe call sites
Mateusz Guzik [Fri, 5 Feb 2021 22:58:27 +0000 (23:58 +0100)]
cache: fix vfs:namecache:lookup:miss probe call sites

3 years agocache: drop spurious arg from panic in cache_validate
Mateusz Guzik [Fri, 5 Feb 2021 22:49:59 +0000 (23:49 +0100)]
cache: drop spurious arg from panic in cache_validate

vp is already reported when noting mismatch

3 years agocache: comment on FNV
Mateusz Guzik [Wed, 3 Feb 2021 20:44:54 +0000 (21:44 +0100)]
cache: comment on FNV

3 years agoPrint DeviceHandle and PhysicalId in hex.
Alexander Motin [Fri, 5 Feb 2021 21:13:55 +0000 (16:13 -0500)]
Print DeviceHandle and PhysicalId in hex.

The first is actually a bitfield.  The second is printed in hex by
dmidecode, so uniformidy should be good.

MFC after: 1 week

3 years ago[POWERPC64LE] add mrsas to GENERIC64LE
Alfredo Dal'Ava Junior [Thu, 4 Feb 2021 06:12:38 +0000 (03:12 -0300)]
[POWERPC64LE] add mrsas to GENERIC64LE

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

3 years agomrsas: update man page
Alfredo Dal'Ava Junior [Thu, 4 Feb 2021 06:13:13 +0000 (03:13 -0300)]
mrsas: update man page

update mrsas(4) since big-endian is supported since
e34a057ca6ebdf8e30ec8b0dc21d18eb450bf36a

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

3 years agorelease: disable the 'reldoc' target after the ASCIIDoctor switch
Glen Barber [Fri, 5 Feb 2021 16:46:49 +0000 (11:46 -0500)]
release: disable the 'reldoc' target after the ASCIIDoctor switch

The 'reldoc' target includes release-related documentation on
installation medium.  Since the switch from XML to ASCIIDoctor,
the file locations have moved, and it will take some time to sort
out how this target should work now.

MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agotruss: Decode sendfile(2) arguments
Mark Johnston [Fri, 5 Feb 2021 16:28:09 +0000 (11:28 -0500)]
truss: Decode sendfile(2) arguments

MFC after: 2 weeks

3 years agomrsas: unbreak i386 build
Alfredo Dal'Ava Junior [Fri, 5 Feb 2021 18:43:48 +0000 (15:43 -0300)]
mrsas: unbreak i386 build

Fix build regression introduced by
e34a057ca6ebdf8e30ec8b0dc21d18eb450bf36a

Reviewed by: jhibbits
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D28494

3 years agoImprove ACPI_NFIT_CONTROL_REGION formatting.
Alexander Motin [Fri, 5 Feb 2021 15:07:37 +0000 (10:07 -0500)]
Improve ACPI_NFIT_CONTROL_REGION formatting.

MFC after: 1 week

3 years agotools/git: Add git-arc
Mark Johnston [Fri, 5 Feb 2021 14:44:47 +0000 (09:44 -0500)]
tools/git: Add git-arc

This is a handy script for creating and updating Differential revisions
from git commits.  It tries to avoid forcing the user to manage their
git tree in any particular way, but makes two major assumptions:
- there is a one-to-one mapping between git commits and Differential
  revisions,
- the title of a Differential revision is the same as the summary line
  of the corresponding commit.

A verbose description of the script's functionality is provided in its
usage message, which should probably be converted to a man page.

A description of workflows using git-arc is here:
https://lists.freebsd.org/pipermail/freebsd-hackers/2021-January/056979.html

There are some loose ends but this is functional enough to be useful.

Discussed with: jhb
Differential Revision: https://reviews.freebsd.org/D28334

3 years agoAdd support for arm64 nGnRE device memory
Andrew Turner [Fri, 5 Feb 2021 10:50:29 +0000 (10:50 +0000)]
Add support for arm64 nGnRE device memory

On arm64 we can select how strongly we order device memory. Currently
we use the strongest type of non-Gathering, non-Reordering, no Early
write acknowledgement. This is equivalent to VM_MEMATTR_SO in the 32-bit
arm code.

Create a new memory type to remove the no Early write acknowledgement
option to create a memory attribute that is equivalent to the arm
VM_MEMATTR_DEVICE.

Keep the the old nGnRnE memory as what we provide for VM_MEMATTR_DEVICE
until we can test nGnRE on more hardware. A method for dynamically
switching back may be needed as at least one vendor is known to have
broken nGnRE memory.

Sponsored by: Innovate UK

3 years agogrep: turn off -w if -x is specified
Kyle Evans [Thu, 4 Feb 2021 21:35:58 +0000 (15:35 -0600)]
grep: turn off -w if -x is specified

-x overcomes -w in gnugrep, and it should here as well.  Flip it off as
needed to avoid confusing other parts of grep.

3 years agogrep: fix null pattern and empty pattern file behavior
Kyle Evans [Thu, 4 Feb 2021 21:26:45 +0000 (15:26 -0600)]
grep: fix null pattern and empty pattern file behavior

The null pattern semantics were terrible because I tried to match gnugrep,
but I got it wrong.  Let's unwind that:

- The null pattern should match every line if neither -w nor -x.
- The null pattern should match empty lines if -x.
- The null pattern should not match any lines if -w.

The first two will stop processing (shortcut) even if additional patterns
are specified. In any other case, we will continue processing other
patterns.  If no other patterns are specified beside a null pattern, then
we match if neither -w nor -x or set and do not match if either of those
are specified.

The justification for -w is that it should match on a whole word, but the
null pattern deos not have a whole word to match on.

Empty pattern files should never match anything, and more importantly, -v
should cause everything to be written.

PR: 253209
MFC-after: 4 days

3 years agocpucontrol(8): Fix display.
Konstantin Belousov [Fri, 5 Feb 2021 01:00:27 +0000 (03:00 +0200)]
cpucontrol(8): Fix display.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

3 years agoamd64 GENERIC: compile in mlx5en(4)
Konstantin Belousov [Wed, 3 Feb 2021 12:19:12 +0000 (14:19 +0200)]
amd64 GENERIC: compile in mlx5en(4)

Reviewed by: hselasky, manu
Sponsored by: NVidia Networking/Mellanox Technologies
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D28469

3 years agoEnable pvscsi and vmx in arm64 GENERIC
Ed Maste [Fri, 5 Feb 2021 00:14:12 +0000 (19:14 -0500)]
Enable pvscsi and vmx in arm64 GENERIC

FreeBSD pvscsi and vmx work with VMware ESXi Arm "Fling"; provide these
in GENERIC for a convenient out-of-the-box experience.

PR: 253202
Reported by: Vincent Milum Jr
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

3 years agoixl(4): Fix VLAN HW filtering
Krzysztof Galazka [Wed, 3 Feb 2021 23:22:55 +0000 (15:22 -0800)]
ixl(4): Fix VLAN HW filtering

X700 family of controllers has limited number of available VLAN
HW filters. Driver did not handle properly a case when user
assigned more VLANs to the interface which had all filters
already in use. Fix that by disabling HW filtering when
it is impossible to create filters for all requested VLANs.
Keep track of registered VLANs using bitstring to be able
to re-enable HW filtering when number of requested VLANs
drops below the limit.

Also switch all allocations to use M_IXL malloc type
to ease detecting memory leaks in the driver.

Reviewed by: erj
Tested by: gowtham.kumar.ks@intel.com
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28137

3 years agoloader.efi: There are systems without ConOut, also use ConOutDev
Toomas Soome [Thu, 4 Feb 2021 20:49:02 +0000 (22:49 +0200)]
loader.efi: There are systems without ConOut, also use ConOutDev

Conout does contian the default output device name.
ConOutDev does contain all possible output device names, so we can
use it as fallback, when there is no ConOut.

PR: 253253

3 years agoAdd a comment notifying that "device axp" requires miibus for build.
Muhammad Moinur Rahman [Thu, 4 Feb 2021 21:05:47 +0000 (21:05 +0000)]
Add a comment notifying that "device axp" requires miibus for build.

Although if RJ-45 interface is not being used the miibus is not required
but miibus is a build time dependency.

Reviewed by:    imp, manu, rajesh1.kumar@amd.com
Approved by:    imp, manu, rajesh1.kumar@amd.com
Differential Revision:  https://reviews.freebsd.org/D28465

3 years agoFix mismerge in OFED update
Ryan Stone [Fri, 29 Jan 2021 20:48:50 +0000 (15:48 -0500)]
Fix mismerge in OFED update

When OFED was upgraded to Linux v4.9, a bunch of Linux-specific
netlink changes were dropped.  Unfortunately, there was a mismerge
in this process and as a result ib_sa_cancel_query() would fail to
cancel an outstanding MAD.

This was causing rdma_destroy_id() to hang indefinitely waiting
for the MAD to complete and release the final reference.

Sponsored by: Dell Inc.
Differential Revision: https://reviews.freebsd.org/D28421
Reviewed by: hselasky, kib
MFC after: 2 months

3 years agoFix race condition in linuxkpi workqueue
Ryan Stone [Thu, 7 Jan 2021 17:25:56 +0000 (12:25 -0500)]
Fix race condition in linuxkpi workqueue

Consider the following scenario:

1. A delayed_work struct in the WORK_ST_TIMER state.
2. Thread A calls mod_delayed_work()
3. Thread B (a callout thread) simultaneously calls
linux_delayed_work_timer_fn()

The following sequence of events is possible:

A: Call linux_cancel_delayed_work()
A: Change state from TIMER TO CANCEL
B: Change state from CANCEL to TASK
B: taskqueue_enqueue() the task
A: taskqueue_cancel() the task
A: Call linux_queue_delayed_work_on().  This is a no-op because the
state is WORK_ST_TASK.

As a result, the delayed_work struct will never be invoked.  This is
causing address resolution in ib_addr.c to stop permanently, as it
never tries to reschedule a task that it thinks is already scheduled.

Fix this by introducing locking into the cancel path (which
corresponds with the lock held while the callout runs).  This will
prevent the callout from changing the state of the task until the
cancel is complete, preventing the race.

Differential Revision: https://reviews.freebsd.org/D28420
Reviewed by: hselasky
MFC after: 2 months

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

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

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

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.

3 years agoserf: Fix the default return value of the BIO control method.
John Baldwin [Wed, 3 Feb 2021 22:59:32 +0000 (14:59 -0800)]
serf: Fix the default return value of the BIO control method.

OpenSSL BIO classes provide an abstraction for dealing with I/O.
OpenSSL provides BIO classes for commonly used I/O primitives backed
by file descriptors, sockets, etc. as well as permitting consumers
of OpenSSL to define custom BIO classes.

One of the methods BIO classes implement is a control method invoked
by BIO_ctrl() for various ancilliary tasks somewhat analgous to
fcntl() and ioctl() on file descriptors.  According to the BIO_ctrl(3)
manual page, control methods should return 0 for unknown control
requests.

KTLS support in OpenSSL adds new control requests.  Two of those new
requests are queries to determine if KTLS is enabled for either
reading or writing.  These control reuquest return 1 if KTLS is
enabled and 0 if it is not.

serf includes two custom BIO classes for wrapping I/O requests from
files and from a buffer in memory.  These BIO classes both use a
custom control method.  However, this custom control method was
returning 1 for unknown or unsupported control requests instead of 0.
As a result, OpenSSL with KTLS believed that these BIOs were using
KTLS and were thus adding headers and doing encryption/decryption in
the BIO.  Correcting the return value removes this confusion.

PR: 253135
Reported by: Guido Falsi <mad@madpilot.net>
Reviewed by: emaste
MFC after: 3 days
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D28472

3 years ago[POWERPC64BE] add mrsas driver to GENERIC64
Alfredo Dal'Ava Junior [Thu, 4 Feb 2021 01:02:28 +0000 (22:02 -0300)]
[POWERPC64BE] add mrsas driver to GENERIC64

Submitted by:   Andre Fernando da Silva <andre.silva@eldorado.org.br>
Reviewed by:    luporl, alfredo, kadesai (on email)
Sponsored by:   Eldorado Research Institute (eldorado.org.br)
Differential Revision:  https://reviews.freebsd.org/D26531

3 years ago[POWERPC64BE] mrsas: add big-endian support
Alfredo Dal'Ava Junior [Thu, 4 Feb 2021 00:52:19 +0000 (21:52 -0300)]
[POWERPC64BE] mrsas: add big-endian support

Add endiannes conversions in order to support big-endian platforms

Submitted by: Andre Fernando da Silva <andre.silva@eldorado.org.br>
Reviewed by: luporl, alfredo, kadesai (on email)
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D26531

3 years agoreadelf: do not trucate section name with -W
Ed Maste [Tue, 2 Feb 2021 14:35:04 +0000 (09:35 -0500)]
readelf: do not trucate section name with -W

PR: 246015
Reviewed by: cem
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28461

3 years agoreadelf: decode LA48 and ASG_DISABLE feature flags
Ed Maste [Wed, 3 Feb 2021 21:16:45 +0000 (16:16 -0500)]
readelf: decode LA48 and ASG_DISABLE feature flags

MFC after: 1 week
Sponsored by: The FreeBSD Foundation