]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agotests/sys/audit: Skip extattr tests if extattrs are not supported
Alex Richardson [Tue, 2 Feb 2021 09:55:18 +0000 (09:55 +0000)]
tests/sys/audit: Skip extattr tests if extattrs are not supported

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

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

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

(cherry picked from commit 40407d3998d1a12cbe929721f4dbe72b4be478a6)

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

Reported by: jrtc27

(cherry picked from commit d4a6843bb1207d71234099ded81cee75d3ae8864)

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

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

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

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

(cherry picked from commit 869cc06480b75b4caea0d049e0cf7f82bb5aeed1)

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

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

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

(cherry picked from commit 83ff5d5d98cbcf9b66dccd70022358aec8918a14)

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

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

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

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

(cherry picked from commit 3454fa118c41a588e2dad20614325297c989c60b)

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

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

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

(cherry picked from commit bcc5b2445674e4691853d7533e4873a6712f67ee)

3 years agokerberos5: Silence compiler warnings
Alex Richardson [Wed, 27 Jan 2021 10:41:57 +0000 (10:41 +0000)]
kerberos5: Silence compiler warnings

Building the kerberos5 subdirectory currently produces lots of warnings.
Since there are many instances of these warnings and it's contrib code,
this change silences the warnings instead of fixing them.

Reviewed By: jhb, cy, bjk
Differential Revision: https://reviews.freebsd.org/D28025

(cherry picked from commit 4f009328a2477f5f1c682629fc5708498b7c689f)

3 years agokern.mk: Fix wrong variable being used for linker path after 172a624f0
Alex Richardson [Mon, 8 Mar 2021 09:37:39 +0000 (09:37 +0000)]
kern.mk: Fix wrong variable being used for linker path after 172a624f0

When I synchronized kern.mk with bsd.sys.mk, I accidentally changed
CCLDFLAGS to LDFLAGS which is not used by the kernel builds. This commit
should unbreak the GitHub actions cross-build CI. I didn't notice it
locally because cheribuild already passes -fuse-ld in the linker flags as
it predates this being done in the makefiles.

Reported By: Jose Luis Duran
Fixes: 172a624f0 ("Silence annoying and incorrect non-default linker warning with GCC")

(cherry picked from commit 01fe4cac28d0b5ab2b8f4ef081fd3c81dcbb4df3)

3 years agoSilence annoying and incorrect non-default linker warning with GCC
Alex Richardson [Thu, 4 Mar 2021 18:27:37 +0000 (18:27 +0000)]
Silence annoying and incorrect non-default linker warning with GCC

The CROSS_TOOLCHAIN GCC .mk files include -B${CROSS_BINUTILS_PREFIX}, so
GCC will select the right linker and we don't need to warn.
While here also apply 17b8b8fb5fc4acc832dabfe7ef11e3e1d399ad0f to kern.mk.

Test Plan: no more warning printed with CROSS_TOOLCHAIN=mips-gcc6
Reviewed By: jhb
Differential Revision: https://reviews.freebsd.org/D29015

(cherry picked from commit 172a624f0c9fbc47d74fd5178d46f771f82dc6a0)

3 years agoreadelf: Fix printing NT_FREEBSD_ARCH_TAG
Alex Richardson [Wed, 3 Feb 2021 15:24:28 +0000 (15:24 +0000)]
readelf: Fix printing NT_FREEBSD_ARCH_TAG

Looking at lib/csu/arm/crt1_s.S, this should be a string and therefore the
restriction to 4 characters seems wrong.
Found whle updating https://reviews.llvm.org/D74393.

Reviewed By: emaste
Differential Revision: https://reviews.freebsd.org/D28470

(cherry picked from commit 2a39919364b5368e026f656ff41861a3fdd56110)

3 years agosys/arm64/arm64/vfp.c: Fix -Wunused and -Wpointer-sign warnings
Alex Richardson [Thu, 4 Mar 2021 14:55:29 +0000 (14:55 +0000)]
sys/arm64/arm64/vfp.c: Fix -Wunused and -Wpointer-sign warnings

These are off by default but were flagged by my IDE while adding some
debugging printfs for D29060.

(cherry picked from commit 0072e5e0f3a0bb3aa06708ba64497ef75021d431)

3 years agotmpfs: implement pathconf(_PC_SYMLINK_MAX)
Alex Richardson [Wed, 17 Mar 2021 09:49:49 +0000 (09:49 +0000)]
tmpfs: implement pathconf(_PC_SYMLINK_MAX)

This fixes one of the sys/audit tests when running them on tmpfs.

Reviewed By: delphij, kib
Differential Revision: https://reviews.freebsd.org/D28387

(cherry picked from commit 1d15bceae63c438e3ff7dc7a0ca8a2c538e357b9)

3 years agoCreate symlinks to host tools on non-FreeBSD hosts
Alex Richardson [Wed, 17 Mar 2021 09:48:28 +0000 (09:48 +0000)]
Create symlinks to host tools on non-FreeBSD hosts

