]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
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)

3 years agoe1000: disable hw.em.sbp debug setting
Kevin Bowling [Thu, 15 Apr 2021 16:48:41 +0000 (09:48 -0700)]
e1000: disable hw.em.sbp debug setting

This is a debugging tunable that shouldn't have retained this setting
after the initial iflib conversion of the driver

PR: 248934
Reported by: Franco Fichtner <franco@opnsense.org>
Reviewed by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29768

(cherry picked from commit 548d8a131d536d5f8e0818ff8cff7ffd63dbedfe)

3 years agosbin/ipfw: Fix parsing error in table based forward
Lutz Donnerhacke [Fri, 7 May 2021 18:59:34 +0000 (20:59 +0200)]
sbin/ipfw: Fix parsing error in table based forward

The argument parser does not recognise the optional port for an
"tablearg" argument.  Fix simplifies the code by make the internal
representation expicit for the parser.  Includes the fix from D30208.

PR: 252744
Reported by: <bugs.freebsd.org@mx.zzux.com>
Approved by: nc
Tested by: <bugs.freebsd.org@mx.zzux.com>
Differential Revision: https://reviews.freebsd.org/D30164

(cherry picked from commit 6cb13813caa09305046e0cecad8bba3ae2287b0d)
(cherry picked from commit f6f297871d469daf808f78faead8f950a2c81e36)

3 years agovfs: fix vnode use count leak in O_EMPTY_PATH support
Mateusz Guzik [Thu, 13 May 2021 09:23:03 +0000 (11:23 +0200)]
vfs: fix vnode use count leak in O_EMPTY_PATH support

The vnode returned by namei_setup is already referenced.

Reported by: pho

(cherry picked from commit cef8a95acbae0c3043d95028d8ebb24d959a82a0)

3 years agonfscl: fix typo in a comment
Rick Macklem [Tue, 4 May 2021 01:29:27 +0000 (18:29 -0700)]
nfscl: fix typo in a comment

(cherry picked from commit 0755df1eeee838e5b114c61886d6462507290977)

3 years agoAdd missing sockaddr length and family validation to various protocols
Mark Johnston [Mon, 3 May 2021 16:51:04 +0000 (12:51 -0400)]
Add missing sockaddr length and family validation to various protocols

Several protocol methods take a sockaddr as input.  In some cases the
sockaddr lengths were not being validated, or were validated after some
out-of-bounds accesses could occur.  Add requisite checking to various
protocol entry points, and convert some existing checks to assertions
where appropriate.

Reported by: syzkaller+KASAN
Reviewed by: tuexen, melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29519

(cherry picked from commit f161d294b92732df6254a89f393ab24999e122bf)

3 years agoin6_mcast: Return EADDRINUSE when we've already joined the group
Kristof Provost [Tue, 4 May 2021 17:23:15 +0000 (19:23 +0200)]
in6_mcast: Return EADDRINUSE when we've already joined the group

Distinguish between truly invalid requests and those that fail because
we've already joined the group. Both cases fail, but differentiating
them allows userspace to make more informed decisions about what the
error means.

For example. radvd tries to join the all-routers group on every SIGHUP.
This fails, because it's already joined it, but this failure should be
ignored (rather than treated as a sign that the interface's multicast is
broken).

This puts us in line with OpenBSD, NetBSD and Linux.

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

(cherry picked from commit 2ef5d803e3847f56771c107d9517ec560cf318c9)

3 years agoservice/ipfw: Silence warning on restart
Lutz Donnerhacke [Sun, 2 May 2021 20:47:04 +0000 (22:47 +0200)]
service/ipfw: Silence warning on restart

Once the ipfw0 interface has been created, ifconfig(8) create will
throw a warning: "ifconfig: create: bad value" when trying to create
it again.

PR: 241013
Submitted by: Jose Luis Duran
Approved by: kp
Differential Revision: https://reviews.freebsd.org/D30083

(cherry picked from commit 5c4fe2ac81a5e05062266d684fb53b9faefd0d38)

3 years agoClean up copyright messages.
Kirk McKusick [Tue, 11 May 2021 06:01:58 +0000 (23:01 -0700)]
Clean up copyright messages.

(cherry picked from commit 9e16b9530aab5e1c4efee2a8fe2feaf33340c764)

3 years agoixgbe: Restore AIM support
Sai Rajesh Tallamraju [Mon, 3 May 2021 17:45:00 +0000 (13:45 -0400)]
ixgbe: Restore AIM support

AIM (adaptive interrupt moderation) was part of BSD11 driver. Upon IFLIB
migration, AIM feature got lost. Re-introducing AIM back into IFLIB
based IXGBE driver.

One caveat is that in BSD11 driver, a queue comprises both Rx and Tx
ring. Starting from BSD12, Rx and Tx have their own queues and rings.
Also, IRQ is now only configured for Rx side. So, when AIM is
re-enabled, we should now consider only Rx stats for configuring EITR
register in contrast to BSD11 where Rx and Tx stats were considered to
manipulate EITR register.

Reviewed by: gallatin, markj
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D27344

(cherry picked from commit 64881da478071431a2d9e62613997a5772c56cdf)

3 years agoClean up fsck_ffs error message output.
Kirk McKusick [Tue, 27 Apr 2021 01:42:48 +0000 (18:42 -0700)]
Clean up fsck_ffs error message output.

(cherry picked from commit 689724cb23c2acf58091c80f27de4823d7cd87ca)

Sponsored by: Netflix

3 years agoMake fsck_ffs more persistent in creating a lost+found directory.
Kirk McKusick [Mon, 26 Apr 2021 23:47:27 +0000 (16:47 -0700)]
Make fsck_ffs more persistent in creating a lost+found directory.

(cherry picked from commit 84a0e3f95700733695115fb2a9d84d6666efe5d9)

Sponsored by: Netflix

3 years agocopy_file_range(2): improve copying of a large hole to EOF
Rick Macklem [Sun, 2 May 2021 23:04:27 +0000 (16:04 -0700)]
copy_file_range(2): improve copying of a large hole to EOF

PR#255523 reported that a file copy for a file with a large hole
to EOF on ZFS ran slowly over NFSv4.2.
The problem was that vn_generic_copy_file_range() would
loop around reading the hole's data and then see it is all
0s. It was coded this way since UFS always allocates a data
block near the end of the file, such that a hole to EOF never exists.

This patch modifies vn_generic_copy_file_range() to check for a
ENXIO returned from VOP_IOCTL(..FIOSEEKDATA..) and handle that
case as a hole to EOF. asomers@ confirms that it works for his
ZFS test case.

PR: 255523

(cherry picked from commit 4f592683c356379c5bac56b52807ed4ad54ee647)

3 years agofind(1): Document the -f option
Ceri Davies [Thu, 13 May 2021 08:10:22 +0000 (10:10 +0200)]
find(1): Document the -f option

PR: 223127
Reported by: Mathieu Arnold <mat at FreeBSD dot org>
Reviewed by: bcr, gbe
Differential Revision: https://reviews.freebsd.org/D30215

(cherry picked from commit 82483ea7adfe4213059f6dacf31f3bd1327b2cc0)

3 years agousr.bin/patch: remove unneeded header.
Xin LI [Sun, 2 May 2021 16:27:32 +0000 (09:27 -0700)]
usr.bin/patch: remove unneeded header.

(cherry picked from commit 9769f6f808210ddc304bc9e3c55121e6ce4d9075)

