]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoApply libc++ fix for <ranges> not compiling at all
Dimitry Andric [Thu, 7 Apr 2022 20:04:53 +0000 (22:04 +0200)]
Apply libc++ fix for <ranges> not compiling at all

Merge commit 44cdca37c01a from llvm git (by Arthur O'Dwyer):

  [libc++] Define `namespace views` in its own detail header.

  Discovered in the comments on D118748: we would like this namespace
  to exist anytime Ranges exists, regardless of whether concepts syntax
  is supported. Also, we'd like to fully granularize the <ranges> header,
  which means not putting any loose declarations at the top level.

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

(cherry picked from commit 53683b95ef66a12337999587cd98302b1b425920)

2 years agoMerge llvm-project release/14.x llvmorg-14.0.0-2-g3f43d803382d
Dimitry Andric [Tue, 29 Mar 2022 20:16:50 +0000 (22:16 +0200)]
Merge llvm-project release/14.x llvmorg-14.0.0-2-g3f43d803382d

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-2-g3f43d803382d.

PR: 261742
MFC after: 2 weeks

(cherry picked from commit dbc822f3bc537e0d8350f63178397156bc163b1c)

2 years agoMerge llvm-project release/14.x llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a
Dimitry Andric [Thu, 17 Mar 2022 19:16:00 +0000 (20:16 +0100)]
Merge llvm-project release/14.x llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a.

PR: 261742
MFC after: 2 weeks

(cherry picked from commit fb03ea46eb853b2d128828e9d82882125bcc1657)

2 years agoApply libc++ fix for firefox visibility push/pop issue
Dimitry Andric [Tue, 15 Mar 2022 20:32:06 +0000 (21:32 +0100)]
Apply libc++ fix for firefox visibility push/pop issue

Merge commit 7ab1ab0db401 from llvm git (by Dimitry Andric):

  [libc++] Make __dir_stream visibility declaration consistent

  The class `__dir_stream` is currently declared in two places: as a
  top-level forward declaration in `directory_iterator.h`, and as a friend
  declaration in class `directory_entry`, in `directory_entry.h`.

  The former has a `_LIBCPP_HIDDEN` attribute, but the latter does not,
  causing the Firefox build to complain about the visibility not matching
  the previous declaration. This is because Firefox plays games with
  pushing and popping visibility.

  Work around this by making both `__dir_stream` declarations consistently
  use `_LIBCPP_HIDDEN`.

  Reviewed By: ldionne, philnik, #libc

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

(cherry picked from commit a1f13cbcbb26465d8b54c18a294896add63d6536)

2 years agoMerge llvm-project release/14.x llvmorg-14.0.0-rc2-12-g09546e1b5103
Dimitry Andric [Sat, 5 Mar 2022 14:16:17 +0000 (15:16 +0100)]
Merge llvm-project release/14.x llvmorg-14.0.0-rc2-12-g09546e1b5103

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc2-12-g09546e1b5103.

PR: 261742
MFC after: 2 weeks

(cherry picked from commit d781ede639f2289ccf0889dd138169e1194b656b)

2 years agoMerge llvm-project release/14.x llvmorg-14.0.0-rc1-74-g4dc3cb8e3255
Dimitry Andric [Fri, 18 Feb 2022 22:41:20 +0000 (23:41 +0100)]
Merge llvm-project release/14.x llvmorg-14.0.0-rc1-74-g4dc3cb8e3255

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc1-74-g4dc3cb8e3255.

PR: 261742
MFC after: 2 weeks

(cherry picked from commit d56accc7c3dcc897489b6a07834763a03b9f3d68)

2 years agoApply fix for asm constraint error in www/php80-opcache
Dimitry Andric [Thu, 17 Feb 2022 21:49:39 +0000 (22:49 +0100)]
Apply fix for asm constraint error in www/php80-opcache

Merge commit 027c16bef4b7 from llvm git (by Nick Desaulniers):

  [X86ISelLowering] permit BlockAddressSDNode "i" constraints for PIC

  When building 32b x86 code as PIC, the existing handling of "i"
  constraints is conservative since generally we have to go through the
  GOT to find references to functions.

  But generally, BlockAddresses from C code refer to the Function in the
  current TU.  Permit BlockAddresses to be used with the "i" constraint
  for those cases.

  I regressed this in
  commit 4edb9983cb8c ("[SelectionDAG] treat X constrained labels as i for asm")

Fixes: https://github.com/llvm/llvm-project/issues/53868
  Reviewed By: efriedma, MaskRay

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

(cherry picked from commit 8885dff6cec52378084211fdd9366a73833eceee)

2 years agoMerge llvm-project release/14.x llvmorg-14-init-18315-g190be5457c90
Dimitry Andric [Sat, 5 Feb 2022 22:51:07 +0000 (23:51 +0100)]
Merge llvm-project release/14.x llvmorg-14-init-18315-g190be5457c90

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-18315-g190be5457c90.

PR: 261742
MFC after: 2 weeks

(cherry picked from commit 1838bd0f4839006b42d41a02a787b7f578655223)

2 years agoMerge llvm-project main llvmorg-14-init-18294-gdb01b123d012
Dimitry Andric [Sat, 5 Feb 2022 20:07:43 +0000 (21:07 +0100)]
Merge llvm-project main llvmorg-14-init-18294-gdb01b123d012

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

PR: 261742
MFC after: 2 weeks

(cherry picked from commit 1fd87a682ad7442327078e1eeb63edc4258f9815)

2 years agoMerge llvm-project main llvmorg-14-init-17616-g024a1fab5c35
Dimitry Andric [Thu, 27 Jan 2022 22:17:16 +0000 (23:17 +0100)]
Merge llvm-project main llvmorg-14-init-17616-g024a1fab5c35

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-17616-g024a1fab5c35.

PR: 261742
MFC after: 2 weeks

(cherry picked from commit 04eeddc0aa8e0a417a16eaf9d7d095207f4a8623)

2 years agoMerge llvm-project main llvmorg-14-init-13186-g0c553cc1af2e
Dimitry Andric [Sat, 25 Dec 2021 22:36:56 +0000 (23:36 +0100)]
Merge llvm-project main llvmorg-14-init-13186-g0c553cc1af2e

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-13186-g0c553cc1af2e.

PR: 261742
MFC after: 2 weeks

(cherry picked from commit 0eae32dcef82f6f06de6419a0d623d7def0cc8f6)

2 years agoMerge llvm-project main llvmorg-14-init-11187-g222442ec2d71
Dimitry Andric [Thu, 2 Dec 2021 21:49:08 +0000 (22:49 +0100)]
Merge llvm-project main llvmorg-14-init-11187-g222442ec2d71

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-11187-g222442ec2d71.

PR: 261742
MFC after: 2 weeks

(cherry picked from commit 4824e7fd18a1223177218d4aec1b3c6c5c4a444e)

2 years agoMerge llvm-project main llvmorg-14-init-10223-g401b76fdf2b3
Dimitry Andric [Sat, 20 Nov 2021 17:39:12 +0000 (18:39 +0100)]
Merge llvm-project main llvmorg-14-init-10223-g401b76fdf2b3

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-10223-g401b76fdf2b3.

PR: 261742
MFC after: 2 weeks

(cherry picked from commit 5e801ac66d24704442eba426ed13c3effb8a34e7)

2 years agoMerge llvm-project main llvmorg-14-init-10186-gff7f2cfa959b
Dimitry Andric [Sun, 20 Mar 2022 11:40:34 +0000 (12:40 +0100)]
Merge llvm-project main llvmorg-14-init-10186-gff7f2cfa959b

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-10186-gff7f2cfa959b.

PR: 261742
MFC after: 2 weeks

(cherry picked from commit 349cc55c9796c4596a5b9904cd3281af295f878f)

2 years agoApply llvm fix for possible hangs with CPUTYPE=skylake-avx512
Dimitry Andric [Wed, 1 Jun 2022 21:43:18 +0000 (23:43 +0200)]
Apply llvm fix for possible hangs with CPUTYPE=skylake-avx512

Merge commit e8305c0b8f49 from llvm git (by Simon Pilgrim)

    [X86] combineX86ShuffleChain - don't fold to truncate(concat(V1,V2)) if it was already a PACK op

    Fixes #55050

PR: 264394
Reported by: VVD <vvd@unislabs.com>
MFC after: 3 days

(cherry picked from commit 592e876a422960a78938caa714f2263ff38eb87b)

2 years agolibc: Add HISTORY sections to the manual pages
Gordon Bergling [Thu, 5 May 2022 16:46:32 +0000 (18:46 +0200)]
libc: Add HISTORY sections to the manual pages

There are some sections which could be improved
and work to do so is on going. The work will be
covered via 'X-MFC-WITH' commits.

Obtained from: OpenBSD
Differential Revision: https://reviews.freebsd.org/D34759

(cherry picked from commit 4b7f35db44cbf901e994fc9a4bcd4c98ebe8c4a1)

2 years agoLinuxKPI 802.11 / iwlwifi / rtw88 : re-factor ieee802211_sta for MLO
Bjoern A. Zeeb [Fri, 20 May 2022 18:37:27 +0000 (18:37 +0000)]
LinuxKPI 802.11 / iwlwifi / rtw88 : re-factor ieee802211_sta for MLO

Working on an update for rtw88 baed on wireless-testing I ran into
a build issue with struct ieee802211_sta.  Some fields were factored
out into their own struct apparently preparing for MLO (Multi Link
Operation).

In order to be able to update one driver we have to adjust both
rtw88 and iwlwifi (and the ones still out-of-tree) now.

This is mostly a sed-replace job and no functional changes are
intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6cf748ad948897de636c972debf5733624f6fc20)