This is unnecessary when cross-building from Linux/macOS.
Additionally, cp -p appears to be broken on macOS Big Sur
(https://openradar.appspot.com/8957219).

For some unknown reason this commit appears to fix
freezes when building on macOS Big Sur.
This also fixes building in docker with volume mounts
with ACLs, since setting the ACL with cp -p fails otherwise.

Obtained From: CheriBSD
Tested By: gnn (macOS Big Sur), Nathaniel Wesley Filardo (docker)
Reviewed By: jrtc27, imp
Differential Revision: https://reviews.freebsd.org/D28267

(cherry picked from commit a8b20f4fabbca9bef377009429848d4f9cea18ae)

3 years agolibc/qsort: Don't allow interposing recursive calls
Alex Richardson [Thu, 18 Feb 2021 10:12:29 +0000 (10:12 +0000)]
libc/qsort: Don't allow interposing recursive calls

This causes problems when using ASAN with a runtime older than 12.0 since
the intercept does not expect qsort() to call itself using an interposable
function call. This results in infinite recursion and stack exhaustion
when a binary compiled with -fsanitize=address calls qsort.
See also https://bugs.llvm.org/show_bug.cgi?id=46832 and
https://reviews.llvm.org/D84509 (ASAN runtime patch).

To prevent this problem, this patch uses a static helper function
for the actual qsort() implementation. This prevents interposition and
allows for direct calls. As a nice side-effect, we can also move the
qsort_s checks to the top-level function and out of the recursive calls.

Reviewed By: kib
Differential Revision: https://reviews.freebsd.org/D28133

(cherry picked from commit cbcfe28f9d5f975f97b7fb4a0d72bc9780eb0c46)

3 years agoAArch64: Don't set flush-subnormals-to-zero flag on startup
Alex Richardson [Mon, 1 Mar 2021 14:27:30 +0000 (14:27 +0000)]
AArch64: Don't set flush-subnormals-to-zero flag on startup

This flag has been set on startup since 65618fdda0f272a823e6701966421bdca0efa301.
However, This causes some of the math-related tests to fail as they report
zero instead of a tiny number. This fixes at least
/usr/tests/lib/msun/ldexp_test and possibly others.
Additionally, setting this flag prevents printf() from printing subnormal
numbers in decimal form.
See also https://www.openwall.com/lists/musl/2021/02/26/1

PR: 253847
Reviewed By: mmel
Differential Revision: https://reviews.freebsd.org/D28938

(cherry picked from commit 0e4ff0acbe80c547988bede738af2e227c7eb47c)

3 years agoArch64: Clear VFP state on execve()
Alex Richardson [Tue, 9 Mar 2021 19:11:40 +0000 (19:11 +0000)]
Arch64: Clear VFP state on execve()

I noticed that many of the math-related tests were failing on AArch64.
After a lot of debugging, I noticed that the floating point exception flags
were not being reset when starting a new process. This change resets the
VFP inside exec_setregs() to ensure no VFP register state is leaked from
parent processes to children.

This commit also moves the clearing of fpcr that was added in 65618fdda0f27
from fork() to execve() since that makes more sense: fork() can retain
current register values, but execve() should result in a well-defined
clean state.

Reviewed By: andrew
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29060

(cherry picked from commit 953a7d7c61f3b2f5351dfe668510ec782ae282e8)

3 years agoFix fget_only_user() to return ENOTCAPABLE on a failed capsicum check
Alex Richardson [Mon, 15 Feb 2021 22:09:33 +0000 (22:09 +0000)]
Fix fget_only_user() to return ENOTCAPABLE on a failed capsicum check

After eaad8d1303da500ed691bd774742a4555a05e729 four additional
capsicum-test tests started failing. It turns out this is because
fget_only_user() was returning EBADF on a failed capsicum check instead
of forwarding the return value of cap_check_inline() like
fget_unlocked_seq().

capsicum-test failures before this:
```
[  FAILED  ] 7 tests, listed below:
[  FAILED  ] Capability.OperationsForked
[  FAILED  ] Capability.NoBypassDAC
[  FAILED  ] Pdfork.OtherUserForked
[  FAILED  ] PipePdfork.WildcardWait
[  FAILED  ] OpenatTest.WithFlag
[  FAILED  ] ForkedOpenatTest_WithFlagInCapabilityMode._
[  FAILED  ] Select.LotsOFileDescriptorsForked
```
After:
```
[  FAILED  ] 3 tests, listed below:
[  FAILED  ] Capability.NoBypassDAC
[  FAILED  ] Pdfork.OtherUserForked
[  FAILED  ] PipePdfork.WildcardWait
```

Reviewed By: mjg
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28691

(cherry picked from commit 0482d7c9e944433abc98fc27a265ae762abce9a0)

3 years agomsun: ctanh/ctanhf: Import fix from musl libc
Alex Richardson [Mon, 15 Feb 2021 22:06:41 +0000 (22:06 +0000)]
msun: ctanh/ctanhf: Import fix from musl libc

This applies musl commit b02eed9c4841913d690a2d0029737d72615384fe by
Szabolcs Nagy and updates the tests accordingly. This also allows
removing an XFAIL from the test.

musl commit message:

complex: fix ctanh(+-0+i*nan) and ctanh(+-0+-i*inf)

These cases were incorrect in C11 as described by
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1886.htm

PR: 217528

Reviewed By: dim
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28578

(cherry picked from commit a7b42c4b7f7ad7bd1b22ab57ed9185bdcea6f0a2)

3 years agovm: Round up npages and alignment for contig reclamation
Mark Johnston [Tue, 2 Mar 2021 15:19:53 +0000 (10:19 -0500)]
vm: Round up npages and alignment for contig reclamation

When searching for runs to reclaim, we need to ensure that the entire
run will be added to the buddy allocator as a single unit.  Otherwise,
it will not be visible to vm_phys_alloc_contig() as it is currently
implemented.  This is a problem for allocation requests that are not a
power of 2 in size, as with 9KB jumbo mbuf clusters.

Reported by: alc
Reviewed by: alc
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28924

(cherry picked from commit 0401989282d1bb9972ae2bf4862c2c6c92ae5f27)

3 years agonfsclient: Fix ReadDS/WriteDS/CommitDS nfsstats RPC counts for a NFSv3 DS
Rick Macklem [Tue, 2 Mar 2021 22:18:23 +0000 (14:18 -0800)]
nfsclient: Fix ReadDS/WriteDS/CommitDS nfsstats RPC counts for a NFSv3 DS

During a recent virtual NFSv4 testing event, a bug in the FreeBSD client
was detected when doing I/O DS operations on a Flexible File Layout pNFS
server.  For an NFSv3 DS, the Read/Write/Commit nfsstats were incremented
instead of the ReadDS/WriteDS/CommitDS counts.
This patch fixes this.

Only the RPC counts reported by nfsstat(1) were affected by this bug,
the I/O operations were performed correctly.

(cherry picked from commit c04199affeacbd9e9dda3aaf5ca0b1b180031e78)

3 years agonfsclient: Fix the stripe unit size for a File Layout pNFS layout
Rick Macklem [Mon, 1 Mar 2021 20:49:32 +0000 (12:49 -0800)]
nfsclient: Fix the stripe unit size for a File Layout pNFS layout

During a recent virtual NFSv4 testing event, a bug in the FreeBSD client
was detected when doing a File Layout pNFS DS I/O operation.
The size of the I/O operation was smaller than expected.
The I/O size is specified as a stripe unit size in bits 6->31 of nflh_util
in the layout.  I had misinterpreted RFC5661 and had shifted the value
right by 6 bits. The correct interpretation is to use the value as
presented (it is always an exact multiple of 64), clearing bits 0->5.
This patch fixes this.

Without the patch, I/O through the DSs work, but the I/O size is 1/64th
of what is optimal.

(cherry picked from commit 94f2e42f5e0b78a7a4684d4a4eb62ea470a57eb1)

3 years agonfsclient: add nfs node locking around uses of n_direofoffset
Rick Macklem [Sun, 28 Feb 2021 22:53:54 +0000 (14:53 -0800)]
nfsclient: add nfs node locking around uses of n_direofoffset

During code inspection I noticed that the n_direofoffset field
of the NFS node was being manipulated without any lock being
held to make it SMP safe.
This patch adds locking of the NFS node's mutex around
handling of n_direofoffset to make it SMP safe.

I have not seen any failure that could be attributed to n_direofoffset
being manipulated concurrently by multiple processors, but I think this
is possible, since directories are read with shared vnode
locking, plus locks only on individual buffer cache blocks.
However, there have been as yet unexplained issues w.r.t reading
large directories over NFS that could have conceivably been caused
by concurrent manipulation of n_direofoffset.

(cherry picked from commit 15bed8c46b32dec19e922cb89e12c8970867a303)

3 years agonfsclient: add checks for a server returning the current directory
Rick Macklem [Sun, 28 Feb 2021 22:15:32 +0000 (14:15 -0800)]
nfsclient: add checks for a server returning the current directory

Commit 3fe2c68ba20f dealt with a panic in cache_enter_time() where
the vnode referred to the directory argument.
It would also be possible to get these panics if a broken
NFS server were to return the directory as an new object being
created within the directory or in a Lookup reply.

This patch adds checks to avoid the panics and logs
messages to indicate that the server is broken for the
file object creation cases.

(cherry picked from commit 3e04ab36ba5ce5cbbf6d22f17a01a391a04e465f)

3 years agodumpon.8: Ask DDB to call doadump() rather than calling it directly
Mark Johnston [Mon, 8 Mar 2021 17:39:05 +0000 (12:39 -0500)]
dumpon.8: Ask DDB to call doadump() rather than calling it directly

Sponsored by: The FreeBSD Foundation

(cherry picked from commit af06ff55535d9b2de253103e974558104e0a3d97)

3 years agoRename _cscan_atomic.h and _cscan_bus.h to atomic_san.h and bus_san.h
Mark Johnston [Mon, 8 Mar 2021 17:39:06 +0000 (12:39 -0500)]
Rename _cscan_atomic.h and _cscan_bus.h to atomic_san.h and bus_san.h

Other kernel sanitizers (KMSAN, KASAN) require interceptors as well, so
put these in a more generic place as a step towards importing the other
sanitizers.

No functional change intended.

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

(cherry picked from commit 435c7cfb2418fdac48fa53e29e38ef03646b817d)

3 years agoath_hal: Stop printing messages during boot
Mark Johnston [Mon, 8 Mar 2021 17:39:06 +0000 (12:39 -0500)]
ath_hal: Stop printing messages during boot

ath_hal is compiled into the kernel by default and so always prints a
message to dmesg even when the system has no ath hardware.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 0e72eb460228e4b9cb790beb7113d0a5c88db503)