3 years agousr.bin/netstat: use roundup2 when rounding up to power of 2.
Xin LI [Sun, 2 May 2021 16:30:22 +0000 (09:30 -0700)]
usr.bin/netstat: use roundup2 when rounding up to power of 2.

(cherry picked from commit f6b6d216cafb154a85313a2d1bd34b18b9bfbba8)

3 years agocxgbe(4): Use ifaddr_event_ext instead of ifaddr_event for CLIP management.
Navdeep Parhar [Sat, 1 May 2021 23:53:50 +0000 (16:53 -0700)]
cxgbe(4): Use ifaddr_event_ext instead of ifaddr_event for CLIP management.

The _ext event notification includes the address being added/removed and
that gives the driver an easy way to ignore non-IPv6 addresses.  Remove
'tom' from the handler's name while here, it was moved out of t4_tom a
long time ago.

Sponsored by: Chelsio Communications

(cherry picked from commit f4ba035bca927e21f0f88ce56915523bafd573d9)

3 years agocxgbe(4): Do not panic when tx is called with invalid checksum requests.
Navdeep Parhar [Wed, 28 Apr 2021 20:45:58 +0000 (13:45 -0700)]
cxgbe(4): Do not panic when tx is called with invalid checksum requests.

There is no need to panic in if_transmit if the checksums requested are
inconsistent with the frame being transmitted.  This typically indicates
that the kernel and driver were built with different INET/INET6 options,
or there is some other kernel bug.  The driver should just throw away
the requests that it doesn't understand and move on.

Sponsored by: Chelsio Communications

(cherry picked from commit b9820bca183aba6c0c03a8b717bedd24da7428da)

3 years agocxgbe(4): hw.cxgbe.panic_on_fatal_err can be changed any time.
Navdeep Parhar [Fri, 23 Apr 2021 19:17:54 +0000 (12:17 -0700)]
cxgbe(4): hw.cxgbe.panic_on_fatal_err can be changed any time.

Sponsored by: Chelsio Communications

(cherry picked from commit 50f5d13eeb8835fe8250d65f033334d7d956d703)

3 years agocxgbe(4): Move the hw-specific parts of VXLAN setup to a separate function.
Navdeep Parhar [Fri, 23 Apr 2021 07:26:47 +0000 (00:26 -0700)]
cxgbe(4): Move the hw-specific parts of VXLAN setup to a separate function.

It can be called to (re)apply the settings in the driver softc to the
hardware.

Sponsored by: Chelsio Communications

(cherry picked from commit 5f00292fe3b76aba9115f3b2dfc887acb647eb91)

3 years agocxgbe(4): Add flag to reliably stop the driver from accessing hw stats.
Navdeep Parhar [Fri, 23 Apr 2021 00:45:52 +0000 (17:45 -0700)]
cxgbe(4): Add flag to reliably stop the driver from accessing hw stats.

There are two kinds of routines in the driver that read statistics from
the hardware: the cxgbe_* variants read the per-port MPS/MAC registers
and the vi_* variants read the per-VI registers.  They can be called
from the 1Hz callout or if_get_counter.  All stats collection now takes
place under the callout lock and there is a new flag to indicate that
these routines should not access any hardware register.

Sponsored by: Chelsio Communications

(cherry picked from commit b47b28e5b28aeaa42e87f905fe6a0fe65dbfc184)

3 years agocxgbe(4): RSS hash for VXLAN traffic is computed from the inner frame.
Navdeep Parhar [Tue, 13 Apr 2021 23:50:12 +0000 (16:50 -0700)]
cxgbe(4): RSS hash for VXLAN traffic is computed from the inner frame.

Sponsored by: Chelsio Communications

(cherry picked from commit d107ee06f3e3c15fe119ea01b120d11bf87ef9f0)

3 years agocxgbe(4): Fix minor nit in the display of MPS TCAM entries.
Navdeep Parhar [Thu, 22 Apr 2021 22:36:51 +0000 (15:36 -0700)]
cxgbe(4): Fix minor nit in the display of MPS TCAM entries.

(cherry picked from commit dc77e7929644b87c0aa3f8f5e8d57fd10f49df54)

3 years agocxgbe(4): make the logging helpers a little more robust.
Navdeep Parhar [Thu, 22 Apr 2021 22:28:43 +0000 (15:28 -0700)]
cxgbe(4): make the logging helpers a little more robust.

Sponsored by: Chelsio Communications

(cherry picked from commit 8f1bc78ef79bc13d88d15cdc5b1bf2f7361ded6d)

3 years agocxgbe/tom: Fix potential leak in t4_aiotx_process_job.
Navdeep Parhar [Sun, 4 Apr 2021 22:04:31 +0000 (15:04 -0700)]
cxgbe/tom: Fix potential leak in t4_aiotx_process_job.

The mbuf allocated could be a chain and must be freed with m_freem.

Reviewed by: jhb@
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D29579

(cherry picked from commit bf5057691bb0d1160d729772cdb4c449e366f5b4)

3 years agocxgbe(4): Always use the per-VI callout to read interface stats.
Navdeep Parhar [Thu, 1 Apr 2021 07:57:19 +0000 (00:57 -0700)]
cxgbe(4): Always use the per-VI callout to read interface stats.

There is no change in the source of the stats (t4_get_port_stats or
t4_get_vi_stats) but the per-port callout is gone.

Sponsored by: Chelsio Communications
Reviewed by: jhb@
Differential Revision: https://reviews.freebsd.org/D29527

(cherry picked from commit 516fe911a6b7a2d2f245ebbc7837e5dc2e353703)

3 years agocxgbe/t4_tom: restore socket's protosw before entering TIME_WAIT.
Navdeep Parhar [Tue, 30 Mar 2021 04:35:05 +0000 (21:35 -0700)]
cxgbe/t4_tom: restore socket's protosw before entering TIME_WAIT.

This fixes a panic due to stale so->so_proto if t4_tom is unloaded and
one or more connections that were previously offloaded are still around
in TIME_WAIT state.

Reviewed by: jhb@
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D29503

(cherry picked from commit 539489326947f2873f21b292941f8e5551f7c17b)

3 years agocxgbe(4): Allow a T6 adapter to switch between TOE and NIC TLS mode.
Navdeep Parhar [Wed, 24 Mar 2021 01:01:01 +0000 (18:01 -0700)]
cxgbe(4): Allow a T6 adapter to switch between TOE and NIC TLS mode.

The hw.cxgbe.kern_tls tunable was used for this in the past and if it
was set then all T6 adapters would be configured for NIC TLS operation
and could not be reconfigured for TOE without a reload.  With this
change ifconfig can be used to manipulate toe and txtls caps like any
other caps.  hw.cxgbe.kern_tls continues to work as usual but its
effects are not permanent any more.

* Enable nic_ktls_ofld in the default configuration file and use the
  firmware instead of direct register manipulation to apply/rollback
  NIC TLS configuration.  This allows the driver to switch the hardware
  between TOE and NIC TLS mode in a safe manner.  Note that the
  configuration is adapter-wide and not per-port.

* Remove the kern_tls config file as it works with 100G T6 cards only
  and leads to firmware crashes with 25G cards.  The configurations
  included with the driver (with the exception of the FPGA configs) are
  supposed to work with all adapters.

Reported by: Veeresh U.K. at Chelsio
Sponsored by: Chelsio Communications
Reviewed by: jhb@
Differential Revision: https://reviews.freebsd.org/D29291