2 years agoLinuxKPI: 802.11 updates
Bjoern A. Zeeb [Wed, 18 May 2022 22:39:57 +0000 (22:39 +0000)]
LinuxKPI: 802.11 updates

Add more values to the ieee80211_min_mpdu_start_spacing enum with
two missing given we do not know how they are called.  Also update
the reference while here.

Add struct ieee80211_hdr_3addr and correct the comment on the
ieee80211_hdr to match the one in net80211 to avoid future confusion.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit d296b65d899249da24a8b277554df4af93357b36)

2 years agoLinuxKPI: implement pcie_capability_set_word()
Bjoern A. Zeeb [Wed, 18 May 2022 22:36:31 +0000 (22:36 +0000)]
LinuxKPI: implement pcie_capability_set_word()

Implement pcie_capability_set_word() using the already available
read/write functions.
Also define the completion timeout disable value to our PCI one.
Both needed by a driver update.

Sponsored by: The FreeBSD Foundation
Reviewed by: manu, hselasky
Differential Revision: https://reviews.freebsd.org/D35250

(cherry picked from commit 85eb99f9a47151f90565a1fb37395b8302c2978c)

2 years agoiwlwifi: update firmware
Bjoern A. Zeeb [Mon, 16 May 2022 16:14:25 +0000 (16:14 +0000)]
iwlwifi: update firmware

Update to the latest iwlwifi firmware based on
 linux-firmware at b19cbdca78ab2adfd210c91be15a22568e8b8cae
 (tag: 20220509)
and update firmware module Makefiles accordingly.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 275172b519e82e2ffd957efde6592cab7d8d7aa9)

2 years agoiwlwifi: import two fixes from linux v5.18-rc7
Bjoern A. Zeeb [Mon, 16 May 2022 18:07:36 +0000 (18:07 +0000)]
iwlwifi: import two fixes from linux v5.18-rc7

Import two changes from torvalds/linux.git at tag: v5.18-rc7:
b20bdd9cc9740ac1f2138adab25ddd51245c67be
    iwlwifi: mvm: Don't fail if PPAG isn't supported
7635a1ad8d92dcc8247b53f949e37795154b5b6f
    iwlwifi: iwl-dbg: Use del_timer_sync() before freeing

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 88a15f72cf6b4e80688daf56a7ac493999f25ccd)

2 years agoiwlwifi: update driver from iwlwifi-next
Bjoern A. Zeeb [Mon, 16 May 2022 15:54:57 +0000 (15:54 +0000)]
iwlwifi: update driver from iwlwifi-next

Import code update from iwlwifi-next
 at e89600ebeeb14d18c0b062837a84196f72542830.

This amongst other things removes the deprecated BCAST_FILTERING option,
which we had disabled before due to firmware issues.
Also prepares us for the next firmware update.

The "enable_ini" module option has become an integer with a
sysctl proc equivalent handler.  Disable the module parameter changing
for the moment until we'll have working LinuxKPI support or implement
it as SYSCTL_PROC in FreeBSD directly.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit fac1f59384114a3fe14076815fc4ede68d6bb1ba)

2 years agoLinuxKPI: 802.11 add rfkill_soft_blocked()
Bjoern A. Zeeb [Mon, 16 May 2022 15:38:31 +0000 (15:38 +0000)]
LinuxKPI: 802.11 add rfkill_soft_blocked()

Add rfkill_soft_blocked() to the list of things to implement in
preparation for an iwlwifi update.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 05d6f4d6968a632645a5dcbedec3752098a66624)

2 years agonet80211: remove (optional) RSN from preobereq
Bjoern A. Zeeb [Tue, 12 Apr 2022 22:01:27 +0000 (22:01 +0000)]
net80211: remove (optional) RSN from preobereq

802.11i-2004 did not specify that RSN can be added to the probereq,
only to the proberesp (and others) yet it was added in what seems was
b032f27c365b992e9d8e42214183b39acfb8c6ac (multi-BSS support).
802.11-2020 does not list the IE either for probereq so remove it.

Sponsored by: The FreeBSD Foundation
Okayed by: adrian
Differential Revision: https://reviews.freebsd.org/D34893

(cherry picked from commit 892b1874ace0245a08b0764a45622fbdee3668a9)

2 years agonet80211: simplify code after STA/AP VAPs traffic hang fix
Bjoern A. Zeeb [Thu, 5 May 2022 22:21:03 +0000 (22:21 +0000)]
net80211: simplify code after STA/AP VAPs traffic hang fix

Combine the comment and double-unsetting of OACTIVE into a single case
after e8de31caceaa36caf5d7b4355072f148e2433b82.
This saves the question of why we do it twice--once right before and
one more time right after the state change check.
Also move the XXX comment about kicking the queue up to where it seems
better suited now.

Sponsored by: The FreeBSD Foundation
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D35135

(cherry picked from commit 464907ce1cf931091fa48999ea64480a6d2ef52c)

2 years agonet80211: Fix traffic hang on STA/AP VAPs on a multi-VAP interface
Adrian Chadd [Tue, 12 Apr 2022 20:20:28 +0000 (13:20 -0700)]
net80211: Fix traffic hang on STA/AP VAPs on a multi-VAP interface

This took an embarrasingly long time to find.

The state changes for a radio with a STA /and/ AP VAP gets a bit messy.
The AP maps are marked as waiting, waiting for the STA AP to find a
channel to use before the AP VAPs become active.

However, the code path that clears the OACTIVE flag on a VAP only runs
during a successful run of ieee80211_newstate_cb().

So here is how it goes:

* the STA VAP goes down and needs to scan;
* the AP vap goes RUN->INIT; but it doesn't YET call ieee80211_newstate_cb();
* meanwhile - a send on the AP VAP causes the VAP to set the OACTIVE flag here;
* then the STA VAP finishes scan and goes to RUN;
* which will call wakeupwaiting() as part of the STA VAP transition to RUN;
* .. then the AP VAP goes INIT->RUN directly via a call to hostap_newstate
  in wakeupwaiting rather than it being through the deferred path;
* /then/ the ieee80211_newstate_cb() is called, but it sees the state go
  RUN->RUN;
* .. which results in the OACTIVE flag never being cleared.

This clears the OACTIVE flag when a VAP transitions RUN->RUN; the
driver layer or net80211 layer can set it if required in a subsequent
transmit.

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