3 years agoposix timers: Improve the overrun calculation
Mark Johnston [Mon, 8 Mar 2021 17:39:06 +0000 (12:39 -0500)]
posix timers: Improve the overrun calculation

timer_settime(2) may be used to configure a timeout in the past.  If
the timer is also periodic, we also try to compute the number of timer
overruns that occurred between the initial timeout and the time at which
the timer fired.  This is done in a loop which iterates once per period
between the initial timeout and now.  If the period is small and the
initial timeout was a long time ago, this loop can take forever to run,
so the system is effectively DOSed.

Replace the loop with a more direct calculation of
(now - initial timeout) / period to compute the number of overruns.

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

(cherry picked from commit 7995dae9d3f58abf38ef0001cee24131f3c9054b)

3 years agoposix timers: Sprinkle some style fixes
Mark Johnston [Mon, 8 Mar 2021 17:39:06 +0000 (12:39 -0500)]
posix timers: Sprinkle some style fixes

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 60d12ef952a39581e967a1a608522fdbdedefa01)

3 years agoposix timers: Declare unexported functions as static
Mark Johnston [Mon, 8 Mar 2021 17:39:06 +0000 (12:39 -0500)]
posix timers: Declare unexported functions as static

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8ff2b41c05a8f98e30250b929e9722f714f1f319)

3 years agowg: Style
Mark Johnston [Mon, 8 Mar 2021 17:39:05 +0000 (12:39 -0500)]
wg: Style

Sponsored by: The FreeBSD Foundation

(cherry picked from commit d8cebef50e7b5fac1e28bcb1f931962210f9b5f6)

3 years agons8250: don't drop IER_TXRDY on bus_grab/ungrab
Mitchell Horne [Wed, 10 Mar 2021 14:57:12 +0000 (10:57 -0400)]
ns8250: don't drop IER_TXRDY on bus_grab/ungrab

It has been observed that some systems are often unable to resume from
ddb after entering with debug.kdb.enter=1. Checking the status further
shows the terminal is blocked waiting in tty_drain(), but it never makes
progress in clearing the output queue, because sc->sc_txbusy is high.

I noticed that when entering polling mode for the debugger, IER_TXRDY is
set in the failure case. Since this bit is never tracked by the softc,
it will not be restored by ns8250_bus_ungrab(). This creates a race in
which a TX interrupt can be lost, creating the hang described above.
Ensuring that this bit is restored is enough to prevent this, and resume
from ddb as expected.

The solution is to track this bit in the sc->ier field, for the same
lifetime that TX interrupts are enabled.

PR: 223917, 240122
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7e7f7beee732810d3afcc83828341ac3e139b5bd)

3 years agodevelopment(7): update to reflect Git transition
Edward Tomasz Napierala [Thu, 11 Mar 2021 20:03:30 +0000 (20:03 +0000)]
development(7): update to reflect Git transition

Reviewed By: debdrup, imp (earlier version)
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D28939

(cherry picked from commit d28cbb7944e5b1015d94a04cadc97d473838611e)

3 years agolinux(4): make getcwd(2) return ERANGE instead of ENOMEM
Edward Tomasz Napierala [Fri, 12 Mar 2021 15:31:37 +0000 (15:31 +0000)]
linux(4): make getcwd(2) return ERANGE instead of ENOMEM

For native FreeBSD binaries, the return value from __getcwd(2)
doesn't really matter, as the libc wrapper takes over and returns
the proper errno.

PR: kern/254120
Reported By: Alex S <iwtcex@gmail.com>
Reviewed By: kib
Sponsored By: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29217

(cherry picked from commit 0dfbdd9fc269f0438ffcc31632d35234a90584ad)

3 years agoMake kern.timecounter.hardware tunable
Konstantin Belousov [Sun, 7 Mar 2021 23:50:12 +0000 (01:50 +0200)]
Make kern.timecounter.hardware tunable

(cherry picked from commit 56b9bee63a42dbac712acf540f23a4c3dbd099a9)

3 years agoMove ic_check_send_space clear to the actual check.
Alexander Motin [Wed, 3 Mar 2021 20:21:26 +0000 (15:21 -0500)]
Move ic_check_send_space clear to the actual check.

It closes tiny race when the flag could be set between being cleared
and the space is checked, that would create us some more work.  The
flag setting is protected by both locks, so we can clear it in either
place, but in between both locks are dropped.

MFC after: 1 week

(cherry picked from commit afc3e54eeee635a525c88e4678cc38e3219302c3)

3 years agoRestore condition removed in df3747c6607b.
Alexander Motin [Wed, 3 Mar 2021 16:58:04 +0000 (11:58 -0500)]
Restore condition removed in df3747c6607b.

I think it allowed to avoid some TX thread wakeups while the socket
buffer is full.  But add there another options if ic_check_send_space
is set, which means socket just reported that new space appeared, so
it may have sense to pull more data from ic_to_send for better TX
coalescing.

MFC after: 1 week

(cherry picked from commit aff9b9ee894e3e6b6d8c7e4182d6b973804df853)

3 years agoReplace STAILQ_SWAP() with simpler STAILQ_CONCAT().
Alexander Motin [Tue, 2 Mar 2021 23:39:44 +0000 (18:39 -0500)]
Replace STAILQ_SWAP() with simpler STAILQ_CONCAT().

Also remove stray STAILQ_REMOVE_AFTER(), not causing problems only
because STAILQ_SWAP() fixed corrupted stqh_last.

MFC after: 1 week

(cherry picked from commit df3747c6607be12d48db825653e6adfc3041e97f)

3 years agoFix initiator panic after 6895f89fe54e.
Alexander Motin [Tue, 2 Mar 2021 21:07:22 +0000 (16:07 -0500)]
Fix initiator panic after 6895f89fe54e.

There are sessions without socket that are not disconnecting yet.

MFC after: 3 weeks

(cherry picked from commit 06e9c710998b83a3be21f7f264187fff5d590bc3)

3 years agoOptimize TX coalescing by keeping pointer to last mbuf.
Alexander Motin [Tue, 2 Mar 2021 04:31:34 +0000 (23:31 -0500)]
Optimize TX coalescing by keeping pointer to last mbuf.

Before m_cat() each time traversed through all the coalesced chain.

MFC after: 1 week

(cherry picked from commit b85a67f54a40053e75658a17c620b89bafaba67f)

3 years agoOptimize out few extra memory accesses.
Alexander Motin [Mon, 1 Mar 2021 23:35:45 +0000 (18:35 -0500)]
Optimize out few extra memory accesses.

MFC after: 1 week

(cherry picked from commit a59e2982fe3e6339629cc77fe9d349d60e03a05e)

3 years agoMicro-optimize OOA queue processing.
Alexander Motin [Sat, 27 Feb 2021 15:14:05 +0000 (10:14 -0500)]
Micro-optimize OOA queue processing.

- Move ctl_get_cmd_entry() calls from every OOA traversal to when
  the requests first inserted, storing seridx in struct ctl_scsiio.
- Move some checks out of the loop in ctl_check_ooa().
- Replace checks for errors that can not happen with asserts.
- Transpose ctl_serialize_table, so that any OOA traversal accessed
  only one row (cache line).  Compact it from enum to uint8_t.
