]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agorsu(4): add ASUS WL-167G V3 to the list of supported devices.
Dmitry Chagin [Sun, 23 May 2021 15:42:29 +0000 (18:42 +0300)]
rsu(4): add ASUS WL-167G V3 to the list of supported devices.

(cherry picked from commit b595729ccfde8e5d5bac0acf9690de9d437a1afd)

2 years agopf: Fix more ioctl memory leaks
Kristof Provost [Tue, 1 Jun 2021 14:05:47 +0000 (16:05 +0200)]
pf: Fix more ioctl memory leaks

We must also remember to free nvlists added to a parent nvlist with
nvlist_append_nvlist_array().

More importantly, when nvlist_pack() allocates memory for us it does so
in the M_NVLIST zone, so we must free it with free(.., M_NVLIST). Using
free(.., M_TEMP) as we did silently failed to free the memory.

MFC after: 3 days
Reported by: kib@
Tested by: kib@
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30595

(cherry picked from commit 0f86492b09ca82042166a41f6f21b2dbe4f4a464)

2 years agonfsd: Add support for CLAIM_DELEG_PREV_FH to the NFSv4.1/4.2 Open
Rick Macklem [Fri, 21 May 2021 01:37:40 +0000 (18:37 -0700)]
nfsd: Add support for CLAIM_DELEG_PREV_FH to the NFSv4.1/4.2 Open

Commit b3d4c70dc60f added support for CLAIM_DELEG_CUR_FH to Open.
While doing this, I noticed that CLAIM_DELEG_PREV_FH support
could be added the same way.  Although I am not aware of any extant
NFSv4.1/4.2 client that uses this claim type, it seems prudent to add
support for this variant of Open to the NFSv4.1/4.2 server.

This patch does not affect mounts from extant NFSv4.1/4.2 clients,
as far as I know.

(cherry picked from commit d80a903a1c2acd73afbf06598955a0887433f8c6)

2 years agonfscl: Fix NFSv4.1/4.2 mount recovery from an expired lease
Rick Macklem [Wed, 19 May 2021 21:52:56 +0000 (14:52 -0700)]
nfscl: Fix NFSv4.1/4.2 mount recovery from an expired lease

The most difficult NFSv4 client recovery case happens when the
lease has expired on the server.  For NFSv4.0, the client will
receive a NFSERR_EXPIRED reply from the server to indicate this
has happened.
For NFSv4.1/4.2, most RPCs have a Sequence operation and, as such,
the client will receive a NFSERR_BADSESSION reply when the lease
has expired for these RPCs.  The client will then call nfscl_recover()
to handle the NFSERR_BADSESSION reply.  However, for the expired lease
case, the first reclaim Open will fail with NFSERR_NOGRACE.

This patch recognizes this case and calls nfscl_expireclient()
to handle the recovery from an expired lease.

This patch only affects NFSv4.1/4.2 mounts when the lease
expires on the server, due to a network partitioning that
exceeds the lease duration or similar.

(cherry picked from commit c28cb257ddfe3339756f6fd659fa4a2efa4de2cb)

2 years agoaic7xxx: Fix re-building firmware with -fno-common
Jessica Clarke [Fri, 28 May 2021 18:07:17 +0000 (19:07 +0100)]
aic7xxx: Fix re-building firmware with -fno-common

The generated C output for aicasm_scan.l defines yylineno already, so
references to it from other files should use an extern declaration.

The STAILQ_HEAD use in aicasm_symbol.h also provided an identifier,
causing it to both define the struct type and define a variable of that
struct type, causing any C file including the header to define the same
variable. This variable is not used (and confusingly clashes with a
field name just below) and was likely caused by confusion when switching
between defining fields using similar type macros and defining the type
itself.

Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30525

(cherry picked from commit 5e912f5fec025766521f535d1237330ede7f18e2)

2 years agolibpfctl: Improve error handling in pfctl_get_states()
Kristof Provost [Thu, 27 May 2021 09:43:17 +0000 (11:43 +0200)]
libpfctl: Improve error handling in pfctl_get_states()

Ensure that we always free nvlists and other allocated memory.

Reviewed by: scottl
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30493

(cherry picked from commit 27c77f42ae7402c313deec47aa67a8a8e0889410)

2 years agolibpfctl: fix memory leak
Kristof Provost [Thu, 27 May 2021 09:28:36 +0000 (11:28 +0200)]
libpfctl: fix memory leak

When we create an nvlist and insert it into another nvlist we must
remember to destroy it. The nvlist_add_nvlist() function makes a copy,
just like nvlist_add_string() makes a copy of the string.

See also 4483fb47735c29408c72045469c9c4b3e549668b

Reviewed by: scottl
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30492

(cherry picked from commit 6dbb729d35d59cc8bc8451bd56f220f9c35a43f3)

2 years agonfscl: Revert commit 5a8b2c5a46dffa3828ad16abee36ac4676f741bf
Rick Macklem [Thu, 3 Jun 2021 01:13:21 +0000 (18:13 -0700)]
nfscl: Revert commit 5a8b2c5a46dffa3828ad16abee36ac4676f741bf

This is a direct commit, since the MFC mis-merged.

2 years agoipfilter: Fix ip_nat memory leak and use-after-free
Cy Schubert [Tue, 25 May 2021 18:54:49 +0000 (11:54 -0700)]
ipfilter: Fix ip_nat memory leak and use-after-free

Unfortunately the wrong elemet is freed, also resulting in use-after-free.

PR: 255859
Submitted by: lylgood@foxmail.com
Reported by: lylgood@foxmail.com

(cherry picked from commit 323a4e2c4e285e6f8eee8db3fe2cb7490a734da0)

2 years agoMFV d60fa10fd872db7e3d8cb1e161cfdae026c43b14:
Cy Schubert [Wed, 10 Feb 2021 04:25:05 +0000 (20:25 -0800)]
MFV d60fa10fd872db7e3d8cb1e161cfdae026c43b14:

Update unbound 1.13.0 --> 1.13.1.

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

(cherry picked from commit f44e67d120ad78ef7894241b519ee79fd190a16e)

2 years agonfscl: Fix NFSv4.1/4.2 mount recovery from an expired lease
Rick Macklem [Wed, 19 May 2021 21:52:56 +0000 (14:52 -0700)]
nfscl: Fix NFSv4.1/4.2 mount recovery from an expired lease

The most difficult NFSv4 client recovery case happens when the
lease has expired on the server.  For NFSv4.0, the client will
receive a NFSERR_EXPIRED reply from the server to indicate this
has happened.
For NFSv4.1/4.2, most RPCs have a Sequence operation and, as such,
the client will receive a NFSERR_BADSESSION reply when the lease
has expired for these RPCs.  The client will then call nfscl_recover()
to handle the NFSERR_BADSESSION reply.  However, for the expired lease
case, the first reclaim Open will fail with NFSERR_NOGRACE.

This patch recognizes this case and calls nfscl_expireclient()
to handle the recovery from an expired lease.

This patch only affects NFSv4.1/4.2 mounts when the lease
expires on the server, due to a network partitioning that
exceeds the lease duration or similar.

(cherry picked from commit c28cb257ddfe3339756f6fd659fa4a2efa4de2cb)

