]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoiicoc: support building as a module
Thomas Skibo [Mon, 1 Nov 2021 04:31:49 +0000 (12:31 +0800)]
iicoc: support building as a module

Only build on RISC-V for now, since we're not aware of any other cores
with this IP supported by FreeBSD.

Reviewed by: jrtc27, philip
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D32737

2 years agoiicoc: fix repeated start
Thomas Skibo [Mon, 1 Nov 2021 04:29:29 +0000 (12:29 +0800)]
iicoc: fix repeated start

Reviewed by: jrtc27, philip
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D32737

2 years agoiicoc: add support for SiFive HiFive Unmatched
Thomas Skibo [Mon, 1 Nov 2021 04:23:22 +0000 (12:23 +0800)]
iicoc: add support for SiFive HiFive Unmatched

Reviewed by: jrtc27, philip
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D32737

2 years agosinpi[fl] etc: Fix the ld128 implementations
Steve Kargl [Sun, 31 Oct 2021 22:26:20 +0000 (00:26 +0200)]
sinpi[fl] etc: Fix the ld128 implementations

Mark Murray graciously provided access to an aarch64 system
to test the ld128 implementations.  This patch address
* Misuses of copysignl() in sinpil() and tanpil().
* Redo the splitting of argument 'x' into an integer part and
  remainder.  The remainder must satify 0 <= r < 1.
* Update the reduction of the integer part to something that can
  easily be seen as even or odd, e.g., sin(pi*x) = (-1)^n*sin(pi*r)
  with n <= 2^112 and we an reduce n by subtracting integer powers
  of 2.
* In s_cospil.c, fix typos where 'x' is used where 'ax', the
  remainder, is required.
* In tanpil(), fix the use of an uninitialized variable, ax = fabsl(ax),
  ax should be x in fabsl().

One item of note, in the limited tested on aarch64, the max ULP
for sinpil() and cospil() were less than 1.1 ULP, which is higher
that the desired max ULP less than 1.  This was traced to the
kernel for cosl() in the fundamental interval [0,pi/4].
The coefficients in the minmax polynomial likely need refinement.

PR: 218514
MFC after: 1 week

2 years agonfscl: Do pNFS layout return_on_close synchronously
Rick Macklem [Sun, 31 Oct 2021 23:31:31 +0000 (16:31 -0700)]
nfscl: Do pNFS layout return_on_close synchronously

For pNFS servers that specify that Layouts are to be returned
upon close, they may expect that LayoutReturn to happen before
the associated Close.

This patch modifies the NFSv4.1/4.2 pNFS client so that this
is done.  This only affects a pNFS mount against a non-FreeBSD
NFSv4.1/4.2 server that specifies return_on_close in LayoutGet
replies.

Found during a recent IETF NFSv4 working group testing event.

MFC after: 2 weeks

2 years agogeli: eli data -> eli_data for consistency with other geom classes
Mateusz Guzik [Sun, 31 Oct 2021 20:36:51 +0000 (20:36 +0000)]
geli: eli data -> eli_data for consistency with other geom classes

PR: 259392
Reported by: dewayne@heuristicsystems.com.au
MFC after: 1 week

2 years agonet80211: add a driver-private pointer to struct ieee80211_node
Bjoern A. Zeeb [Sun, 31 Oct 2021 19:08:28 +0000 (19:08 +0000)]
net80211: add a driver-private pointer to struct ieee80211_node

Add a void *ni_drv_data field to struct ieee80211_node that drivers
can use to backtrack to their internal state from a net80211 node.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week
X-Differential Revision: https://reviews.freebsd.org/D30654 (abandoned)

2 years agoBump __FreeBSD_version following the libdialog shared library
Xin LI [Sun, 31 Oct 2021 06:09:29 +0000 (23:09 -0700)]
Bump __FreeBSD_version following the libdialog shared library
version number bump.

2 years agoprocfs: return right hardlink from /proc/curproc/file
Konstantin Belousov [Fri, 29 Oct 2021 01:43:32 +0000 (04:43 +0300)]
procfs: return right hardlink from /proc/curproc/file

Use proc_get_binpath() to get the hardlink right.

PR: 248184
Reviewed by: emaste, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32738

2 years agoExtract proc_get_binpath() from sysctl_kern_proc_pathname()
Konstantin Belousov [Fri, 29 Oct 2021 01:42:59 +0000 (04:42 +0300)]
Extract proc_get_binpath() from sysctl_kern_proc_pathname()

Reviewed by: emaste, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32738

2 years agosys/proc.h: put proc_add_orphan() into proper place
Konstantin Belousov [Fri, 29 Oct 2021 22:02:32 +0000 (01:02 +0300)]
sys/proc.h: put proc_add_orphan() into proper place

Noted by: markj
Reviewed by: emaste, markjd
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32738

2 years agonfscl: Add setting n_localmodtime to the Write RPC code
Rick Macklem [Sun, 31 Oct 2021 00:08:28 +0000 (17:08 -0700)]
nfscl: Add setting n_localmodtime to the Write RPC code

Similar to commit 2be417843a, I believe there could be a race between
the NFS client VOP_LOOKUP() and file Writing that could result in stale
file attributes being loaded into the NFS vnode by VOP_LOOKUP().

I have not been able to reproduce a failure due to this race, but
I believe that there are two possibilities:

The Lookup RPC happens while VOP_WRITE() is being executed and loads
stale file attributes after VOP_WRITE() returns when it has already
completed the Write/Commit RPC(s).
--> For this case, setting the local modify timestamp at the end of
  VOP_WRITE() should ensure that stale file attributes are not loaded.

The Lookup RPC occurs after VOP_WRITE() has returned, while
asynchronous Write/Commit RPCs are in progress and then is
blocked by the vnode held by VOP_OPEN/VOP_CLOSE/VOP_FSYNC which
will flush writes via ncl_flush() or ncl_vinvalbuf(), clearing the
NMODIFIED flag (which indicates Writes-in-progress). The VOP_LOOKUP()
then acquires the NFS vnode lock and fills in stale file attributes.
 --> Setting the local modify timestamp in ncl_flsuh() and ncl_vinvalbuf()
   when they clear NMODIFIED should ensure that stale file attributes
   are not loaded.

This patch does the above.

PR: 259071
Reviewed by: asomers
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D32677

2 years agonfscl: Set n_localmodtime in Deallocate
Rick Macklem [Sat, 30 Oct 2021 23:46:14 +0000 (16:46 -0700)]
nfscl: Set n_localmodtime in Deallocate

