]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agonull_bypass(): some style
Konstantin Belousov [Tue, 20 Jul 2021 00:48:49 +0000 (03:48 +0300)]
null_bypass(): some style

(cherry picked from commit 7b7227c4a601d92a46cf625ca7ae245664a809fe)

3 years agoRemove opensolaris_atomic.S dependency.
Alexander Motin [Tue, 27 Jul 2021 23:50:52 +0000 (19:50 -0400)]
Remove opensolaris_atomic.S dependency.

This file is no longer there, so this broke static zfs build.

(cherry picked from commit e0229c5110d2a35e1cc464a596fff2498b836b1c)

3 years agoigb: clean up igb_txrx comments
Kevin Bowling [Sat, 31 Jul 2021 15:04:25 +0000 (08:04 -0700)]
igb: clean up igb_txrx comments

Reviewed by: grehan
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D31227

(cherry picked from commit ff01d6343f1f0c6550e4072eddda91dabd366d09)

3 years agoe1000: Add missing branch prediction
Kevin Bowling [Tue, 20 Jul 2021 07:21:21 +0000 (00:21 -0700)]
e1000: Add missing branch prediction

I missed this edit from the ixgbe review (D30074)

Reviewed by: gallatin
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30073

(cherry picked from commit 9fd0cda92d3346e1daa30eb48e185e2077ac0566)

3 years agoe1000: Clean up igb_txrx
Kevin Bowling [Tue, 20 Jul 2021 07:06:31 +0000 (00:06 -0700)]
e1000: Clean up igb_txrx

The intention here is to reduce differences between em, igb, igc, ixgbe.

The main functional change is logical simplification in igb_rx_checksum
and getting interface caps from scctx instead of the ifp.

Reviewed by: gallatin, markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30073

(cherry picked from commit 41f02257146d128cdd4aa2bdcfdab7f9e08a4314)

3 years agorip: Add missing minimum length validation in rip_output()
Mark Johnston [Mon, 26 Jul 2021 20:39:18 +0000 (16:39 -0400)]
rip: Add missing minimum length validation in rip_output()

If the socket is configured such that the sender is expected to supply
the IP header, then we need to verify that it actually did so.

Reported by: syzkaller+KMSAN
Reviewed by: donner
Sponsored by: The FreeBSD Foundation

(cherry picked from commit ba21825202737a8b7e90e1ef669c7fe7e7d50325)

3 years agolibvmmapi: Fix warnings and stop overridding WARNS
Mark Johnston [Mon, 26 Jul 2021 20:40:16 +0000 (16:40 -0400)]
libvmmapi: Fix warnings and stop overridding WARNS

- Avoid shadowing the global optarg.
- Sprinkle __unused.
- Cast nitems() to int.
- Fix sign in vm_copy_setup().

Reviewed by: grehan
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 45cd18ec73dcd262612898bf1a263cacde17d348)

3 years agomrsas(4): Report more correct maximum I/O size.
Alexander Motin [Thu, 1 Jul 2021 19:28:55 +0000 (15:28 -0400)]
mrsas(4): Report more correct maximum I/O size.

Subtract one SGE for the case of misaligned address.  Also take into
account maximum number of sectors reported by firmware, that gives
nicer 256KB limit instead of 276KB calculated from the SGE limit.

While there, remove number of I/O size checks, duplicating what is
already checked by CAM and busdma(9).

MFC after: 1 month
Sponsored by: iXsystems, Inc.

(cherry picked from commit fa3d57c256104649217b5022947de9c1c59a326e)

3 years agonet tests: basic test case for bpf(4)'s ability to set vlan pcp
Kristof Provost [Thu, 22 Jul 2021 12:50:27 +0000 (14:50 +0200)]
net tests: basic test case for bpf(4)'s ability to set vlan pcp

Use dhclient with its 'vlan-pcp' option to set a VLAN PCP value and
verify that it actually gets set.

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

(cherry picked from commit 3e87f800f01b6d2cbe49924a01038379889d8b3b)

3 years agovlan: deduplicate bpf_setpcp() and pf_ieee8021q_setpcp()
Kristof Provost [Thu, 22 Jul 2021 08:35:08 +0000 (10:35 +0200)]
vlan: deduplicate bpf_setpcp() and pf_ieee8021q_setpcp()

These two fuctions were identical, so move them into the common
vlan_set_pcp() function, exposed in the if_vlan_var.h header.

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

(cherry picked from commit 9ef8cd0b7906371803421aa897056b6fc0710fcb)

3 years agobpf: Add an ioctl to set the VLAN Priority on packets sent by bpf
Luiz Otavio O Souza [Wed, 21 Jul 2021 15:41:22 +0000 (17:41 +0200)]
bpf: Add an ioctl to set the VLAN Priority on packets sent by bpf

This allows the use of VLAN PCP in dhclient, which is required for
certain ISPs (such as Orange.fr).

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

(cherry picked from commit 1e7fe2fbb9c0bed230d8db94d7444a90ca5ce199)

3 years agobridge tests: test linking bridges with a gif tunnel
Kristof Provost [Wed, 21 Jul 2021 15:32:24 +0000 (17:32 +0200)]
bridge tests: test linking bridges with a gif tunnel

Fairly basic test case for using gif(4)'s ability to tunnel Ethernet
traffic between bridges.

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

(cherry picked from commit 4b765ab4cda051a6d9ceb5fb9cac80c7f3b910bf)

3 years agoinet6_option_space is deprecated, refer to inet6_opt_init instead
Tom Jones [Fri, 30 Jul 2021 13:23:39 +0000 (14:23 +0100)]
inet6_option_space is deprecated, refer to inet6_opt_init instead

Reviewed by: bz, hrs
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D26273

(cherry picked from commit 0943200b1308bcf2e2b331f6aba514d64d74545f)

3 years agotcp: Add PRR cwnd reduction for non-SACK loss
Richard Scheffenegger [Sat, 19 Jun 2021 17:06:48 +0000 (19:06 +0200)]
tcp: Add PRR cwnd reduction for non-SACK loss

This completes PRR cwnd reduction in all circumstances
for the base TCP stack (SACK loss recovery, ECN window reduction,
non-SACK loss recovery), preventing the arriving ACKs to
clock out new data at the old, too high rate. This
reduces the chance to induce additional losses while
recovering from loss (during congested network conditions).

For non-SACK loss recovery, each ACK is assumed to have
one MSS delivered. In order to prevent ACK-split attacks,
only one window worth of ACKs is considered to actually
have delivered new data.

MFC after: 6 weeks
Reviewed By: rrs, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29441

(cherry picked from commit 74d7fc8753a76851db6db556ff0f09de1fbb26d5)

3 years agoless: upgrade to v590.
Xin LI [Sun, 18 Jul 2021 05:20:44 +0000 (22:20 -0700)]
less: upgrade to v590.

(cherry picked from commit 30a1828c5196c415c8afc0d50f9131885d0c6b43)
(cherry picked from commit 4bcc6d14e23d1443a275fc3a494094274a2f8382)