3 years agopf tests: Only log critical errors from scapy
Kristof Provost [Wed, 26 May 2021 11:07:50 +0000 (13:07 +0200)]
pf tests: Only log critical errors from scapy

See a26e895f3d803cc1f4ee1c2b33c61330998808b9. Silence these new tests as
well.

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

(cherry picked from commit 9d0bc96ef8c0288c05a627b3961edd2da046c5c9)

3 years agopf tests: Test cases for fragment reassembly
Kristof Provost [Thu, 25 Feb 2021 08:50:57 +0000 (09:50 +0100)]
pf tests: Test cases for fragment reassembly

Obtained from: Alexander Bluhm, OpenBSD

(cherry picked from commit d39d5ee2d67f61abc890b51973b5c4a0c81d6647)

3 years agoCirrus-CI: avoid boot smoke test on stable/12
Ed Maste [Wed, 2 Jun 2021 14:11:40 +0000 (10:11 -0400)]
Cirrus-CI: avoid boot smoke test on stable/12

The boot smoke test boots from a FAT filesystem (created in-memory
by QEMU), but this does not work on stable/12:

mountroot: waiting for device /dev/ada0s1...
Mounting from msdosfs:/dev/ada0s1 failed with error 19.

For now on stable/12 use Cirrus-CI as only a build test.

Sponsored by: The FreeBSD Foundation

3 years agonetsmb: Avoid a read-after-free in smb_t2_request_int()
Mark Johnston [Wed, 26 May 2021 13:57:38 +0000 (09:57 -0400)]
netsmb: Avoid a read-after-free in smb_t2_request_int()

Defer freeing the request structure until we've decided whether the
request should be retried.

PR: 255881
MFC after: 1 week

(cherry picked from commit 771e95d2e2ee1b60539f1273c62837b48249590a)

3 years agorpcsec_gss: Use a designated initializer for rpc_gss_ops
Mark Johnston [Wed, 26 May 2021 14:14:35 +0000 (10:14 -0400)]
rpcsec_gss: Use a designated initializer for rpc_gss_ops

No functional change intended.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit ba5bc6e8f9cb9c523d09599d7290a6d75ec9fd8b)

3 years agocxgb: Avoid a read-after-free in get_packet() when cxgb_debug is on
Mark Johnston [Wed, 26 May 2021 14:02:19 +0000 (10:02 -0400)]
cxgb: Avoid a read-after-free in get_packet() when cxgb_debug is on

PR: 255863
MFC after: 1 week

(cherry picked from commit 16f8f89c5c1f324a15a7e0607f03f041a230a572)

3 years agoacpi: Add missing error handling to acpi_pci_link_route_irqs()
Mark Johnston [Wed, 26 May 2021 14:34:39 +0000 (10:34 -0400)]
acpi: Add missing error handling to acpi_pci_link_route_irqs()

Otherwise the resouce buffer may have been freed when
AcpiSetCurrentResources() is called, leading to a use-after-free.

PR: 255862
Submitted by: Lv Yunlong <lylgood@foxmail.com> (original version)
MFC after: 1 week

(cherry picked from commit 4cf33275289088e3b0a913a44b5cd549e348094d)

3 years agotests/libalias: Test LibAliasIn and redirection
Lutz Donnerhacke [Sun, 23 May 2021 12:43:00 +0000 (14:43 +0200)]
tests/libalias: Test LibAliasIn and redirection

Rework the tests to check the correct layer in a single test. Factor
out tests for reuse in other modules. Extend the test suite for
libalias(3) to incoming connections. Test the various types of
redirections.

gettimeofday(3) is almost as expensive as the calls to libalias.
So the call frequency for this call is reduced by a factor of 1000 in
order to neglect it's influence.

Using NAT entries became more realistic: A communication of a random
length of up to 150 packets (10% outgoing, 90% incoming) is applied
for each entry.

Add port forwardings to the performance tests.  This will cause random
incoming packets to match the random port forwardings opends beforehand.

After a long test run, a lot of ressouces have been allocated.
Measure the time tot free them.

Reviewed by: kp (partially)
Differential Revision: https://reviews.freebsd.org/D30412
Differential Revision: https://reviews.freebsd.org/D30408
Differential Revision: https://reviews.freebsd.org/D30405
Differential Revision: https://reviews.freebsd.org/D30443

(cherry picked from commit f1462ab0512c1a0e59f03a7a145df2889bed2997)
(cherry picked from commit 755bab6d55e6e2df168f352f3e2fbdea87002ed8)
(cherry picked from commit 6e87898a2c7e99937656a0c12d03333a43a10c5e)
(cherry picked from commit d62e1ecba07b2acee37e019778087f0f55d977d1)
(cherry picked from commit 5434ebd256a08e452dec376c1488abdf7ff02af8)

Fix various bugs:
(cherry picked from commit ccac04cae538a625cbce224e4005360fa85e1b9d)
(cherry picked from commit 7b8696bf128754712a24ba98ce2d88eed2ee68dc)
(cherry picked from commit fef99da69f983566de3cb8ad4a1b8decc31348ce)
(cherry picked from commit f4c460dacdda5c6e1896a0c51d6096c4f3417b32)

3 years agoiwn(4): Remove duplicate device entry
Gordon Bergling [Sun, 30 May 2021 13:40:33 +0000 (15:40 +0200)]
iwn(4): Remove duplicate device entry

'Intel Centrino Wireless-N 6250' is listed twice in the description
section of the manual page.

PR: 256257
Reported by: Daniel Cervus <danielthedeer at outlook dot com>

(cherry picked from commit 66e2a5803b0f80fff3bb8e3659ae7411ef94cc35)

3 years agotcsh: update to version 6.22.04.
Dmitry Chagin [Wed, 19 May 2021 21:12:27 +0000 (00:12 +0300)]
tcsh: update to version 6.22.04.

Merge commit '174d8b60324d7e8754709f7155e13ca95220b48c' into main.

(cherry picked from commit 6560ac57ce879857203bc456cdc3849808dc0700)

3 years agotcsh: cleanup source tree to reduce diff size.
Dmitry Chagin [Wed, 19 May 2021 21:08:25 +0000 (00:08 +0300)]
tcsh: cleanup source tree to reduce diff size.

Remove makefiles, configure files and unused at build time files
to reduce the diff size. Otherwise the diff contains a lot of
unnecessary lines what makes reviewing and merging proccess so hard,
especially for re@.

(cherry picked from commit 6190ff6104aed4cd753019325a252c4d66495b5e)

3 years agoFix packet cbs/ebs conversion.
Alexander Motin [Wed, 19 May 2021 15:00:21 +0000 (11:00 -0400)]
Fix packet cbs/ebs conversion.

Each packet is counted as 128 bytes by the code, not 125.  Not sure
what I was thinking about here 14 years ago.  May be just a typo.

Reported by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after: 2 weeks

(cherry picked from commit 4a6830761c6552bfe2c118a73a5a461694cb84c7)

3 years agopf: Move nvlist conversion functions to pf_nv
Kristof Provost [Tue, 18 May 2021 07:24:50 +0000 (09:24 +0200)]
pf: Move nvlist conversion functions to pf_nv