(cherry picked from commit 15f33555678300953858f6ed98dfc72c399a9139)

3 years agocxgbe(4): create a separate helper routine to write the global RSS key.
Navdeep Parhar [Fri, 19 Mar 2021 20:28:11 +0000 (13:28 -0700)]
cxgbe(4): create a separate helper routine to write the global RSS key.

While here, make sure only the PF driver attempts to program the global
RSS key (with options RSS).  The VF driver doesn't have access to those
device registers.

Sponsored by: Chelsio Communications

(cherry picked from commit 3cc6f777befc2e494b39a4c0dcd91aaf99267f40)

3 years agocxgbe(4): make it safe to call setup_memwin repeatedly.
Navdeep Parhar [Fri, 19 Mar 2021 19:30:57 +0000 (12:30 -0700)]
cxgbe(4): make it safe to call setup_memwin repeatedly.

A repeat call will recreate the memory windows in the hardware and move
them to their last-known positions without repeating any of the software
initialization.

Sponsored by: Chelsio Communications

(cherry picked from commit a1d803c162067b6cd334fc8a44a89f26cc82d83b)

3 years agocxgbe(4): use standard sysctl routines to deal with 16b values.
Navdeep Parhar [Fri, 19 Mar 2021 17:56:24 +0000 (10:56 -0700)]
cxgbe(4): use standard sysctl routines to deal with 16b values.

These routines to handle 8b and 16b types were added in r289773 5+ years
ago.

Sponsored by: Chelsio Communications

(cherry picked from commit 473f6163e310b773dfd7e500e255d01d7328dd16)

3 years agocxgbe(4): catch up with the latest cryptocaps.
Navdeep Parhar [Mon, 15 Mar 2021 19:54:34 +0000 (12:54 -0700)]
cxgbe(4): catch up with the latest cryptocaps.

There are two crypto capabilities that the driver didn't know about.

Sponsored by: Chelsio Communications

(cherry picked from commit 0b373f26bea17e4b569531b94df30e1af6a0327b)

3 years agocxgbe(4): Remove extra blank line.
Navdeep Parhar [Fri, 5 Mar 2021 20:48:39 +0000 (12:48 -0800)]
cxgbe(4): Remove extra blank line.

No functional change.

(cherry picked from commit 765d623d606c0800f2f2689c03edecac473e30a9)

3 years agocxgbe(4): Fix an assertion that is not valid during attach.
Navdeep Parhar [Fri, 5 Mar 2021 19:28:18 +0000 (11:28 -0800)]
cxgbe(4): Fix an assertion that is not valid during attach.

Firmware access from t4_attach takes place without any synchronization.
The driver should not panic (debug kernels) if something goes wrong in
early communication with the firmware.  It should still load so that
it's possible to poke around with cxgbetool.

Sponsored by: Chelsio Communications

(cherry picked from commit 4a4e9c516cfc54181264c92276301a45ea4680d4)

3 years agocxgbetool(8): Add support for setting the hashfilter mode (filter mask).
Navdeep Parhar [Fri, 19 Feb 2021 22:22:08 +0000 (14:22 -0800)]
cxgbetool(8): Add support for setting the hashfilter mode (filter mask).

Tighten up the validation of filter modes while here.  Unrecognized
keywords will be now be flagged as errors instead of being ignored.

(cherry picked from commit 038148c108c4e7251c52364616273eec72b0c061)

3 years agocxgbe(4): Use the correct filter width for T5+.
Navdeep Parhar [Fri, 19 Feb 2021 22:18:08 +0000 (14:18 -0800)]
cxgbe(4): Use the correct filter width for T5+.

T5 and above have extra bits for the optional filter fields.  This is a
correctness issue and not just a waste because a filter mode valid on a
T4 (36b) may not be valid on a T5+ (40b).

Sponsored by: Chelsio Communications

(cherry picked from commit 0460a45062dfeb98b1f1f7a3a7b9268662b61545)

3 years agocxgbe(4): Add a driver ioctl to set the filter mask.
Navdeep Parhar [Fri, 19 Feb 2021 21:47:18 +0000 (13:47 -0800)]
cxgbe(4): Add a driver ioctl to set the filter mask.

Allow the filter mask (aka the hashfilter mode when hashfilters are
in use) to be set any time it is safe to do so.  The requested mask
must be a subset of the filter mode already.  The driver will not change
the mode or ingress config just to support a new mask.

Sponsored by: Chelsio Communications

(cherry picked from commit c91dda5ad923f24ef2e538b8dc180fa98598b4db)

3 years agocxgbe(4): Use firmware commands to get/set filter configuration.
Navdeep Parhar [Fri, 19 Feb 2021 21:05:19 +0000 (13:05 -0800)]
cxgbe(4): Use firmware commands to get/set filter configuration.

1. Query the firmware for filter mode, mask, and related ingress config
   instead of trying to figure them out from hardware registers.  Read
   configuration from the registers only when the firmware does not
   support this query.

2. Use the firmware to set the filter mode.  This is the correct way to
   do it and is more flexible as well.  The filter mode (and associated
   ingress config) can now be changed any time it is safe to do so.

   The user can specify a subset of a valid mode and the driver will
   enable enough bits to make sure that the mode is maxed out -- that
   is, it is not possible to set another bit without exceeding the
   total width for optional filter fields.  This is a hardware
   requirement that was not enforced by the driver previously.

Sponsored by: Chelsio Communications

(cherry picked from commit 7ac8040a99319456c3225cd5166390f5bd172fdf)

3 years agocxgbe(4): Break up t4_read_chip_settings.
Navdeep Parhar [Thu, 18 Feb 2021 09:15:46 +0000 (01:15 -0800)]
cxgbe(4): Break up t4_read_chip_settings.

Read the PF-only hardware settings directly in get_params__post_init.
Split the rest into two routines used by both the PF and VF drivers: one
that reads the SGE rx buffer configuration and another that verifies
miscellaneous hardware configuration.

Sponsored by: Chelsio Communications

(cherry picked from commit fae028dd97d8fc8f9ba5153408b177481dbefd70)

3 years agoImprove UMA cache reclamation.
Alexander Motin [Sun, 2 May 2021 23:35:28 +0000 (19:35 -0400)]
Improve UMA cache reclamation.

When estimating working set size, measure only allocation batches, not free
batches.  Allocation and free patterns can be very different.  For example,
ZFS on vm_lowmem event can free to UMA few gigabytes of memory in one call,
but it does not mean it will request the same amount back that fast too, in
fact it won't.

Update working set size on every reclamation call, shrinking caches faster
under pressure.  Lack of this caused repeating vm_lowmem events squeezing
more and more memory out of real consumers only to make it stuck in UMA
caches.  I saw ZFS drop ARC size in half before previous algorithm after
periodic WSS update decided to reclaim UMA caches.

Introduce voluntary reclamation of UMA caches not used for a long time. For
each zdom track longterm minimal cache size watermark, freeing some unused
items every UMA_TIMEOUT after first 15 minutes without cache misses. Freed
memory can get better use by other consumers.  For example, ZFS won't grow
its ARC unless it see free memory, since it does not know it is not really
used.  And even if memory is not really needed, periodic free during
inactivity periods should reduce its fragmentation.

Reviewed by: markj, jeff (previous version)
MFC after: 2 weeks
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D29790