- Optimize static branch predictions in hottest places.

Due to O(n) nature on deep LUN queues this can be the hottest code
path in CTL, and additional 20% of IOPS I see in some 4KB I/O tests
are good to have in reserve.  About 50% of CPU time here according
to the profiles is now spent in two memory accesses per traversed
request in OOA.

Sponsored by: iXsystems, Inc.
MFC after: 2 weeks

(cherry picked from commit 9d9fd8b79f0ebe59f791c8225fa01ab59858b7b5)

3 years agoCoalesce socket reads in software iSCSI.
Alexander Motin [Mon, 22 Feb 2021 17:23:35 +0000 (12:23 -0500)]
Coalesce socket reads in software iSCSI.

Instead of 2-4 socket reads per PDU this can do as low as one read
per megabyte, dramatically reducing TCP overhead and lock contention.

With this on iSCSI target I can write more than 4GB/s through a
single connection.

MFC after: 1 month

(cherry picked from commit 6895f89fe54e0858aea70d2bd2a9651f45d7998e)

3 years agoFix build after 2c7dc6bae9fd.
Alexander Motin [Sun, 21 Feb 2021 22:21:14 +0000 (17:21 -0500)]
Fix build after 2c7dc6bae9fd.

MFC after: 1 month

(cherry picked from commit c02a28754bc229c05e8baf9b6632cbd59bc73e48)

3 years agoRefactor CTL datamove KPI.
Alexander Motin [Sun, 21 Feb 2021 21:45:14 +0000 (16:45 -0500)]
Refactor CTL datamove KPI.

 - Make frontends call unified CTL core method ctl_datamove_done()
to report move completion.  It allows to reduce code duplication
in differerent backends by accounting DMA time in common code.
 - Add to ctl_datamove_done() and be_move_done() callback samethr
argument, reporting whether the callback is called in the same
context as ctl_datamove().  It allows for some cases like iSCSI
write with immediate data or camsim frontend write save one context
switch, since we know that the context is sleepable.
 - Remove data_move_done() methods from struct ctl_backend_driver,
unused since forever.

MFC after:  1 month

(cherry picked from commit 2c7dc6bae9fd5c2fa0a65768df8e4e99c2f159f1)

3 years agoMicrooptimize CTL I/O queues.
Alexander Motin [Fri, 19 Feb 2021 20:42:57 +0000 (15:42 -0500)]
Microoptimize CTL I/O queues.

Switch OOA queue from TAILQ to LIST and change its direction, so that
we traverse it forward, not backward.  There is only one place where
we really need other direction, and it is not critical.

Use STAILQ_REMOVE_HEAD() instead of STAILQ_REMOVE() in backends.

Replace few impossible conditions with assertions.

MFC after: 1 month

(cherry picked from commit 05d882b780f5be2da6f3d3bfef9160aacc4888d6)

3 years agoSave context switch per I/O for iSCSI and IOCTL frontends.
Alexander Motin [Fri, 19 Feb 2021 03:07:32 +0000 (22:07 -0500)]
Save context switch per I/O for iSCSI and IOCTL frontends.

Introduce new CTL core KPI ctl_run(), preprocessing I/Os in the caller
context instead of scheduling another thread just for that.  This call
may sleep, that is not acceptable for some frontends like the original
CAM/FC one, but iSCSI already has separate sleepable per-connection RX
threads, and another thread scheduling is mostly just a waste of time.
IOCTL frontend actually waits for the I/O completion in the caller
thread, so the use of another thread for this has even less sense.

With this change I can measure ~5% IOPS improvement on 4KB iSCSI I/Os
to ZFS.

MFC after: 1 month

(cherry picked from commit 812c9f48a2b7bccc31b2a6077b299822357832e4)

3 years agoMove XPT_IMMEDIATE_NOTIFY handling out of periph lock.
Alexander Motin [Thu, 18 Feb 2021 21:22:01 +0000 (16:22 -0500)]
Move XPT_IMMEDIATE_NOTIFY handling out of periph lock.

It is a rare, but still better to not have lock dependencies.

MFC after: 1 month

(cherry picked from commit c67a2909a629db138227993e1093e66bb6c00af5)

3 years agonewsyslog(8): Implement a new 'E' flag to not rotate empty log files
Juraj Lutter [Sun, 28 Feb 2021 22:07:14 +0000 (23:07 +0100)]
newsyslog(8): Implement a new 'E' flag to not rotate empty log files

Based on an idea from dvl's coworker, László DANIELISZ, implement
a new flag, 'E', that prevents newsyslog(8) from rotating the empty
log files. This 'E' flag ist mostly usable in conjunction with 'B'
flag that instructs newsyslog(8) to not insert an informational
message into the log file after rotation, keeping it still empty.

Reviewed by: markj, ian, manpages (rpokala)
Approved by: markj, ian, manpages (rpokala)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28940

(cherry picked from commit c7d27b225df8d7fb36a31a21737d4309593c4604)

3 years agoDo not complain about incorrect cylinder group check-hashes when
Kirk McKusick [Fri, 12 Mar 2021 06:44:33 +0000 (22:44 -0800)]
Do not complain about incorrect cylinder group check-hashes when
asked to add them to a filesystem.

Sponsored by: Netflix

(cherry picked from commit 6385cabd5be627c4f395e3abf215882aaeb36320)

3 years agolib/flua/libjail: Allow empty params table
Ryan Moeller [Thu, 25 Feb 2021 05:16:52 +0000 (05:16 +0000)]
lib/flua/libjail: Allow empty params table

The name or jid always gets added to the params, and that's enough to
avoid allocating a 0 length params array.

Reported by: kevans
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D28778

(cherry picked from commit e175b519a6fb83889fb3ca679b73d11ea5bea7ad)

3 years agosbin/ifconfig: Get lagg status with libifconfig
Ryan Moeller [Sat, 27 Feb 2021 03:05:31 +0000 (03:05 +0000)]
sbin/ifconfig: Get lagg status with libifconfig

Also trimmed an unused block of code that never prints out LAGG_PROTOS.
Reviewed by: kp (earlier version)
Differential Revision: https://reviews.freebsd.org/D28961

(cherry picked from commit a0ebb915045ed0056decec5f001471af4e999f61)

3 years agolibifconfig: Add a function to get down reason
Ryan Moeller [Sun, 28 Feb 2021 09:34:30 +0000 (09:34 +0000)]
libifconfig: Add a function to get down reason

For use in ifconfig.

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

(cherry picked from commit b12a960e4274926171dc7a4f9887a0d0a5195b44)

3 years agosbin/ifconfig: Get bridge status with libifconfig
Ryan Moeller [Fri, 26 Feb 2021 23:04:38 +0000 (23:04 +0000)]
sbin/ifconfig: Get bridge status with libifconfig

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

(cherry picked from commit 6f497e47e925f6886f444a8e31e2e939fca264f2)

3 years agosbin/ifconfig: Get groups with libifconfig
Ryan Moeller [Sat, 27 Feb 2021 08:17:04 +0000 (08:17 +0000)]
sbin/ifconfig: Get groups with libifconfig

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

(cherry picked from commit 64bacab177f7c743af3268a3e1ffcddaf77a68d0)

3 years agosbin/ifconfig: Get carp status with libifconfig
Ryan Moeller [Fri, 26 Feb 2021 23:40:58 +0000 (23:40 +0000)]
sbin/ifconfig: Get carp status with libifconfig

A trivial change now that ifconfig is already using libifconfig.
Reviewed by: kp (earlier version)
Differential Revision: https://reviews.freebsd.org/D28955

(cherry picked from commit da393346ac47b22b5f8af4040a59971faadd2c5c)