(cherry picked from commit e8de31caceaa36caf5d7b4355072f148e2433b82)

2 years agortw88: update man page for loader tunable for >4GB of main memory
Bjoern A. Zeeb [Thu, 5 May 2022 21:17:40 +0000 (21:17 +0000)]
rtw88: update man page for loader tunable for >4GB of main memory

Mention the loader tunable from 6a50157090f2d0c5ab8c570d9cf2e2e3535dbdbf
that needs to be set for system with more than 4GB of physical memory.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 0881eb9665dbfc8a53d9914a9dca1f0473ee1acb)

2 years agortw88: deal with debug messages
Bjoern A. Zeeb [Wed, 27 Apr 2022 15:20:34 +0000 (15:20 +0000)]
rtw88: deal with debug messages

The 'failed to write TX skb to HCI' error message is twice in the code.
Print the function name and along with the message and also the reported
error so it can possibly be helpful.

The 'failed to get tx report from firmware' was purposefully changed
away from debugging in the upstream Linux driver in
584dce175f0461d5d9d63952a1e7955678c91086 . Revert that decision and
extend the logging by the actual queue length so we get an idea how
sever the problem is (see PR for a report).

PR:  248235
Sponsored by: The FreeBSD Foundation

(cherry picked from commit e140d551b78670fbf99c83a59438cb13de50420f)

2 years agortw88: add man pages and hook up to build
Bjoern A. Zeeb [Wed, 30 Mar 2022 22:36:03 +0000 (22:36 +0000)]
rtw88: add man pages and hook up to build

Add man pages for rtw88 and rtw88fw.  Install a copy of the firmware
license file and hook up the driver and firmware modules to the build.

Sponsored by: The FreeBSD Foundation
Relnotes: yes

(cherry picked from commit 20eeed6844e2ab82b909e02c720101297e78d916)

2 years agortw88: import firmware for Realtek's rtw88 supported chipsets.
Bjoern A. Zeeb [Wed, 30 Mar 2022 22:06:14 +0000 (22:06 +0000)]
rtw88: import firmware for Realtek's rtw88 supported chipsets.

Import the most recent versions of the firmware images for the
rtw88 driver.

This is based on linux-firmware at 681281e49fb6778831370e5d94e6e1d97f0752d6.

rtw8822c firmware got downgraded in a later commit to 9.9.10:
firmware version 9.9.11 added support for hw_scan and is reportedly
causing more problems than 9.9.10 does.

The license of the firmware matches the previous rtwnfw(4) firmware
files (modulo a Copyright year) and you can find a copy in
sys/contrib/dev/rtw88fw/LICENCE.rtlwifi_firmware.txt.

Add build infrastructure to create the .ko files but do not yet hook
it up to the build until all parts are in the tree.

Approved by: core (imp)
PR: 248235

(cherry picked from commit 73d4ebea3567f18db549638c3d897b6d6758faa4)
(cherry picked from commit 3443476ca9e751cebbb1c467091551bf3d518814)

2 years agortw88: import Realtek's rtw88 driver
Bjoern A. Zeeb [Wed, 30 Mar 2022 21:54:04 +0000 (21:54 +0000)]
rtw88: import Realtek's rtw88 driver

Import rtw88 based on wireless-testing at
5d5d68bcff1f7ff27ba0b938a4df5849849b47e3 with adjustments for FreeBSD.

While our version of the driver has knowledge about the incapablity
of DMA above 4GB we do see errors if people have more than that
often already showing when laoding firmware.
The problem for that is currently believed to be outside this driver
so importing it anyway for now.

Given the lack of full license texts on non-local files this is
imported under the draft policy for handling SPDX files (D29226). [1]

Approved by: core (imp) [1]

(cherry picked from commit 2774f206809b8fd3a4904fe945f029a414fbc642)

2 years agoLinuxKPI: skbuff: add memlimit tunable for 64bit systems
Bjoern A. Zeeb [Thu, 5 May 2022 20:43:34 +0000 (20:43 +0000)]
LinuxKPI: skbuff: add memlimit tunable for 64bit systems

Some drivers, such as Realtek's rtw88, require 32bit DMA in
a single segment.  busdma(9) has a hard time providing this
currently for 3-ish pages at large quantities
(see lkpi_pci_nseg1_fail in linux_pci.c e86707418c8e8).
Work around this for now by allowing a tunable to enforce
physical addresses allocation limits on 64bit platforms (ignoring PAE)
using "old-school" contigmalloc(9) to avoid bouncing.

A patch needing a custom kernel compiled was tested in the last weeks
by rtw88 users providing the 32bit limit only hardcoded.  The 36bit
limit can be found in iwlwifi so is added as a testing option along.

This is put in as a bandaid for now, so people no longer need to patch
and compile their own kernels to use rtw88 and to allow us to MFC the
driver as well before the amounts of commits to track increases by
much more.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6a50157090f2d0c5ab8c570d9cf2e2e3535dbdbf)

2 years ago[vlan + lagg] add IFNET_EVENT_UPDATE_BAUDRATE event
Andrey V. Elsukov [Thu, 19 May 2022 06:02:27 +0000 (08:02 +0200)]
[vlan + lagg] add IFNET_EVENT_UPDATE_BAUDRATE event

use it to update if_baudrate for vlan interfaces created on the LACP lagg.

Differential revision: https://reviews.freebsd.org/D33405

(cherry picked from commit f2ab91608440338e5574eff098ad4f69e4541a1d)

2 years agorpc.tlsclntd: Add an option to force use of TLS version 1.2
Rick Macklem [Fri, 20 May 2022 21:57:42 +0000 (14:57 -0700)]
rpc.tlsclntd: Add an option to force use of TLS version 1.2

Commit 0b4f2ab0e913 fixes the krpc so that it can use TLS
version 1.3 for NFS-over-TLS, as required by
the draft (someday to be an RFC).
Since FreeBSD 13.0, 13.1 use TLS version 1.2 for
NFS-over-TLS mounts, this command line option
may be used so that NFS-over-TLS mounts to 13.0, 13.1
servers will still work.

Without the command line option, NFS-over-TLS mounts
will use TLS version 1.3.

The man page update will be a separate commit.

(cherry picked from commit 72bf76d6b8c9e9de81661b68389e0035805b8606)

2 years agorpc.tlsservd: Add an option to allow TLS version 1.2
Rick Macklem [Fri, 20 May 2022 21:44:50 +0000 (14:44 -0700)]
rpc.tlsservd: Add an option to allow TLS version 1.2

Commit 0b4f2ab0e913 fixes the krpc so that it can use TLS
version 1.3 for NFS-over-TLS, as required by
the draft (someday to be an RFC).
Since FreeBSD 13.0, 13.1 use TLS version 1.2 for
NFS-over-TLS mounts, this command line option
may be used so that mounts from 13.0, 13.1 will still work.

Without the command line option, only TLS version 1.3
mounts are permitted.

The man page update will be a separate commit.

(cherry picked from commit 0637b12b13be442aacda808bb937d45e538dd98f)

2 years agorpc.tlsclntd, rpc.tlsservd: Fix getopt_long argument
Rick Macklem [Thu, 5 May 2022 23:22:12 +0000 (16:22 -0700)]
rpc.tlsclntd, rpc.tlsservd: Fix getopt_long argument

The "C" option in the argument to getopt_long() was
missing a ":" for both rpc.tlsclntd.c and rpc.tlsservd.c.
This patch fixes this.

(cherry picked from commit 15881823b9dabbd9f561c4fa264fffc4f497b10c)

2 years agorpc.tlsservd: Add a -C command line option for preferred_ciphers
Rick Macklem [Thu, 5 May 2022 22:54:14 +0000 (15:54 -0700)]
rpc.tlsservd: Add a -C command line option for preferred_ciphers

rpc.tlsclntd has a -C command line option for setting
preferred_ciphers.  Testing at a recent IETF NFSv4 testing
event showed that setting preferred_ciphers is not normally
needed for the rpc.tlsservd.