(cherry picked from commit 2760658b211c654bce1dbde597bc52b49fde5d7e)

3 years agocryptodev: Fix some input validation bugs
Mark Johnston [Tue, 11 May 2021 21:36:12 +0000 (17:36 -0400)]
cryptodev: Fix some input validation bugs

- When we do not have a separate IV, make sure that the IV length
  specified by the session is not larger than the payload size.
- Disallow AEAD requests without a separate IV.  crp_sanity() asserts
  that CRYPTO_F_IV_SEPARATE is set for AEAD requests, and some (but not
  all) drivers require it.
- Return EINVAL for AEAD requests if an IV is specified but the
  transform does not expect one.

Reported by: syzbot+c9e8f6ff5cb7fa6a1250@syzkaller.appspotmail.com
Reported by: syzbot+007341439ae295cee74f@syzkaller.appspotmail.com
Reported by: syzbot+46e0cc42a428b3b0a40d@syzkaller.appspotmail.com
Reported by: syzbot+2c4d670173b8bdb947df@syzkaller.appspotmail.com
Reported by: syzbot+220faa5eeb4d47b23877@syzkaller.appspotmail.com
Reported by: syzbot+e83434b40f05843722f7@syzkaller.appspotmail.com
Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30154

(cherry picked from commit 1a04f0156c4e6abfc01d5841341a94179f317f31)

3 years agolibc: Some enhancements to syslog(3)
Dmitry Wagin [Tue, 23 Mar 2021 16:01:15 +0000 (12:01 -0400)]
libc: Some enhancements to syslog(3)

- Defined MAXLINE constant (8192 octets by default instead 2048) for
  centralized limit setting up. It sets maximum number of characters of
  the syslog message. RFC5424 doesn't limit maximum size of the message.
  Named after MAXLINE in syslogd(8).
- Fixed size of fmt_cpy buffer up to MAXLINE for rendering formatted
  (%m) messages.
- Introduced autoexpansion of sending socket buffer up to MAXLINE.

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

(cherry picked from commit 9bd7345212203924046009e29ce3f1515556f989)

3 years agosyslogd: Increase message size limits
Dmitry Wagin [Tue, 23 Mar 2021 16:15:28 +0000 (12:15 -0400)]
syslogd: Increase message size limits

Add a -M option to control the maximum length of forwarded messages.
syslogd(8) used to truncate forwarded messages to 1024 bytes, but after
commit 1a874a126a54 ("Add RFC 5424 syslog message output to syslogd.")
applies a more conservative limit of 480 bytes for IPv4 per RFC 5426
section 3.2.  Restore the old default behaviour of truncating to 1024
bytes.  RFC 5424 specifies no upper limit on the length of forwarded
messages, while for RFC 3164 the limit is 1024 bytes.

Increase MAXLINE to 8192 bytes to correspond to commit 672ef817a192.

Replaced bootfile[] size for MAXPATHLEN used in getbootfile(3) as a
returned value. Using (MAXLINE+1) as a size for bootfile[] is excessive.

PR: 241937
Differential Revision: https://reviews.freebsd.org/D27206

(cherry picked from commit 2d82b47a5b4ef18550565dd55628d51f54d0af2e)

3 years agopf tests: Test killing matching states
Kristof Provost [Mon, 3 May 2021 13:31:03 +0000 (15:31 +0200)]
pf tests: Test killing matching states

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

(cherry picked from commit ac200a9c3847d3a92c347de60e32a7af430dede6)

3 years agopf: Support killing 'matching' states
Kristof Provost [Mon, 3 May 2021 13:35:50 +0000 (15:35 +0200)]
pf: Support killing 'matching' states

Optionally also kill states that match (i.e. are the NATed state or
opposite direction state entry for) the state we're killing.

See also https://redmine.pfsense.org/issues/8555

Submitted by: Steven Brown
Reviewed by: bcr (man page)
Obtained from: https://github.com/pfsense/FreeBSD-src/pull/11/
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30092

(cherry picked from commit 93abcf17e6cf3c1cd8511c8ff7a8bf20b2d76367)

3 years agoauthpf: Start using libpfctl
Kristof Provost [Fri, 30 Apr 2021 08:26:52 +0000 (10:26 +0200)]
authpf: Start using libpfctl

Use pfctl_kill_states() rather than the DIOCKILLSTATES ioctl directly.

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

(cherry picked from commit 2b2ed4a69730be72f792179d57dedf2945b3d1aa)

3 years agopf tests: Test killing states by gateway
Kristof Provost [Fri, 30 Apr 2021 15:07:23 +0000 (17:07 +0200)]
pf tests: Test killing states by gateway

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

(cherry picked from commit c2e11d81d295f7d55ac8b6858b09d8fa123cbfe8)

3 years agopf: Allow states to by killed per 'gateway'
Kristof Provost [Fri, 30 Apr 2021 13:15:05 +0000 (15:15 +0200)]
pf: Allow states to by killed per 'gateway'

This allows us to kill states created from a rule with route-to/reply-to
set.  This is particularly useful in multi-wan setups, where one of the
WAN links goes down.

Submitted by: Steven Brown
Obtained from: https://github.com/pfsense/FreeBSD-src/pull/11/
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30058

(cherry picked from commit abbcba9cf5b1c26e837f00e0fbc205652cb05e51)

3 years agopfctl: Optionally show gateway information for states
Kristof Provost [Wed, 28 Apr 2021 16:17:40 +0000 (18:17 +0200)]
pfctl: Optionally show gateway information for states

When showing the states, in very verbose mode, also display the gateway
(i.e. the target for route-to/reply-to).

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

(cherry picked from commit cc948296e632e023f9374ccee68b5710f2ad54a9)

3 years agopfctl: Start using DIOCKILLSTATESNV
Kristof Provost [Thu, 29 Apr 2021 19:24:56 +0000 (21:24 +0200)]
pfctl: Start using DIOCKILLSTATESNV

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

(cherry picked from commit 2a00c4db93b8db0c326a57363ca8a690ef6ab082)

3 years agopfctl: Start using DIOCCLRSTATESNV
Kristof Provost [Thu, 29 Apr 2021 13:10:50 +0000 (15:10 +0200)]
pfctl: Start using DIOCCLRSTATESNV

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

(cherry picked from commit 53714a586133fd8ae662427007f84ec663cd83ef)

3 years agopf: Introduce DIOCKILLSTATESNV
Kristof Provost [Thu, 29 Apr 2021 15:20:36 +0000 (17:20 +0200)]
pf: Introduce DIOCKILLSTATESNV

Introduce an nvlist based alternative to DIOCKILLSTATES.

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

(cherry picked from commit e989530a09b6e9f77b89c950ecf32f1b4fa709da)

3 years agopf: Introduce DIOCCLRSTATESNV
Kristof Provost [Thu, 29 Apr 2021 09:07:02 +0000 (11:07 +0200)]
pf: Introduce DIOCCLRSTATESNV

Introduce an nvlist variant of DIOCCLRSTATES.

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

(cherry picked from commit 7606a45dcc87cb6b222af929dad37b615cb925cf)

3 years agorelease: fix ports checkout if /usr/ports does not exist
Glen Barber [Wed, 12 May 2021 16:08:59 +0000 (12:08 -0400)]
release: fix ports checkout if /usr/ports does not exist

Reported by: Yasuhiro Kimura
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit c0dbc49ab3f7e43a2972c932fcd2b2ed4d06448b)