Separate the conversion functions (between kernel structs and nvlists)
to pf_nv. This reduces the size of pf_ioctl.c, which is already quite
large and complex, a good bit. It also keeps all the fairly
straightforward conversion code together.

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

(cherry picked from commit 3032c353882aa70a461ef251b8aa6c59a0829ec5)

3 years agorun(4): fix manual after d6fd321ef60d43dce9f437187c94a7de2b91ab69.
Dmitry Chagin [Sun, 23 May 2021 13:35:31 +0000 (16:35 +0300)]
run(4): fix manual after d6fd321ef60d43dce9f437187c94a7de2b91ab69.

PR: 255759

(cherry picked from commit 43f5d5bf01fdf821e8037272c636a9be18323e00)

3 years agorun(4): add support for ASUS USB-N14 wireless adaptor.
Dmitry Chagin [Sat, 22 May 2021 10:52:12 +0000 (13:52 +0300)]
run(4): add support for ASUS USB-N14 wireless adaptor.

PR: 255759
Submitted by: john.lmurdoch at gmail.com

(cherry picked from commit d6fd321ef60d43dce9f437187c94a7de2b91ab69)

3 years agoDRIVER_MODULE(9): Correct the SYNOPSIS of EARLY_DRIVER_MODULE()
J.R. Oldroyd [Mon, 24 May 2021 14:54:45 +0000 (16:54 +0200)]
DRIVER_MODULE(9): Correct the SYNOPSIS of EARLY_DRIVER_MODULE()

The man page SYNOPSIS for EARLY_DRIVER_MODULE() shows that it has
an "enum sysinit_elem_order order" argument.

The actual macro in sys/bus.h does not have an order argument.

PR: 256103
Reported by: J.R. Oldroyd <fbsd at opal dot com>
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D30411

(cherry picked from commit 3fdd5c1e49cbc0a77935eb34e3561c6021b93650)

3 years agonfsd: Add support for CLAIM_DELEG_CUR_FH to the NFSv4.1/4.2 Open
Rick Macklem [Tue, 18 May 2021 22:53:54 +0000 (15:53 -0700)]
nfsd: Add support for CLAIM_DELEG_CUR_FH to the NFSv4.1/4.2 Open

The Linux NFSv4.1/4.2 client now uses the CLAIM_DELEG_CUR_FH
variant of the Open operation when delegations are recalled and
the client has a local open of the file.  This patch adds
support for this variant of Open to the NFSv4.1/4.2 server.

This patch only affects mounts from Linux clients when delegations
are enabled on the server.

(cherry picked from commit b3d4c70dc60f1913f2363751b905b562c39ca126)

3 years agonfsd: Reduce the callback timeout to 800msec
Rick Macklem [Tue, 18 May 2021 23:17:58 +0000 (16:17 -0700)]
nfsd: Reduce the callback timeout to 800msec

Recent discussion on the nfsv4@ietf.org mailing list confirmed
that an NFSv4 server should reply to an RPC in less than 1second.
If an NFSv4 RPC requires a delegation be recalled,
the server will attempt a CB_RECALL callback.
If the client is not responsive, the RPC reply will be delayed
until the callback times out.
Without this patch, the timeout is set to 4 seconds (set in
ticks, but used as seconds), resulting in the RPC reply taking over 4sec.
This patch redefines the constant as being in milliseconds and it
implements that for a value of 800msec, to ensure the RPC
reply is sent in less than 1second.

This patch only affects mounts from clients when delegations
are enabled on the server and the client is unresponsive to callbacks.

(cherry picked from commit fc0dc94029df8150301b925bda690b20d9d0bcbf)

3 years agotaskqueue: Add missing comma to TASKQUEUE_FAST_DEFINE_THREAD
Colin Percival [Tue, 25 May 2021 03:37:55 +0000 (20:37 -0700)]
taskqueue: Add missing comma to TASKQUEUE_FAST_DEFINE_THREAD

Add missing comma to TASKQUEUE_FAST_DEFINE_THREAD arguments to prevent
compilation errors.

Submitted by: ashafer_badland.io

(cherry picked from commit 27f09959d5f507465cc7f202c1b34987f0cdee55)

3 years agotcp: Use local CC data only in the correct context
Richard Scheffenegger [Wed, 26 May 2021 17:45:06 +0000 (19:45 +0200)]
tcp: Use local CC data only in the correct context

Most CC algos do use local data, and when calling
newreno_cong_signal from there, the latter misinterprets
the data as its own struct, leading to incorrect behavior.

Reported by:  chengc_netapp.com
Reviewed By:  chengc_netapp.com, tuexen, #transport
MFC after:    3 days
Sponsored By: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D30470

(cherry picked from commit c358f1857f0c749ad166fb9e9bef04f4033f3a72)

3 years agoNFSv4 server: Re-establish the delegation recall timeout
Rick Macklem [Sun, 16 May 2021 23:40:01 +0000 (16:40 -0700)]
NFSv4 server: Re-establish the delegation recall timeout

Commit 7a606f280a3e allowed the server to do retries of CB_RECALL
callbacks every couple of seconds.  This was needed to allow the
Linux client to re-establish the back channel.
However this patch broke the delegation timeout check, such that
it would just keep retrying CB_RECALLS.
If the client has crashed or been network patitioned from the
server, this continues until the client TCP reconnects to
the server and re-establishes the back channel.

This patch modifies the code such that it still times out the
delegation recall after some minutes, so that the server will
allow the conflicting client request once the delegation times out.

This patch only affects the NFSv4 server when delegations are
enabled and a NFSv4 client that holds a delegation has crashed
or been network partitioned from the server for at least several
minutes when a delegation needs to be recalled.

(cherry picked from commit 46269d66ed02598c86756d81a7d7b27ec0f0c5cd)

3 years agoFix handling of embedded symbolic links
Kirk McKusick [Mon, 17 May 2021 00:02:42 +0000 (17:02 -0700)]
Fix handling of embedded symbolic links

Sponsored by: Netflix

(cherry picked from commit 9a2fac6ba65fbd14d37ccedbc2aec27a190128ea)

3 years agolibalias: replace placeholder with static constant
Lutz Donnerhacke [Thu, 13 May 2021 21:47:57 +0000 (23:47 +0200)]
libalias: replace placeholder with static constant

The field nullAddress in struct libalias is never set and never used.
It exists as a placeholder for an unused argument only.

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

(cherry picked from commit 189f8eea138a78b09c9f19114b1362b0df1cf87d)
(cherry picked from commit b03a41befeaf17ef25da96fc7bc2dc19c9a6b253)

3 years agolibalias: Style cleanup
Lutz Donnerhacke [Fri, 14 May 2021 13:08:08 +0000 (15:08 +0200)]
libalias: Style cleanup

libalias is a convolut of various coding styles modified by a series
of different editors enforcing interesting convetions on spacing and
comments.

This patch is a baseline to start with a perfomance rework of
libalias.  Upcoming patches should be focus on the code, not on the
style.  That's why most annoying style errors should be fixed
beforehand.

Reviewed by: hselasky
Discussed by: emaste
Differential Revision: https://reviews.freebsd.org/D30259