3 years agosbin/ifconfig: Minor housekeeping
Ryan Moeller [Sun, 28 Feb 2021 02:08:43 +0000 (02:08 +0000)]
sbin/ifconfig: Minor housekeeping

Coalesce adjacent lint ifdefs.
Fix spelling of nitems.

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

(cherry picked from commit 88832d59dec10e97dd64b44391606776b20e782b)

3 years agolibifconfig: Fix typo in symbol map
Ryan Moeller [Wed, 3 Mar 2021 01:55:18 +0000 (01:55 +0000)]
libifconfig: Fix typo in symbol map

(cherry picked from commit 80545a16df95263781b3422695527b6238f4bd2c)

3 years agosbin/ifconfig: Drop local name var in sfp_status
Ryan Moeller [Sun, 28 Feb 2021 02:15:11 +0000 (02:15 +0000)]
sbin/ifconfig: Drop local name var in sfp_status

There is already a globally defined name variable.

(cherry picked from commit 9995455218ff19df9cf0dcaf0198269dc76eeb2d)

3 years agolibifconfig: Set error in ifconfig_get_groups
Ryan Moeller [Sat, 27 Feb 2021 08:07:21 +0000 (08:07 +0000)]
libifconfig: Set error in ifconfig_get_groups

This should return -1 with OTHER/ENOMEM set in the handle when malloc
fails, like everywhere else in libifconfig.

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

(cherry picked from commit 1d9ba697f99a88b321a7d8b96fa142ea774cd3be)

3 years agovm_reserv: Fix list locking in vm_reserv_reclaim_contig()
Mark Johnston [Thu, 11 Mar 2021 15:34:28 +0000 (10:34 -0500)]
vm_reserv: Fix list locking in vm_reserv_reclaim_contig()

The per-domain partpop queue is locked by the combination of the
per-domain lock and individual reservation mutexes.
vm_reserv_reclaim_contig() scans the queue looking for partially
populated reservations that can be reclaimed in order to satisfy the
caller's allocation.

During the scan, we drop the per-domain lock.  At this point, the rvn
pointer may be invalidated.  Take care to load rvn after re-acquiring
the per-domain lock.

While here, simplify the condition used to check whether a reservation
was dequeued while the per-domain lock was dropped.

Reviewed by: alc, kib
Reported by: gallatin
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29203

(cherry picked from commit 968079f253c11433d47bece4b41b46fcbf985903)

3 years agoFlush remaining routes from the routing table during VNET shutdown.
Alexander V. Chernikov [Mon, 8 Mar 2021 21:35:41 +0000 (21:35 +0000)]
Flush remaining routes from the routing table during VNET shutdown.

Summary:
This fixes rtentry leak for the cloned interfaces created inside the
 VNET.

Loopback teardown order is `SI_SUB_INIT_IF`, which happens after `SI_SUB_PROTO_DOMAIN` (route table teardown).
Thus, any route table operations are too late to schedule.
As the intent of the vnet teardown procedures to minimise the amount of effort by doing global cleanups instead of per-interface ones, address this by adding a relatively light-weight routing table cleanup function, `rib_flush_routes()`.
It removes all remaining routes from the routing table and schedules the deletion, which will happen later, when `rtables_destroy()` waits for the current epoch to finish.

Test Plan:
```
set_skip:set_skip_group_lo  ->  passed  [0.053s]
tail -n 200 /var/log/messages | grep rtentry
```

PR: 253998
Reported by: rashey at superbox.pl
Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D29116

(cherry picked from commit b1d63265ac399112b3bca36c3d75df1a3c2c8102)

3 years agoFix various NOINET* builds broken by 145bf6c0af48.
Alexander V. Chernikov [Fri, 12 Feb 2021 20:36:20 +0000 (20:36 +0000)]
Fix various NOINET* builds broken by 145bf6c0af48.

Reported by: mjg, bdragon

(cherry picked from commit 8ca99aecf749dd088310f81f3c5364a462f1e332)

3 years agoFix blackhole/reject routes.
Alexander V. Chernikov [Mon, 8 Feb 2021 23:29:05 +0000 (23:29 +0000)]
Fix blackhole/reject routes.

Traditionally *BSD routing stack required to supply some
 interface data for blackhole/reject routes. This lead to
 varieties of hacks in routing daemons when inserting such routes.
With the recent routeing stack changes, gateway sockaddr without
 RTF_GATEWAY started to be treated differently, purely as link
 identifier.

This change broke net/bird, which installs blackhole routes with
 127.0.0.1 gateway without RTF_GATEWAY flags.

Fix this by automatically constructing necessary gateway data at
 rtsock level if RTF_REJECT/RTF_BLACKHOLE is set.

Reported by: Marek Zarychta <zarychtam at plan-b.pwste.edu.pl>
Reviewed by: donner

(cherry picked from commit 145bf6c0af48b89f13465e145f4516de37c31d85)

3 years agoPartially revert libcxxrt changes to avoid _Unwind_Exception change
Dimitry Andric [Sat, 13 Mar 2021 13:54:05 +0000 (14:54 +0100)]
Partially revert libcxxrt changes to avoid _Unwind_Exception change

(Note I am also applying this to main and stable/13, to restore the old
libcxxrt ABI and to avoid having to maintain a compat library.)

After the recent cherry-picking of libcxxrt commits 0ee0dbfb0d26 and
d2b3fadf2db5, users reported that editors/libreoffice packages from the
official package builders did not start anymore. It turns out that the
combination of these commits subtly changes the ABI, requiring all
applications that depend on internal details of struct _Unwind_Exception
(available via unwind-arm.h and unwind-itanium.h) to be recompiled.

However, the FreeBSD package builders always use -RELEASE jails, so
these still use the old declaration of struct _Unwind_Exception, which
is not entirely compatible. In particular, LibreOffice uses this struct
in its internal "uno bridge" component, where it attempts to setup its
own exception handling mechanism.

To fix this incompatibility, go back to the old declarations of struct
_Unwind_Exception, and restore the __LP64__ specific workaround we had
in place before (which was to cope with yet another, older ABI bug).

Effectively, this reverts upstream libcxxrt commits 88bdf6b290da
("Specify double-word alignment for ARM unwind") and b96169641f79
("Updated Itanium unwind"), and reapplies our commit 3c4fd2463bb2
("libcxxrt: add padding in __cxa_allocate_* to fix alignment").

PR: 253840

3 years agoRestore AT_RESOLVE_BENEATH support for funlinkat(2)/unlinkat(2).
Konstantin Belousov [Fri, 5 Mar 2021 02:07:57 +0000 (04:07 +0200)]
Restore AT_RESOLVE_BENEATH support for funlinkat(2)/unlinkat(2).

(cherry picked from commit ead7697f04c036853535a4281cec9aa09ef21270)

3 years agoMFC jail: Don't allow jails under dying parents
Jamie Gritton [Tue, 23 Feb 2021 01:04:06 +0000 (17:04 -0800)]
MFC jail: Don't allow jails under dying parents

If a jail is created with jail_set(...JAIL_DYING), and it has a parent
currently in a dying state, that will bring the parent jail back to
life.  Restrict that to require that the parent itself be explicitly
brought back first, and not implicitly created along with the new
child jail.

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

(cherry picked from commit 0a2a96f35a4c2dab3486438680fa289e12971e4b)

MFC jail: Fix locking on an early jail_set error.

I had locked allprison_lock without immediately setting PD_LIST_LOCKED.

(cherry picked from commit 108a9384e9e945cccba73c959f7e9cdb023cbcad)

