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

2 years agoAugment systat(1) -swap to display large swap space processes
Konstantin Belousov [Tue, 26 Oct 2021 08:43:08 +0000 (11:43 +0300)]
Augment systat(1) -swap to display large swap space processes

This change updates the systat(1) -swap display to use libprocstat to
obtain and display per-process swap space usage infomation following its
existing swap devise/file statistics. It also incorporates the disk I/O
information from the -vmstat display.

The new screen looks like below with 'systat -swap':
                    /0   /1   /2   /3   /4   /5   /6   /7   /8   /9 /10
     Load Average   |

Device/Path       Size  Used |0%  /10  /20  /30  /40  / 60\  70\  80\ 90\ 100|
ada0s1b          2048M 2034M
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
zvol/sys/tempora 1024M 1015M
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
zvol/sys/swap    1024M 1014M
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Total            4096M 4063M
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Pid    Username   Command     Swap/Total Per-Process    Per-System
 24153 hiro       seamonkey   98M /   1G  7%              2%
 23677 hiro       xfce4-pane  28M /  81M 34% XXX          0%
 23629 hiro       xfce4-sess  25M / 118M 21% XX           0%
 23681 hiro       xfdesktop   20M /  58M 34% XXX          0%
 23678 hiro       thunar      15M /  43M 36% XXX          0%
 23658 hiro       at-spi-bus  14M /  23M 63% XXXXXX       0%
 23660 hiro       gvfsd       12M /  21M 56% XXXXX        0%

Disks  ada0  ada1  ada2   cd0 pass0 pass1 pass2 pass3
KB/t   8.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00
tps       0     0     0     0     1     0     0     0
MB/s   0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00
%busy     0     0     0     0     0     0     0     0

Submitted by: Yoshihiro Ota
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D29754

2 years agolibutil: add kinfo_getswapvmobject(3)
Konstantin Belousov [Tue, 26 Oct 2021 08:40:10 +0000 (11:40 +0300)]
libutil: add kinfo_getswapvmobject(3)

which is the wrapper around the vm.swap_objects sysctl, same as
kinfo_getvmobject(3) wraps vm.objects.

Submitted by: Yoshihiro Ota
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D29754

2 years agoMana: move mana polling from EQ to CQ
Wei Hu [Tue, 26 Oct 2021 12:25:22 +0000 (12:25 +0000)]
Mana: move mana polling from EQ to CQ

    -Each CQ start task queue to poll when completion happens.
    This means every rx and tx queue has its own cleanup task
    thread to poll the completion.
    - Arm EQ everytime no matter it is mana or hwc. CQ arming
    depends on the budget.
    - Fix a warning in mana_poll_tx_cq() when cqe_read is 0.
    - Move cqe_poll from EQ to CQ struct.
    - Support EQ sharing up to 8 vPorts.
    - Ease linkdown message from mana_info to mana_dbg.

Tested by: whu
MFC after: 2 weeks
Sponsored by: Microsoft

2 years agostress2: Added two syzkaller reproducers
Peter Holm [Tue, 26 Oct 2021 09:59:04 +0000 (09:59 +0000)]
stress2: Added two syzkaller reproducers

2 years agonfscl: Add a missing delegation lock release
Rick Macklem [Tue, 26 Oct 2021 02:09:14 +0000 (19:09 -0700)]
nfscl: Add a missing delegation lock release

There was a case in nfscl_doiods() where the function would return
without releasing the delegation shared lock, if it was aquired by
the call to nfscl_getstateid().  This patch adds that release.

I have never observed a failure due to this missing release, so I
do not know if it ever happens in practice.  However, since the pNFS
client is not yet heavily used, it might be the case.

Found by code inspection during a recent NFSv4 IETF working group
testing event.

MFC after: 2 week

2 years ago[LIBM] implementations of sinpi[fl], cospi[fl], and tanpi[fl]
Steve Kargl [Mon, 25 Oct 2021 13:13:52 +0000 (16:13 +0300)]
[LIBM] implementations of sinpi[fl], cospi[fl], and tanpi[fl]