This patch modifies rpc.tlsservd to not specify preferred_ciphers
by default, but provides the same -C option as rpc.tlsclntd to
set preferred_ciphers, in case it is needed.

The man page update will be done as a separate commit.

(cherry picked from commit 712aac1389e8476ff3da98fd7ec80bf71fc601f4)

2 years agoLinuxKPI: Switch irq_work implementation back to standard taskqueue
Vladimir Kondratyev [Tue, 17 May 2022 12:10:20 +0000 (15:10 +0300)]
LinuxKPI: Switch irq_work implementation back to standard taskqueue

from fast one as dmabuf does not run callbacks from critical sections
since drm-kmod 5.7.
Consumers which requires fair irq_work like drm-kmod 5.4 must #define
LKPI_IRQ_WORK_USE_FAST_TQ somewhere in source file before linux/irq_work.h
inclusion to enable old behavior.

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D35052

(cherry picked from commit 71fe907dfb03c4d89a6370ce3d161603d0f40e5e)

2 years agoLinuxKPI: Do not use forward declaration for struct llist_node
Vladimir Kondratyev [Tue, 17 May 2022 12:10:20 +0000 (15:10 +0300)]
LinuxKPI: Do not use forward declaration for struct llist_node

in linux/irq_work.h as irq_work structure contains full version of
llist_node rather than reference to it.

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D35052

(cherry picked from commit bec4576e4c194a3b3bc8fb8cce613d7088dbfb2c)

2 years agoLinuxKPI: IRQ work add TASKQUEUE_FAIL_IF_PENDING flag to taskqueue_enqueue
Vladimir Kondratyev [Tue, 17 May 2022 12:10:20 +0000 (15:10 +0300)]
LinuxKPI: IRQ work add TASKQUEUE_FAIL_IF_PENDING flag to taskqueue_enqueue

call to match Linux.

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D35052

(cherry picked from commit fa30bff5da319304f534aba747befe686fa2071a)

2 years agoLinuxKPI: Implement kthread_worker related functions
Vladimir Kondratyev [Tue, 17 May 2022 12:10:20 +0000 (15:10 +0300)]
LinuxKPI: Implement kthread_worker related functions

Kthread worker is a single thread workqueue which can be used in cases
where specific kthread association is necessary, for example, when it
should have RT priority or be assigned to certain cgroup.

This change implements Linux v4.9 interface which mostly hides kthread
internals from users thus allowing to use ordinary taskqueue(9) KPI.
As kthread worker prohibits enqueueing of already pending or canceling
tasks some minimal changes to taskqueue(9) were done.
taskqueue_enqueue_flags() was added to taskqueue KPI which accepts extra
flags parameter. It contains one or more of the following flags:

TASKQUEUE_FAIL_IF_PENDING - taskqueue_enqueue_flags() fails if the task
    is already scheduled to execution. EEXIST is returned and the
    ta_pending counter value remains unchanged.
TASKQUEUE_FAIL_IF_CANCELING - taskqueue_enqueue_flags() fails if the
    task is in the canceling state and ECANCELED is returned.

Required by: drm-kmod 5.10

MFC after: 1 week
Reviewed by: hselasky, Pau Amma (docs)
Differential Revision: https://reviews.freebsd.org/D35051

(cherry picked from commit b6f87b78b5bb48e00f54b96ddea7ad5bf5e3aa1f)

2 years agoLinuxKPI: Implement sched_set_fifo(_low) functions
Vladimir Kondratyev [Tue, 17 May 2022 12:10:20 +0000 (15:10 +0300)]
LinuxKPI: Implement sched_set_fifo(_low) functions

Required by: drm-kmod

MFC after: 1 week
Reviewed by: hselasky, manu
Differential Revision: https://reviews.freebsd.org/D35050

(cherry picked from commit 0093bc3cd17c2f657682258fae73737655b8a573)

2 years agoLinuxKPI: Add some pollution required by drm-kmod to linux/sched.h
Vladimir Kondratyev [Tue, 17 May 2022 12:10:20 +0000 (15:10 +0300)]
LinuxKPI: Add some pollution required by drm-kmod to linux/sched.h

MFC after: 1 week
Reviewed by: hselasky, manu
Differential Revision: https://reviews.freebsd.org/D35050

(cherry picked from commit 1ebd7aeecace66b0a21029aedaa4776064f5b6b5)

2 years agoLinuxKPI: Add cpu_latency_qos_request_active stub to linux/pm_qos.h
Vladimir Kondratyev [Tue, 17 May 2022 12:10:20 +0000 (15:10 +0300)]
LinuxKPI: Add cpu_latency_qos_request_active stub to linux/pm_qos.h

Required by: drm-kmod 5.10

MFC after: 1 week
Reviewers: hselasky, manu
Differential Revision: https://reviews.freebsd.org/D35049

(cherry picked from commit 6bcd13222215da58f17a54db1592afc36df47f83)

2 years agoLinuxKPI: Fix typo in cond_resched_lock
Vladimir Kondratyev [Tue, 17 May 2022 12:10:20 +0000 (15:10 +0300)]
LinuxKPI: Fix typo in cond_resched_lock

Lock must be released rather than acquired around mi_switch call.

MFC after: 1 week
Reviewed by: hselasky, manu
Differential Revision: https://reviews.freebsd.org/D35048

(cherry picked from commit 41559beb000555770cff1e1b3ef0275157aeb608)

2 years agoLinuxKPI: Convert lkpi-shrinker lock to sx.
Vladimir Kondratyev [Tue, 17 May 2022 12:10:20 +0000 (15:10 +0300)]
LinuxKPI: Convert lkpi-shrinker lock to sx.

This fixes "might_sleep() with the following non-sleepable locks held:
exclusive sleep mutex lkpi-shrinker" warnings.

MFC after: 1 week
Reviewed by: hselasky, manu
Differential Revision: https://reviews.freebsd.org/D35047

(cherry picked from commit 29d5f0c148059806d8f0d9e55acdd072994fa450)

2 years agoLinuxKPI: Implement linux/hashtable.h for FreeBSD.
Hans Petter Selasky [Tue, 10 May 2022 12:16:20 +0000 (14:16 +0200)]
LinuxKPI: Implement linux/hashtable.h for FreeBSD.

This implementation uses the concurrency kit, CK, API directly which is
suitable for use with EPOCH(9) and RCU under FreeBSD.

No functional change intended.

The initial "linux/hash.h" code was obtained from DragonFlyBSD via
FreeBSD's drm-kmod in ports.

Differential Revision: https://reviews.freebsd.org/D35162
Reviewed by: bz@ and markj@
MFC after: 1 week
Sponsored by: NVIDIA Networking

(cherry picked from commit f9e90c24737f96ab97ad534d925fe37a7f0a6f58)

2 years agobacklight: Update cached value when getting the brightness
Emmanuel Vadot [Wed, 25 May 2022 14:48:10 +0000 (16:48 +0200)]
backlight: Update cached value when getting the brightness

External events can cause the backlight level to change (AC adapter
plug/unplug for example) so cache the value there too.

PR: 257796
Sponsored by: Beckhoff Automation GmbH & Co. KG
MFC after: 1 week

(cherry picked from commit e26ef41f79902991c772b59927c721aa7fa5fc64)

2 years agonet: remove incorrect assertions
Kristof Provost [Tue, 31 May 2022 10:02:01 +0000 (12:02 +0200)]
net: remove incorrect assertions