3 years agoMerge llvm-project 12.0.1 release and follow-up fixes
Dimitry Andric [Sun, 13 Jun 2021 19:31:46 +0000 (21:31 +0200)]
Merge llvm-project 12.0.1 release and follow-up fixes

Merge llvm-project main llvmorg-12-init-17869-g8e464dd76bef

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12-init-17869-g8e464dd76bef, the last commit before the
upstream release/12.x branch was created.

PR: 255570

(cherry picked from commit e8d8bef961a50d4dc22501cde4fb9fb0be1b2532)

Merge llvm-project 12.0.0 release

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.0-0-gd28af7c654d8, a.k.a. 12.0.0 release.

PR: 255570

(cherry picked from commit d409305fa3838fb39b38c26fc085fb729b8766d5)

Disable strict-fp for powerpcspe, as it does not work properly yet

Merge commit 5c18d1136665 from llvm git (by Qiu Chaofan)

  [SPE] Disable strict-fp for SPE by default

  As discussed in PR50385, strict-fp on PowerPC SPE has not been
  handled well. This patch disables it by default for SPE.

  Reviewed By: nemanjai, vit9696, jhibbits

  Differential Revision: https://reviews.llvm.org/D103235

PR: 255570

(cherry picked from commit 715df83abc049b23d9acddc81f2480bd4c056d64)

Apply upstream libc++ fix to allow building with devel/xxx-xtoolchain-gcc

Merge commit 52e9d80d5db2 from llvm git (by Jason Liu):

  [libc++] add `inline` for __open's definition in ifstream and ofstream

  Summary:

  When building with gcc on AIX, it seems that gcc does not like the
  `always_inline` without the `inline` keyword.
  So adding the inline keywords in for __open in ifstream and ofstream.
  That will also make it consistent with __open in basic_filebuf
  (it seems we added `inline` there before for gcc build as well).

  Differential Revision: https://reviews.llvm.org/D99422

PR: 255570

(cherry picked from commit d099db25464b826c5724cf2fb5b22292bbe15f6e)

Undefine HAVE_(DE)REGISTER_FRAME in llvm's config.h on arm

Otherwise, the lli tool (enable by WITH_CLANG_EXTRAS) won't link on arm,
stating that __register_frame is undefined. This function is normally
provided by libunwind, but explicitly not for the ARM Exception ABI.

Reported by: oh
PR: 255570

(cherry picked from commit f336b45e943c7f9a90ffcea1a6c4c7039e54c73c)

Merge llvm-project 12.0.1 rc2

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.1-rc2-0-ge7dac564cd0e, a.k.a. 12.0.1 rc2.

PR: 255570

(cherry picked from commit 23408297fbf3089f0388a8873b02fa75ab3f5bb9)

Revert libunwind change to fix backtrace segfault on aarch64

Revert commit 22b615a96593 from llvm git (by Daniel Kiss):

  [libunwind] Support for leaf function unwinding.

  Unwinding leaf function is useful in cases when the backtrace finds a
  leaf function for example when it caused a signal.
  This patch also add the support for the DW_CFA_undefined because it marks
  the end of the frames.

  Ryan Prichard provided code for the tests.

  Reviewed By: #libunwind, mstorsjo

  Differential Revision: https://reviews.llvm.org/D83573

  Reland with limit the test to the x86_64-linux target.

Bisection has shown that this particular upstream commit causes programs
using backtrace(3) on aarch64 to segfault. This affects the lang/rust
port, for instance. Until we can upstream to fix this problem, revert
the commit for now.

Reported by: mikael
PR: 256864

(cherry picked from commit 5866c369e4fd917c0d456f0f10b92ee354b82279)

Merge llvm-project 12.0.1 release

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.1-0-gfed41342a82f, a.k.a. 12.0.1 release.

PR: 255570

(cherry picked from commit 4652422eb477731f284b1345afeefef7f269da50)

compilert-rt: build out-of-line LSE atomics helpers for aarch64

Both clang >= 12 and gcc >= 10.1 now default to -moutline-atomics for
aarch64. This requires a bunch of helper functions in libcompiler_rt.a,
to avoid link errors like "undefined symbol: __aarch64_ldadd8_acq_rel".

(Note: of course you can use -mno-outline-atomics as a workaround too,
but this would negate the potential performance benefit of the faster
LSE instructions.)

Bump __FreeBSD_version so ports maintainers can easily detect this.

PR: 257392

(cherry picked from commit cc55ee8009a550810d38777fd6ace9abf3a2f6b4)

3 years agoawk: remove proctab.c
Warner Losh [Mon, 12 Jul 2021 03:26:08 +0000 (21:26 -0600)]
awk: remove proctab.c

proctab.c is a generated file and never should have been committed to
the tree. This file has been added and removed a couple of times, most
recently added by me in my 2019 updates.

Sponsored by: Netflix

(cherry picked from commit 0c92d88c9180bf25187f01f1d7e419edea9a0fef)

3 years agopf: fix ABI breakage
Kristof Provost [Wed, 28 Jul 2021 09:24:44 +0000 (11:24 +0200)]
pf: fix ABI breakage

The introduction of synproxy support changed the size of struct
pf_status, which in turn broke the userspace ABI.

Revert the relevant change. More work is needed on the synproxy code to
keep and expose the counters, but in the mean time this restores the
ABI.

PR:             257469
MFC after:      3 days
Sponsored by:   Modirum MDPay

(cherry picked from commit da8d8b22e69c72f1d001d55b5eff5acbb0265cfc)

3 years agopf.conf.5: Document new 'match' keyword
Kristof Provost [Tue, 2 Mar 2021 19:34:41 +0000 (20:34 +0100)]
pf.conf.5: Document new 'match' keyword

Reviewed by: bcr
Obtained from: pfSense
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31117

(cherry picked from commit 0351b9875a3eb5eb4b502a4106b1917ce954e959)

3 years agopf tests: Test the match keyword
Kristof Provost [Tue, 2 Mar 2021 15:57:27 +0000 (16:57 +0100)]
pf tests: Test the match keyword

The new match keyword can currently only assign queues, so we can only
test it with ALTQ.
Set up a basic scenario where we use 'match' to assign ICMP traffic to a
slow queue, and confirm that it's really getting slowed down.

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

(cherry picked from commit d363ebc78cbb50bc334d74fb5bb755af53c69ff0)

3 years agopf: match keyword support
Kristof Provost [Tue, 2 Mar 2021 15:01:04 +0000 (16:01 +0100)]
pf: match keyword support

Support the 'match' keyword.
Note that support is limited to adding queuing information, so without
ALTQ support in the kernel setting match rules is pointless.

For the avoidance of doubt: this is NOT full support for the match
keyword as found in OpenBSD's pf. That could potentially be built on top
of this, but this commit is NOT that.

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

(cherry picked from commit ef950daa35d43dd396958ca28ce9de0514daf873)