3 years agorelease: remove logic to locate the svn{,lite} binary
Glen Barber [Wed, 12 May 2021 14:32:03 +0000 (10:32 -0400)]
release: remove logic to locate the svn{,lite} binary

Approved by: re (delphij, insta-MFC)
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 69b6abb7b2bb2b07600b27660d864ddcd0b28cec)

3 years agorelease: follow-up to previous commit to use Git for the ports tree
Glen Barber [Wed, 12 May 2021 14:29:53 +0000 (10:29 -0400)]
release: follow-up to previous commit to use Git for the ports tree

Approved by: re (delphij, insta-MFC)
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit fb6e261c20ebcd94875d623e167369802721f2dd)

3 years agorelease: update release.sh to use Git for ports tree checkouts
Glen Barber [Wed, 12 May 2021 14:27:21 +0000 (10:27 -0400)]
release: update release.sh to use Git for ports tree checkouts

Approved by: re (delphij, insta-MFC)
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 3f25cfea55922780fe47eb6ebcef49ca15297261)

3 years agorelease: permanently remove the 'reldoc' target and associates
Glen Barber [Thu, 18 Feb 2021 04:00:03 +0000 (23:00 -0500)]
release: permanently remove the 'reldoc' target and associates

Following 7b1d1a1658ffb69eff93afc713f9e88ed8b20eac, the structure
for the reldoc target has significantly changed as result of the
ASCIIDoctor/Hugo migration.  As the release notes related files
on the installation medium are inherently out of date, purge them
entirely.

Discussed within: re, doceng
No objection: re (silence), doceng (silence)
Timeout: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit f61e92ca5a23450bc28169bbdd71d7674df98c19)

3 years agoigmp: Avoid an out-of-bounds access when zeroing counters
Mark Johnston [Wed, 5 May 2021 21:06:23 +0000 (17:06 -0400)]
igmp: Avoid an out-of-bounds access when zeroing counters

When verifying, byte-by-byte, that the user-supplied counters are
zero-filled, sysctl_igmp_stat() would check for zero before checking the
loop bound.  Perform the checks in the correct order.

Reported by: KASAN
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6c34dde83ee61fc0ba095dcfdac2f381f6bae007)

3 years agofull(4): Use correct section name for AUTHORS
Gordon Bergling [Sun, 9 May 2021 15:31:52 +0000 (17:31 +0200)]
full(4): Use correct section name for AUTHORS

PR: 255715
Reported by: Christos Margiolis <christos at christosmarg dot xyz>

(cherry picked from commit 416051f5818e3270e019ef8978e2f1168f2628fc)

3 years agonfscl: add check for NULL clp and forced dismounts to nfscl_delegreturnvp()
Rick Macklem [Wed, 28 Apr 2021 00:30:16 +0000 (17:30 -0700)]
nfscl: add check for NULL clp and forced dismounts to nfscl_delegreturnvp()

Commit aad780464fad added a function called nfscl_delegreturnvp()
to return delegations during the NFS VOP_RECLAIM().
The function erroneously assumed that nm_clp would
be non-NULL. It will be NULL for NFSV4.0 mounts until
a regular file is opened. It will also be NULL during
vflush() in nfs_unmount() for a forced dismount.

This patch adds a check for clp == NULL to fix this.

Also, since it makes no sense to call nfscl_delegreturnvp()
during a forced dismount, the patch adds a check for that
case and does not do the call during forced dismounts.

PR: 255436
(cherry picked from commit f6fec55fe30088bbefd3efe70b62565399a7b9b8)

3 years agonfscl: return delegations in the NFS VOP_RECLAIM()
Rick Macklem [Mon, 26 Apr 2021 00:57:55 +0000 (17:57 -0700)]
nfscl: return delegations in the NFS VOP_RECLAIM()

After a vnode is recycled it can no longer be
acquired via vfs_hash_get() and, as such,
a delegation for the vnode cannot be recalled.

In the unlikely event that a delegation still
exists when the vnode is being recycled, return
the delegation since it will no longer be
recallable.

Until you have this patch in your NFSv4 client,
you should consider avoiding the use of delegations.

(cherry picked from commit aad780464fad1e32c97316515a4044d661413a6b)

3 years agoautofs: best effort to maintain mounttab and mountdtab
Robert Wing [Wed, 17 Feb 2021 07:51:38 +0000 (22:51 -0900)]
autofs: best effort to maintain mounttab and mountdtab

When an automounted filesystem is successfully unmounted, call
rpc.umntall(8) with the -k flag.

rpc.umntall(8) is used to clean up /var/db/mounttab on the client and
/var/db/mountdtab on the server. This is only useful for NFSv3.

PR:     251906
Reviewed by: trasz
Differential Revision:  https://reviews.freebsd.org/D27801

(cherry picked from commit 88e531f38c2412bf030f4e8dd563efc45b70797e)

3 years agopf: Error tracing SDTs
Kristof Provost [Tue, 20 Apr 2021 09:18:26 +0000 (11:18 +0200)]
pf: Error tracing SDTs

Add additional DTrace static trace points to facilitate debugging
failing pf ioctl calls.

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

(cherry picked from commit 6b146f3b9b665c9baf6ba2cb038bbee359cb738a)

3 years agopf tests: Test set keepcounters
Kristof Provost [Thu, 15 Apr 2021 14:53:16 +0000 (16:53 +0200)]
pf tests: Test set keepcounters

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

(cherry picked from commit e14d56f370184fdf7ef33ec57883a45f4a220cff)

3 years agopf: Optionally attempt to preserve rule counter values across ruleset updates
Kristof Provost [Thu, 15 Apr 2021 14:12:11 +0000 (16:12 +0200)]
pf: Optionally attempt to preserve rule counter values across ruleset updates

Usually rule counters are reset to zero on every update of the ruleset.
With keepcounters set pf will attempt to find matching rules between old
and new rulesets and preserve the rule counters.

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

(cherry picked from commit 42ec75f83aa321fcea8d2eddc4e9099724f0669e)

3 years agopf: Implement the NAT source port selection of MAP-E Customer Edge
Kurosawa Takahiro [Tue, 13 Apr 2021 08:50:00 +0000 (10:50 +0200)]
pf: Implement the NAT source port selection of MAP-E Customer Edge

MAP-E (RFC 7597) requires special care for selecting source ports
in NAT operation on the Customer Edge because a part of bits of the port
numbers are used by the Border Relay to distinguish another side of the
IPv4-over-IPv6 tunnel.

PR: 254577
Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D29468

(cherry picked from commit 2aa21096c7349390f22aa5d06b373a575baed1b4)

3 years agotruss: Add missing underscore to compat_prefix for FreeBSD32
Alex Richardson [Tue, 11 May 2021 09:52:56 +0000 (10:52 +0100)]
truss: Add missing underscore to compat_prefix for FreeBSD32

I accidentally dropped this in the final version of D27625, so it didn't
actually work as intended. I found this while testing the MFC to stable/13.

MFC after: immediately
Fixes: 7daca4e2043f ("truss: improved support for decoding compat32 arguments")

(cherry picked from commit 3cbad8287aa0ed72e07df1130ce2ae490642e63a)

3 years agotools/build/bootstrap-m4: regenerate after d37f81e35b
Alex Richardson [Wed, 21 Apr 2021 09:53:04 +0000 (10:53 +0100)]
tools/build/bootstrap-m4: regenerate after d37f81e35b