Commit 2be417843a04 added n_localmodtime, which is used by Lookup
and ReaddirPlus to check to see if the file attributes in an RPC
reply might be stale.  This patch sets n_localmodtime in Deallocate.
Done as a separate commit, since Deallocate is not in stable/13.

PR: 259071
Reviewed by: asomers
Differential Revision: https://reviews.freebsd.org/D32635

2 years agoPR#259071 provides a test program that fails for the NFS client.
Rick Macklem [Sat, 30 Oct 2021 23:35:02 +0000 (16:35 -0700)]
PR#259071 provides a test program that fails for the NFS client.
Testing with it, there appears to be a race between Lookup
and VOPs like Setattr-of-size, where Lookup ends up loading
stale attributes (including what might be the wrong file size)
into the NFS vnode's attribute cache.

The race occurs when the modifying VOP (which holds a lock
on the vnode), blocks the acquisition of the vnode in Lookup,
after the RPC (with now potentially stale attributes).

Here's what seems to happen:
Child                                Parent

does stat(), which does
VOP_LOOKUP(), doing the Lookup
RPC with the directory vnode
locked, acquiring file attributes
valid at this point in time

blocks waiting for locked file       does ftruncate(), which
vnode                                does VOP_SETATTR() of Size,
                                     changing the file's size
                                     while holding an exclusive
                                     lock on the file's vnode
                                     releases the vnode lock
acquires file vnode and fills in
now stale attributes including
the old wrong Size
                                     does a read() which returns
                                     wrong data size

This patch fixes the problem by saving a timestamp in the NFS vnode
in the VOPs that modify the file (Setattr-of-size, Allocate).
Then lookup/readdirplus compares that timestamp with the time just
before starting the RPC after it has acquired the file's vnode.
If the modifying RPC occurred during the Lookup, the attributes
in the RPC reply are discarded, since they might be stale.

With this patch the test program works as expected.

Note that the test program does not fail on a July stable/12,
although this race is in the NFS client code.  I suspect a
fairly recent change to the name caching code exposed this
bug.

PR: 259071
Reviewed by: asomers
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D32635

2 years agolinux: make PTRACE_SETREGS use a correct struct
Edward Tomasz Napierala [Sat, 30 Oct 2021 09:13:32 +0000 (10:13 +0100)]
linux: make PTRACE_SETREGS use a correct struct

Note that this is largely untested at this point, as was
the previous version; I'm committing this mostly to get
rid of `struct linux_pt_reg`.

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32735

2 years agolinux: Add additional ptracestop only if the debugger is Linux
Edward Tomasz Napierala [Sat, 30 Oct 2021 08:53:55 +0000 (09:53 +0100)]
linux: Add additional ptracestop only if the debugger is Linux

In 6e66030c4c0, additional ptracestop was added in order
to implement PTRACE_EVENT_EXEC.  Make it only apply to cases
where the debugger is a Linux processes; native FreeBSD
debuggers can trace Linux processes too, but they don't
expect that additonal ptracestop.

Fixes: 6e66030c4c0
Reported By: kib
Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32726

2 years agousr.bin/stat: honour locale for "-t %+"
Stefan Eßer [Sat, 30 Oct 2021 07:00:34 +0000 (09:00 +0200)]
usr.bin/stat: honour locale for "-t %+"

The man page states that "-t %+" prints time information in the same
format as date with no format specifier.

This was not the case, the format used was always that of date for the
POSIX locale.

The fix suggested by the reporter leads to output that matches the
documentation.

Reported by: Jamie Landeg-Jones <jamie@catflap.org>
MFC after: 3 days

2 years agonfscl: Use NFSMNTP_DELEGISSUED in two more functions
Rick Macklem [Sat, 30 Oct 2021 03:35:02 +0000 (20:35 -0700)]
nfscl: Use NFSMNTP_DELEGISSUED in two more functions

Commit 5e5ca4c8fc53 added a NFSMNTP_DELEGISSUED flag to indicate when
a delegation has been issued to the mount.  For the common case
where an NFSv4 server is not issuing delegations, this flag
can be checked to avoid acquisition of the NFSCLSTATEMUTEX.

This patch adds checks for NFSMNTP_DELEGISSUED being set
to two more functions.

This change appears to be performance neutral for a small number
of opens, but should reduce lock contention for a large number of opens
for the common case where server is not issuing delegations.

MFC after: 2 week

2 years agotcp: Rack might retransmit forever.
Randall Stewart [Fri, 29 Oct 2021 21:37:49 +0000 (17:37 -0400)]
tcp: Rack might retransmit forever.

If we get a Sacked peer with an MTU change we can retransmit forever if the
last bytes are sacked and the client goes away (think power off). Then we
never see the end condition and continually retransmit.

Reviewed by: Michael Tuexen
Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D32671

2 years agotimecounter: Load the currently selected tc once in tc_windup()
Mark Johnston [Fri, 29 Oct 2021 18:29:22 +0000 (14:29 -0400)]
timecounter: Load the currently selected tc once in tc_windup()

Reported by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32729

2 years agosort: Fix random sort
Mark Johnston [Fri, 29 Oct 2021 18:25:42 +0000 (14:25 -0400)]
sort: Fix random sort

bwsrawdata() is supposed to return the string buffer.

PR: 259451
Reported by: sigsys@gmail.com
Fixes: d053fb22f6d3 ("usr.bin/sort: Avoid UBSan errors")
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

2 years agoMerge commit 'ce929fe84f9c453263af379f3b255ff8eca01d48'
Olivier Houchard [Fri, 29 Oct 2021 17:18:03 +0000 (19:18 +0200)]
Merge commit 'ce929fe84f9c453263af379f3b255ff8eca01d48'

Import CK as of commit 2265c7846f4ce667f5216456afe2779b23c3e5f7.

2 years agoImport CK as of commit 2265c7846f4ce667f5216456afe2779b23c3e5f7.
Olivier Houchard [Fri, 29 Oct 2021 17:01:15 +0000 (19:01 +0200)]
Import CK as of commit 2265c7846f4ce667f5216456afe2779b23c3e5f7.

2 years agolinux: make PTRACE_GETREGS return correct struct
Edward Tomasz Napierala [Fri, 29 Oct 2021 15:18:13 +0000 (16:18 +0100)]
linux: make PTRACE_GETREGS return correct struct

Previously it returned a shorter struct.  I can't find any
modern software that uses it, but tests/ptrace from strace(1)
repo complained.

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

2 years agolinux: Make PTRACE_GETREGSET return proper buffer size
Edward Tomasz Napierala [Fri, 29 Oct 2021 14:28:56 +0000 (15:28 +0100)]
linux: Make PTRACE_GETREGSET return proper buffer size

This fixes Chrome warning:

[1022/152319.328632:ERROR:ptracer.cc(476)] Unexpected registers size 0 != 216, 68

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

2 years agolinux: Also translate the signal if the code is CLD_KILLED
Edward Tomasz Napierala [Fri, 29 Oct 2021 13:56:43 +0000 (14:56 +0100)]
linux: Also translate the signal if the code is CLD_KILLED

This fixes ./waitid.gen.test from the strace(1) test suite.

Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32617

2 years agoDo not build libatf-c++ when WITHOUT_CXX
Ed Maste [Fri, 29 Oct 2021 03:01:21 +0000 (23:01 -0400)]
Do not build libatf-c++ when WITHOUT_CXX

libatf-c++ requires C++ support.

From jrtc27: bit slightly odd this isn't gated by MK_TESTS (which itself
depends on MK_CXX), but this makes sense given the current behaviour.

Reported by: Michael Dexter, Build Option Survey
Reviewed by: imp, jrtc27
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32732

2 years agosrc.opts.mk: Add WITHOUT_CXX dependencies
Ed Maste [Fri, 29 Oct 2021 01:43:33 +0000 (21:43 -0400)]
src.opts.mk: Add WITHOUT_CXX dependencies

OFED, OPENMP, and PMC depend on C++ support.  Force them off when
building WITHOUT_CXX.

Reported by: Michael Dexter, Build Option Survey
Reviewed by: imp, jrtc27
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32730

2 years agoDon't build sanitizer runtimes under WITHOUT_CXX
Ed Maste [Fri, 29 Oct 2021 00:49:12 +0000 (20:49 -0400)]
Don't build sanitizer runtimes under WITHOUT_CXX

In the past we built the sanitizer runtimes when building Clang
(and using Clang as the compiler) but 7676b388adbc changed this to
be conditional only on using Clang, to make the runtimes available
for external Clang.

They fail to build when WITHOUT_CXX is set though, so add MK_CXX
as part of the condition.

Reported by: Michael Dexter, Build Option Survey
Reviewed by: imp, jrtc27
Fixes: 7676b388adbc ("Always build the sanitizer runtimes...")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32731

2 years agolinux: Fix ptrace panic with ERESTART
Edward Tomasz Napierala [Fri, 29 Oct 2021 13:21:21 +0000 (14:21 +0100)]
linux: Fix ptrace panic with ERESTART

Translate ERESTART into Linux "internal" errno ERESTARTSYS.
This fixes the erestartsys.gen.test from strace(1).

Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32623

2 years agoRevert "qoriq_gpio: Implement interrupt controller functionality"
Wojciech Macek [Fri, 29 Oct 2021 10:05:55 +0000 (12:05 +0200)]
Revert "qoriq_gpio: Implement interrupt controller functionality"

This reverts commit 027a58aab2cee5589a3a639afb77ecbb607f8fee.

2 years agostress2: Added a regression test
Peter Holm [Fri, 29 Oct 2021 09:04:49 +0000 (09:04 +0000)]
stress2: Added a regression test

2 years agomvneta: fix encap property
Wojciech Macek [Fri, 29 Oct 2021 08:56:57 +0000 (10:56 +0200)]
mvneta: fix encap property

Fix MVNETA encap property.

2 years agoqoriq_gpio: Implement interrupt controller functionality
Kornel Duleba [Tue, 28 Sep 2021 15:09:41 +0000 (17:09 +0200)]
qoriq_gpio: Implement interrupt controller functionality

The pic_* interface was used.
Only edge interrupts are supported by this controller.
Driver mutex had to be converted to a spin lock so that it can
be used in the interrupt filter context.
Two types of intr_map_data are supported - INTR_MAP_DATA_GPIO and
INTR_MAP_DATA_FDT. This way interrupts can be allocated using the
userspace gpio interrupt allocation method, as well as directly from
simplebus. The latter can be used by devices that have its irq routed
to a GPIO pin.

Obtained from: Semihalf
Sponsored by: Alstom Group
Differential revision: https://reviews.freebsd.org/D32587

2 years agofelix: Add a sysctl to control timer routine frequency
Kornel Duleba [Mon, 25 Oct 2021 13:18:27 +0000 (15:18 +0200)]
felix: Add a sysctl to control timer routine frequency

Driver polls status of all PHYs connected to the switch in a
fixed interval.
Add a sysctl that allows to control frequency of that.
The value is expressed in ticks and defaults to "hz", or 1 second.

Obtained from: Semihalf
Sponsored by: Alstom Group

2 years agoRemove enetc_mdio driver
Kornel Duleba [Tue, 26 Oct 2021 08:41:09 +0000 (10:41 +0200)]
Remove enetc_mdio driver

It was previously used by felix(4) for PHY communication.
Since that is not the case anymore this driver is now left unused.

Obtained from: Semihalf
Sponsored by: Alstom Group

2 years agofelix: Use internal MDIO regs for PHY communication
Kornel Duleba [Tue, 26 Oct 2021 08:36:35 +0000 (10:36 +0200)]
felix: Use internal MDIO regs for PHY communication

Previously we would use an external MDIO device found on the PCI bus.
Switch to using MDIO mapped in a separate BAR of the switch device.
It is much easier this way since we don't have to depend on another
driver anymore.

Obtained from: Semihalf
Sponsored by: Alstom Group

2 years agodmar: Disable protected memory regions after initialization
Kornel Duleba [Thu, 21 Oct 2021 14:02:26 +0000 (16:02 +0200)]
dmar: Disable protected memory regions after initialization

Some BIOSes protect memory region they reside in by using DMAR to
prevent devices from doing any DMA transactions to that part of RAM.
AMI refers to this as "DMA Control Guarantee".
Disable the protection when address translation is enabled.
I stumbled upon this while investigation a failing coredump on a device
which has this feature enabled.

Sponsored by: Stormshield
Obtained from: Semihalf
Reviewed by: kib
Differential revision: https://reviews.freebsd.org/D32591

2 years agodmar: Don't try to reserve PCI regions for non-existing devices
Kornel Duleba [Thu, 21 Oct 2021 12:46:51 +0000 (14:46 +0200)]
dmar: Don't try to reserve PCI regions for non-existing devices

In some cases we might have to create DMAR context before the
corresponding device has been enumerated by the PCI bus.
In that case we get called with NULL dev, because of that trying
to reserve PCI regions causes a NULL pointer dereference in
pci_find_pcie_root_port.

Sponsored by: Stormshield
Obtained from: Semihalf
MFC after: 2 weeks
Reviewed by: kib, rlibby
Differential revision: https://reviews.freebsd.org/D32589