3 years agoaltq tests: Basic ALTQ test
Kristof Provost [Sat, 23 Jan 2021 09:37:03 +0000 (10:37 +0100)]
altq tests: Basic ALTQ test

Activate ALTQ_HFSC, crudely check if it really limits bandwidth as we'd expect.

Reviewed by: donner@
Differential Revision: https://reviews.freebsd.org/D28303

(cherry picked from commit 16b3833344ad04194f10b567bc6fae829a52a850)

3 years agoaltq: Fix typo in features sysctl description
Kristof Provost [Tue, 26 Jan 2021 15:02:45 +0000 (16:02 +0100)]
altq: Fix typo in features sysctl description

Reported by: Jose Luis Duran

(cherry picked from commit 35dabb7b9cff601045b623aeca59ccc68930d520)

3 years agoAdd FEATURE sysctls for ALTQ disciplines
Kristof Provost [Sat, 23 Jan 2021 09:36:33 +0000 (10:36 +0100)]
Add FEATURE sysctls for ALTQ disciplines

This will allow userspace to more easily figure out if ALTQ is built
into the kernel and what disciplines are supported.

Reviewed by: donner@
Differential Revision: https://reviews.freebsd.org/D28302

(cherry picked from commit e111d79806fe3652bc85593ca77ee1b4ff85498d)

3 years agoRELNOTES: add notes about awk updates
Warner Losh [Fri, 30 Jul 2021 23:04:53 +0000 (17:04 -0600)]
RELNOTES: add notes about awk updates

Direct commit to stable/13 to note user-visible changes in the awk
update.

Sponsored by: Netflix

3 years agoFix the pattern for changing PermitRootLogin
Jose Luis Duran [Fri, 16 Jul 2021 17:11:47 +0000 (14:11 -0300)]
Fix the pattern for changing PermitRootLogin

The previous pattern had the (harmless) side-effect of duplicating the
entry in the config file.

No functional change intended.

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

(cherry picked from commit 73358cd2cfccf9aafde069ffcb8185a0f3420ffd)

3 years agonanobsd: fix typo in NANO_WORLDDIR
Yann Kerherve [Tue, 20 Jul 2021 17:10:28 +0000 (11:10 -0600)]
nanobsd: fix typo in NANO_WORLDDIR

Reviewed by: imp
PR: 257299

(cherry picked from commit 5a9e5a5111af59dbc96383fcd73129e31648e017)

3 years agoawk: Make -F '' and -v FS="" behave the same
Warner Losh [Tue, 20 Jul 2021 04:47:30 +0000 (22:47 -0600)]
awk: Make -F '' and -v FS="" behave the same

IEEE Std 1003.1-2008 mandates that -F str be treated the same as -v
FS=str. For a null string, this was not the case. Since awk(1) documents
that a null string for FS has a specific behavior, make -F '' behave
consistently with -v FS="".

PR: 241441
Upstream issue: https://github.com/onetrueawk/awk/issues/127
Upstream pull request: https://github.com/onetrueawk/awk/pull/128
MFC After: 2 weeks
Sponsored by: Netflix

(cherry picked from commit a2e3e1187309f9404940b61ca49a93bd0536559d)

3 years agoawk: Remove last markings we have on awk
Warner Losh [Thu, 22 Jul 2021 02:24:57 +0000 (20:24 -0600)]
awk: Remove last markings we have on awk

We normally don't add $FreeBSD$ to contrib software. However, these
changes date back to the CVS era of source code management and have been
overlooked. Now that all these files are back to the same as the
upstream bsd-features branch, remove the FreeBSD specific changes, which
are now just $FreeBSD$ and the (FreeBSD) in the version string.

MFC After: 2 weeks
Sponsored by: Netflix

(cherry picked from commit 5ab82b00cca74feb9d047e9c8aa29e5118810edc)

3 years agoawk: revert to upstream behavior for ranges for gawk compatibility
Warner Losh [Thu, 22 Jul 2021 02:22:43 +0000 (20:22 -0600)]
awk: revert to upstream behavior for ranges for gawk compatibility

In 2005, FreeBSD changed one-true-awk to honor the locale's collating
order. This was billed as a temporary patch. It was also compatible with
the then-current behavior of gawk. That temporary patch has lasted 16
years now.

However, IEEE Std 1003.1-2008 changed the behaivor of ranges in regular
expressions outside of the "C" and "POSIX" locales to be undefined.

Starting in 2011, gawk 4.0 stopped using the locale for the range
regular expressions and used the traditional behavior only. The
maintainer had grown weary of answering why '[A-Z]' would sometimes
match lower-case expressions. The details about are explained here:
https://www.gnu.org/software/gawk/manual/html_node/Ranges-and-Locales.html

To restore compatibility with other implementaitons of awk, revert this
patch. FreeBSD is the odd-system out. It also has the nice side effect
of eliminating the last of our differences with upstream one-true-awk.

Reviewed by: cy, rgrimes
MFC After: 2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31114

(cherry picked from commit 628bd30ab5a492839b84dbf2aaf25848dae3866a)

3 years agoawk: Reduce diffs with upstream to almost nothing.
Warner Losh [Fri, 9 Jul 2021 03:51:24 +0000 (21:51 -0600)]
awk: Reduce diffs with upstream to almost nothing.

In the merge of 20210215, I left two merge conflicts #if 0'd by mistake
to check later rather than resolve them as part of the merge.  This code
turns out to be from the original one-true-awk import and not FreeBSD
specific, so remove them.

Remove a extra definition of HAT.

Remove a stylistic change that also appears to be a mismerge along the
way.

Remove FREEBSD-upgrade. Nobody has updated it since the original 2007
cvs import. It talks about old CVS branches that never made it into svn,
let alone git. New imports will follow the standard practices now, so
there's nothing left to document.

Move README to README.md and copy the README.md from upstream over.