This assertion relies on the 80e60e236d85d change ("ifnet: make if_index
global"), which is not present in stable/13.

This fixes the LINT build (and any configuration with INVARIANTS)

Reported by:    Dimitry Andric <dim@FreeBSD.org>

2 years agokrpc: Fix NFS-over-TLS for KTLS1.3
Rick Macklem [Sun, 15 May 2022 18:51:56 +0000 (11:51 -0700)]
krpc: Fix NFS-over-TLS for KTLS1.3

When NFS-over-TLS uses KTLS1.3, the client can receive
post-handshake handshake records.  These records can be
safely thown away, but are not handled correctly via the
rpctls_ct_handlerecord() upcall to the daemon.

Commit 373511338d95 changed soreceive_generic() so that it
will only return ENXIO for Alert records when MSG_TLSAPPDATA
is specified.  As such, the post-handshake handshake
records will be returned to the krpc.

This patch modifies the krpc so that it will throw
these records away, which seems sufficient to make
NFS-over-TLS work with KTLS1.3.  This change has
no effect on the use of KTLS1.2, since it does not
generate post-handshake handshake records.

(cherry picked from commit 0b4f2ab0e91307bd1fa6e884b0fccef9d10d5a2d)

2 years agoApply clang fix for assertion failure building putty 0.77 on i386
Dimitry Andric [Sat, 28 May 2022 21:26:37 +0000 (23:26 +0200)]
Apply clang fix for assertion failure building putty 0.77 on i386

Merge commit 45084eab5e63 from llvm git (by Arthur Eubanks):

  [clang] Fix some clang->llvm type cache invalidation issues

  Take the following as an example

    struct z {
      z (*p)();
    };

    z f();

  When we attempt to get the LLVM type of f, we recurse into z. z itself
  has a function pointer with the same type as f. Given the recursion,
  Clang simply treats z::p as a pointer to an empty struct `{}*`. The
  LLVM type of f is as expected. So we have two different potential
  LLVM types for a given Clang type. If we store one of those into the
  cache, when we access the cache with a different context (e.g. we
  are/aren't recursing on z) we may get an incorrect result. There is some
  attempt to clear the cache in these cases, but it doesn't seem to handle
  all cases.

  This change makes it so we only use the cache when we are not in any
  sort of function context, i.e. `noRecordsBeingLaidOut() &&
  FunctionsBeingProcessed.empty()`, which are the cases where we may
  decide to choose a different LLVM type for a given Clang type. LLVM
  types for builtin types are never recursive so they're always ok.

  This allows us to clear the type cache less often (as seen with the
  removal of one of the calls to `TypeCache.clear()`). We
  still need to clear it when we use a placeholder type then replace it
  later with the final type and other dependent types need to be
  recalculated.

  I've added a check that the cached type matches what we compute. It
  triggered in this test case without the fix. It's currently not
  check-clang clean so it's not on by default for something like expensive
  checks builds.

  This change uncovered another issue where the LLVM types for an argument
  and its local temporary don't match. For example in type-cache-3, when
  expanding z::dc's argument into a temporary alloca, we ConvertType() the
  type of z::p which is `void ({}*)*`, which doesn't match the alloca GEP
  type of `{}*`.

  No noticeable compile time changes:
  https://llvm-compile-time-tracker.com/compare.php?from=3918dd6b8acf8c5886b9921138312d1c638b2937&to=50bdec9836ed40e38ece0657f3058e730adffc4c&stat=instructions

  Fixes #53465.

  Reviewed By: rnk

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

PR: 264318
Reported by: mandree
MFC after: 3 days

(cherry picked from commit 6a5eebc190ab98de98ed7977cbdee3218758376e)

2 years agoApply clang fix for assertion failure building webkit2-gtk
Dimitry Andric [Fri, 27 May 2022 17:43:39 +0000 (19:43 +0200)]
Apply clang fix for assertion failure building webkit2-gtk

Merge commit 30baa5d2a450 from llvm git (by Richard Smith):

  PR45879: Fix assert when constant evaluating union assignment.

  Consider the form of the first operand of a class assignment not the
  second operand when implicitly starting the lifetimes of union members.
  Also add a missing check that the assignment call actually came from a
  syntactic assignment, not from a direct call to `operator=`.

PR: 264280
Reported by: bapt
MFC after: 3 days

(cherry picked from commit eca6e0f7e460bf9a4a6e1bd5198d75168280c88e)

2 years agoAvoid adding -d to kernel module link command lines for lld >= 14
Dimitry Andric [Sat, 14 May 2022 20:07:01 +0000 (22:07 +0200)]
Avoid adding -d to kernel module link command lines for lld >= 14

Since 0b3178a45cd0 we have added '-d' to the link command line for
kernel modules, so if any unexpected common symbols turn up (even though
we use -fno-common in CFLAGS), storage will be allocated in in the
module itself.

However, with lld this option did not have any effect since ~2017, and
as of lld 14 it warns: "-d, -dc, -dp, and --[no-]define-common will be
removed. See https://github.com/llvm/llvm-project/issues/53660"

Add a linker type and version check, to avoid adding the option for lld
14 and later.

Reported by: bz
MFC after: 2 weeks

(cherry picked from commit 0817c8dc2a48efedac38d1b9b5c4747a15dbe840)

2 years agoASAN: reduce verbosity
Baptiste Daroussin [Mon, 25 Apr 2022 09:23:23 +0000 (11:23 +0200)]
ASAN: reduce verbosity

When running binaries compiled with libasan in PIE and with ALSR on,
the previous code always print the WARNING message, the new code only
printed it if the run is made with the right verbosity

Before this change, many unit test will always fail because of the extra
message which is printed

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D35055
MFC after: 2 weeks

(cherry picked from commit 0a736f0a6aeb0bf8b7e677fab8b562704eb4980e)

2 years agoclang: Skip attempts to access /proc/self/fd
Mateusz Guzik [Sun, 27 Mar 2022 18:01:38 +0000 (18:01 +0000)]
clang: Skip attempts to access /proc/self/fd

In contrast to Linux it does not provide entries which can be readlinked
-- these are just regular files, not giving the expected outcome. That's
on top of procfs not being mounted by default to begin with.

Reviewed by: dim
Differential Revision: https://reviews.freebsd.org/D34684

(cherry picked from commit 30ed48b0a50a062415addcac216371a55e1f6a66)

2 years agoExport _Unwind_Complete and _Unwind_VRS_Pop from arm's libgcc_s
Dimitry Andric [Wed, 27 Apr 2022 09:04:10 +0000 (11:04 +0200)]
Export _Unwind_Complete and _Unwind_VRS_Pop from arm's libgcc_s

Apparently some ports on arm require these symbols, and while they were
available in llvm's libunwind, they were never exported via the arm
specific Symbol.map. Put them in the same version block as gcc does
(GCC_3.5).

Reported by: Robert Clausecker <fuz_at_fuz.su>
MFC after: 3 days

(cherry picked from commit 8e5bcff58b77f8108b2bef0f1d113a91aef502a4)

2 years agolibsa: mark head_errlog feature supported.
Toomas Soome [Fri, 20 May 2022 10:45:33 +0000 (13:45 +0300)]
libsa: mark head_errlog feature supported.

head_errlog is new format for errlog, but we do not really
use errlog, so we can just mark it supported, to enable reading
from pool.

(cherry picked from commit 9cd45772a44f268ccb3e20caf7f3f764f6b5e1a1)

2 years agouipc_socket.c: Modify MSG_TLSAPPDATA to only do Alert Records
Rick Macklem [Sat, 14 May 2022 19:56:50 +0000 (12:56 -0700)]
uipc_socket.c: Modify MSG_TLSAPPDATA to only do Alert Records

Without this patch, the MSG_TLSAPPDATA flag would cause
soreceive_generic() to return ENXIO for any non-application
data record in a TLS receive stream.

This works ok for TLS1.2, since Alert records appear to be
the only non-application data records received.
However, for TLS1.3, there can be post-handshake handshake
records, such as NewSessionKey sent to the client from the
server. These handshake records cannot be handled by the
upcall which does an SSL_read() with length == 0.

It appears that the client can simply throw away these
NewSessionKey records, but to do so, it needs to receive
them within the kernel.

This patch modifies the semantics of MSG_TLSAPPDATA slightly,
so that it only applies to Alert records and not Handshake
records. It is needed to allow the krpc to work with KTLS1.3.

(cherry picked from commit 373511338d954895752e957f3028a178587c8c84)

2 years agoif: avoid interface destroy race
Kristof Provost [Sun, 27 Mar 2022 18:23:25 +0000 (20:23 +0200)]
if: avoid interface destroy race

When we destroy an interface while the jail containing it is being
destroyed we risk seeing a race between if_vmove() and the destruction
code, which results in us trying to move a destroyed interface.

Protect against this by using the ifnet_detach_sxlock to also covert
if_vmove() (and not just detach).

PR: 262829
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D34704

(cherry picked from commit 868bf82153e8ff22f09a8860c872149e0fb6bdef)

2 years agodumpon: warn if the configured netdump link is down
Mitchell Horne [Sat, 14 May 2022 13:25:21 +0000 (10:25 -0300)]
dumpon: warn if the configured netdump link is down

Previously we expected the DIOCSKERNELDUMP ioctl to return ENXIO if the
interface was down, but it does not actually do this. Grab the link
status using getifaddrs(3) instead, and downgrade this case from an
error to a warning; the user might bring the link back up at a later
time.

Reviewed by: cem
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D35196

(cherry picked from commit 6543fa5a5c47cfbea92586f0994431fc8ba09f6a)

2 years agodebugnet: fix an errant assertion
Mitchell Horne [Sat, 14 May 2022 13:23:08 +0000 (10:23 -0300)]
debugnet: fix an errant assertion

We may call debugnet_free() before g_debugnet_pcb_inuse is true,
specifically in the cases where the interface is down or does not
support debugnet. pcb->dp_drv_input is used to hold the real driver
if_input callback while debugnet is in use, so we can check the status
of this field in the assertion.

This can be triggered trivially by trying to configure netdump on an
unsupported interface at the ddb prompt.

Initializing the dp_drv_input field to NULL explicitly is not necessary
but helps display the intent.

PR: 263929
Reported by: Martin Filla <freebsd@sysctl.cz>
Reviewed by: cem, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D35179

(cherry picked from commit a84bf5eaa10c2db8856c7497b63ae3caceac8c17)

2 years agonetdump: check the support status of the interface
Mitchell Horne [Sat, 14 May 2022 13:23:58 +0000 (10:23 -0300)]
netdump: check the support status of the interface

If the interface does not support debugnet(4) we should bail early,
rather than having the user find this out at the time of the panic.
dumpon(8) already expects this return value and will print a helpful
error message.

Reviewed by: cem, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D35180

(cherry picked from commit 38a36057ae56c8023878f3c3c2185bafc2896964)

2 years agoDrop d_dump from struct cdevsw
Mitchell Horne [Fri, 13 May 2022 13:38:54 +0000 (10:38 -0300)]
Drop d_dump from struct cdevsw

It appears to be unused. These days struct disk has a d_dump member,
which is what gets passed to the kernel dump framework.

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

(cherry picked from commit 0f50da2e09b7dddad25953d0c167efe09f7282eb)

2 years agolibsa: Make the nvlist implementation more self-contained
Mark Johnston [Fri, 20 May 2022 14:17:35 +0000 (10:17 -0400)]
libsa: Make the nvlist implementation more self-contained

Move declarations into a new nvlist.h rather than putting everything in
libzfs.h.  This makes this nvlist code easier to reuse elsewhere.  In
particular, the nvlist implementation in sys/contrib/libnv does not
provide XDR encoding, but this is needed when reading from or writing to
ZFS pools.

Also:
- Remove references to boolean_t.  It has to be a 32-bit int here, so
  just reference the underlying type.
- Add includes needed when compiling the nvlist code outside of stand/.

No functional change intended.

Reviewed by: tsoome
Sponsored by: The FreeBSD Foundation

(cherry picked from commit e097436cb2bc42e74d1dc2bf188c4491eeff3ec0)

2 years agolibsa: Fix a bug in nvlist creation
Mark Johnston [Fri, 20 May 2022 14:15:00 +0000 (10:15 -0400)]
libsa: Fix a bug in nvlist creation

When adding an entry to an nvlist, the data buffer might need to be
resized.  When this happens, the XDR encoder's notion of the buffer size
also needs to be updated, otherwise the operation may erroneously fail.

Reviewed by: tsoome, imp
Sponsored by: The FreeBSD Foundation

(cherry picked from commit bcc3148c70c72cc409881e7a25e2bb053a39a0da)

2 years agobitstring_test: Add regression tests for bit_ff(c|s)_area_at()
Mark Johnston [Fri, 20 May 2022 14:18:10 +0000 (10:18 -0400)]
bitstring_test: Add regression tests for bit_ff(c|s)_area_at()

Validate the cases where a match can be found immediately and where no
match can be found.  This extends the existing test cases and is enough
to catch the bug fixed in commit 6e7a585348d5 ("bitstring: fix ff_area()
when start!=0").

Reviewed by: dougm
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 670be460e4089038aadb47917bd71fe07d2cac21)

2 years agoping: add missing test files to Makefile
Mike Karels [Sat, 21 May 2022 03:13:02 +0000 (22:13 -0500)]
ping: add missing test files to Makefile

Should fix ATF tests after 5af718a5927a.

(cherry picked from commit a30eee517dfd238b1988ae2f0279f579abe81c95)

2 years agoping: if -S srcaddr uses a numeric address, use that protocol
Mike Karels [Fri, 20 May 2022 14:16:01 +0000 (09:16 -0500)]
ping: if -S srcaddr uses a numeric address, use that protocol

The command "ping -S dotted.quad hostname" fails on dual-stack hosts
with the confusing message "ping: invalid source address: Name does
not resolve" because IPv6 is selected in preference.  If the argument
to -S is numeric (likely), select the corresponding address family,
as if -4 or -6 was specified.  Add tests that either IPv4 or IPv6 can
be forced via a -S parameter.

Reviewed by: asomers
Differential Revision: https://reviews.freebsd.org/D35271

(cherry picked from commit 5af718a5927a9e078201ebc7ad1310e5b4918b7a)

2 years agomakefs: Remove execute permission from in-tree test scripts
Mark Johnston [Wed, 23 Mar 2022 17:32:17 +0000 (13:32 -0400)]
makefs: Remove execute permission from in-tree test scripts

Let the build system set it as needed.  No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 21add93b58189322b00421f428917759a7034736)

2 years agosrc.libnames: Replace redundant += with =
Cy Schubert [Wed, 18 May 2022 01:59:13 +0000 (18:59 -0700)]
src.libnames: Replace redundant += with =

The += for unique assignments is equivalent to =. Make these confusing
assignments simply assignments.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D35242

(cherry picked from commit e343ebbfbe97104093ba1ab5d089e8363c170df5)

2 years agoHide -fuse-ld= not supported message for non-build targets
Ed Maste [Thu, 12 May 2022 14:49:30 +0000 (10:49 -0400)]
Hide -fuse-ld= not supported message for non-build targets

In some build configurations a warning about (an absolute path for)
-fuse-ld= not being supported by GCC was emitted during cleandir or
other non-build make targets.

For these non-build targets COMPILER_TYPE is set to "none" but we
treated the .else case for COMPILER_TYPE==clang as implying gcc.
Check instead for COMPILER_TYPE==gcc.

PR: 263913
Reported by: pstef
Reviewed by: pstef
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4143e4fb197bec8cad4cdf129c86d45b0e942fd9)