(cherry picked from commit effc8e57fbf03d7f1423c662caf2b63f0d1d21a9)

At some places the ASSERT was inserted before variable declarations are
finished.  This is fixed now.

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

(cherry picked from commit 2e6b07866f9e1520626a1523f6609cc411bdda1c)

3 years agoliblias: clean up empty lines in .c and .h files
Mateusz Guzik [Sun, 30 May 2021 19:12:53 +0000 (21:12 +0200)]
liblias: clean up empty lines in .c and .h files

Partial apply of a huge commit to libalias only
(cherry picked from commit 662c13053f4bf2d6245ba7e2b66c10d1cd5c1fb9)

3 years agolibalias: Fix remaining compiler warnings
Alex Richardson [Tue, 19 Jan 2021 11:32:32 +0000 (11:32 +0000)]
libalias: Fix remaining compiler warnings

This fixes some sign-compare warnings and adds a missing static to a
variable declaration.

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

3 years agolibalias: Fix -Wcast-align compiler warnings
Alex Richardson [Tue, 19 Jan 2021 11:32:32 +0000 (11:32 +0000)]
libalias: Fix -Wcast-align compiler warnings

This fixes -Wcast-align warnings caused by the underaligned `struct ip`.
This also silences them in the public functions by changing the function
signature from char * to void *. This is source and binary compatible and
avoids the -Wcast-align warning.

Reviewed By: ae, gbe (manpages)
Differential Revision: https://reviews.freebsd.org/D27882

3 years agotests/libalias: Reduce stress
Lutz Donnerhacke [Sun, 23 May 2021 20:41:26 +0000 (22:41 +0200)]
tests/libalias: Reduce stress

Due to the new, external performance test utility, the regular test
suite can reduce the stress test to a fair amount of activity.

(cherry picked from commit a660948b7b2d875591aba3713620424c51330038)

3 years agoAdd support for Gemini Lake LPSS UARTs.
Konstantin Belousov [Sun, 23 May 2021 16:38:54 +0000 (19:38 +0300)]
Add support for Gemini Lake LPSS UARTs.

PR: 256101

(cherry picked from commit eaf00819bcfa90ab7ac8af324826eb985197d8c8)

3 years agotest/libalias: Tests for instantiation and outgoing NAT
Lutz Donnerhacke [Sun, 16 May 2021 21:37:37 +0000 (23:37 +0200)]
test/libalias: Tests for instantiation and outgoing NAT

In order to modify libalias for performance, the existing
functionality must not change.  Enforce this.

Testing LibAliasOut functionality. This concentrates the typical use
case of initiating data transfers from the inside.  Provide a
exhaustive test for the data structure in order to check for
performance improvements.

In order to compare upcoming changes for their effectivness, measure
performance by counting opertions and the runtime of each operation
over the time.  Accumulate all tests in a single instance, so make it
complicated over the time.  If you wait long enough, you will notice
the expiry of old flows.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D30307
Differential Revision: https://reviews.freebsd.org/D30335
Differential Revision: https://reviews.freebsd.org/D30379

(cherry picked from commit 7fd8baee756efa18b6bbb17cbf3a652eb2058d87)
(cherry picked from commit c1fbb54f4b100d576da7ab065d1887a21f691936)
(cherry picked from commit 33c1bdfc3e098862100bab7a8dc729d8c78ffa7c)

3 years agolibradius: Fix attribute length validation in rad_get_attr(3)
Mark Johnston [Fri, 28 May 2021 14:41:43 +0000 (10:41 -0400)]
libradius: Fix attribute length validation in rad_get_attr(3)

The length of the attribute header needs to be excluded when comparing
the attribute length against the length of the packet.  Otherwise,
validation may incorrectly fail when fetching the final attribute in a
message.

Fixes: 8d5c78130 ("libradius: Fix input validation bugs")
Reported by: Peter Eriksson
Tested by: Peter Eriksson
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6bb5699d2b59491097bc21ffa3c097cdd4853f89)

3 years agoe1000: Correct promisc multicast filter handling
Kevin Bowling [Fri, 16 Apr 2021 23:15:50 +0000 (16:15 -0700)]
e1000: Correct promisc multicast filter handling

There are a number of issues in the e1000 multicast filter handling
that have been present for a long time. Take the updated approach from
ixgbe(4) which does not have the issues.

The issues are outlined in the PR, in particular this solves crossing
over and under the hardware's filter limit, not programming the
hardware filter when we are above its limit, disabling SBP (show bad
packets) when the tunable is enabled and exiting promiscuous mode, and
an off-by-one error in the em_copy_maddr function.

PR: 140647
Reported by: jtl
Reviewed by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29789

(cherry picked from commit 4b38eed76da9c36f09bff33b5cf15687cd99016f)

3 years agoixgbe: Improve device name strings
Kevin Bowling [Wed, 21 Apr 2021 02:35:14 +0000 (19:35 -0700)]
ixgbe: Improve device name strings

This is just clerical work to ease bug triage and may be used to set
expectations around the ability for anyone in the community to perform
testing and development on older parts.

Approved by: erj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29876

(cherry picked from commit fdbcd35a75e596a78b4c0330eaded476eaa14797)

3 years agoe1000: Rework em_msi_link interrupt filter
Kevin Bowling [Sun, 25 Apr 2021 08:22:23 +0000 (01:22 -0700)]
e1000: Rework em_msi_link interrupt filter

* Fix 82574 Link Status Changes, carrying the OTHER mask bit around as
  needed.
* Move igb-class LSC re-arming out of FAST back into the handler.
* Clarify spurious/other interrupt re-arms in FAST.

In MSI-X mode, 82574 and igb-class devices use an interrupt filter to
handle Link Status Changes. We want to do LSC re-arms in the handler
to take advantage of autoclear (EIAC) single shot behavior.

82574 uses 'Other' in ICR and IMS for LSC interrupt types when in MSI-X
mode, so we need to set and re-arm the 'Other' bit during attach and
after ICR reads in the FAST handler if not an LSC or after handling on
LSC due to autoclearing.

This work was primarily done to address the referenced PR, but inspired
some clarification and improvement for igb-class devices once the
intentions of previous bug fix attempts became clearer.

PR: 211219
Reported by: Alexey <aserp3@gmail.com>
Tested by: kbowling (I210 lagg), markj (I210)
Approved by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29943

(cherry picked from commit eea55de7b10808b86277d7fdbed2d05d3c6db1b2)

3 years agoe1000: Improve device name strings
Kevin Bowling [Wed, 21 Apr 2021 05:27:48 +0000 (22:27 -0700)]
e1000: Improve device name strings

This is just clerical work to ease bug triage and may be used to set
expectations around the ability for anyone in the community to perform
testing and development on older parts (this driver covers over 20 years
of silicon)

Reviewed by: erj
Approved by: markj
Sponsored by: Pink Floyd - Any Colour You Like (in kind)
Differential Revision: https://reviews.freebsd.org/D29872

(cherry picked from commit 0f6bea61edb4d055fe6e340aab3685054a582020)

3 years agoixgbe: Clean up unneeded set in ixgbe_if_multi_set
Kevin Bowling [Mon, 19 Apr 2021 19:22:22 +0000 (12:22 -0700)]
ixgbe: Clean up unneeded set in ixgbe_if_multi_set