This leaves just the $FreeBSD$ lines (which remain for the stable/12
merge) and the strcoll part of ru@'s r201989/d98dd8e5f94c as the only
diffs with upstream. FreeBSD also still has its own man page, which I
don't plan on changing. Once this commit is merged to stable/12, I plan
no further merges to stable/12. Sometime after that I'll remove the
$FreeBSD$ lines to reduce the diffs even more (though i want to make
sure plans won't change first). I also plan to talk to upstream about
this change...

MFC After: 2 weeks
Sponsored by: Netflix

(cherry picked from commit f68a53dba933f9c1143863603f5a16fdbe5f070e)

3 years agotypo: becauce -> because
Warner Losh [Thu, 22 Jul 2021 02:02:44 +0000 (20:02 -0600)]
typo: becauce -> because

Noticed by: Piotr P. Stefaniak
Sponsored by: Netflix

(cherry picked from commit 2b720db8d409f6fcdffa7f06b1d8c1b981435a83)

3 years agoboot: fix OBJS to not include BTX's crt0.o
Warner Losh [Thu, 6 May 2021 19:05:09 +0000 (13:05 -0600)]
boot: fix OBJS to not include BTX's crt0.o

According to comments in the Makefile, to make pxeboot work we need to
have crt0.o first. This is needed because the simplified loader in
pxeboot assumes that the startup code is at offset 0 in this binary. In
normal booting, the start address can be obtained from headers of the
binary, but since pxeboot encodes this as a pure binary, it has no way
of knowing where that is and assumes 0. Added comments to that effect
in the Makefile.

We've done this by adding it to OBJS before all the other .o's are
added. However, there's a problem. This also adds it to the CLEANFILES
variable, which causes it to be removed from multiple places. The
dependencies may also cause it to be re-built at a time that's after
boot2 is built. This causes installs to fail because at install time
boot2 is considered to be out of date and the programs to rebuild it are
no longer in the path.

Cope with this problem by just adding it to LDFLAGS instead.

Glanced at by: kevans ("I thought that went in ages ago")
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D28876

(cherry picked from commit e713d3a013882893fceb84dd14569052271497a9)

3 years agopf tests: make killstate:match more robust
Kristof Provost [Tue, 27 Jul 2021 13:31:00 +0000 (15:31 +0200)]
pf tests: make killstate:match more robust

Only lists the states relevant to the connection we're killing.
Sometimes there are IPv6 related states (due to the usual IPv6
background traffic of router solicitations, DAD, ...) that causes us to
think we failed to kill the state, which in turn caused the test to fail
intermittently.

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

(cherry picked from commit 4e860bd5da1423aac9aed0541c484ebf9c1d1621)

3 years agoktrace: Zero request structures when populating the pool
Mark Johnston [Fri, 23 Jul 2021 14:29:53 +0000 (10:29 -0400)]
ktrace: Zero request structures when populating the pool

Otherwise uninitialized pad bytes may be copied into the ktrace log
file.

Reported by: KMSAN
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 5c18bf9d5fd7684024e0a55da1e8537d4cfaf0bf)

3 years agoselect: Define select_flags[] as const
Mark Johnston [Fri, 23 Jul 2021 14:30:32 +0000 (10:30 -0400)]
select: Define select_flags[] as const

Sponsored by: The FreeBSD Foundation

(cherry picked from commit cae3f9dd01fd1f8d579546b359305e985f8087d8)

3 years agocdefs: Add a default definition for __nosanitizememory
Mark Johnston [Fri, 23 Jul 2021 14:30:00 +0000 (10:30 -0400)]
cdefs: Add a default definition for __nosanitizememory

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4cd7e82a4c7aed19dd722afa809466d5a45765d6)

3 years agortld/arm64: Remove checks for undefined symbols when processing TPREL64
Mark Johnston [Fri, 16 Jul 2021 02:26:25 +0000 (22:26 -0400)]
rtld/arm64: Remove checks for undefined symbols when processing TPREL64

lld emits several GOT relocations referencing the null sumbol in libc.so
when compiled with -ftls-model=initial-exec.  This symbol is specified
to be undefined.

We generally do not handle dynamic TLS relocations against weak,
undefined symbols, so avoid printing a warning here.  This makes it
possible to compile libc.so using the initial-exec TLS model on arm64.

Reviewed by: jrtc27, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f238ebd1429312ac2a4cb9f764babc4b6f69721e)

3 years agolio_listio: Don't post a completion notification if none was requested
Mark Johnston [Fri, 16 Jul 2021 02:38:46 +0000 (22:38 -0400)]
lio_listio: Don't post a completion notification if none was requested

One is allowed to use LIO_NOWAIT without specifying a sigevent.  In this
case, lj->lioj_signal is left uninitialized, but several code paths
examine liov_signal.sigev_notify to figure out which notification to
post.  Unconditionally initialize that field to SIGEV_NONE.

Add a dumb test case which triggers the bug.

Reported by: KMSAN+syzkaller
Reviewed by: asomers
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2e5f6152952e4cfbaab3d96368c3dc4218786632)

3 years agoimgact_elf: Avoid redefining suword()
Mark Johnston [Fri, 23 Jul 2021 19:40:54 +0000 (15:40 -0400)]
imgact_elf: Avoid redefining suword()

Otherwise this interferes with the definition for sanitizer
interceptors.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit ebf9886654f42718229011524a81e2b36e51f9b1)

3 years agoacct: Zero pad bytes in accounting records
Mark Johnston [Fri, 23 Jul 2021 14:29:57 +0000 (10:29 -0400)]
acct: Zero pad bytes in accounting records

Reported by: KMSAN
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 90959dd1e50ee820e84bed4bc63fbed140298441)

3 years agovfs: Initialize "lastfail" in vfs_mountroot_wait()
Mark Johnston [Fri, 23 Jul 2021 16:04:02 +0000 (12:04 -0400)]
vfs: Initialize "lastfail" in vfs_mountroot_wait()

This variable is only used to rate-limit "Root mount waiting for: ..."
messages using ppsratecheck().

Reported by: KMSAN
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 048cd371f3d793fa354f1d3a1d484bc2725a3fc1)

3 years agoAdd required sysctl name length checks to various handlers
Mark Johnston [Fri, 23 Jul 2021 14:37:11 +0000 (10:37 -0400)]
Add required sysctl name length checks to various handlers

Reported by: KMSAN
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 0dcef81de9915e8ce1e3985204bebe7026d96b6f)

3 years agoixgbe: Clean up ix_txrx
Kevin Bowling [Sun, 18 Jul 2021 06:24:28 +0000 (23:24 -0700)]
ixgbe: Clean up ix_txrx

The intention here is to reduce differences with D30072.
The only functional change is logical simplification in
ixgbe_rx_checksum.

Reviewed by: gallatin
Differential Revision: https://reviews.freebsd.org/D30074

(cherry picked from commit 51e46835e10a2628482deefc0efd356fb733337a)

3 years agoixgbe: Print FW NVM and Option ROM versions
Kevin Bowling [Fri, 16 Jul 2021 06:50:14 +0000 (23:50 -0700)]
ixgbe: Print FW NVM and Option ROM versions

It can be useful for system operators to see this kind of information
when correlating issues or requesting support from the OEM or Intel for
hardware and firmware issues.

Reviewed by: gallatin
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30178

(cherry picked from commit 7660e4ea5cb750ded38a0bd81cde2e2b130222df)

3 years agolibpmc: Import AMD Zen 3 PMU events
Greg V [Wed, 30 Jun 2021 21:15:21 +0000 (18:15 -0300)]
libpmc: Import AMD Zen 3 PMU events

Reviewed by: mav, mhorne
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30965

(cherry picked from commit 8c2dd68caa963f1900a8228b0732b04f5d530ffa)

3 years agohwpmc_arm64: add a PMCDBG to the interrupt handler
Mitchell Horne [Wed, 19 May 2021 16:29:59 +0000 (13:29 -0300)]
hwpmc_arm64: add a PMCDBG to the interrupt handler

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 13f5a3076bc8f3774b82f2d5ca29e2e0e2af997b)