2 years agortsock: fix a stack overflow
Kurosawa Takahiro [Fri, 13 May 2022 17:58:11 +0000 (19:58 +0200)]
rtsock: fix a stack overflow

struct sockaddr is not sufficient for buffer that can hold any
sockaddr_* structure. struct sockaddr_storage should be used.

Test:
ifconfig epair create
ifconfig epair0a inet6 add 2001:db8::1 up
ndp -s 2001:db8::2 02:86:98:2e:96:0b proxy # this triggers kernel stack overflow

Reviewed by: markj, kp
Differential Revision: https://reviews.freebsd.org/D35188

(cherry picked from commit 9573cc35555eb0da35da5712462de9f6107fb974)

2 years agomakefs: Fix warnings and reset WARNS to the default
Mark Johnston [Fri, 29 Apr 2022 13:18:02 +0000 (09:18 -0400)]
makefs: Fix warnings and reset WARNS to the default

Leave -Wcast-align disabled, at least for now, since there are numerous
instances of that warning in places where buffer pointers are cast to
pointers to various filesystem structures.  Fixing this properly would
be too much work for too little gain.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit cc1a53bc1aea0675d64e9547cdca241612906592)

2 years agonewfs_msdos: Fix warnings that arise when compiled for makefs
Mark Johnston [Fri, 29 Apr 2022 13:16:54 +0000 (09:16 -0400)]
newfs_msdos: Fix warnings that arise when compiled for makefs