2 years agoNXP: Add ls1028a SPI clock driver
Wojciech Macek [Fri, 22 Oct 2021 08:12:09 +0000 (10:12 +0200)]
NXP: Add ls1028a SPI clock driver

Provide driver for LS1028A and LX2160 SPI clock modules.

Obtained from: Semihalf
Sponsored by: Alstom
Differential revision: https://reviews.freebsd.org/D32689

2 years agotcp: Rack at times can miscalculate the RTT from what it thinks is a persists probe...
Randall Stewart [Fri, 29 Oct 2021 07:17:43 +0000 (03:17 -0400)]
tcp: Rack at times can miscalculate the RTT from what it thinks is a persists probe respone.

Turns out that if a peer sends in a window update right after rack fires off
a persists probe, we can mis-interpret the window update and calculate
a bogus RTT (very short). We still process the window update and send
the data but we incorrectly generate an RTT. We should be only doing
the RTT stuff if the rwnd is still small and has not changed.

Reviewed by: Michael Tuexen
Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D32717

2 years agoAllow GEOM utilities to specify a -v option.
Kirk McKusick [Fri, 29 Oct 2021 05:49:48 +0000 (22:49 -0700)]
Allow GEOM utilities to specify a -v option.

Geom utilities (geli(8), glabel(8), gmirror(8), gpart(8), gmirror(8),
gmountver(8), etc) all use the geom(8) utility as their back end
to process their commands and pass them into the kernel. Creating
a new utility requires no more than filling out a template describing
the commands and arguments that the utility supports. Consider the
specification for the very simple gmountver(8) utility:

struct g_command class_commands[] = {
{ "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL,
    {
G_OPT_SENTINEL
    },
    "[-v] prov ..."
},
{ "destroy", G_FLAG_VERBOSE, NULL,
    {
{ 'f', "force", NULL, G_TYPE_BOOL },
G_OPT_SENTINEL
    },
    "[-fv] name"
},
G_CMD_SENTINEL
};

It has just two commands of its own: "create" and "destroy" along
with the four standard commands "list", "status", "load", and
"unload" provided by the base geom(8) utility. The base geom(8)
utility allows each command to use the G_FLAG_VERBOSE flag to specify
that a command should accept the -v flag and when the -v flag is
given the utility prints "Done." if the command completes successfully.
In the above example, both of the commands set the G_FLAG_VERBOSE,
so have the -v option available. In addition the "destroy" command
accepts the -f boolean flag to force the destruction.

If the "destroy" command wanted to also print out verbose information,
it would need to explicitly declare its intent by adding a line:

{ 'v', "verbose", NULL, G_TYPE_BOOL },

Before this change, the geom utility would silently ignore the above
line in the configuration file, so it was impossible for the utility
to know that the -v flag had been set on the command. With this
change a geom command can explicitly specify a -v option with a
line as given above and handle it as it would any other option. If
both a -v option and G_FLAG_VERBOSE are specified for a command
then both types of verbose information will be output when that
command is run with -v.

MFC after:    1 week
Sponsored by: Netflix

2 years agowpa: Fix WITHOUT_CRYPT build
Cy Schubert [Thu, 28 Oct 2021 23:55:48 +0000 (16:55 -0700)]
wpa: Fix WITHOUT_CRYPT build

PASN requires CRYPT and when built WITHOUT_CRYPT buildworld
fails. Only enable PASN when MK_CRYPT is enabled (default).

PR: 259517
Reported by: emaste
Fixes: c1d255d3ffdbe447de3ab875bf4e7d7accc5bfc5
MFC after: 1 week

2 years agosinpi,cospi,tanpi: float.h needed for week reference
Steve Kargl [Thu, 28 Oct 2021 22:53:13 +0000 (01:53 +0300)]
sinpi,cospi,tanpi: float.h needed for week reference

The patch fixes the omission of '#include <float.h>', which is needed for
the weak reference on systems with LDBL_MANT_DIG == DBL_MANT_DIG.

PR: 218514
MFC after: 1 week

2 years agoForce WITHOUT_OPENSSL_KTLS off when WITHOUT_OPENSSL
Ed Maste [Thu, 28 Oct 2021 21:07:34 +0000 (17:07 -0400)]
Force WITHOUT_OPENSSL_KTLS off when WITHOUT_OPENSSL

Discussed with: jhb
MFC after: 1 week
Reported by: Michael Dexter, Build Option Survey
Sponsored by: The FreeBSD Foundation

2 years agoEnable net.inet.tcp.nolocaltimewait.
Gleb Smirnoff [Thu, 28 Oct 2021 22:34:00 +0000 (15:34 -0700)]
Enable net.inet.tcp.nolocaltimewait.

This feature has been used for many years at large sites and
didn't show any pitfalls.

2 years agokern_tc.c: Scaling/large delta recalculation
Sebastian Huber [Thu, 28 Oct 2021 08:22:58 +0000 (10:22 +0200)]
kern_tc.c: Scaling/large delta recalculation

This change is a slight performance optimization for systems with a slow
64-bit division.

The th->th_scale and th->th_large_delta values only depend on the
timecounter frequency and the th->th_adjustment. The timecounter
frequency of a timehand only changes when a new timecounter is activated
for the timehand. The th->th_adjustment is only changed by the NTP
second update. The NTP second update is not done for every call of
tc_windup().

Move the code block to recalculate the scaling factor and
the large delta of a timehand to the new helper function
recalculate_scaling_factor_and_large_delta().

Call recalculate_scaling_factor_and_large_delta() when a new timecounter
is activated and a NTP second update occurred.

MFC after: 1 week

2 years agolibradius: fix WITHOUT_OPENSSL build
Ed Maste [Thu, 28 Oct 2021 20:27:10 +0000 (16:27 -0400)]
libradius: fix WITHOUT_OPENSSL build

int alen is used only with SSL.

Reported by: Michael Dexter, Build Option Survey
MFC after: 3 days
Fixes: 8d5c7813061d ("libradius: Fix input validation bugs")
Sponsored by: The FreeBSD Foundation

2 years agoUnmap shared page manually before doing vm_map_remove() on exit or exec
Konstantin Belousov [Wed, 20 Oct 2021 20:32:59 +0000 (23:32 +0300)]
Unmap shared page manually before doing vm_map_remove() on exit or exec

This allows the pmap_remove(min, max) call to see empty pmap and exploit
empty pmap optimization.

Reviewed by: markj
Tested by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32569

2 years agoamd64 pmap: adjust the empty pmap optimization in pmap_remove()
Konstantin Belousov [Wed, 20 Oct 2021 20:30:34 +0000 (23:30 +0300)]
amd64 pmap: adjust the empty pmap optimization in pmap_remove()