3 years agoarm64 support for pmu-events
Mitchell Horne [Wed, 19 May 2021 16:11:33 +0000 (13:11 -0300)]
arm64 support for pmu-events

8cc3815f:
hwpmc_arm64: accept raw event codes for PMC_OP_PMCALLOCATE

Make it possible to specify event codes without an offset of
PMC_EV_ARMV8_FIRST, by setting a machine-dependent flag. This is
required to make use of event definitions from pmu-events.

Reviewed by: ray (slightly earlier version)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30602

28dd6730:
libpmc: enable pmu_utils on arm64

This allows supported libpmc to query/select from the pmu-events table,
which may have a more complete set of events than what we define
manually. A future update to these definitions should greatly improve
this support. The alias table is empty for now, until this future import
is complete.

Add the Foundation's copyright for recent work on this file.

Reviewed by: ray (slightly earlier version)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30603

27ea55fc:
libpmc/hwpmc: fix issues with arm64 pmu-events support

Due to a mis-merge, the changes committed to libpmc never called
pmu_parse_event(), or set pm->pm_ev. However, this field shouldn't be
used to carry the actual pmc event code anyway, as it is expected to
contain the index into the pmu event array (otherwise, it breaks event
name lookup in pmclog_get_event()). Add a new MD field,
pm_md.pm_md_config, to pass the raw event code to arm64_allocate_pmc().

Additionally, the change made to pmc_md_op_pmcallocate was incorrect, as
this is a union, not a struct. Restore the proper padding size.

Reviewed by: luporl, ray, andrew
Fixes: 28dd6730a5d6 ("libpmc: enable pmu_utils on arm64")
Fixes: 8cc3815f02be ("hwpmc_arm64: accept raw event codes...")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31221

(cherry picked from commit 8cc3815f02be9fa2a96e47713ad989e6d787e12a)
(cherry picked from commit 28dd6730a5d6bc73aca4c015c0ff875a9def25ac)
(cherry picked from commit 27ea55fc655b0081f760a34ff5dd5526ba02a0fb)

3 years agohwpmc_arm64: fill kern.hwpmc.cpuid
Mitchell Horne [Thu, 1 Apr 2021 13:19:43 +0000 (10:19 -0300)]
hwpmc_arm64: fill kern.hwpmc.cpuid

This will be used to detect supported pmu events. The expected format is
the MIDR register with the revision and variant fields masked. See also:
lib/libpmc/pmu-events/arch/arm64/mapfile.csv.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30601

(cherry picked from commit 5867cccdc49df3e7eb3147d6516b488dd8384afe)

3 years agohwpmc_arm64.c: fix return style
Mitchell Horne [Mon, 14 Jun 2021 15:21:08 +0000 (12:21 -0300)]
hwpmc_arm64.c: fix return style

In accordance to style(9).

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2129c8f6771a9a33253a1fe2d4e9d3494bc77f10)

3 years agolibpmc: make libpmc_pmu_utils.c more amenable to porting
Mitchell Horne [Mon, 31 May 2021 14:24:44 +0000 (11:24 -0300)]
libpmc: make libpmc_pmu_utils.c more amenable to porting

The current version has every function stubbed out for !x86. Only two
functions (pmu_alias_get() and pmc_pmu_pmcallocate() are really platform
dependent, so reduce the width of the ifdefs and remove some of the
stubs.

Reviewed by: ray
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30532

(cherry picked from commit 0024f1aa7720d5f4f587a6c5911fc5238195ae49)

3 years agolibpmc: limit pmu-events to 64-bit powerpc
Mitchell Horne [Mon, 31 May 2021 20:24:15 +0000 (17:24 -0300)]
libpmc: limit pmu-events to 64-bit powerpc

Although currently unused, there are only pmu event definitions for
POWER8 and POWER9. There is no sense in building these on 32-bit
platforms.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 507d68984a010dab0c3ecc5477c36526c3a7fa48)

3 years agolibpmc: use $MACHINE_CPUARCH
Mitchell Horne [Mon, 31 May 2021 20:20:08 +0000 (17:20 -0300)]
libpmc: use $MACHINE_CPUARCH

This is preferred over $MACHINE_ARCH for these types of checks, although
it makes no difference for amd64 or i386. No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 3864da302af34853ddb2c33a42de5668a0d68cdd)

3 years agopmccontrol: improve -L with pmu-events
Mitchell Horne [Mon, 31 May 2021 14:14:36 +0000 (11:14 -0300)]
pmccontrol: improve -L with pmu-events

Check if the pmu utils are supported rather than carrying a
machine-dependent #ifdef.

Reviewed by: gnn, ray, emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30526

(cherry picked from commit 167cdaa7e30093215a753d4f788d921b1f7c1474)

3 years agolibpmc: eliminate pmc_pmu_stat_mode()
Mitchell Horne [Mon, 31 May 2021 14:21:57 +0000 (11:21 -0300)]
libpmc: eliminate pmc_pmu_stat_mode()

There is a single consumer, the pmc utility, that clearly has knowledge
of which counters it is expecting. Remove this function and have it
use common counter aliases instead.

Reviewed by: gnn
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30528

(cherry picked from commit ec66cc955b629e614cf493bf168048de033f6a2c)

3 years agolibpmc: remove pe->alias
Mitchell Horne [Mon, 31 May 2021 14:23:19 +0000 (11:23 -0300)]
libpmc: remove pe->alias

It has never been a part of upstream's struct pmu_event. The jevents
utility will not fill this field, so remove it.

Reviewed by: gnn
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30530

(cherry picked from commit 0c915023dbb7000cd30bb768eb84f6dc757adcc5)

3 years agolibpmc: always generate libpmc_events.c
Mitchell Horne [Mon, 31 May 2021 14:24:04 +0000 (11:24 -0300)]
libpmc: always generate libpmc_events.c

The jevents build tool will create an empty table if it doesn't find any
events, so we can remove the extra $MACHINE_CPUARCH checks.

Reviewed by: gnn, ray, emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30531

(cherry picked from commit 689c7e7975cdee38ca6fd60ad3372d55c43c948c)

3 years agolibpmc: remove unused 'isfixed' variable
Mitchell Horne [Mon, 31 May 2021 14:22:30 +0000 (11:22 -0300)]
libpmc: remove unused 'isfixed' variable

Reviewed by: gnn, emaste
MFC after: 5 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30529

(cherry picked from commit 0092642f863946ee1edc88fa634887d7c8a54656)

3 years agolibpmc: fix "instructions" alias on Intel
Mitchell Horne [Mon, 31 May 2021 14:16:16 +0000 (11:16 -0300)]
libpmc: fix "instructions" alias on Intel

The typo prevents the counter from being allocated.

This fixes e.g. pmcstat -s instructions sleep 5

Reviewed by: mizhka, gnn, ray, emaste
MFC after: 5 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30527

(cherry picked from commit bc1a6a9d692a1f827514144b6bce0654a8be4f4d)