3 years agoMFC jail: Add PD_KILL to remove a prison in prison_deref().
Jamie Gritton [Mon, 22 Feb 2021 20:27:44 +0000 (12:27 -0800)]
MFC jail: Add PD_KILL to remove a prison in prison_deref().

Add the PD_KILL flag that instructs prison_deref() to take steps
to actively kill a prison and its descendents, namely marking it
PRISON_STATE_DYING, clearing its PR_PERSIST flag, and killing any
attached processes.

This replaces a similar loop in sys_jail_remove(), bringing the
operation under the same single hold on allprison_lock that it already
has. It is also used to clean up failed jail (re-)creations in
kern_jail_set(), which didn't generally take all the proper steps.

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

(cherry picked from commit 811e27fa3c445664e36071a7d08228fc7fb85676)

MFC jail: back out 811e27fa3c44 until it doesn't break Jenkins

Reported by: arichardson

(cherry picked from commit ddfffb41a22d4798a036fe2d30e59694ba7cdad3)

MFC jail: re-commit 811e27fa3c44 with fixes

Make sure PD_KILL isn't passed to do_jail_attach, where it might end
up trying to kill the caller's prison (even prison0).

Fix the child jail loop in prison_deref_kill, which was doing the
post-order part during the pre-order part.  That's not a system-
killer, but make jails not always die correctly.

(cherry picked from commit c861373bdff90d8167a0d998899ca718ccdb541b)

MFC jail: Add safety around prison_deref() flags.

do_jail_attach() now only uses the PD_XXX flags that refer to lock
status, so make sure that something else like PD_KILL doesn't slip
through.

Add a KASSERT() in prison_deref() to catch any further PD_KILL misuse.

(cherry picked from commit 589e4c1df4a6e4b1368f26fc7fef704a2e5cb42c)

3 years agoMFC jail: Add pr_state to struct prison
Jamie Gritton [Sun, 21 Feb 2021 21:24:47 +0000 (13:24 -0800)]
MFC jail: Add pr_state to struct prison

Rather that using references (pr_ref and pr_uref) to deduce the state
of a prison, keep track of its state explicitly.  A prison is either
"invalid" (pr_ref == 0), "alive" (pr_uref > 0) or "dying"
(pr_uref == 0).

State transitions are generally tied to the reference counts, but with
some flexibility: a new prison is "invalid" even though it now starts
with a reference, and jail_remove(2) sets the state to "dying" before
the user reference count drops to zero (which was prviously
accomplished via the PR_REMOVE flag).

pr_state is protected by both the prison mutex and allprison_lock, so
it has the same availablity guarantees as the reference counts do.

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

(cherry picked from commit 1158508a8086a1a93492c1a2e22b61cd7fee4ec7)

MFC jail: Fix a LOR introduced in 1158508a8086

(cherry picked from commit 701d6b50ae7b0b2b50fbd191c2dbd646ef3b4a67)

3 years agox86: tsc: deprioritize TSC on VirtualBox
Kyle Evans [Mon, 8 Mar 2021 20:20:10 +0000 (14:20 -0600)]
x86: tsc: deprioritize TSC on VirtualBox

Misbehavior has been observed with TSC under VirtualBox, where threads
doing small sleeps (~1 second) may miss their wake up and hang around
in a sleep state indefinitely.  Switching back to ACPI-fast decidedly
fixes it, so stop using TSC on VirtualBox at least for the time being.

This partially reverts 84eaf2ccc6aa, applying it only to VirtualBox and
increasing the quality to 0. Negative qualities can never be chosen and
cannot be chosen with the tunable recently added. If we do not have a
timecounter with a higher quality than 0, then TSC does at least leave
the system mostly usable.

PR: 253087

(cherry picked from commit 8cc15b0dfc2f3299662e78f18bd6127f83c14ab4)

3 years agoMFC jail: Change the locking around pr_ref and pr_uref
Jamie Gritton [Sun, 21 Feb 2021 18:55:44 +0000 (10:55 -0800)]
MFC jail: Change the locking around pr_ref and pr_uref

Require both the prison mutex and allprison_lock when pr_ref or
pr_uref go to/from zero.  Adding a non-first or removing a non-last
reference remain lock-free.  This means that a shared hold on
allprison_lock is sufficient for prison_isalive() to be useful, which
removes a number of cases of lock/check/unlock on the prison mutex.

Expand the locking in kern_jail_set() to keep allprison_lock held
exclusive until the new prison is valid, thus making invalid prisons
invisible to any thread holding allprison_lock (except of course the
one creating or destroying the prison).  This renders prison_isvalid()
nearly redundant, now used only in asserts.

Differential Revision: https://reviews.freebsd.org/D28419
Differential Revision: https://reviews.freebsd.org/D28458

(cherry picked from commit f7496dcab0360a74bfb00cd6118f66323fffda61)

MFC jail: fix build after the previous commit
Noted by: Michael Butler <imb protected-networks.net>

(cherry picked from commit ee9b37ae5c115c41835119bb5c9d2e14c83abd65)

3 years agoMFC jail: Improve locking when removing prisons
Jamie Gritton [Sat, 20 Feb 2021 22:38:58 +0000 (14:38 -0800)]
MFC jail: Improve locking when removing prisons

Change the flow of prison_deref() so it doesn't let go of allprison_lock
until it's completely done using it (except for a possible drop as part
of an upgrade on its first try).

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

(cherry picked from commit 6e1d1bfcac77603541706807803a198c6d954d7c)

3 years agoopencrypto: Make cryptosoft attach silently
Mark Johnston [Fri, 5 Mar 2021 18:11:25 +0000 (13:11 -0500)]
opencrypto: Make cryptosoft attach silently

cryptosoft is always present and doesn't print any useful information
when it attaches.

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29098

(cherry picked from commit 4fc60fa9294f82c7f4e1a0e71f9a17794124217f)

3 years agonetmap: Stop printing a line to the dmesg in netmap_init()
Mark Johnston [Fri, 5 Mar 2021 23:07:47 +0000 (18:07 -0500)]
netmap: Stop printing a line to the dmesg in netmap_init()

netmap is compiled into the kernel by default so initialization was
always reported, and netmap uses a formatting convention not used in the
rest of the kernel.

Reviewed by: vmaffione
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29099

(cherry picked from commit fef845097190f0ecb783d6c75a9398c4e4a4c0e1)

3 years agoktls: Hide initialization message behind bootverbose
Mark Johnston [Fri, 5 Mar 2021 18:11:02 +0000 (13:11 -0500)]
ktls: Hide initialization message behind bootverbose

We don't typically print anything when a subsystem initializes itself,
and KTLS is currently disabled by default anyway.

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29097

(cherry picked from commit 89b650872bba2e4bfbc94a200946b461ef69ae22)

3 years agoacpi: Make nexus_acpi quiet on amd64 and i386
Mark Johnston [Fri, 5 Mar 2021 17:53:30 +0000 (12:53 -0500)]
acpi: Make nexus_acpi quiet on amd64 and i386

Otherwise during attach newbus prints "nexus0", which is not very
useful.

The generic nexus device is already quiet, as is nexus_acpi on arm64.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 732b69c9f9c84408e7e680a93ab91ce76ffef2ce)

3 years agoAdd ObsoleteFiles.inc entries for various OCF headers removed in 13.
John Baldwin [Mon, 8 Mar 2021 19:17:21 +0000 (11:17 -0800)]
Add ObsoleteFiles.inc entries for various OCF headers removed in 13.

(cherry picked from commit ef74bfc6fed298d5ca0e3cb92bf008b715ea0c2f)

3 years agoCorrect the name of the structure used for TCP socket options.
John Baldwin [Mon, 8 Mar 2021 18:46:40 +0000 (10:46 -0800)]
Correct the name of the structure used for TCP socket options.