to match the added accounting of the top-level page table pages.

Reviewed by: markj
Tested by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32569

2 years agoamd64 pmap: account for the top-level pages
Konstantin Belousov [Wed, 20 Oct 2021 01:03:43 +0000 (04:03 +0300)]
amd64 pmap: account for the top-level pages

both for kernel and user page tables, the later exist in the PTI case.

Reviewed by: markj
Tested by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32569

2 years agoi386: fix struct proc layout asserts after 351d5f7fc5161ede
Konstantin Belousov [Thu, 28 Oct 2021 18:31:58 +0000 (21:31 +0300)]
i386: fix struct proc layout asserts after 351d5f7fc5161ede

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

2 years agoconfig(5): Update upper limit for maxusers on 64-bit systems
Felix Johnson [Thu, 28 Oct 2021 18:15:08 +0000 (14:15 -0400)]
config(5): Update upper limit for maxusers on 64-bit systems

The limit of 384 maxusers for auto configuration was only imposed on
32-bit systems. Document that maxusers scales above 384 based on memory
for 64-bit systems.

PR: 204938
MFC after: 3 days
Reported by: David Höppner <0xffea@gmail.com>

2 years agosysctl kern.proc.procname: report right hardlink name
Konstantin Belousov [Sat, 23 Oct 2021 19:01:37 +0000 (22:01 +0300)]
sysctl kern.proc.procname: report right hardlink name

PR: 248184
Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32611

2 years agoexec: store parent directory and hardlink name of the binary in struct proc
Konstantin Belousov [Sat, 23 Oct 2021 18:44:22 +0000 (21:44 +0300)]
exec: store parent directory and hardlink name of the binary in struct proc

While doing it, also move all the code to resolve pathnames and obtain
text vp and dvp, into single place.   Besides simplifying the code, it
avoids spurious vnode relocks and validates the explanation why
a transient text reference on the script vnode is not harmful.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32611

2 years agoexec: provide right hardlink name in AT_EXECPATH
Konstantin Belousov [Sat, 23 Oct 2021 00:24:08 +0000 (03:24 +0300)]
exec: provide right hardlink name in AT_EXECPATH

For this, use vn_fullpath_hardlink() to resolve executable name for
execve(2).

This should provide the right hardlink name, used for execution, instead
of random hardlink pointing to this binary.  Also this should make the
AT_EXECNAME reliable for execve(2), since kernel only needs to resolve
parent directory path, which should always succeed (except pathological
cases like unlinking a directory).

PR: 248184
Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32611

2 years agoMake vn_fullpath_hardlink() externally callable
Konstantin Belousov [Sat, 23 Oct 2021 00:23:17 +0000 (03:23 +0300)]
Make vn_fullpath_hardlink() externally callable

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32611

2 years agostruct image_params: use bool type for boolean members
Konstantin Belousov [Sat, 23 Oct 2021 15:05:56 +0000 (18:05 +0300)]
struct image_params: use bool type for boolean members

Also re-align comments, and group booleans and char members together.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32611

2 years agodo_execve(): switch boolean locals to use bool type
Konstantin Belousov [Sat, 23 Oct 2021 14:47:28 +0000 (17:47 +0300)]
do_execve(): switch boolean locals to use bool type

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32611

2 years agokern_exec.c: style
Konstantin Belousov [Fri, 22 Oct 2021 23:49:30 +0000 (02:49 +0300)]
kern_exec.c: style

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32611

2 years agoident: replace sbuf(9) with open_memstream(3)
Baptiste Daroussin [Thu, 28 Oct 2021 13:39:24 +0000 (15:39 +0200)]
ident: replace sbuf(9) with open_memstream(3)

This change makes ident only dependant on libc functions

This makes our ident(1) more portable, also the fact that we only
depend on libc which is maintained with excellent backward compatibility
means that if one day ident is removed from base, someone using FreeBSD
22 will be able to fetch ident from FreeBSD 14 to run ident against
FreeBSD 1.0 binary

MFC After: 1 week

2 years agonetpfil tests: dummynet+NAT test for pf
Kristof Provost [Tue, 26 Oct 2021 08:56:30 +0000 (10:56 +0200)]
netpfil tests: dummynet+NAT test for pf

Ensure that NAT still works as expected when combined with dummynet.

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

2 years agopf: fix dummynet + NAT
Kristof Provost [Tue, 26 Oct 2021 07:59:42 +0000 (09:59 +0200)]
pf: fix dummynet + NAT

Dummynet differs from ALTQ in that ALTQ schedules packets after they
leave pf. Dummynet schedules them after they leave pf, but then
re-injects them.
We currently deal with this by ensuring we don't re-schedule a packet we
get from dummynet, but this produces unexpected results when combined
with NAT, as dummynet processing is done after the NAT transformation.
In other words, the second time the packet is handed to pf it may have a
different source and destination address.

Simplify this by moving dummynet processing to after all other pf
processing, and not re-processing (but always passing) packets from
dummynet.

This fixes NAT of dummynet delayed packets, and also reduces processing
overhead (because we only do state/rule lookup for each dummynet packet
once, rather than twice).

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

2 years agombuf: PACKET_TAG_PF should not be persistent
Kristof Provost [Tue, 26 Oct 2021 07:51:33 +0000 (09:51 +0200)]
mbuf: PACKET_TAG_PF should not be persistent

We should clear firewall tags on loopback, icmp reflection, or if_epair
transmission. Left over tags can produce unexpected behaviour,
especially on if_epair where a and b interfaces can be in different
vnets, and have different firewall policies set.

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

2 years agoif_epair: delete mbuf tags
Kristof Provost [Tue, 26 Oct 2021 07:57:56 +0000 (09:57 +0200)]
if_epair: delete mbuf tags

Remove all (non-persistent) tags when we transmit a packet. Real network
interfaces do not carry any tags either, and leaving tags attached can
produce unexpected results.

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

2 years agomroute: add missing WUNLOCK
Wojciech Macek [Thu, 28 Oct 2021 04:59:37 +0000 (06:59 +0200)]
mroute: add missing WUNLOCK

Add missing WNLOCK as in all other error cases.

Reported by: Stormshield
Obtained from: Semihalf

2 years agomroute: fix memory leak
Wojciech Macek [Thu, 28 Oct 2021 04:41:15 +0000 (06:41 +0200)]
mroute: fix memory leak

Add MFC to linked list to store incoming packets
before MCAST JOIN was captured.

Sponsored by: Stormshield
Obtained from: Semihalf
MFC after: 2 weeks