Both IEEE-754 2008 and ISO/IEC TS 18661-4 define the half-cycle
trignometric functions cospi, sinpi, and tanpi.  The attached
patch implements cospi[fl], sinpi[fl], and tanpi[fl].  Limited
testing on the cospi and sinpi reveal a max ULP less than 0.89;
while tanpi is more problematic with a max ULP less than 2.01
in the interval [0,0.5].  The algorithms used in these functions
are documented in {ks}_cospi.c, {ks}_sinpi.c, and s_tanpi.c.

Note.  I no longer have access to a system with ld128 and
adequate support to compile and test the ld128 implementations
of these functions.  Given the almost complete lack of input from
others on improvements to libm, I doubt that anyone cares.  If
someone does care, the ld128 files contain a number of FIXME comments,
and in particular, while the polynomial coefficients are given
I did not update the polynomial algorithms to properly use the
coefficients.

PR: 218514
MFC after: 2 weeks

2 years agostrip/objcopy: handle empty file as unknown
Ed Maste [Mon, 25 Oct 2021 21:25:26 +0000 (17:25 -0400)]
strip/objcopy: handle empty file as unknown

Previously strip reported a somewhat cryptic error for empty files:

    strip: elf_begin() failed: Invalid argument

Add a special case to treat empty files as with an unknown file format.
This is consistent with llvm-strip.  GNU strip produces no output which
does not seem like useful behaviour (but it does exit with status 1).

Reported by: andrew
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32648

2 years agotcp: allow new reno functions to be called from other CC modules
Michael Tuexen [Mon, 25 Oct 2021 20:48:36 +0000 (22:48 +0200)]
tcp: allow new reno functions to be called from other CC modules

Some new reno functions use the internal data, but are also called
from functions of other CC modules. Ensure that in this case, the
internal data is not accessed.

Reported by: syzbot+1d219ea351caa5109d4b@syzkaller.appspotmail.com
Reported by:     syzbot+b08144f8cad9c67258c5@syzkaller.appspotmail.com
Reviewed by: rrs
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D32649

2 years agoLinuxKPI: module.h add MODULE_SUPPORTED_DEVICE()
Bjoern A. Zeeb [Mon, 25 Oct 2021 16:39:56 +0000 (16:39 +0000)]
LinuxKPI: module.h add MODULE_SUPPORTED_DEVICE()

Add a dummy MODULE_SUPPORTED_DEVICE define as we do for other
MODULE_* macros.  This is needed by a wireless driver.

MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D32641

2 years agoiscsid: set max_recv_data_segment_length to what we advertise
Ed Maste [Thu, 21 Oct 2021 15:09:58 +0000 (11:09 -0400)]
iscsid: set max_recv_data_segment_length to what we advertise

Previously we updated the conection's conn_max_recv_data_segment_length
only when we received a response containing MaxRecvDataSegmentLength
from the target.  If the target did not send MaxRecvDataSegmentLength
then we left conn_max_recv_data_segment_length at the default (i.e.,
8192).  A target could then send more data than that defult (up to our
advertised maximum), and we would drop the connection.

RFC 7143 specifies that MaxRecvDataSegmentLength is Declarative, not
negotiated.  Just set conn_max_recv_data_segment_length to our
advertised value in login_negotiate().

PR: 259355
Reviewed by: mav
MFC after: 1 week
Fixes: a15fbc904a4d ("Alike to r312190 decouple iSCSI...")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32605

2 years agoLinuxKPI: add bcd.h
Bjoern A. Zeeb [Mon, 25 Oct 2021 18:14:08 +0000 (18:14 +0000)]
LinuxKPI: add bcd.h

Add bcd2bin() as linuxkpi_bcd2bin().  Libkern does provide a bcd2bin()
which cannot be used leaving us with a conflict (see comment in file).
Fortunately this is only seen in one driver so far and it seems easier
to drop this in and change a single line in the driver than to add this
inline in the driver.