We don't need to set the bits here since the if/else if/else statements
fully cover setting these bit pairs.

Reported by: markj
Reviewed by: markj, erj
Approved by: #intel_networking
MFC aftter: 1 week
Differential Revision: https://reviews.freebsd.org/D29827

(cherry picked from commit deecaa144526a5d001aeb99149e2139601388427)

3 years agopft_test.py: Support --replyif
Kristof Provost [Thu, 28 Jan 2021 10:02:20 +0000 (11:02 +0100)]
pft_test.py: Support --replyif

Partial cherry-picks from:

(cherry picked from commit cd579b6fba46b9f5005358d1e82def7b26703224)
(cherry picked from commit 6b52139eb8e8eda0ea263b24735556194f918642)

3 years agopf tests: Install common test code
Kristof Provost [Thu, 27 May 2021 20:45:10 +0000 (22:45 +0200)]
pf tests: Install common test code

(Direct commit to stable/12)

3 years agoMerge a bunch of googletest build improvements
Dimitry Andric [Thu, 27 May 2021 18:45:13 +0000 (20:45 +0200)]
Merge a bunch of googletest build improvements

googletest: pick from upstream: Don't allow signed/unsigned wchar_t in gcc 9 and later

Pick 711fccf8317b4fb7adc21c00fc1e20823c5d875f from upstream googletest:

    Don't allow signed/unsigned wchar_t in gcc 9 and later

Upstream pull request: https://github.com/google/googletest/pull/2270

Sponsored by: Dell EMC Isilon

(cherry picked from commit f157ca4696f5922275d5d451736005b9332eb136)

Major improvement to build parallelism for googletest internal tests

Currently the googletest internal tests build after the matching library.
However, each of these is serialized at the top level makefile.
Additionally some of the tests (e.g. the gmock-matches-test) take up to
90 seconds to build with clang -O2. Having to wait for this test to
complete before continuing to the next directory seriously slows down the
parllelism of a -j32 build.
Before this change running `make -C lib/googletest -j32 -s` in buildenv
took 202 seconds, now it's 153 due to improved parallelism.

Reviewed By: emaste (no objection)
Differential Revision: https://reviews.freebsd.org/D26748

(cherry picked from commit 2ed3236082a4473c1da8f72c1ebc071a7b54321f)

Enable SUBDIR_PARALLEL for lib/googletest

This saves a few seconds in a parallel build since we can build the
gtest_main and gmock subdirectories in parallel.

Reviewed By: ngie
Differential Revision: https://reviews.freebsd.org/D26760

(cherry picked from commit 4fa4bd6312cbeebda23a80feb77f29691af0cd7b)

Significantly reduce compile time for googletest internal tests

Clang's optimizer spends a really long time on these tests at -O2, so we now
use -O0 instead. This reduces the -j32 time for lib/googletest/test from 131s
to 29s. Using -O0 also reduces the disk usage from 144MB (at -O2) / 92MB (at
-O1) to 82MB.

Reviewed By: ngie, dim
Differential Revision: https://reviews.freebsd.org/D26751

(cherry picked from commit 433f33d285eee7cd6a822b9d833a537dfc808634)

3 years agoscsi(4): fix "NMVe" typo
Mitchell Horne [Fri, 21 May 2021 14:50:15 +0000 (11:50 -0300)]
scsi(4): fix "NMVe" typo

(cherry picked from commit 788401188f950001cd9796cdcea9a7e5f92050ab)

3 years agobuild(7): use a more relevant example for PORTS_MODULES
Mitchell Horne [Sat, 15 May 2021 14:14:52 +0000 (11:14 -0300)]
build(7): use a more relevant example for PORTS_MODULES

emulators/kqemu-kmod no longer exists in the ports tree.

Reviewed by: imp, bcr
Differential Revision: https://reviews.freebsd.org/D30261

(cherry picked from commit 7fbc0c98a8efaef86d72759372ec7746d929302e)

3 years agoufs: Avoid M_WAITOK allocations when building a dirhash
Don Morris [Thu, 20 May 2021 14:54:38 +0000 (10:54 -0400)]
ufs: Avoid M_WAITOK allocations when building a dirhash

At this point the directory's vnode lock is held, so blocking while
waiting for free pages makes the system more susceptible to deadlock in
low memory conditions.  This is particularly problematic on NUMA systems
as UMA currently implements a strict first-touch policy.

ufsdirhash_build() already uses M_NOWAIT for other allocations and
already handled failures for the block array allocation, so just convert
to M_NOWAIT.

PR: 253992
Reviewed by: markj, mckusick, vangyzen

(cherry picked from commit f17a5900850b4d449a91cbe9c61dfb62373c3cd1)

3 years agonetgraph/ng_bridge: Avoid cache thrashing
Lutz Donnerhacke [Thu, 11 Feb 2021 22:59:11 +0000 (23:59 +0100)]
netgraph/ng_bridge: Avoid cache thrashing

Hint the compiler, that this update is needed at most once per second.
Only in this case the memory line needs to be written.  This will
reduce the amount of cache trashing during forward of most frames.

Suggested by: zec
Approved by: zec
Differential Revision: https://reviews.freebsd.org/D28601

(cherry picked from commit 4dfe70fdbda05453e824bc9edfc0d09eab7b2929)

3 years agonetgraph/ng_bridge: become SMP aware
Lutz Donnerhacke [Tue, 12 Jan 2021 21:28:29 +0000 (22:28 +0100)]
netgraph/ng_bridge: become SMP aware

The node ng_bridge underwent a lot of changes in the last few months.
All those steps were necessary to distinguish between structure
modifying and read-only data transport paths.  Now it's done, the node
can perform frame forwarding on multiple cores in parallel.

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

(cherry picked from commit 9674c2e68c613757ddf5a8780743842b5ac4d74f)

3 years agonetgraph/ng_bridge: move MACs via control message
Lutz Donnerhacke [Tue, 9 Feb 2021 13:28:48 +0000 (14:28 +0100)]
netgraph/ng_bridge: move MACs via control message

Use the new control message to move ethernet addresses from a link to
a new link in ng_bridge(4).  Send this message instead of doing the
work directly requires to move the loop detection into the control
message processing.  This will delay the loop detection by a few
frames.

This decouples the read-only activity from the modification under a
more strict writer lock.

Reviewed by: manpages (gbe)
Differential Revision: https://reviews.freebsd.org/D28559

(cherry picked from commit f6e0c471691e0005e450ec968a9fa3b5346a3c45)

3 years agonetgraph/ng_bridge: learn MACs via control message
Lutz Donnerhacke [Tue, 4 May 2021 20:14:59 +0000 (22:14 +0200)]
netgraph/ng_bridge: learn MACs via control message

Add a new control message to move ethernet addresses to a given link
in ng_bridge(4). Send this message instead of doing the work directly.
This decouples the read-only activity from the modification under a
more strict writer lock.

Decoupling the work is a prerequisite for multithreaded operation.

Approved by: manpages (bcr), kp (earlier version)
Differential Revision: https://reviews.freebsd.org/D28516

(cherry picked from commit b1bd44732d8332930dc6a17092f47a201caff1ef)