Reviewed by: jkim

(cherry picked from commit f8e57f89f3f550501c54ce839213a08981ff9250)

3 years agousr.bin/lex: regenerate bootstrap files after d37f81e35b
Alex Richardson [Wed, 21 Apr 2021 09:50:33 +0000 (10:50 +0100)]
usr.bin/lex: regenerate bootstrap files after d37f81e35b

Reviewed by: jkim

(cherry picked from commit c6e66cbfbbd1c5dec215cf91a79689037255171c)

3 years agocontrib/flex: Drop local __dead2 patch
Alex Richardson [Wed, 21 Apr 2021 09:48:55 +0000 (10:48 +0100)]
contrib/flex: Drop local __dead2 patch

Upstream flex has added a yynoreturn macro, so this diff is no longer
needed. Partially reverts r181269.

Reviewed By: jkim
Differential Revision: https://reviews.freebsd.org/D29679

(cherry picked from commit d37f81e35b6e8f114b04315e06bab2cf0c03946c)

3 years agolinker_set: fix globl/weak symbol redefinitions to work on clang 12
Greg V [Tue, 20 Apr 2021 00:47:15 +0000 (01:47 +0100)]
linker_set: fix globl/weak symbol redefinitions to work on clang 12

In clang 12.0.0.rc2, going from weak to global is now a hard error:

```
/usr/src/stand/libsa/amd64/_setjmp.S:67:25: error: _longjmp changed binding to STB_GLOBAL
.text; .p2align 4,0x90; .globl _longjmp; .type _longjmp,@function; _longjmp:; .cfi_startproc
```

And the other way is a warning, but we have -Werror:

```
error: __start_set_Xcommand_set changed binding to STB_WEAK [-Werror,-Winline-asm]
error: __stop_set_Xcommand_set changed binding to STB_WEAK [-Werror,-Winline-asm]
```

ref: https://reviews.llvm.org/D90108

Reviewed By: arichardson
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29159

(cherry picked from commit 32231805fbe2b9438c2de50c229b43c016207a08)

3 years agolibc/string/memset.c: Use unsigned long for stores
Alex Richardson [Mon, 19 Apr 2021 23:19:20 +0000 (00:19 +0100)]
libc/string/memset.c: Use unsigned long for stores

While most 64-bit architectures have an assembly implementation of this
file, RISC-V does not. As we now store 8 bytes instead of 4 it should speed
up RISC-V.

Reviewed By: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29536

(cherry picked from commit ab147542b7c0bbc41f7f0499b16933bd8f3f31d7)

3 years agolibc/string/bcopy.c: Use intptr_t as the copy type
Alex Richardson [Mon, 19 Apr 2021 23:15:57 +0000 (00:15 +0100)]
libc/string/bcopy.c: Use intptr_t as the copy type

While most 64-bit architectures have an assembly implementation of this
file RISC-V does not. As we now copy 8 bytes instead of 4 it should speed
up RISC-V. Using intptr_t instead of int also allows using this file for
CHERI pure-capability code since trying to copy pointers using integer
loads/stores will invalidate pointers.

Reviewed By: kib
Obtained from: CheriBSD (partially)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29535

(cherry picked from commit 0b4ad01d91a3b24cea00d54d25beed0f487c0183)

3 years agobsd.compiler.mk: detect Apple Clang for cross-builds
Alex Richardson [Tue, 20 Apr 2021 00:46:36 +0000 (01:46 +0100)]
bsd.compiler.mk: detect Apple Clang for cross-builds

Apple clang uses a different versioning scheme, so if we enable or
disable certain warnings for Clang 11+, those might not be supported
in Apple Clang 11+. This adds 'apple-clang' to COMPILER_FEATURES, so that
bootstrap tools Makefiles can avoid warnings on macOS.

Reviewed By: imp
Differential Revision: https://reviews.freebsd.org/D29680

(cherry picked from commit ba1182e26376987fe424707b2abc4d6532b28623)

3 years agotruss: improved support for decoding compat32 arguments
Alex Richardson [Thu, 25 Mar 2021 11:12:17 +0000 (11:12 +0000)]
truss: improved support for decoding compat32 arguments

Currently running `truss -a -e` does not decode any
argument values for freebsd32_* syscalls (open/readlink/etc.)

This change checks whether a syscall starts with freebsd{32,64}_ and if
so strips that prefix when looking up the syscall information. To ensure
that the truss logs include the real syscall name we create a copy of
the syscall information struct with the updated.

The other problem is that when reading string array values, truss
naively iterates over an array of char* and fetches the pointer value.
This will result in arguments not being loaded if the pointer is not
aligned to sizeof(void*), which can happens in the compat32 case. If it
happens to be aligned, we would end up printing every other value.
To fix this problem, this changes adds a pointer_size member to the
procabi struct and uses that to correctly read indirect arguments
as 64/32 bit addresses in the the compat32 case (and also compat64 on
CheriBSD).

The motivating use-case for this change is using truss for 64-bit
programs on a CHERI system, but most of the diff also applies to 32-bit
compat on a 64-bit system, so I'm upstreaming this instead of keeping it
as a local CheriBSD patch.

Output of `truss -aef ldd32 /usr/bin/ldd32` before:
39113: freebsd32_mmap(0x0,0x1000,0x3,0x1002,0xffffffff,0x0,0x0) = 543440896 (0x20644000)
39113: freebsd32_ioctl(0x1,0x402c7413,0xffffd2a0) = 0 (0x0)
/usr/bin/ldd32:
39113: write(1,"/usr/bin/ldd32:\n",16)  = 16 (0x10)
39113: fork()  = 39114 (0x98ca)
39114: <new process>
39114: freebsd32_execve(0xffffd97e,0xffffd680,0x20634000) EJUSTRETURN
39114: freebsd32_mmap(0x0,0x20000,0x3,0x1002,0xffffffff,0x0,0x0) = 541237248 (0x2042a000)
39114: freebsd32_mprotect(0x20427000,0x1000,0x1) = 0 (0x0)
39114: issetugid()  = 0 (0x0)
39114: openat(AT_FDCWD,"/etc/libmap32.conf",O_RDONLY|O_CLOEXEC,00) ERR#2 'No such file or directory'
39114: openat(AT_FDCWD,"/var/run/ld-elf32.so.hints",O_RDONLY|O_CLOEXEC,00) = 3 (0x3)
39114: read(3,"Ehnt\^A\0\0\0\M^@\0\0\0#\0\0\0\0"...,128) = 128 (0x80)
39114: freebsd32_fstat(0x3,0xffffbd98)  = 0 (0x0)
39114: freebsd32_pread(0x3,0x2042f000,0x23,0x80,0x0) = 35 (0x23)
39114: close(3)  = 0 (0x0)
39114: openat(AT_FDCWD,"/usr/lib32/libc.so.7",O_RDONLY|O_CLOEXEC|O_VERIFY,00) = 3 (0x3)
39114: freebsd32_fstat(0x3,0xffffc7d0)  = 0 (0x0)
39114: freebsd32_mmap(0x0,0x1000,0x1,0x40002,0x3,0x0,0x0) = 541368320 (0x2044a000)