MFC after: 3 days
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D32647

2 years agoLinuxKPI: pci.h / linux_pci.c rename pci_driver field
Bjoern A. Zeeb [Mon, 25 Oct 2021 17:15:01 +0000 (17:15 +0000)]
LinuxKPI: pci.h / linux_pci.c rename pci_driver field

Rename the struct pci_driver {} field got the list_head from links
to node as a driver is actually initialsing this to {} which seems
questionable but it will at least make us match the Linux structure
field name.

MFC after: 3 days
Reviewed by: manu, hselasky
Differential Revision: https://reviews.freebsd.org/D32645

2 years agoLinuxKPI: pci.h make pci_dev argument const for pci_{read,write}_config*()
Bjoern A. Zeeb [Mon, 25 Oct 2021 17:06:09 +0000 (17:06 +0000)]
LinuxKPI: pci.h make pci_dev argument const for pci_{read,write}_config*()

Make the struct pci_dev argument to the pci_{read,write}_config*()
functions "const" to match the Linux definition as some drivers
try to pass in a const argument which we currently fail to honor.

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

2 years agoLinuxKPI: add netdev_features.h
Bjoern A. Zeeb [Mon, 25 Oct 2021 16:50:27 +0000 (16:50 +0000)]
LinuxKPI: add netdev_features.h

Add netdev_features.h as a spearate file from the future netdevice.h
implementation to avoid include problems with a future skbuff.h.

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

2 years agoLinuxKPI: add simple_open() to fs.h
Bjoern A. Zeeb [Mon, 25 Oct 2021 16:44:18 +0000 (16:44 +0000)]
LinuxKPI: add simple_open() to fs.h

Add a dummy simple_open() to fs.h as we have for other
(unsupported) functions.
This is needed by a wireless driver.

MFC after: 3 days
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D32642

2 years agomlx4: rename conflicting netdev_priv() to mlx4_netdev_priv()
Bjoern A. Zeeb [Mon, 25 Oct 2021 16:18:11 +0000 (16:18 +0000)]
mlx4: rename conflicting netdev_priv() to mlx4_netdev_priv()

netdev_priv() is a LinuxKPI function which was used with the old ifnet
linux/netdevice.h implementation which was not adaptable to modern
Linux drviers unless rewriting them for ifnet in first place which
defeats the purpose.
Rename the netdev_priv() calls in mlx4 to mlx4_netdev_priv()
returning the ifnet softc to avoid conflicting symbol names
with different implementations in the future.

MFC after: 3 days
Reviewed by: hselasky, kib
Differential Revision: https://reviews.freebsd.org/D32640

2 years agoInline critical enter/exit for "tied" kernel modules
Mateusz Guzik [Mon, 25 Oct 2021 17:29:46 +0000 (17:29 +0000)]
Inline critical enter/exit for "tied" kernel modules

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

2 years agoarm: fix a typo in nvidia/drm2/tegra_bo.c
Mateusz Guzik [Mon, 25 Oct 2021 18:42:10 +0000 (18:42 +0000)]
arm: fix a typo in nvidia/drm2/tegra_bo.c

Unbreaks building TEGRA124

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

2 years agoDon't run ip_ctloutput() for divert socket.
Gleb Smirnoff [Fri, 22 Oct 2021 23:24:56 +0000 (16:24 -0700)]
Don't run ip_ctloutput() for divert socket.

It was here since divert(4) was introduced, probably just came with a
protocol definition boilerplate.  There is no useful socket option
that can be set or get for a divert socket.

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

2 years agoRemove div_ctlinput().
Gleb Smirnoff [Fri, 22 Oct 2021 23:21:10 +0000 (16:21 -0700)]
Remove div_ctlinput().

This function does nothing since 97d8d152c28b. It was introduced
in 252f24a2cf40 with a sidenote "may not be needed".

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