2 years agoWrap mutex(9), rwlock(9) and sx(9) macros into __extension__ ({})
Gleb Smirnoff [Wed, 27 Oct 2021 17:33:01 +0000 (10:33 -0700)]
Wrap mutex(9), rwlock(9) and sx(9) macros into __extension__ ({})
instead of do {} while (0).

This makes them real void expressions, and they can be used anywhere
where a void function call can be used, for example in a conditional
operator.

Reviewed by: kib, mjg
Differential revision: https://reviews.freebsd.org/D32696

2 years agoFix off-by-one error in msdosfs FAT32 volume label copying
Jessica Clarke [Thu, 28 Oct 2021 00:01:00 +0000 (01:01 +0100)]
Fix off-by-one error in msdosfs FAT32 volume label copying

I dropped the + 1 from the other two instances in each file but failed
to do so for this one, resulting in a more egregious buffer overread
than the one I was fixing (since the read character ended up in the
output if there was space).

Reported by: Jenkins
Fixes: 34fb1c133c5b ("Fix intra-object buffer overread for labeled msdosfs volumes")

2 years agoktls: Fix assertion for TLS 1.0 CBC when using non-zero starting seqno.
John Baldwin [Wed, 27 Oct 2021 23:35:56 +0000 (16:35 -0700)]
ktls: Fix assertion for TLS 1.0 CBC when using non-zero starting seqno.

The starting sequence number used to verify that TLS 1.0 CBC records
are encrypted in-order in the OCF layer was always set to 0 and not to
the initial sequence number from the struct tls_enable.

In practice, OpenSSL always starts TLS transmit offload with a
sequence number of zero, so this only matters for tests that use a
random starting sequence number.

Reviewed by: markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D32676

2 years agosh: Fix heredoc at certain places in case and for
Jilles Tjoelker [Thu, 14 Oct 2021 20:53:42 +0000 (22:53 +0200)]
sh: Fix heredoc at certain places in case and for

After an unescaped newline, there may be a here-document. Some places in
case and for did not check for one.

Reviewed by: bdrewery
Differential Revision: https://reviews.freebsd.org/D32628

2 years agocache: only let non-dir descriptors through when doing EMPTYPATH lookups
Mateusz Guzik [Wed, 27 Oct 2021 18:17:59 +0000 (20:17 +0200)]
cache: only let non-dir descriptors through when doing EMPTYPATH lookups

Otherwise things like realpath against a file and '.' end up with an
illegal state of having a regular vnode for the parent.

Reported by: syzbot+9aa5439dd9c708aeb1a8@syzkaller.appspotmail.com

2 years agoFix intra-object buffer overread for labeled msdosfs volumes
Jessica Clarke [Sun, 24 Oct 2021 18:49:21 +0000 (19:49 +0100)]
Fix intra-object buffer overread for labeled msdosfs volumes

Volume labels, like directory entries, are padded with spaces and so
have no NUL terminator. Whilst the MIN for the dsize argument to strlcpy
ensures that the copy does not overflow the destination, strlcpy is
defined to return the number of characters in the source string,
regardless of the provided dsize, and so keeps reading until it finds a
NUL, which likely exists somewhere within the following fields, but On
CHERI with the subobject bounds enabled in the compiler this buffer
overread will be detected and trap with a bounds violation.

Found by: CHERI
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D32579

2 years agoada: Fix intra-object buffer overread of identify strings
Jessica Clarke [Sun, 24 Oct 2021 18:48:59 +0000 (19:48 +0100)]
ada: Fix intra-object buffer overread of identify strings

In the ATA/ATAPI spec these are space-padded fixed-length strings with
no NUL-terminator (and byte swapped). When performing the identify we
call ata_param_fixup to swap the bytes back to be in order, strip any
leading/trailing spaces and coalesce consecutive spaces, padding with
NULs. However, if the input has no padding spaces, the fixed-up strings
are still not NUL-terminated. This causes two issues. The first is that
strlcpy will truncate the string by replacing the final byte with a NUL.
The second is that strlcpy will keep reading src until it finds a NUL in
order to calculate the return value, which is defined as the length of
src (so that callers can then compare it with the dsize input to see if
the input string was truncated), thereby reading past the end of the
buffer and into whatever adjacent fields are in the structure. In
practice there's a NUL byte somewhere in the structure, but on CHERI
with subobject bounds enabled in the compiler this overread will be
detected and trap as a bounds violation.

Note this matches ata_xpt's aprobedone, which does a bcopy to a
malloc'ed buffer and manually NUL-terminates it for the CAM path's
device's serial_num.

Found by: CHERI
Reviewed by: imp, scottl
Differential Revision: https://reviews.freebsd.org/D32567

2 years agoxhci: Rework 64-byte context support to avoid pointer abuse
Jessica Clarke [Sun, 24 Oct 2021 18:48:46 +0000 (19:48 +0100)]
xhci: Rework 64-byte context support to avoid pointer abuse

Currently, to support 64-byte contexts, xhci_ctx_[gs]et_le(32|64) take a
pointer to the field within a 32-byte context and, if 64-byte contexts
are in use, compute where the 64-byte context field is and use that
instead by deriving a pointer from the 32-byte field pointer. This is
done by exploiting a combination of 64-byte contexts being the same
layout as their 32-byte counterparts, just with 32 bytes of padding at
the end, and that all individual contexts are either in a device
context or an input context which itself is page-aligned. By masking out
the low 4 bits (which is the offset of the field within the 32-byte
contxt) of the offset within the page, the offset of the invididual
context within the containing device/input context can be determined,
which is itself 32 times the number of preceding contexts. Thus, adding
this value to the pointer again gets 64 times the number of preceding
contexts plus the field offset, which gives the offset of the 64-byte
context plus the field offset, which is the address of the field in the
64-byte context.

However, this involves a fair amount of lying to the compiler when
constructing these intermediate pointers, and is rather difficult to
reason about. In particular, this is problematic for CHERI, where we
compile the kernel with subobject bounds enabled; that is, unless
annotated to opt out (e.g. for C struct inheritance reasons where you
need to be able to downcast, or containerof idioms), a pointer to a
member of a struct is a capability whose bounds only cover that field,
and any attempt to dereference outside those bounds will fault,
protecting against intra-object buffer overflows. Thus the pointer given
to xhci_ctx_[gs]et_le(32|64) is a capability whose bounds only cover the
field in the 32-byte context, and computing the pointer to the 64-byte
context field takes the address out of bounds, resulting in a fault when
later dereferenced.