3 years agopf: fix ioctl() memory leak
Kristof Provost [Mon, 24 May 2021 06:32:16 +0000 (08:32 +0200)]
pf: fix ioctl() memory leak

When we create an nvlist and insert it into another nvlist we must
remember to destroy it. The nvlist_add_nvlist() function makes a copy,
just like nvlist_add_string() makes a copy of the string. If we don't
we're leaking memory on every (nvlist-based) ioctl() call.

While here remove two redundant 'break' statements.

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

(cherry picked from commit 4483fb47735c29408c72045469c9c4b3e549668b)

3 years agopfctl tests: Test fairq configuration
Kristof Provost [Wed, 19 May 2021 07:52:50 +0000 (09:52 +0200)]
pfctl tests: Test fairq configuration

We used to have a bug where pfctl could crash setting fairq queues. Test
this case and ensure it does not crash pfctl.

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

(cherry picked from commit 9938fcaa6565a660c555a0e9c712842ba1a2d31c)

3 years agopfctl: Fix crash on ALTQ configuration
Kristof Provost [Tue, 18 May 2021 13:03:01 +0000 (15:03 +0200)]
pfctl: Fix crash on ALTQ configuration

The following config could crash pfctl:
altq on igb0 fairq bandwidth 1Gb queue { qLink }
queue qLink fairq(default)

That happens because when we're parsing the parent queue (on igb0) it
doesn't have a parent, and the check in eval_pfqueue_fairq() checks
pa->parent rather than parent.

This was changed in eval_pfqueue_hfsc() in
1d34c9dac8624c5c315ae39ad3ae8e5879b23256, but not for fairq.

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

(cherry picked from commit 26705a39e51eaf5b32efa98fb86df2d4ecfbdc61)

3 years agopf tests: Test the ability to kill floating states by interface
Kristof Provost [Thu, 13 May 2021 08:04:20 +0000 (10:04 +0200)]
pf tests: Test the ability to kill floating states by interface

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

(cherry picked from commit 7bd7933f9a4f1757fdefeee2e1ac8b8c4d299fc3)

3 years agopf: Support killing floating states by interface
Kristof Provost [Thu, 13 May 2021 07:51:28 +0000 (09:51 +0200)]
pf: Support killing floating states by interface

Floating states get assigned to interface 'all' (V_pfi_all), so when we
try to flush all states for an interface states originally created
through this interface are not flushed. Only if-bound states can be
flushed in this way.

Given that we track the original interface we can check if the state's
interface is 'all', and if so compare to the orig_if instead.

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

(cherry picked from commit b62489cc92edbec318fb6c57cdc02b5e3cfa3a67)

3 years agopf: Track the original kif for floating states
Kristof Provost [Wed, 12 May 2021 11:24:57 +0000 (13:24 +0200)]
pf: Track the original kif for floating states

Track (and display) the interface that created a state, even if it's a
floating state (and thus uses virtual interface 'all').

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

(cherry picked from commit d0fdf2b28f9b981d2cb98e9da8a715e046ef1e92)

3 years agopfctl: Use DIOCGETSTATESNV
Kristof Provost [Mon, 10 May 2021 14:51:38 +0000 (16:51 +0200)]
pfctl: Use DIOCGETSTATESNV

Migrate to using the new nvlist-based DIOCGETSTATESNV call to obtain the
states list.

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

(cherry picked from commit bc941291473d8a2164e4ffc3f3e7e6a356cbe747)

3 years agopf: Add DIOCGETSTATESNV
Kristof Provost [Wed, 5 May 2021 19:00:16 +0000 (21:00 +0200)]
pf: Add DIOCGETSTATESNV

Add DIOCGETSTATESNV, an nvlist-based alternative to DIOCGETSTATES.

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

(cherry picked from commit 0592a4c83d67547644763fb023abd5eb28e57f92)

3 years agopf: Add DIOCGETSTATENV
Kristof Provost [Wed, 5 May 2021 12:33:55 +0000 (14:33 +0200)]
pf: Add DIOCGETSTATENV

Add DIOCGETSTATENV, an nvlist-based alternative to DIOCGETSTATE.

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

(cherry picked from commit 1732afaa0dae9d844e341f2c1d6ed4b79c403bfb)

3 years agopfctl: Ensure parent queue is configured for FAIRQ
Kristof Provost [Tue, 18 May 2021 16:22:13 +0000 (18:22 +0200)]
pfctl: Ensure parent queue is configured for FAIRQ

We failed to account for the FAIRQ scheduler in expand_altq(), which led
it to be set up without its parent queue.

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

(cherry picked from commit dc784287967d45ab681dc51e9e20b78c8c535834)

3 years agohda: correct comment about Asus laptop digital mics
Philippe Michaud-Boudreault [Wed, 19 May 2021 14:32:25 +0000 (10:32 -0400)]
hda: correct comment about Asus laptop digital mics

Reported in review D30333

MFC after: 1 week

(cherry picked from commit 5d698386fbfe166df72a17712ffde8cefeecefab)

3 years agokldxref: do not error out if specified path is not directory, for -d mode
Konstantin Belousov [Thu, 20 May 2021 19:12:11 +0000 (22:12 +0300)]
kldxref: do not error out if specified path is not directory, for -d mode

(cherry picked from commit d7751071bc41c63c5dadd81ef4b0a26748d8f9b0)

3 years agolibradius: Fix input validation bugs
Mark Johnston [Tue, 25 May 2021 17:59:09 +0000 (13:59 -0400)]
libradius: Fix input validation bugs

Approved by: so
Security: FreeBSD-SA-21:12.libradius
Security: CVE-2021-29629
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8d5c7813061dfa0b187500dfe3aeea7a28181c13)

3 years agoamd64/linux*: add required header to get the constant value
Konstantin Belousov [Tue, 25 May 2021 22:19:44 +0000 (01:19 +0300)]
amd64/linux*: add required header to get the constant value

Otherwise asm silently interpret it as the external global symbol.

Reported by: bz
Sponsored by: The FreeBSD Foundation
Fixes: 91aae953cb80

(cherry picked from commit a59f0285377aa3d61cccda64e9ade126ecb3d2d9)

3 years agoamd64: clear PSL.AC in the right frame
Konstantin Belousov [Sat, 22 May 2021 19:48:36 +0000 (22:48 +0300)]
amd64: clear PSL.AC in the right frame

If copyin family of routines fault, kernel does clear PSL.AC on the
fault entry, but the AC flag of the faulted frame is kept intact.  Since
onfault handler is effectively jump, AC survives until syscall exit.

Reported by: m00nbsd, via Sony
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
admbugs: 975

(cherry picked from commit 91aae953cb807d6fb7a70782b323bf9beb60d7c9)

3 years agoalc(4): add support for Mikrotik 10/25G NIC
Konstantin Belousov [Wed, 19 May 2021 22:14:18 +0000 (01:14 +0300)]
alc(4): add support for Mikrotik 10/25G NIC

PR: 256000

(cherry picked from commit 77b637338a3656d4ccedb9798a3f98ac283962f4)

3 years agodummynet: Fix mbuf tag allocation failure handling
Mark Johnston [Tue, 18 May 2021 19:22:21 +0000 (15:22 -0400)]
dummynet: Fix mbuf tag allocation failure handling