After:
  783: freebsd32_mmap(0x0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 543543296 (0x2065d000)
  783: freebsd32_ioctl(1,TIOCGETA,0xffffd7b0)    = 0 (0x0)
/usr/bin/ldd32:
  783: write(1,"/usr/bin/ldd32:\n",16)           = 16 (0x10)
  784: <new process>
  783: fork()                                    = 784 (0x310)
  784: freebsd32_execve("/usr/bin/ldd32",[ "(null)" ],[ "LD_32_TRACE_LOADED_OBJECTS_PROGNAME=/usr/bin/ldd32", "LD_TRACE_LOADED_OBJECTS_PROGNAME=/usr/bin/ldd32", "LD_32_TRACE_LOADED_OBJECTS=yes", "LD_TRACE_LOADED_OBJECTS=yes", "USER=root", "LOGNAME=root", "HOME=/root", "SHELL=/bin/csh", "BLOCKSIZE=K", "MAIL=/var/mail/root", "MM_CHARSET=UTF-8", "LANG=C.UTF-8", "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin", "TERM=vt100", "HOSTTYPE=FreeBSD", "VENDOR=amd", "OSTYPE=FreeBSD", "MACHTYPE=x86_64", "SHLVL=1", "PWD=/root", "GROUP=wheel", "HOST=freebsd-amd64", "EDITOR=vi", "PAGER=less" ]) EJUSTRETURN
  784: freebsd32_mmap(0x0,135168,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 541212672 (0x20424000)
  784: freebsd32_mprotect(0x20421000,4096,PROT_READ) = 0 (0x0)
  784: issetugid()                               = 0 (0x0)
  784: sigfastblock(0x1,0x204234fc)              = 0 (0x0)
  784: open("/etc/libmap32.conf",O_RDONLY|O_CLOEXEC,00) ERR#2 'No such file or directory'
  784: open("/var/run/ld-elf32.so.hints",O_RDONLY|O_CLOEXEC,00) = 3 (0x3)
  784: read(3,"Ehnt\^A\0\0\0\M^@\0\0\0\v\0\0\0"...,128) = 128 (0x80)
  784: freebsd32_fstat(3,{ mode=-r--r--r-- ,inode=18680,size=32768,blksize=0 }) = 0 (0x0)
  784: freebsd32_pread(3,"/usr/lib32\0",11,0x80) = 11 (0xb)

Reviewed By: jhb
Differential Revision: https://reviews.freebsd.org/D27625

(cherry picked from commit 7daca4e2043fa8d88658eb8c2fc195128cb5c3da)

3 years agotruss: split counting of syscalls and syscall calling convention
Alex Richardson [Thu, 4 Mar 2021 18:28:25 +0000 (18:28 +0000)]
truss: split counting of syscalls and syscall calling convention

This change is a refactoring cleanup to improve support for compat32
syscalls (and compat64 on CHERI systems). Each process ABI now has it's
own struct sycall instead of using one global list. The list of all
syscalls is replaced with a list of seen syscalls. Looking up the syscall
argument passing convention now interates over the fixed-size array instead
of using a link-list that's populated on startup so we no longer need the
init_syscall() function.
The actual functional changes are in D27625.

Reviewed By: jhb
Differential Revision: https://reviews.freebsd.org/D27636

(cherry picked from commit 6019514b0b53c3fc151868b88357405b6d67f308)

3 years agonfscl: fix the handling of NFSERR_DELAY for Open/LayoutGet RPCs
Rick Macklem [Tue, 27 Apr 2021 00:48:21 +0000 (17:48 -0700)]
nfscl: fix the handling of NFSERR_DELAY for Open/LayoutGet RPCs

For a pNFS mount, the NFSv4.1/4.2 client uses compound RPCs that
have both Open and LayoutGet operations in them.
If the pNFS server were tp reply NFSERR_DELAY for one of these
compounds, the retry after a delay cannot be handled by
newnfs_request(), since there is a reference held on the open
state for the Open operation in them.

Fix this by adding these RPCs to the "don't do delay here"
list in newnfs_request().

This patch is only needed if the mount is using pNFS (the "pnfs"
mount option) and probably only matters if the MDS server
is issuing delegations as well as pNFS layouts.

Found by code inspection.

(cherry picked from commit f5ff282bc025f0395afcef40f5b6e778202c4181)

3 years agonfsd: fix a NFSv4.1 Linux client mount stuck in CLOSE_WAIT
Rick Macklem [Tue, 27 Apr 2021 22:32:35 +0000 (15:32 -0700)]
nfsd: fix a NFSv4.1 Linux client mount stuck in CLOSE_WAIT

It was reported that a NFSv4.1 Linux client mount against
a FreeBSD12 server was hung, with the TCP connection in
CLOSE_WAIT state on the server.
When a NFSv4.1/4.2 mount is done and the back channel is
bound to the TCP connection, the soclose() is delayed until
a new TCP connection is bound to the back channel, due to
a reference count being held on the SVCXPRT structure in
the krpc for the socket. Without the soclose() call, the socket
will remain in CLOSE_WAIT and this somehow caused the Linux
client to hang.

This patch adds calls to soshutdown(.., SHUT_WR) that
are performed when the server side krpc sees that the
socket is no longer usable.  Since this can be done
before the back channel is bound to a new TCP connection,
it allows the TCP connection to proceed to CLOSED state.

PR: 254590
(cherry picked from commit db8c27f499105dcc9872dcc46e88bdd570c24fee)

3 years agopath_test: Add a few new test cases
Mark Johnston [Tue, 4 May 2021 12:56:31 +0000 (08:56 -0400)]
path_test: Add a few new test cases

Sponsored by: The FreeBSD Foundation

(cherry picked from commit b59851e99c20f3a72c34bdf9919e3bf49b894e4e)

3 years agonfsclient: Copy only initialized fields in nfs_getattr()
Mark Johnston [Tue, 4 May 2021 12:53:57 +0000 (08:53 -0400)]
nfsclient: Copy only initialized fields in nfs_getattr()

When loading attributes from the cache, the NFS client is careful to
copy only the fields that it initialized.  After fetching attributes
from the server, however, it would copy the entire vattr structure
initialized from the RPC response, so uninitialized stack bytes would
end up being copied to userspace.  In particular, va_birthtime (v2 and
v3) and va_gen (v3) had this problem.

Use a common subroutine to copy fields provided by the NFS client, and
ensure that we provide a dummy va_gen for the v3 case.

Reviewed by: rmacklem
Reported by: KMSAN
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30090

(cherry picked from commit 8bde6d15d1fa9a947c2bdc5eddae36cfbb1076dc)

3 years agopf: Trivial typo fix
Kristof Provost [Thu, 29 Apr 2021 08:34:00 +0000 (10:34 +0200)]
pf: Trivial typo fix

PV -> PF

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

(cherry picked from commit eaabed8ac449dbd9a7f4f567e9378bda4636221e)

3 years agopfsync: Expose PFSYNCF_OK flag to userspace
Kristof Provost [Fri, 23 Apr 2021 12:24:59 +0000 (14:24 +0200)]
pfsync: Expose PFSYNCF_OK flag to userspace

Add 'syncok' field to ifconfig's pfsync interface output. This allows
userspace to figure out when pfsync has completed the initial bulk
import.

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

(cherry picked from commit 5f5bf88949df421ec3ccd7e14a999e8d8b9251bf)

3 years agopf tests: Test killing states with multiple labels
Kristof Provost [Wed, 21 Apr 2021 14:12:48 +0000 (16:12 +0200)]
pf tests: Test killing states with multiple labels

Now that we support having multiple labels on a rule ensure that we can
use each rule label to kill states.

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

(cherry picked from commit 5632f585355ad380cb9ef932c419e2efdb1fc46b)

3 years agopf: Allow multiple labels to be set on a rule
Kristof Provost [Tue, 20 Apr 2021 09:04:48 +0000 (11:04 +0200)]
pf: Allow multiple labels to be set on a rule

Allow up to 5 labels to be set on each rule.
This offers more flexibility in using labels. For example, it replaces
the customer 'schedule' keyword used by pfSense to terminate states
according to a schedule.

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

(cherry picked from commit 6fcc8e042ac480f9276177339f7de1ad0f95c1b0)

3 years agopf tests: Test automatically generated tables
Kristof Provost [Mon, 26 Apr 2021 09:14:44 +0000 (11:14 +0200)]
pf tests: Test automatically generated tables

Add a test case where the pfctl optimizer will generate a table
automatically. These tables have long names, which we accidentally broke
in the nvlist ADDRULE ioctl.

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

(cherry picked from commit 08d77308211f823b8532d27790e8fd29eaf75c77)

3 years agopf: Fix parsing of long table names
Kristof Provost [Sat, 24 Apr 2021 13:55:24 +0000 (15:55 +0200)]
pf: Fix parsing of long table names

When parsing the nvlist for a struct pf_addr_wrap we unconditionally
tried to parse "ifname". This broke for PF_ADDR_TABLE when the table
name was longer than IFNAMSIZ. PF_TABLE_NAME_SIZE is longer than
IFNAMSIZ, so this is a valid configuration.

Only parse (or return) ifname or tblname for the corresponding
pf_addr_wrap type.

This manifested as a failure to set rules such as these, where the pfctl
optimiser generated an automatic table:

pass in proto tcp to 192.168.0.1 port ssh
pass in proto tcp to 192.168.0.2 port ssh
pass in proto tcp to 192.168.0.3 port ssh
pass in proto tcp to 192.168.0.4 port ssh
pass in proto tcp to 192.168.0.5 port ssh
pass in proto tcp to 192.168.0.6 port ssh
pass in proto tcp to 192.168.0.7 port ssh

Reported by: Florian Smeets
Tested by: Florian Smeets
Reviewed by: donner
X-MFC-With: 5c11c5a3655842a176124ef2334fcdf830422c8a
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29962

(cherry picked from commit 402dfb0a8d2c6417cb9bff4460ef250a42b0aa05)

3 years agoUPDATING: Add an entry for commit 272f39942254
Rick Macklem [Mon, 10 May 2021 15:20:48 +0000 (08:20 -0700)]
UPDATING: Add an entry for commit 272f39942254

3 years agoparam.h: Bump __FreeBSD_version to 1300505 for 272f39942254
Rick Macklem [Mon, 10 May 2021 15:14:57 +0000 (08:14 -0700)]
param.h: Bump __FreeBSD_version to 1300505 for 272f39942254

Commit 272f39942254 changed the internal KAPI between the
nscl.ko and nfscommon.ko modules, so they both need to be
rebuilt from sources.

3 years agonfsd: fix the slot sequence# when a callback fails
Rick Macklem [Mon, 26 Apr 2021 23:24:10 +0000 (16:24 -0700)]
nfsd: fix the slot sequence# when a callback fails

Commit 4281bfec3628 patched the server so that the
callback session slot would be free'd for reuse when
a callback attempt fails.
However, this can often result in the sequence# for
the session slot to be advanced such that the client
end will reply NFSERR_SEQMISORDERED.

To avoid the NFSERR_SEQMISORDERED client reply,
this patch negates the sequence# advance for the
case where the callback has failed.
The common case is a failed back channel, where
the callback cannot be sent to the client, and
not advancing the sequence# is correct for this
case.  For the uncommon case where the client's
reply to the callback is lost, not advancing the
sequence# will indicate to the client that the
next callback is a retry and not a new callback.
But, since the FreeBSD server always sets "csa_cachethis"
false in the callback sequence operation, a retry
and a new callback should be handled the same way
by the client, so this should not matter.

Until you have this patch in your NFSv4.1/4.2 server,
you should consider avoiding the use of delegations.
Even with this patch, interoperation with the
Linux NFSv4.1/4.2 client in kernel versions prior
to 5.3 can result in frequent 15second delays if
delegations are enabled.  This occurs because, for
kernels prior to 5.3, the Linux client does a TCP
reconnect every time it sees multiple concurrent
callbacks and then it takes 15seconds to recover
the back channel after doing so.

(cherry picked from commit 87597731488105dd1ab921a95e39bb62e1abe668)

3 years agonfsd: fix session slot handling for failed callbacks
Rick Macklem [Fri, 23 Apr 2021 22:24:47 +0000 (15:24 -0700)]
nfsd: fix session slot handling for failed callbacks

When the NFSv4.1/4.2 server does a callback to a client
on the back channel, it will use a session slot in the
back channel session. If the back channel has failed,
the callback will fail and, without this patch, the
session slot will not be released.
As more callbacks are attempted, all session slots
can become busy and then the nfsd thread gets stuck
waiting for a back channel session slot.

This patch frees the session slot upon callback
failure to avoid this problem.

Without this patch, the problem can be avoided by leaving
delegations disabled in the NFS server.

(cherry picked from commit 4281bfec36285e2212f41568459c077bf4dbd91c)

3 years agonet: Introduce IPV6_DSCP(), IPV6_ECN() and IPV6_TRAFFIC_CLASS() macros
Hans Petter Selasky [Mon, 10 May 2021 14:30:44 +0000 (16:30 +0200)]
net: Introduce IPV6_DSCP(), IPV6_ECN() and IPV6_TRAFFIC_CLASS() macros

Introduce convenience macros to retrieve the DSCP, ECN or traffic class
bits from an IPv6 header.

Use them where appropriate.

Reviewed by: ae (previous version), rscheff, tuexen, rgrimes
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29056

(cherry picked from commit bb4a7d94b99fbf7f59c876ffff8ded5f6a5b5c3e)

3 years agoAdd more USB quirks for Garmin devices.
Hans Petter Selasky [Thu, 22 Apr 2021 10:31:33 +0000 (12:31 +0200)]
Add more USB quirks for Garmin devices.
Sort the Garmin products while at it.

PR: 254664
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 28af0c4814f5fb8ce047d4ac0bbf26997ac5cc8f)

3 years agoRemove USB device ID added by SVN r150701 in the CDC USB ethernet driver.
Hans Petter Selasky [Thu, 22 Apr 2021 10:22:39 +0000 (12:22 +0200)]
Remove USB device ID added by SVN r150701 in the CDC USB ethernet driver.
Since then, the FreeBSD USB stack has got proper USB RNDIS support.

PR: 254345
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit d2c87140648f61a6f139a2ecdf831e6a08cc4de2)

3 years agoAdd more USB quirks for Kingston devices.
Hans Petter Selasky [Thu, 22 Apr 2021 10:40:17 +0000 (12:40 +0200)]
Add more USB quirks for Kingston devices.

PR: 253855
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 47bc8fc9ae6ba7aa708e0d4ee059a377ae707e5a)

3 years agoFix build of stand/usb .
Hans Petter Selasky [Mon, 12 Apr 2021 14:12:18 +0000 (16:12 +0200)]
Fix build of stand/usb .

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 7497dd58890131251441ab992016c9457295094b)