This can be cleaned up by using a different abstraction. Instead of
doing the 32-byte to 64-byte conversion on access to the field, we can
do the conversion when getting a pointer to the context itself, and
define proper 64-byte versions of contexts in order to let the compiler
do all the necessary arithmetic rather than do it manually ourselves.
This provides a cleaner implementation, works for CHERI and may even be
slightly more performant as it avoids the need to mess with masking
pointers (which cannot in the general case be optimised by compilers to
be reused across accesses to different fields within the same context,
since it does not know that the contexts are over-aligned compared with
the C ABI requirements).

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

2 years agolibdialog: Bump shared library version to 10.
John Baldwin [Wed, 27 Oct 2021 16:30:24 +0000 (09:30 -0700)]
libdialog: Bump shared library version to 10.

The upgrade to libdialog 1.3 included changes to the ABI.

Bump libdpv to 3 since it links against libdialog.

Reported by: Mark Millard <marklmi@yahoo.com>
Reviewed by: bapt
Fixes: a96ef4501919 dialog: import dialog 1.3-20210117
Differential Revision: https://reviews.freebsd.org/D32675

2 years agoarm: Remove obsolete comments
Warner Losh [Wed, 27 Oct 2021 15:44:41 +0000 (09:44 -0600)]
arm: Remove obsolete comments

FreeBSD has never supported arm26, so remove comments about what
trapframes look like for that platform.

Noticed by: kevans
Sponsored by: Netflix

2 years agorack: Update the fast send block on setsockopt(2)
Gleb Smirnoff [Tue, 26 Oct 2021 03:54:26 +0000 (20:54 -0700)]
rack: Update the fast send block on setsockopt(2)

Rack caches TCP/IP header for fast send, so it doesn't call
tcpip_fillheaders().  After certain socket option changes,
namely IPV6_TCLASS, IP_TOS and IP_TTL it needs to update
its fast block to be in sync with the inpcb.

Reviewed by: rrs
Differential Revision: https://reviews.freebsd.org/D32655

2 years agoFactor out tcp6_use_min_mtu() to handle IPV6_USE_MIN_MTU by TCP.
Gleb Smirnoff [Tue, 26 Oct 2021 03:53:07 +0000 (20:53 -0700)]
Factor out tcp6_use_min_mtu() to handle IPV6_USE_MIN_MTU by TCP.

Pass control for IP/IP6 level options from generic tcp_ctloutput_set()
down to per-stack ctloutput.

Call tcp6_use_min_mtu() from tcp stack tcp_default_ctloutput().

Reviewed by: rrs
Differential Revision: https://reviews.freebsd.org/D32655

2 years agoSeveral IP level socket options may affect TCP.
Gleb Smirnoff [Tue, 26 Oct 2021 03:40:12 +0000 (20:40 -0700)]
Several IP level socket options may affect TCP.

After handling them in IP level ctloutput, pass them down to TCP
ctloutput.

We already have a hack to handle IPV6_USE_MIN_MTU. Leave it in place
for now, but comment out how it should be handled.

For IPv4 we are interested in IP_TOS and IP_TTL.

Reviewed by: rrs
Differential Revision: https://reviews.freebsd.org/D32655

2 years agoSplit tcp_ctloutput() into set/get parts.
Gleb Smirnoff [Tue, 26 Oct 2021 03:38:31 +0000 (20:38 -0700)]
Split tcp_ctloutput() into set/get parts.

Reviewed by: rrs
Differential Revision: https://reviews.freebsd.org/D32655

2 years agotcp: socket option to get stack alias name
Peter Lei [Tue, 26 Oct 2021 03:08:54 +0000 (20:08 -0700)]
tcp: socket option to get stack alias name

TCP stack sysctl nodes are currently inserted using the stack
name alias. Allow the user to get the current stack's alias to
allow for programatic sysctl access.

Obtained from: Netflix

2 years agormslock: Update td_locks during lock and unlock operations
Mark Johnston [Wed, 27 Oct 2021 15:18:13 +0000 (11:18 -0400)]
rmslock: Update td_locks during lock and unlock operations

Reviewed by: mjg
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32692

2 years agocrunchgen: use realpath(3) instead of ``pwd -P''
Alexey Dokuchaev [Sun, 11 Oct 2020 08:23:00 +0000 (08:23 +0000)]
crunchgen: use realpath(3) instead of ``pwd -P''

r366466 (9c7bd4f198e1) fixed a subtle bug by stripping the trailing
'\n' appended to the output of popen("cd %s && pwd -P", p->srcdir).

Replace this cumbersome implementation with a single realpath(3) call
which avoids spawning a shell, reading from the stream with fgets(3),
and final strdup(3).

Reviewed by: arichardson, kevans
Approved by: imp
Differential Revision: https://reviews.freebsd.org/D26734

2 years agojail(8): Fix a few common typos in source code comments
Gordon Bergling [Wed, 27 Oct 2021 04:16:06 +0000 (06:16 +0200)]
jail(8): Fix a few common typos in source code comments

- s/phyiscal/physical/

MFC after: 3 days

2 years agobxe(4): Fix a few common typos in source code comments
Gordon Bergling [Wed, 27 Oct 2021 04:15:06 +0000 (06:15 +0200)]
bxe(4): Fix a few common typos in source code comments

- s/controled/controlled/
- s/allignment/alignment/

MFC after: 3 days

2 years agoiwm: Update SCD register accesses
Adrian Chadd [Mon, 25 Oct 2021 04:29:53 +0000 (21:29 -0700)]
iwm: Update SCD register accesses

This brings it inline with what's in openbsd.  I tested it locally
with 2G and 5G association; it seems to work.

Tested: Intel 7260 AC, hw 0x140, STA mode, 2G/5G

Differential Revision: https://reviews.freebsd.org/D32627
Subscribers: imp
Obtainde from: OpenBSD

2 years agoiwm: update if_iwmreg.h to the latest (as of today) openbsd changes
Adrian Chadd [Sun, 24 Oct 2021 15:47:04 +0000 (08:47 -0700)]
iwm: update if_iwmreg.h to the latest (as of today) openbsd changes

Summary:
This updates the if_iwmreg.h definitions to;

OpenBSD: if_iwmreg.h,v 1.65 2021/10/11 09:03:22 stsp Exp

A few things haven't been fully converted, namely:

* I left a couple things as enums for now just to reduce the
  other diffs needed; but they're the same values

* The IWM_SCD_QUEUE_* macros have different offsets which I
  didn't update in case they broke things / changed based on later
  firmware.  But they also may be real bugfixes which are needed
  for later chips.  It'll need more testing before flipping this on.

The c file updates are:

* Use the newer names for things if the name changed but the semantics
  didn't
* Explicitly use the earlier firmware structs which maintain compat
  with the current firmware and code.  The newer ones are in here and
  they'll get converted when more openbsd code is merged into this tree.