PR: 255875, 255878, 255879, 255880
Reviewed by: donner, kp
Sponsored by: The FreeBSD Foundation

(cherry picked from commit c4a6258d70f73c27d8f0c6233edbcc609791806b)

3 years agosocket: Release cred reference later in sodealloc()
Lv Yunlong [Tue, 18 May 2021 19:23:15 +0000 (15:23 -0400)]
socket: Release cred reference later in sodealloc()

We dereference so->so_cred to update the per-uid socket buffer
accounting, so the crfree() call must be deferred until after that
point.

PR: 255869

(cherry picked from commit b295c5ddcef4744ef7044d2327b4258b6ad055f0)

3 years agottydev_write: prevent stops while terminal is busied
Konstantin Belousov [Thu, 13 May 2021 01:35:06 +0000 (04:35 +0300)]
ttydev_write: prevent stops while terminal is busied

PR: 255816

(cherry picked from commit 8cf912b017a04a2eec01fbaa1f7b9ef556403ede)

3 years agoipfw.8: Fix table example
Lutz Donnerhacke [Mon, 10 May 2021 18:31:52 +0000 (20:31 +0200)]
ipfw.8: Fix table example

Fix some erronous lines in the example section.

PR: 248943
Submitted by: Jose Luis Duran
Reviewers: ae, manpages (gbe)
Differential Revision: https://reviews.freebsd.org/D30191

(cherry picked from commit 802637be06457c7593692bdf79f8466fa5f54d4a)

3 years agopf tests: Explicitly ask for python3
Kristof Provost [Wed, 17 Feb 2021 10:45:54 +0000 (11:45 +0100)]
pf tests: Explicitly ask for python3

If we install the scapy package (which we do list as a dependency) we
don't automatically install python (but we do have python3).

MFC after:      1 week
Sponsored by:   Rubicon Communications, LLC (“Netgate”’)

(cherry picked from commit 4a7d84058d88244c405fc0b73d6985681eb661f5)

3 years agonetpfil tests: Add missing copyright & license statements
Kristof Provost [Tue, 29 Oct 2019 09:47:12 +0000 (09:47 +0000)]
netpfil tests: Add missing copyright & license statements

(cherry picked from commit 65d553b0f055e192b80217632a91833c9f509ccf)

3 years agodummynet: Remove unused code
Kristof Provost [Mon, 17 May 2021 11:41:39 +0000 (13:41 +0200)]
dummynet: Remove unused code

We never set 'busy' and never dequeue from the pending mq. Remove this
code.

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

(cherry picked from commit 02c44f40f984951fe34a1c5a43f40ff8147c52ca)

3 years agopf tests: More set skip on <ifgroup> tests
Kristof Provost [Sun, 16 May 2021 06:51:54 +0000 (08:51 +0200)]
pf tests: More set skip on <ifgroup> tests

Test the specific case reported in PR 255852. Clearing the skip flag
on groups was broken because pfctl couldn't work out if a kif was a
group or not, because the kernel no longer set the pfik_group pointer.

PR: 255852
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30285

(cherry picked from commit 45db38554517c7e1b0cc0265113c22f92a0eb494)

3 years agopf: Set the pfik_group for userspace
Kristof Provost [Sun, 16 May 2021 06:50:17 +0000 (08:50 +0200)]
pf: Set the pfik_group for userspace

Userspace relies on this pointer to work out if the kif is a group or
not. It can't use it for anything else, because it's a pointer to a
kernel address. Substitute 0xfeedc0de for 'true', so that we don't leak
kernel memory addresses to userspace.

PR: 255852
Reviewed by: donner
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30284

(cherry picked from commit d69cc040147284c414dfd1c9f498dcc7c8291a8b)

3 years agolinux: Fix a mistake in commit fb58045145
Mark Johnston [Mon, 17 May 2021 02:17:53 +0000 (22:17 -0400)]
linux: Fix a mistake in commit fb58045145

The change to futex_andl_smap() should have ordered stac before the
load from a user address, otherwise it does not fix anything.

Fixes: fb58045145 ("linux: Fix SMAP-enabled futex routines")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 60cb98a1bd2e4ea8fda532261f7211f5d4eba9c0)

3 years agolinux: Fix SMAP-enabled futex routines
Mark Johnston [Sun, 16 May 2021 17:41:41 +0000 (13:41 -0400)]
linux: Fix SMAP-enabled futex routines

Some of them were dereferencing the user pointer before disabling SMAP.

PR: 255591
Reviewed by: kib
Tested by: pitwuu@gmail.com
Sponsored by: The FreeBSD Foundation

(cherry picked from commit fb580451456aa769daa2f4b2f077e39692f80c62)

3 years agorpi_ft5406: Recognize raspberrypi,firmware-ts touchscreen
Juraj Lutter [Fri, 7 May 2021 21:48:21 +0000 (23:48 +0200)]
rpi_ft5406: Recognize raspberrypi,firmware-ts touchscreen

- Recognize raspberrypi,firmware-ts touchscreen
- Move the driver from ofwbus to simplebus

Reviewed by: manu
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30169

(cherry picked from commit c2c9ef3cedf6d83bdf27308e9e022658cc9b2a08)
(cherry picked from commit e7cd56cfe03720b5c0e8596303f6d1672a402903)

3 years agonetgraph/ng_checksum: Fix double free error
Lutz Donnerhacke [Sat, 15 May 2021 09:32:57 +0000 (11:32 +0200)]
netgraph/ng_checksum: Fix double free error

m_pullup(9) frees the mbuf(9) chain in the case of an allocation error.
The mbuf chain must not be freed again in this case.

PR: 255874
Submitted by: <lylgood@foxmail.com>
Approved by: markj
Differential Revision: https://reviews.freebsd.org/D30273

(cherry picked from commit 687e510e5ce32fddf46a9dc1d517ccc8a8e25581)

3 years agoif_vlan.c: really fix it.
Eugene Grosbein [Sun, 23 May 2021 03:01:56 +0000 (10:01 +0700)]
if_vlan.c: really fix it.

Sigh... Another direct commit to stable/12 to fix build.

3 years agoif_vlan.c: fix breakage after previous merge
Eugene Grosbein [Sun, 23 May 2021 01:04:47 +0000 (08:04 +0700)]
if_vlan.c: fix breakage after previous merge

Fix breakage after the commit 18fa0cbfc4e906fbf824651140f68d0a85c1d08f.
This is direct commit to stable/12 due to code base difference with head.

3 years agoMFC r351629: sys/net/if_vlan.c: Wrap a vlan's parent's if_output
Matt Joras [Fri, 30 Aug 2019 20:19:43 +0000 (20:19 +0000)]
MFC r351629: sys/net/if_vlan.c: Wrap a vlan's parent's if_output
in a separate function.

The merge is done in preparation of another merge
to support 802.1ad (qinq). Original commit log follows.

When a vlan interface is created, its if_output is set directly to the
parent interface's if_output. This is fine in the normal case but has an
unfortunate consequence if you end up with a certain combination of vlan
and lagg interfaces.