Sponsored by: The FreeBSD Foundation

(cherry picked from commit f775c417fd9dd29d7bd987fc1cd30c6024540312)

2 years agorpc.tlsservd: Add logging of TLS version and cipher used
Rick Macklem [Fri, 6 May 2022 21:03:43 +0000 (14:03 -0700)]
rpc.tlsservd: Add logging of TLS version and cipher used

This patch adds logging of the version of TLS and cipher
negotiated successfully by the TLS handshake for each client,
if the "-v" command line option has been specified.

This information may be useful for monitoring and debugging
NFS-over-TLS mounts.

(cherry picked from commit d71c9f14682fee73f3694426fb47e66aab721835)

2 years agocpuset: Fix the KASAN and KMSAN builds
Mark Johnston [Fri, 20 May 2022 14:11:31 +0000 (10:11 -0400)]
cpuset: Fix the KASAN and KMSAN builds

Rename the "copyin" and "copyout" fields of struct cpuset_copy_cb to
something less generic, since sanitizers define interceptors for
copyin() and copyout() using #define.

Reported by: syzbot+2db5d644097fc698fb6f@syzkaller.appspotmail.com
Fixes: 47a57144af25 ("cpuset: Byte swap cpuset for compat32 on big endian architectures")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4a3e51335e86cee02569c04b9f1e95ca9abcb170)

2 years agoFix the build after 47a57144
Dmitry Chagin [Thu, 19 May 2022 18:40:59 +0000 (21:40 +0300)]
Fix the build after 47a57144

(cherry picked from commit 89737eb8290a10d96b77afac1b68e4740b43353b)

2 years agocpuset: Byte swap cpuset for compat32 on big endian architectures
Justin Hibbits [Thu, 12 May 2022 20:38:22 +0000 (15:38 -0500)]
cpuset: Byte swap cpuset for compat32 on big endian architectures

Summary:
BITSET uses long as its basic underlying type, which is dependent on the
compile type, meaning on 32-bit builds the basic type is 32 bits, but on
64-bit builds it's 64 bits.  On little endian architectures this doesn't
matter, because the LSB is always at the low bit, so the words get
effectively concatenated moving between 32-bit and 64-bit, but on
big-endian architectures it throws a wrench in, as setting bit 0 in
32-bit mode is equivalent to setting bit 32 in 64-bit mode.  To
demonstrate:

32-bit mode:

BIT_SET(foo, 0):        0x00000001

64-bit sees: 0x0000000100000000

cpuset is the only system interface that uses bitsets, so solve this
by swapping the integer sub-components at the copyin/copyout points.

Reviewed by: kib
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D35225

(cherry picked from commit 47a57144af25a7bd768b29272d50a36fdf2874ba)

2 years agoFix overflow errors in sbttous and sbttoms
Alan Somers [Wed, 6 Apr 2022 20:03:11 +0000 (14:03 -0600)]
Fix overflow errors in sbttous and sbttoms

Both of these functions would overflow for very large inputs.  Add tests
for them.  Also, add tests for the inverse functions, *stosbt, whose
overflow errors were fixed by 4c30b9ecd47.

PR: 263073
Sponsored by: Axcient
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D34809

(cherry picked from commit 10f44229dcd93672583ad6b6e1193a9bc9e4f7c7)

2 years agoCorrectly measure system load averages > 1024
Alan Somers [Thu, 5 May 2022 21:35:23 +0000 (15:35 -0600)]
Correctly measure system load averages > 1024

The old fixed-point arithmetic used for calculating load averages had an
overflow at 1024.  So on systems with extremely high load, the observed
load average would actually fall back to 0 and shoot up again, creating
a kind of sawtooth graph.

Fix this by using 64-bit math internally, while still reporting the load
average to userspace as a 32-bit number.

Sponsored by: Axcient
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D35134

(cherry picked from commit 1d2421ad8b6d508ef155752bdfc5948f7373bac3)

2 years agofusefs: annotate more file descriptor leaks in the tests
Alan Somers [Thu, 5 May 2022 15:06:04 +0000 (09:06 -0600)]
fusefs: annotate more file descriptor leaks in the tests

The fusefs tests intentionally leak file descriptors.  Annotate all of
the leakages in order to hopefully pacify Coverity.

Reported by: Coverity (20 different CIDs)
Sponsored by: Axcient

(cherry picked from commit 4ac4b12699fd423165a0ac0d05630a1fae022bbb)

2 years agofusefs: fix an undefined variable access
Alan Somers [Thu, 5 May 2022 14:43:51 +0000 (08:43 -0600)]
fusefs: fix an undefined variable access

In an error path, a dtrace probe could access an undefined variable.

Reported by: Coverity (CID 1471986)
Sponsored by: Axcient

(cherry picked from commit dcfa054216ef8dfebed9c7c06c066bce0098bd94)

2 years agofusefs: use the fsname mount option if set
Alan Somers [Fri, 29 Apr 2022 16:43:47 +0000 (10:43 -0600)]
fusefs: use the fsname mount option if set

The daemon can specify fsname=XXX in its mount options.  If so, the file
system should report f_mntfromname as XXX during statfs.  This will show
up in the output of commands like mount and df.

Submitted by: Ali Abdallah <ali.abdallah@suse.com>
Differential Revision: https://reviews.freebsd.org/D35090

(cherry picked from commit 2f6362484c0e1250ef6a76cccdbe4a95587e850c)

2 years agofusefs: add a test for the subtype= option
Alan Somers [Fri, 29 Apr 2022 13:59:29 +0000 (07:59 -0600)]
fusefs: add a test for the subtype= option

At mount time server can set, for example, "subtype=xfs", so that
mount(8) will later show the mountpoint's file system as "fusefs.xfs".
fusefs has had this feature ever since the original GSoC commit in 2012,
but there's never been a test for it.

(cherry picked from commit 616eaa66aa4955f182eb0117e17e07da76fcf696)

2 years agogenet: fix output packet corruption in uncommon case
Mike Karels [Mon, 9 May 2022 12:19:52 +0000 (07:19 -0500)]
genet: fix output packet corruption in uncommon case

The code for the "shift" block in the COPY macro set the pointer for
the next copy block to the wrong value.  In this case, the link-layer
header would be overwritten by the network-layer header.  This case is
difficult or impossible to exercise in the current driver without
changing the value of the hw.genet.tx_hdr_min sysctl.  Correct the
pointer.  While here, remove a line in the macro that was marked
"unneeded", which was actually wrong.

PR: 263824
Submitted by: jiahali@blackberry.com

(cherry picked from commit 1de9aa4d4f7938f36e6485dad817908a6e45bb32)

2 years agombuf: Properly set the default value for mb_use_ext_pgs
Mark Johnston [Tue, 16 Nov 2021 21:23:11 +0000 (16:23 -0500)]
mbuf: Properly set the default value for mb_use_ext_pgs

Reported by: Jenkins
Fixes: fcaa890c4469 ("mbuf: Only allow extpg mbufs if the system has a direct map")
Pointy hat: markj

(cherry picked from commit 32854e528ac6f99e019674f545d0a27940fb8bba)

2 years agopowerpc: enable supported sanitizers on powerpc64*
Piotr Kubaj [Tue, 17 May 2022 06:39:29 +0000 (08:39 +0200)]
powerpc: enable supported sanitizers on powerpc64*