The structure was renamed while refactoring Netflix's KTLS changes for
upstreaming, but the original name remained in tcp.4 and was
subsequently copied to ktls.4.

PR: 254141
Reported by: asomers

(cherry picked from commit c5a365623f88999b524d94003187ef09fda55f67)

3 years agoRemove the usr/tests/usr.bin/yacc/yacc directory when removing yacc.
John Baldwin [Wed, 3 Mar 2021 22:46:45 +0000 (14:46 -0800)]
Remove the usr/tests/usr.bin/yacc/yacc directory when removing yacc.

(cherry picked from commit e6cfd2939a4261c1f4bf802368cea8faf824c128)

3 years agowg(4): Fix an example in the manual page
Gordon Bergling [Sun, 7 Mar 2021 19:27:59 +0000 (20:27 +0100)]
wg(4): Fix an example in the manual page

The example in the manual page of wg(4) for connecting to a
peer was missing the 'public-key' ifconfig(8) keyword and for the
addressed peer the port must be specified.

PR: 253866
Reported by: Sergey Akhmatov <sergey at akhmatov dot ru>
Reviewed by: debdrup
Differential Revision: https://reviews.freebsd.org/D29115

(cherry picked from commit f7bfe310191c8292da51c8da166a521ff16e0e46)

3 years agosecurity(7): mention new W^X sysctls in the manual page
Evgeniy Khramtsov [Tue, 2 Mar 2021 18:52:22 +0000 (19:52 +0100)]
security(7): mention new W^X sysctls in the manual page

Reviewed by: emaste, gbe
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28986

(cherry picked from commit 907023b454f06a6af87f21f8a9d6de6c11b2d275)

3 years agowg: Avoid leaking mbufs when the input handshake queue is full
Mark Johnston [Mon, 8 Mar 2021 17:39:05 +0000 (12:39 -0500)]
wg: Avoid leaking mbufs when the input handshake queue is full

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

(cherry picked from commit a11009dccb6a2e75de2b8f1b45a0896eda2e6d85)

3 years agoqat.4: Fix some firmware module names
Mark Johnston [Wed, 3 Mar 2021 14:07:53 +0000 (09:07 -0500)]
qat.4: Fix some firmware module names

PR: 252984

(cherry picked from commit 3adf72a36b9b151eef57e3d83f71a3a9fbacb78d)

3 years agoFix 'in6_purgeaddr: err=65, destination address delete failed' message.
Alexander V. Chernikov [Mon, 8 Mar 2021 20:27:29 +0000 (20:27 +0000)]
Fix 'in6_purgeaddr: err=65, destination address delete failed' message.

P2P ifa may require 2 routes: one is the loopback route, another is
 the "prefix" route towards its destination.

Current code marks loopback routes existence with IFA_RTSELF and
 "prefix" p2p routes with IFA_ROUTE.

For historic reasons, we fill in ifa_dstaddr for loopback interfaces.
To avoid installing the same route twice, we preemptively set
 IFA_RTSELF when adding "prefix" route for loopback.
However, the teardown part doesn't have this hack, so we try to
 remove the same route twice.

Fix this by checking if ifa_dstaddr is different from the ifa_addr
 and moving this logic into a separate function.

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

(cherry picked from commit 7634919e15f1147b6f26d55354be375bc9b198db)

3 years agoEnforce net epoch in in6_selectsrc().
Alexander V. Chernikov [Sat, 13 Feb 2021 14:32:10 +0000 (14:32 +0000)]
Enforce net epoch in in6_selectsrc().

in6_selectsrc() may call fib6_lookup() in some cases, which requires
 epoch. Wrap in6_selectsrc* calls into epoch inside its users.
Mark it as requiring epoch by adding NET_EPOCH_ASSERT().

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

(cherry picked from commit 605284b894748d23136b30a202689493d8f8af52)

3 years agoFix dpdk/ldradix fib lookup algorithm preference calculation.
Alexander V. Chernikov [Sun, 7 Mar 2021 22:05:34 +0000 (22:05 +0000)]
Fix dpdk/ldradix fib lookup algorithm preference calculation.

The current preference number were copied from IPv4 code,
 assuming 500k routes to be the full-view. Adjust with the current
 reality (100k full-view).

Reported by: Marek Zarychta <zarychtam at plan-b.pwste.edu.pl>

(cherry picked from commit d5be41beb7c44119730791d92782d8e77174d312)

3 years agoFix setting static entries for arp/ndp.
Alexander V. Chernikov [Sat, 20 Feb 2021 18:21:52 +0000 (18:21 +0000)]
Fix setting static entries for arp/ndp.

rtsock message validation changes committed in 2fe5a79425c7
 did not take llinfo messages into account.

Add a special validation case for RTA_GATEWAY llinfo messages.

(cherry picked from commit e5b394f2d0d94f190c9da2346fd22d7c6fb14730)

3 years agoFix arp/ndp deletion broken by 2fe5a79425c7.
Alexander V. Chernikov [Fri, 19 Feb 2021 21:09:17 +0000 (21:09 +0000)]
Fix arp/ndp deletion broken by 2fe5a79425c7.

Changes in the 2fe5a79425c7 moved dst sockaddr masking from the
 routing control plane to the rtsock code.

It broke arp/ndp deletion.
It turns out, arp/ndp perform RTM_GET request first to get an
 interface index necessary for the deletion.
Then they simply stamp the reply with RTF_LLDATA and set the
 command to RTM_DELETE.
As a result, kernel receives request with non-empty RTA_NETMASK
 and clears RTA_DST host bits before passing the message to the
 lla code.

De facto, the only needed bits are RTA_DST, RTA_GATEWAY and the
 subset of rtm_flags.

With that in mind, fix the interace by clearing RTA_NETMASK
 for every messages with RTF_LLDATA.

While here, cleanup arp/ndp code a bit.

Reviewed by: gnn
Differential Revision: https://reviews.freebsd.org/D28804

(cherry picked from commit f9e1cd6c99200846b324a8b65f7f31ded74013bd)

3 years agoFix NOINET6 build broken by 2fe5a79425c7.
Alexander V. Chernikov [Tue, 16 Feb 2021 21:49:48 +0000 (21:49 +0000)]
Fix NOINET6 build broken by 2fe5a79425c7.

Reported by: mjg

(cherry picked from commit a4513bace0e0c38d38b0c49c1daea60f2741d781)

3 years agoFix dst/netmask handling in routing socket code.
Alexander V. Chernikov [Tue, 16 Feb 2021 20:30:04 +0000 (20:30 +0000)]
Fix dst/netmask handling in routing socket code.

Traditionally routing socket code did almost zero checks on
 the input message except for the most basic size checks.

This resulted in the unclear KPI boundary for the routing system code
 (`rtrequest*` and now `rib_action()`) w.r.t message validness.

Multiple potential problems and nuances exists:
* Host bits in RTAX_DST sockaddr. Existing applications do send prefixes
 with hostbits uncleared. Even `route(8)` does this, as they hope the kernel
 would do the job of fixing it. Code inside `rib_action()` needs to handle
 it on its own (see `rt_maskedcopy()` ugly hack).
* There are multiple way of adding the host route: it can be DST without
 netmask or DST with /32(/128) netmask. Also, RTF_HOST has to be set correspondingly.
 Currently, these 2 options create 2 DIFFERENT routes in the kernel.
* no sockaddr length/content checking for the "secondary" fields exists: nothing
 stops rtsock application to send sockaddr_in with length of 25 (instead of 16).
 Kernel will accept it, install to RIB as is and propagate to all rtsock consumers,
 potentially triggering bugs in their code. Same goes for sin_port, sin_zero, etc.