3 years agohwpmc: fix PMC_CPU_LAST
Mitchell Horne [Wed, 5 May 2021 18:40:39 +0000 (15:40 -0300)]
hwpmc: fix PMC_CPU_LAST

It is unused, but incorrect.

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f59127dac5ca0be3648ecc0a031a21e472afb133)

3 years agolibpmc: fall-back to kernel tables if pmu-events fails
Mitchell Horne [Thu, 13 May 2021 18:57:37 +0000 (15:57 -0300)]
libpmc: fall-back to kernel tables if pmu-events fails

On x86, the pmu_events table is the source of truth for finding
supported events. However, events not found there may still be present
in the kernel's static event tables. For example, the pmc.soft(3) events
will never be available from pmu-events.

Update pmc_allocate() to search the legacy event tables if
pmc_pmu_pmcallocate() fails to return a result. This allows both event
sources to be consulted before giving up, thus restoring pmc.soft(3) and
pmc.tsc(3) on x86.

Reviewed by: emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30216

(cherry picked from commit dfdc57e8aa8ba4b4e4484f736e8c7645ab69b54a)

3 years agolibpmc: remove PMC_MDEP_TABLE logic
Mitchell Horne [Thu, 13 May 2021 19:00:07 +0000 (16:00 -0300)]
libpmc: remove PMC_MDEP_TABLE logic

This logic was added for handling some of the complicated relationships
between events and x86 CPU models. Since that logic has been mostly
removed from libpmc(3) in favor of pmu-events, this no longer serves
much of a purpose. Mapping CPU types to event tables is already handled
by the switch statement in pmc_init().

Reviewed by: ray, emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30196

(cherry picked from commit da13ef6aa0565c8d79326bba5606671062033bbf)

3 years agolibpmc: remove unused PMC_MDEP_INIT_INTEL_V2
Mitchell Horne [Thu, 13 May 2021 18:56:39 +0000 (15:56 -0300)]
libpmc: remove unused PMC_MDEP_INIT_INTEL_V2

All uses of this macro were removed in e92a1350b50e. Remove
cpu_has_iaf_counters as well.

Reviewed by: ray, emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30195

(cherry picked from commit 4d8d74a4f52efd078bd6298e0adbdd476ed70de9)

3 years agoarm64: Fix finding the pmc event ID
Andrew Turner [Thu, 1 Apr 2021 14:38:09 +0000 (14:38 +0000)]
arm64: Fix finding the pmc event ID

The lower pmc event bits were masked off to find the PMC event ID.
The doesn't work when there are more events. Switch it to use the
offser relative to the first event while also checking the ID is
in the expected range.

Reviewed by: gnn, ray
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D29600

(cherry picked from commit 24b2f4ea49229618c5608846acfc10be2eb0d567)

3 years agoeli: Zero pad bytes that arise when certain auth algorithms are used
Mark Johnston [Thu, 15 Jul 2021 16:23:04 +0000 (12:23 -0400)]
eli: Zero pad bytes that arise when certain auth algorithms are used

When authentication is configured, GELI ensures that the amount of data
per sector is a multiple of 16 bytes.  This is done in
eli_metadata_softc().  When the digest size is not a multiple of 16
bytes, this leaves some extra pad bytes at the end of every sector, and
they were not being zeroed before being written to disk.  In particular,
this happens with the HMAC/SHA1, HMAC/RIPEMD160 and HMAC/SHA384 data
authentication algorithms.

This change ensures that they are zeroed before being written to disk.

Reported by: KMSAN
Reviewed by: delphij, asomers
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 0fcafe8516d170852aa73f029a6a28bed1e29292)

3 years agoAssert that valid PTEs are not overwritten when installing a new PTP
Mark Johnston [Thu, 15 Jul 2021 16:17:33 +0000 (12:17 -0400)]
Assert that valid PTEs are not overwritten when installing a new PTP

amd64 and 32-bit ARM already had assertions to this effect.  Add them to
other pmaps.

Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit b092c58c006fd5c5c051b30ab097f5c1655e0d53)

3 years agopf: Constify tag name and queue name helper functions
Mark Johnston [Thu, 15 Jul 2021 16:17:58 +0000 (12:17 -0400)]
pf: Constify tag name and queue name helper functions

No functional change intended.

Reviewed by: kp
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 81f95106b8c14d7ce935864b4705d54a8e437ed6)

3 years agommc: Drain the intrhook in mmc_detach()
Yang Zhong [Thu, 22 Jul 2021 17:16:01 +0000 (13:16 -0400)]
mmc: Drain the intrhook in mmc_detach()

Buggy SD card drivers may attach and detach a mmc(4) driver instance in
quick succession.  In this case mmc(4) must disestablish its intrhook
callback during detach.  Thus, this change adds a call to
config_intrhook_drain(), which blocks or does nothing if the intrhook is
running or has already ran (the SD card was plugged in), and
disestablishes the hook if it hasn't ran yet (the SD card was not
plugged in).

PR: 254373
Reviewed by: imp, manu, markj
Sponsored by: The FreeBSD Foundation

(cherry picked from commit d5341d72a11be200e536ac7d8967449a3f521792)

3 years agoman9: Update guarantees for userspace fetch/store operations
Mark Johnston [Thu, 22 Jul 2021 17:08:42 +0000 (13:08 -0400)]
man9: Update guarantees for userspace fetch/store operations

Platforms may either silently handle unaligned accesses or return an
error.  Atomicity is not guaranteed in this case, however.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit fd5827b1785a9363abe601cbd9d8558b0fc8d3e8)

3 years agoman9: Remove stray .In macros
Mark Johnston [Thu, 22 Jul 2021 16:47:43 +0000 (12:47 -0400)]
man9: Remove stray .In macros

Fixes: 9c11d8d483c4

(cherry picked from commit 18c696c00159d1071ed17e3bed1863e412dd5cb5)

3 years agonfsclient: Avoid copying uninitialized bytes into statfs
Mark Johnston [Thu, 15 Jul 2021 16:18:17 +0000 (12:18 -0400)]
nfsclient: Avoid copying uninitialized bytes into statfs

hst will be nul-terminated but the remaining space in the buffer is left
uninitialized.  Avoid copying the entire buffer to ensure that
uninitialized bytes are not leaked via statfs(2).

Reported by: KMSAN
Reviewed by: rmacklem
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 44de1834b53f4654cc2f6d76406f5705f8167927)

3 years agoarm64: Print CPU features slightly earlier
Mark Johnston [Tue, 20 Jul 2021 16:06:01 +0000 (12:06 -0400)]
arm64: Print CPU features slightly earlier

In particular, print them before we release APs.  Otherwise they tend to
get mixed with other kernel messages.

Reviewed by: andrew, manu
Sponsored by: The FreeBSD Foundation

(cherry picked from commit fa46a46a82498532f547be5f6b5a94d05f53b0be)