Consider you have a lagg interface with a single laggport member. When
an interface is added to a lagg its if_output is set to
lagg_port_output, which blackholes traffic from the normal networking
stack but not certain frames from BPF (pseudo_AF_HDRCMPLT). If you now
create a vlan with the laggport member (not the lagg interface) as its
parent, its if_output is set to lagg_port_output as well. While this is
confusing conceptually and likely represents a misconfigured system, it
is not itself a problem. The problem arises when you then remove the
lagg interface. Doing this resets the if_output of the laggport member
back to its original state, but the vlan's if_output is left pointing to
lagg_port_output. This gives rise to the possibility that the system
will panic when e.g. bpf is used to send any frames on the vlan
interface.

Fix this by creating a new function, vlan_output, which simply wraps the
parent's current if_output. That way when the parent's if_output is
restored there is no stale usage of lagg_port_output.

Reviewed by: rstone
Differential Revision: D21209

(cherry picked from commit 16cf6bdbb6cb18a5af7b499034b2176a1fa0a503)

3 years agostorvsc: fix auto-sense reporting
Andriy Gapon [Fri, 7 May 2021 07:17:57 +0000 (10:17 +0300)]
storvsc: fix auto-sense reporting

I saw a situation where the driver set CAM_AUTOSNS_VALID on a failed ccb
even though SRB_STATUS_AUTOSENSE_VALID was not set in the status.
The actual sense data remained all zeros.
The problem seems to be that create_storvsc_request() always sets
hv_storvsc_request::sense_info_len, so checking for sense_info_len != 0
is not enough to determine if any auto-sense data is actually available.

Sponsored by: CyberSecure

(cherry picked from commit 8afecefd57c5ac95200f43227cd00f265154acee)

3 years agompsutil: extend show adapter information, add NCQ control
Daniel Austin [Fri, 7 May 2021 11:41:53 +0000 (14:41 +0300)]
mpsutil: extend show adapter information, add NCQ control

'show adapter' now shows PCIe width and speed, IOC Speed, and the
temperature of the controller.

A new command, 'set ncq', is added.
It enables or disables SATA NCQ in the NVRAM of the card.
Its current setting is added to 'show adapter' as well.

PR: 254841
Relnotes: perhaps

(cherry picked from commit e2ea6942ab316d4cd5c2fef73ab28dc974b8dc51)

3 years agoPCI hot-plug: use dedicated taskqueue for device attach / detach
Andriy Gapon [Thu, 6 May 2021 18:49:37 +0000 (21:49 +0300)]
PCI hot-plug: use dedicated taskqueue for device attach / detach

Attaching and detaching devices can be heavy-weight and detaching can
sleep waiting for events.  For that reason using the system-wide
single-threaded taskqueue_thread is not really appropriate.
There is even a possibility for a deadlock if taskqueue_thread is used
for detaching.

In fact, there is an easy to reproduce deadlock involving nvme, pass
and a sudden removal of an NVMe device.
A pass peripheral would not release a reference on an nvme sim until
pass_shutdown_kqueue() is executed via taskqueue_thread.  But the
taskqueue's thread is blocked in nvme_detach() -> ... -> cam_sim_free()
because of the outstanding reference.

Sponsored by: CyberSecure
Reviewed by: mav, imp

(cherry picked from commit 12588ce02dd835b332952d9fece5881d943554a9)

3 years agoCorrect assert added to dump program.
Kirk McKusick [Mon, 17 May 2021 23:33:59 +0000 (16:33 -0700)]
Correct assert added to dump program.

(cherry picked from commit efe145a7453e4208f032816ce3f80e9fb6b0e4ee)

3 years agonetgraph/ng_bridge: Handle send errors during loop handling
Lutz Donnerhacke [Tue, 27 Apr 2021 07:49:50 +0000 (09:49 +0200)]
netgraph/ng_bridge: Handle send errors during loop handling

If sending out a packet fails during the loop over all links, the
allocated memory is leaked and not all links receive a copy.  This
patch fixes those problems, clarifies a premature abort of the loop,
and fixes a minory style(9) bug.

PR: 255430
Submitted by: Dancho Penev
Tested by: Dancho Penev
Differential Revision: https://reviews.freebsd.org/D30008

(cherry picked from commit a56e5ad6903037861457da754574b4903dcb0e7e)

3 years agoEnsure that files with no allocated blocks are trimmed to zero length.
Kirk McKusick [Tue, 11 May 2021 21:51:06 +0000 (14:51 -0700)]
Ensure that files with no allocated blocks are trimmed to zero length.

(cherry picked from commit a3628327e7b62c955e7bad9e43044cdb01984d80)

3 years agotests: Only log critical errors from scapy
Kristof Provost [Wed, 12 May 2021 17:13:40 +0000 (19:13 +0200)]
tests: Only log critical errors from scapy

Since 2.4.5 scapy started issuing warnings about a few different
configurations during our tests. These are harmless, but they generate
stderr output, which upsets atf_check.

Configure scapy to only log critical errors (and thus not warnings) to
fix these tests.

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

(cherry picked from commit a26e895f3d803cc1f4ee1c2b33c61330998808b9)

3 years agobridge tests: Test STP config BPDU validation
Kristof Provost [Thu, 15 Apr 2021 12:55:00 +0000 (14:55 +0200)]
bridge tests: Test STP config BPDU validation

PR: 254924
Reviewed by: donner
Differential Revision: https://reviews.freebsd.org/D29783

(cherry picked from commit 4ae3a97e127cea14277b904af31483af7e6e2891)

3 years agobridgestp: validate timer values in config BPDU
Jonah Caplan [Thu, 15 Apr 2021 09:28:42 +0000 (11:28 +0200)]
bridgestp: validate timer values in config BPDU

IEEE Std 802.1D-2004 Section 17.14 defines permitted ranges for timers.
Incoming BPDU messages should be checked against the permitted ranges.
The rest of 17.14 appears to be enforced already.

PR: 254924
Reviewed by: kp, donner
Differential Revision: https://reviews.freebsd.org/D29782

(cherry picked from commit 0e4025bffa2bab3461b72b40d0b1468722ff76e6)

3 years agonetinet6 tests: Fix Python warning
Kristof Provost [Tue, 11 May 2021 13:47:45 +0000 (15:47 +0200)]
netinet6 tests: Fix Python warning

Python 3.8 warns about line 112:
    'SyntaxWarning: "is" with a literal. Did you mean "=="?'

Use '==' as Python suggests.

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

(cherry picked from commit 80430c15caac0c10832455f868fa01c912996982)

3 years agoe1000: fix em_mac_min and 82547 packet buffer
Kevin Bowling [Thu, 15 Apr 2021 16:58:36 +0000 (09:58 -0700)]
e1000: fix em_mac_min and 82547 packet buffer

The boundary differentiating "lem" vs "em" class devices was wrong
after the iflib conversion of lem(4).

The Packet Buffer size for 82547 class chips was not set correctly
after the iflib conversion of lem(4).

These changes restore functionality on an 82547 for the submitter.

PR: 236119
Reported by: Jeff Gibbons <jgibbons@protogate.com>
Reviewed by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29766

(cherry picked from commit bb1b375fa7487ee5c3843121a0621ac8379c18e6)