The goal of this change is to make rtsock verify all sockaddr and prefix consistency.
Said differently, `rib_action()` or internals should NOT require to change any of the
 sockaddrs supplied by `rt_addrinfo` structure due to incorrectness.

To be more specific, this change implements the following:
* sockaddr cleanup/validation check is added immediately after getting sockaddrs from rtm.
* Per-family dst/netmask checks clears host bits in dst and zeros all dst/netmask "secondary" fields.
* The same netmask checking code converts /32(/128) netmasks to "host" route case
 (NULL netmask, RTF_HOST), removing the dualism.
* Instead of allowing ANY "known" sockaddr families (0<..<AF_MAX), allow only actually
 supported ones (inet, inet6, link).
* Automatically convert `sockaddr_sdl` (AF_LINK) gateways to
  `sockaddr_sdl_short`.

Reported by: Guy Yur <guyyur at gmail.com>
Reviewed By: donner
Differential Revision: https://reviews.freebsd.org/D28668

(cherry picked from commit 2fe5a79425c79f7b828acd91da66d97230925fc8)

3 years agoAdd ifa_try_ref() to simplify ifa handling inside epoch.
Alexander V. Chernikov [Tue, 16 Feb 2021 20:12:58 +0000 (20:12 +0000)]
Add ifa_try_ref() to simplify ifa handling inside epoch.

More and more code migrates from lock-based protection to the NET_EPOCH
 umbrella. It requires some logic changes, including, notably, refcount
 handling.

When we have an `ifa` pointer and we're running inside epoch we're
 guaranteed that this pointer will not be freed.
However, the following case can still happen:
 * in thread 1 we drop to 0 refcount for ifa and schedule its deletion.
 * in thread 2 we use this ifa and reference it
 * destroy callout kicks in
 * unhappy user reports bug

To address it, new `ifa_try_ref()` function is added, allowing to return
 failure when we try to reference `ifa` with 0 refcount.
Additionally, existing `ifa_ref()` is enforced with `KASSERT` to provide
 cleaner error in such scenarious.

Reviewed By: rstone, donner
Differential Revision: https://reviews.freebsd.org/D28639

(cherry picked from commit 600eade2fb4faacfcd408a01140ef15f85f0c817)

3 years agoMake in_localip_more() fib-aware.
Alexander V. Chernikov [Tue, 16 Feb 2021 20:00:46 +0000 (20:00 +0000)]
Make in_localip_more() fib-aware.

It fixes loopback route installation for the interfaces
 in the different fibs using the same prefix.

Reviewed By: donner
PR: 189088
Differential Revision: https://reviews.freebsd.org/D28673

(cherry picked from commit 9fdbf7eef5c006002769add15b1ebb8fa8d9e220)

3 years agoRemove per-packet ifa refcounting from IPv6 fast path.
Alexander V. Chernikov [Mon, 15 Feb 2021 21:59:21 +0000 (21:59 +0000)]
Remove per-packet ifa refcounting from IPv6 fast path.

Currently ip6_input() calls in6ifa_ifwithaddr() for
 every local packet, in order to check if the target ip
 belongs to the local ifa in proper state and increase
 its counters.

in6ifa_ifwithaddr() references found ifa.
With epoch changes, both `ip6_input()` and all other current callers
 of `in6ifa_ifwithaddr()` do not need this reference
 anymore, as epoch provides stability guarantee.

Given that, update `in6ifa_ifwithaddr()` to allow
 it to return ifa without referencing it, while preserving
 option for getting referenced ifa if so desired.

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

(cherry picked from commit 8268d82cff1bcd7969e5b3c676f28684784a7a43)

3 years agoRemove now-unused RTF_RNH_LOCKED route flag.
Alexander V. Chernikov [Sun, 14 Feb 2021 13:45:14 +0000 (13:45 +0000)]
Remove now-unused RTF_RNH_LOCKED route flag.

(cherry picked from commit 64d5c2777731c1376dd44b6a5fdb68b168d073dc)

3 years agoDo not reference returned ifa in in6_ifawithifp().
Alexander V. Chernikov [Sun, 14 Feb 2021 10:11:06 +0000 (10:11 +0000)]
Do not reference returned ifa in in6_ifawithifp().

The only place where in6_ifawithifp() is used is ip6_output(),
 which uses the returned ifa to bump traffic counters.
Given ifa stability guarantees is provided by epoch, do not refcount ifa.

This eliminates 2 atomic ops from IPv6 fast path.

Reviewed By: rstone
Differential Revision: https://reviews.freebsd.org/D28649

(cherry picked from commit 1bd44b11e59f1e9ee7245f8de1f823bc5287b9ef)

3 years agobacklight(8): Add note that with option it print the current brightness.
Emmanuel Vadot [Wed, 3 Mar 2021 08:00:42 +0000 (09:00 +0100)]
backlight(8): Add note that with option it print the current brightness.

MFC after:    3 days
PR:        253737

(cherry picked from commit 1df30489a8f7083c98010c94d9ce522f9e8213dc)

3 years agobacklight: Fix incr/decr with percent value of 0
David Schlachter [Wed, 3 Mar 2021 07:57:35 +0000 (08:57 +0100)]
backlight: Fix incr/decr with percent value of 0

This now does nothing instead of incr/decr by 10%

MFC After:    3 days
PR:        253736

(cherry picked from commit 3b005d51bd0fe4d8d19fb2df4d470b6e8baebf16)

3 years agozfs: update openzfs version reference to bedbc13da
Martin Matuska [Fri, 5 Mar 2021 14:52:04 +0000 (15:52 +0100)]
zfs: update openzfs version reference to bedbc13da

It was missed in the latest merge.

(cherry picked from commit 6781b8a32e702c694d3f813959d326e36facc19f)

3 years agozfs: merge OpenZFS master-bedbc13da
Martin Matuska [Wed, 3 Mar 2021 01:15:33 +0000 (02:15 +0100)]
zfs: merge OpenZFS master-bedbc13da

Notable upstream commits:
  8e43fa12c Fix vdev_rebuild_thread deadlock
  03ef8f09e Add missing checks for unsupported features
  2e160dee9 Fix assert in FreeBSD-specific dmu_read_pages
  bedbc13da Cancel TRIM / initialize on FAULTED non-writeable vdevs

Obtained from: OpenZFS

(cherry picked from commit caed7b1c399de04279822028e15b36367e84232f)

3 years agoopenzfs: attach pam_zfs_key to build
Greg V [Tue, 2 Mar 2021 11:01:14 +0000 (06:01 -0500)]
openzfs: attach pam_zfs_key to build

This PAM module allows unlocking encrypted user home datasets when
logging in (and changing passphrase when changing the account password),
see https://github.com/openzfs/zfs/pull/9903

Also supposed to unload the key when the last session for the user is
done, but there are EBUSY issues:
https://github.com/openzfs/zfs/issues/11222#issuecomment-731897858

Submitted by: Greg V <greg_unrelenting.technology>
Reviewed by: mm
Differential Revision: https://reviews.freebsd.org/D28018

(cherry picked from commit ee21ee1572d40a3b74f18638dae38c1a9ad1e9e3)

3 years agozfs: add missing seqc write begin/end around zfs_acl_chown_setattr
Mateusz Guzik [Sat, 27 Feb 2021 22:26:20 +0000 (22:26 +0000)]
zfs: add missing seqc write begin/end around zfs_acl_chown_setattr

It happens to trip over an assert but does not matter for correctness at
this time. However, do it for future proofing.

Reported by: avg

(cherry picked from commit 1d8510c1a64d61a85c74c8b02fb12e6f31ede5a1)