3 years agobsdinstall: Only show menu if there are more items to be installed
Renato Botelho [Thu, 22 Jul 2021 20:02:34 +0000 (16:02 -0400)]
bsdinstall: Only show menu if there are more items to be installed

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

(cherry picked from commit 95f0da5be1e3456c930f5f9538cbc099c65f2014)

3 years agoFix the 'linux' rc script on aarch64.
Edward Tomasz Napierala [Tue, 16 Mar 2021 16:48:13 +0000 (16:48 +0000)]
Fix the 'linux' rc script on aarch64.

Previously it would try to load linux.ko instead of linux64.ko
and fail.  While here, don't try to match 'linuxaout'; even if
implemented, it's the same module as `linuxelf`.

Reviewed By: emaste
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D29288

(cherry picked from commit e026f4243c5a65d19a63d98f55be17e8294a1e87)

3 years agofreebsd-tips: Use a fetchable URL as example
Li-Wen Hsu [Sun, 4 Jul 2021 14:00:46 +0000 (22:00 +0800)]
freebsd-tips: Use a fetchable URL as example

MFC after: 3 days

(cherry picked from commit ffe6afc4f0121f1909f2fa88694228f771dd3fcb)

freebsd-tips: Fix the description of fetch(1) to match the command

Reported by: jrtc27
MFC with: ffe6afc4f0121f1909f2fa88694228f771dd3fcb

(cherry picked from commit 167897510919a76740eca0d79713abbd088660fe)

3 years agoman7: Update FreeBSD.org URLs
Li-Wen Hsu [Sun, 4 Jul 2021 14:07:23 +0000 (22:07 +0800)]
man7: Update FreeBSD.org URLs

MFC after: 3 days

(cherry picked from commit 8dfb00245701a4f9290cd3a24e9bdcafa55a075b)

3 years agoshare/misc: Update FreeBSD.org URLs
Li-Wen Hsu [Sun, 4 Jul 2021 14:04:33 +0000 (22:04 +0800)]
share/misc: Update FreeBSD.org URLs

MFC after: 3 days

(cherry picked from commit 89c0640c7090d5dfbe46adbe50186399923f360f)

3 years agofreebsd-update: Update URL of supported platforms information
Li-Wen Hsu [Sun, 4 Jul 2021 13:45:08 +0000 (21:45 +0800)]
freebsd-update: Update URL of supported platforms information

MFC after: 3 days

(cherry picked from commit 86d0d3aadb48a9a917167078ed197a061179fa4f)

3 years ago[skip ci] correct a few SPDX license tags
Alan Somers [Wed, 7 Jul 2021 19:52:20 +0000 (13:52 -0600)]
[skip ci] correct a few SPDX license tags

These were all incorrectly labeled as 2-clause BSD licenses by a
semi-automated process, when in fact they are 3-clause.

Discussed with: pfg, imp
Sponsored by: Axcient

(cherry picked from commit 3874c0abb0afaea6adc24ac96dc9dc5043f2b69e)

3 years agofusefs: correctly set lock owner during FUSE_SETLK
Alan Somers [Thu, 20 May 2021 01:10:15 +0000 (19:10 -0600)]
fusefs: correctly set lock owner during FUSE_SETLK

During FUSE_SETLK, the owner field should uniquely identify the calling
process.  The fusefs module now sets it to the process's pid.
Previously, it expected the calling process to set it directly, which
was wrong.

libfuse also apparently expects the owner field to be set during
FUSE_GETLK, though I'm not sure why.

PR: 256005
Reported by: Agata <chogata@moosefs.pro>
Reviewed by: pfg
Differential Revision: https://reviews.freebsd.org/D30622

(cherry picked from commit 18b19f8c6e04935a63a951afe0e540674bc94455)

3 years agopf: clean up syncookie callout on vnet shutdown
Kristof Provost [Tue, 20 Jul 2021 19:03:08 +0000 (21:03 +0200)]
pf: clean up syncookie callout on vnet shutdown

Ensure that we cancel any outstanding callouts for syncookies when we
terminate the vnet.

MFC after: 1 week
Sponsored by: Modirum MDPay

(cherry picked from commit 32271c4d383effeac7878201ef5cbdfaeedc3755)

3 years agopf: remove stray debug line
Kristof Provost [Tue, 20 Jul 2021 19:02:33 +0000 (21:02 +0200)]
pf: remove stray debug line

MFC after: 1 week
Sponsored by: Modirum MDPay

(cherry picked from commit 84db87b8dafd9e9970fd36ac48c11ffdc89d31d0)

3 years agopf: fix LINT build
Kristof Provost [Tue, 20 Jul 2021 14:48:35 +0000 (16:48 +0200)]
pf: fix LINT build

We failed to list the new pf_syncookies.c file in sys/conf/files. This
worked for the usual configurations, where pf is a module, but not for
LINT builds.

Reported by: lwhsu
MFC after: 1 week
Sponsored by: Modirum MDPay

(cherry picked from commit b972a7fa9e1e01367435a5699b71cc7b5e494fee)

3 years agopf tests: ensure syncookie does not create state
Kristof Provost [Wed, 30 Jun 2021 13:27:46 +0000 (15:27 +0200)]
pf tests: ensure syncookie does not create state

Test that with syncookies enabled pf does not create state for
connections before the remote peer has replied to the SYN|ACK message.

MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D31142

(cherry picked from commit 27ab791a55191c0b6503391d411303b042b41047)

3 years agopf tests: Forwarding syncookie test
Kristof Provost [Wed, 2 Jun 2021 16:16:03 +0000 (18:16 +0200)]
pf tests: Forwarding syncookie test

Test syncookies on a forwarding host. That is, in a setup where the
machine (or vnet) running pf is not the same as the machine (or vnet)
running the server it's protecting.

MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D31141

(cherry picked from commit 3be9301a7e4fbd630cbde1bd3e1b59ac726e21af)

3 years agopfctl: syncookie configuration
Kristof Provost [Wed, 26 May 2021 11:41:34 +0000 (13:41 +0200)]
pfctl: syncookie configuration

pfctl and libpfctl code required to enable/disable the syncookie
feature.

MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D31140

(cherry picked from commit c69121c473d75abab55f9ade8e8138ac09c0942c)

3 years agopf: syncookie ioctl interface
Kristof Provost [Wed, 26 May 2021 08:18:19 +0000 (10:18 +0200)]
pf: syncookie ioctl interface

Kernel side implementation to allow switching between on and off modes,
and allow this configuration to be retrieved.

MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D31139

(cherry picked from commit 231e83d3422ff58fe94de8375a9532a1726056ed)

3 years agopf: syncookie support
Kristof Provost [Thu, 20 May 2021 09:54:41 +0000 (11:54 +0200)]
pf: syncookie support

Import OpenBSD's syncookie support for pf. This feature help pf resist
TCP SYN floods by only creating states once the remote host completes
the TCP handshake rather than when the initial SYN packet is received.

This is accomplished by using the initial sequence numbers to encode a
cookie (hence the name) in the SYN+ACK response and verifying this on
receipt of the client ACK.