1. Merge LLVM's 315d792130258a9b7250494be8d002ebb427b08f, adding support
for FreeBSD/powerpc64*.
2. Add sanitizer list to lib/libclang_rt/Makefile, taken from the list of
libraries that llvm-devel port builds.
3. powerpc64le supports the same sanitizers that powerpc64, but powerpc64le
also supports xray* sanitizers.
4. lib/libclang_rt/xray/Makefile hardcodes amd64-specific files, so that needs
to be conditionalized.
5. Sanitizers are not enabled for powerpc, because powerpc supports only
builtins and profile.

Reviewed by: dim
Differential Revision: https://reviews.freebsd.org/D35228
Relnotes: yes
MFC after: 3 days

(cherry picked from commit f5024381ac16ba43d37a8bd32d54c27f6a6afa66)

2 years agoriscv: also enable includes, stats and stats_client in libclang_rt
Piotr Kubaj [Mon, 18 Apr 2022 18:26:40 +0000 (20:26 +0200)]
riscv: also enable includes, stats and stats_client in libclang_rt

Reviewed by: dim (earlier version)
Differential Revision: https://reviews.freebsd.org/D34735
MFC after: 3 days

(cherry picked from commit c1e0431c2202faa178642c8b54e545df3ed44f5f)

2 years agoipfw.8: MFC: spell "layer2" consistently throughout the manual page
Eugene Grosbein [Fri, 13 May 2022 21:30:29 +0000 (04:30 +0700)]
ipfw.8: MFC: spell "layer2" consistently throughout the manual page

(cherry picked from commit 9d7cefc278027a2e52fa56c38536712c6a309629)

2 years agonfsd: Fix handling of Open/Create for the pNFS server
Rick Macklem [Wed, 4 May 2022 20:52:33 +0000 (13:52 -0700)]
nfsd: Fix handling of Open/Create for the pNFS server

When the MDS of a pNFS service receives an Open/Create
and the file already exists, it must do a Setattr of
size == 0.  Without this patch, this was eroneously
done via a VOP_SETAATR() call, which would set the
length of the MDS file to 0 (which is already is,
since all data lives on the DSs).

This patch fixes the problem by doing a nfsvno_setattr()
instead of VOP_SETATTR(), which knows to do a proxied
Setattr on the DSs.

For a non-pNFS server, the change has no effect, since
nfsvno_setattr() only does a VOP_SETATTR() for that case.

This was found during a recent IETF NFSv4 testing event.

(cherry picked from commit f32bf50d43be1e898cebf751ce749b07d1301b8f)

2 years agoigc: Increase rx_buffer_size local variable to 32b
Kevin Bowling [Tue, 17 May 2022 03:15:34 +0000 (20:15 -0700)]
igc: Increase rx_buffer_size local variable to 32b

Apply 6987c47569b377f4b6eba9966afdedfb1b39fca8 to igc. This is not
expected to have any benefit on current parts with current observed PBA
sizes but will avoid surprises if they are increased in future chips.

Approved by: grehan
Differential Revision: https://reviews.freebsd.org/D35217

(cherry picked from commit 9b88ecd674ac292cb6d7ab644595091edd6ec87b)

2 years agotruss: add ppoll(2) argument decoding
Christian Weisgerber [Tue, 17 May 2022 18:20:53 +0000 (20:20 +0200)]
truss: add ppoll(2) argument decoding

PR: 264029
Approved by: emaste
MFC after: 3 days

(cherry picked from commit 9bf4983f54919c38a0e3aae2bea09c04c8ee4421)

2 years agonfsd: Add a sanity check for Owner/OwnerGroup string length
Rick Macklem [Wed, 4 May 2022 20:58:22 +0000 (13:58 -0700)]
nfsd: Add a sanity check for Owner/OwnerGroup string length

Robert Morris reported that, if a client sends an absurdly
large Owner/OwnerGroup string, the kernel malloc() for the
large size string can block forever.

This patch adds a sanity limit for Owner/OwnerGroup string
length.  Since the RFCs do not specify any limit and FreeBSD
can handle a group name greater than 1Kbyte, the limit is
set at a generous 10Kbytes.

PR: 260546

(cherry picked from commit ef4edb70c909fc2b1de867601c2230597d07daa0)

2 years agosetkey(8): Clarify language around AEAD ciphers.
John Baldwin [Wed, 27 Apr 2022 19:18:52 +0000 (12:18 -0700)]
setkey(8): Clarify language around AEAD ciphers.

AEAD ciphers for IPsec combine both encryption and authentication.  As
such, ESP configurations using an AEAD cipher should not use a
seperate authentication algorithm via -A.  However, this was not
apparent from the setkey manpage and 12.x and earlier did not perform
sufficient argument validation permitting users to pair an explicit -A
such as SHA256-HMAC with AES-GCM.  (The result was a non-standard
combination of AES-CTR with the specified MAC, but with the wrong
initial block counter (and thus different keystream) compared to using
AES-CTR as the cipher.)

Attempt to clarify this in the manpage by explicitly calling out AEAD
ciphers (currently only AES-GCM) and noting that AEAD ciphers should
not use -A.

While here, explicitly note which authentication algorithms can be
used with esp vs esp-old.  Also add subsection headings for the
different algorithm lists and tidy some language.

I did not convert the tables to column lists (Bl -column) though that
would probably be more correct than using literal blocks (Bd
-literal).

PR: 263379
Reviewed by: Pau Amma <pauamma@gundo.com>, markj
Differential Revision: https://reviews.freebsd.org/D34947

(cherry picked from commit e6dede145616ed8f98c629c23a2ba206b812c921)

2 years agoamd64 NOTES: Add entries for qlxgb, glxgbe, and glxge.
John Baldwin [Fri, 22 Apr 2022 22:18:06 +0000 (15:18 -0700)]
amd64 NOTES: Add entries for qlxgb, glxgbe, and glxge.

(cherry picked from commit f2d166d5322e557ff1388a5419ed694187fc1dbc)

2 years agoamd64 NOTES: Sort the axp entry.
John Baldwin [Fri, 22 Apr 2022 22:18:06 +0000 (15:18 -0700)]
amd64 NOTES: Sort the axp entry.

(cherry picked from commit 5bf623bbcdfaa5be2d639317b601f2019ba3ed28)

2 years agoqlxgb/qlxgbe/qlxge: Fix build without INET and/or without INET6.
John Baldwin [Fri, 22 Apr 2022 22:18:05 +0000 (15:18 -0700)]
qlxgb/qlxgbe/qlxge: Fix build without INET and/or without INET6.

This is in preparation for adding these drivers to amd64 NOTES.

(cherry picked from commit 618aa8cd0ae0edca7d9a4e37ff242a6bb77bbccc)

2 years agonvdimm_e820: Use driver->name in identify method.
John Baldwin [Fri, 6 May 2022 21:42:02 +0000 (14:42 -0700)]
nvdimm_e820: Use driver->name in identify method.

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

(cherry picked from commit 216ca4cee1189ce1dd38b293c9dd431eb5ff8b02)

2 years agopbio: Add locking and remove D_NEEDGIANT.
John Baldwin [Thu, 5 May 2022 23:40:04 +0000 (16:40 -0700)]
pbio: Add locking and remove D_NEEDGIANT.

Use a sx lock to permit uiomove directly into/out of the the per-port
buffers.  In addition, the sx lock provides a stronger guarantee that
I think this driver wants which is to single-thread read and write
calls even while paused.  Finally, replace tsleep with dummy wait
channels with calls to pause_sig to more clearly communicate the
intent.

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

(cherry picked from commit 51f481235c29fb38b92fb08a830385e39df80093)

2 years agopbio: Return BUS_PROBE_DEFAULT from probe instead of 0.
John Baldwin [Thu, 5 May 2022 23:39:19 +0000 (16:39 -0700)]
pbio: Return BUS_PROBE_DEFAULT from probe instead of 0.

0 should only be returned from probe in legacy drivers that need to
preserve softc state between probe and attach.

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

(cherry picked from commit 4942e8df472bdb49e72a8c9b60e8189bdb037b8c)