* Use the older iwm rate table for now, which has entries for legacy
  rates, HT and VHT.  Our code works with that right now, updating it
  to openbsd's err, "different" version can be done at a later date
  when HT/VHT support is added.

Notably, a bunch of definitions were deleted that weren't used.
They're not used either in the openbsd/dfbsd drivers so I think it's
safe to delete them in the long run.

Test Plan: 7260 hw 0x140

Subscribers: imp
Differential Revision: https://reviews.freebsd.org/D32627
Reviewed by: md5
Obtained From: OpenBSD

2 years agolib/msun: Move the files to appropriate locations in the Makefile
Steve Kargl [Tue, 26 Oct 2021 20:53:51 +0000 (23:53 +0300)]
lib/msun: Move the files to appropriate locations in the Makefile

Fixes: dce5f3abed7181cc533ca5ed
PR: 218514
MFC after: 1 week

2 years agolib/msun/ld128/s_tanpil.c: make it compile.
Konstantin Belousov [Tue, 26 Oct 2021 21:14:35 +0000 (00:14 +0300)]
lib/msun/ld128/s_tanpil.c: make it compile.

Declare local, add missed ';'.
Name function properly.

Fixes: dce5f3abed7181cc533ca5ed
Reviewed by: kargl
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

2 years agoctld: Always declare MaxRecvDataSegmentLength.
John Baldwin [Tue, 26 Oct 2021 21:52:40 +0000 (14:52 -0700)]
ctld: Always declare MaxRecvDataSegmentLength.

This key is Declarative and should always be sent even if the
initiator did not send it's own limit.  This is similar to the fix in
fc79cf4fea72 but for the target side.  However, unlike that fix,
failure to send the key simply results in reduced performance.

PR: 259439
Reviewed by: mav, emaste
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D32651

2 years agoFurther refine the ExpDataSN checks for SCSI Response PDUs.
John Baldwin [Tue, 26 Oct 2021 21:50:05 +0000 (14:50 -0700)]
Further refine the ExpDataSN checks for SCSI Response PDUs.

According to 11.4.8 in RFC 7143, ExpDataSN MUST be 0 if the response
code is not Command Completed, but we were requiring it to always be
the count of DataIn PDUs regardless of the response code.

In addition, at least one target (OCI Oracle iSCSI block device)
returns an ExpDataSN of 0 when returning a valid completion with an
error status (Check Condition) in response to a SCSI Inquiry.  As a
workaround for this target, only warn without resetting the connection
for a 0 ExpDataSN for responses with a non-zero error status.

PR: 259152
Reported by: dch
Reviewed by: dch, mav, emaste
Fixes: 4f0f5bf99591 iscsi: Validate DataSN values in Data-In PDUs in the initiator.
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D32650

2 years agoAvoid building libfido2 if WITHOUT_USB
Ed Maste [Tue, 26 Oct 2021 21:15:54 +0000 (17:15 -0400)]
Avoid building libfido2 if WITHOUT_USB

libfido2 requires USB, so disable it if not available.

Reported by: peterj
Fixes: 7b1e19ad78c6 ("Add libfido2 to the build")
Sponsored by: The FreeBSD Foundation

2 years agoRetire obsolete iscsi_initiator(4)
Ed Maste [Tue, 26 Oct 2021 17:24:30 +0000 (13:24 -0400)]
Retire obsolete iscsi_initiator(4)

The new iSCSI initiator iscsi(4) was introduced with FreeBSD 10.0, and
the old intiator was marked obsolete shortly thereafter (in commit
d32789d95cfbf, MFC'd to stable/10 in ba54910169c4).  Remove it now.

Reviewed by: jhb, mav
Relnotes: yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32673

2 years agotcp: The rack stack can incorrectly have an overflow when calculating a burst delay.
Randall Stewart [Tue, 26 Oct 2021 17:17:58 +0000 (13:17 -0400)]
tcp: The rack stack can incorrectly have an overflow when calculating a burst delay.

If the congestion window is very large the fact that we multiply it by 1000 (for microseconds) can
cause the uint32_t to overflow and we incorrectly calculate a very small divisor. This will then
cause the burst timer to be very large when it should be 0. Instead lets make the three variables
uint64_t and avoid the issue.

Reviewed by: Michael Tuexen
Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D32668

2 years agolualoader: fix the autoboot_delay countdown message
Katsuyuki Miyoshi [Tue, 26 Oct 2021 16:21:34 +0000 (11:21 -0500)]
lualoader: fix the autoboot_delay countdown message

When the timer drops from double to single digits, a spare 'e' is left
on the end of the line as we don't overwrite it. Include an extra space
at the end to account for this and overwrite the leftover character.

PR: 259429
MFC after: 3 days
Reviewed by: emaste

2 years ago/etc/periodic/weekly/310.locate must read /etc/locate.rc
Wolfram Schneider [Tue, 26 Oct 2021 14:59:39 +0000 (14:59 +0000)]
/etc/periodic/weekly/310.locate must read /etc/locate.rc

PR:             160225
Reported by:    Hiroaki Abe
Reviewed by:    se
Approved by:    se
Differential Revision: https://reviews.freebsd.org/D32646

2 years agosh: Set PATH envvar after setting HOME in dotfile
Ka Ho Ng [Tue, 26 Oct 2021 14:48:57 +0000 (22:48 +0800)]
sh: Set PATH envvar after setting HOME in dotfile

In single-user mode, all env vars are absent, so exptilde() would not be
able to expand ~ correctly.
Place the lines setting PATH below HOME, so exptilde() would work as
expected.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: jilles, emaste
Differential Revision: https://reviews.freebsd.org/D27003

2 years agobpf: Fix the write filter for detached descriptors
Mark Johnston [Tue, 26 Oct 2021 13:57:27 +0000 (09:57 -0400)]
bpf: Fix the write filter for detached descriptors

A BPF descriptor only has an associated interface descriptor once it is
attached to an interface, e.g., with BIOCSETIF.  Avoid dereferencing a
NULL pointer in filt_bpfwrite() if the BPF descriptor is not attached.

Reviewed by: ae
Reported by: syzbot+ae45d5166afe15a5a21d@syzkaller.appspotmail.com
Fixes: ded77e0237a8 ("Allow the BPF to be select for write.")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32561

2 years agoncurses: rework static linker script generation
Baptiste Daroussin [Tue, 26 Oct 2021 10:02:00 +0000 (12:02 +0200)]
ncurses: rework static linker script generation

Rework the generation of the linker script to make it in par with
ldscript, this also forces the regeneration of the .aldscript in the obj
dir which might in the past have ended up empty.

Tested by: manu