Reviewed by: kbowling
Obtained from: OpenBSD
MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D31138

(cherry picked from commit 8e1864ed07121b479b95d7e3a5931a9e0ffd4713)

3 years agopf: factor out pf_synproxy()
Kristof Provost [Thu, 10 Jun 2021 13:49:09 +0000 (15:49 +0200)]
pf: factor out pf_synproxy()

MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D31137

(cherry picked from commit ee9c3d38039eb29966e1f0b8f617bc564c078289)

3 years agoRevert "loader: support.4th resets the read buffer incorrectly"
Warner Losh [Mon, 26 Jul 2021 22:40:41 +0000 (16:40 -0600)]
Revert "loader: support.4th resets the read buffer incorrectly"

This reverts commit 9c1c02093b90ae49745a174eb26ea85dd1990eec. It seems
to have broken all old nextboot.conf files causing hangs on boot.

PR: 239315

(cherry picked from commit 4783fb730fa1cfdbe5c905bb23ac74f681e2df6b)

3 years agogmirror: Zero the metadata block before writing
Mark Johnston [Tue, 13 Jul 2021 21:45:57 +0000 (17:45 -0400)]
gmirror: Zero the metadata block before writing

The mirror metadata fields contain string buffers and pad bytes, neither
were being zeroed before metadata was written to disk.  Also, the
metadata structure is smaller than the sector size, and in one case
gmirror was failing to zero-fill the full buffer before writing.

Fix these problems by pre-zeroing the metadata structure and the sector
buffer.

Reported by: KMSAN
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7f053a44aef75eab395ce15a1c8a1399a2f89cad)

3 years agoblist: Correct the node count computed in blist_create()
Mark Johnston [Tue, 13 Jul 2021 21:47:27 +0000 (17:47 -0400)]
blist: Correct the node count computed in blist_create()

Commit bb4a27f927a1 added the ability to allocate a span of blocks
crossing a meta node boundary.  To ensure that blst_next_leaf_alloc()
does not walk past the end of the tree, an extra all-zero meta node
needs to be present at the end of the allocation, and
blst_next_leaf_alloc() is implemented such that the presence of this
node terminates the search.

blist_create() computes the number of nodes required.  It had two
problems:
1. When the size of the blist is a power of BLIST_RADIX, we would
   unnecessarily allocate an extra level in the tree.
2. When the size of the blist is a multiple of BLIST_RADIX, we would
   fail to allocate a terminator node.  In this case,
   blst_next_leaf_alloc() could scan beyond the bounds of the
   allocation.  This was found using KASAN.

Modify blist_create() to handle these cases correctly.

Reported by: pho
Reviewed by: dougm

(cherry picked from commit 2783335caeae964bd8a1aa15726b523876613e45)

3 years agograid3: Zero the metadata block before writing
Mark Johnston [Tue, 13 Jul 2021 21:46:02 +0000 (17:46 -0400)]
graid3: Zero the metadata block before writing

Ensure that string buffers and pad bytes are zero-filled before writing
graid3 metadata.

Reported by: KMSAN
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 39552dff7bb5463a74e5195d65a3252c583d9414)

3 years agofifo: Explicitly initialize generation numbers when opening
Mark Johnston [Tue, 13 Jul 2021 21:45:49 +0000 (17:45 -0400)]
fifo: Explicitly initialize generation numbers when opening

The fi_rgen and fi_wgen fields are generation numbers used when sleeping
waiting for the other end of the fifo to be opened.  The fields were not
explicitly initialized after allocation, but this was harmless.  To
avoid false positives from KMSAN, though, ensure that they get
initialized to zero.

Reported by: KMSAN
Sponsored by: The FreeBSD Foundation

(cherry picked from commit b9ca419a21d109948bf0fcea5c59725f1fe0cd7b)

3 years agouart: Fix an out-of-bounds read in ns8250_bus_probe()
Mark Johnston [Tue, 13 Jul 2021 21:49:39 +0000 (17:49 -0400)]
uart: Fix an out-of-bounds read in ns8250_bus_probe()

The problem is that ns8250_bus_probe() accesses a field from the
ns8250_softc, which embeds the generic UART softc, but the ns8250_softc
hasn't yet been allocated because we're still probing.

This is a regression from commit 0aefb0a63c50.  This fixed a problem
where one of the upper four IER bits, which are usually reserved, needs
to be set in order to get RX interrupts before the RX FIFO is full.  At
the same time, we avoid clearing those reserved bits (see commit
58957d87173, though other UART drivers I looked at do not bother with
this).

So, copy what ns8250_init() does to disable interrupts, since we don't
know what the "right" mask is at this point.

Reported by: syzbot+f256beefd0df9eb796e7@syzkaller.appspotmail.com
Reviewed by: imp
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4a9a41650c909706bc0b9a3f29817c11b262b0a0)

3 years agocxgbe(4): Remove some dead code.
Navdeep Parhar [Wed, 19 May 2021 06:16:03 +0000 (23:16 -0700)]
cxgbe(4): Remove some dead code.

(cherry picked from commit 3965469eaa33aca03837baf5f88a55fa89f3f987)

3 years agoFix mismerge in OFED update
Hans Petter Selasky [Mon, 26 Jul 2021 16:12:35 +0000 (18:12 +0200)]
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

(cherry picked from commit 8a06ca2f734c726799688d65a7dad67284275438)

3 years agoipoib: Fix for accessing uninitialized pointers and freed memory during attach and...
Hans Petter Selasky [Mon, 12 Jul 2021 13:01:19 +0000 (15:01 +0200)]
ipoib: Fix for accessing uninitialized pointers and freed memory during attach and detach.

Call infiniband_ifdetach() early to stop ifioctl(9) calls from user-space
during device removal. Also make sure that ifioctl(9) calls are blocked from
executing until the device is fully initialized. Ideally we would delay the
infiniband_ifattach() call, but because part of the initialization is to update
the link level address, that is not possible without more significant changes.

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

(cherry picked from commit cd2c05d323d272163d04dd94caabe018ca2d4dc5)

3 years agomlx5: Numa domain improvements.
Hans Petter Selasky [Mon, 21 Jun 2021 13:42:20 +0000 (15:42 +0200)]
mlx5: Numa domain improvements.

Properly allocate all mlx5en(4) structures from correct numa domain.

While at it cleanup unused numa domain integers deriving from the
Linux version of mlx5en(4).

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

(cherry picked from commit 7c3eff94bda8bb746bfa7a5edc81b014e2dc97f6)

3 years agomlx5: Fix for uninitialized "uid" field.
Hans Petter Selasky [Mon, 21 Jun 2021 13:41:11 +0000 (15:41 +0200)]
mlx5: Fix for uninitialized "uid" field.

Make sure the "uid" field gets properly set when destroying DCT and QP
objects by making a copy of the field when creating such objects.

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

(cherry picked from commit cbf6911e10d7ed4e772affdd03cb4d439669acbd)