]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agolinker: Permit CTFv3 containers
Mark Johnston [Mon, 7 Mar 2022 13:53:05 +0000 (08:53 -0500)]
linker: Permit CTFv3 containers

Approved by: re (gjb)
Reviewed by: Domagoj Stolfa
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8dbae4ce32bde42daee050ccfceee5eb2d306786)
(cherry picked from commit 8409eb0251ce54b4a901b534198ca82f5048c7fe)

2 years agofbt: Add support for CTFv3 containers
Mark Johnston [Mon, 7 Mar 2022 13:45:53 +0000 (08:45 -0500)]
fbt: Add support for CTFv3 containers

The general aim in this and subsequent patches is to minimize the
amount of code that directly references CTF types such as ctf_type_t,
ctf_array_t, etc.  To that end, introduce some routines similar to the
existing fbt_get_ctt_size() (which exists to deal with differences
between v1 and v2) and change ctf_lookup_by_id() to return a void
pointer.

Support for v2 containers is preserved.

Approved by: re (gjb)
Sponsored by: The FreeBSD Foundation

(cherry picked from commit d9175438c0e77ef2b400601aa8cf8098c82a77a7)
(cherry picked from commit 2ecf3b58ebdfd6452b8ce269943da362b40c2e63)

2 years agoctf: Add definitions for CTFv3
Mark Johnston [Mon, 7 Mar 2022 13:44:02 +0000 (08:44 -0500)]
ctf: Add definitions for CTFv3

These are based on definitions added to binutils' libctf.  Specifically:
- Type IDs are now encoded in 32 bits rather than 16, changing the
  layout of ctf_type_t, ctf_array_t, ctf_member_t and ctf_lmember_t.
- Type info is encoded in 32 bits rather than 16.  The type "kind" is
  extended from 5 bits to 6, and the type "vlen" is extended from 10
  bits to 25.

The main upside is that we remove the current limit, imposed by CTFv2,
of 2^{15} distinct types in the main kernel executable.  Other limits,
such as that on the number of elements in an enum, imposed by the vlen
limit, are also raised.

This change adds v2 and v3 flavours of macros and type definitions which
differ between the two versions.  Compatibility is preserved for now by
having generic names refer to the v2 definitions, so, e.g., ctf_type_t
is still a v2 type.

No functional change intended.

Approved by: re (gjb)
Reviewed by: Domagoj Stolfa
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 994297b01b98816bea1abf45ae4bac1bc69ee7a0)
(cherry picked from commit 9818e5ebf3376ee5dbd01afe24e9972d9201633e)

2 years agolinker: Simplify CTF container handling
Mark Johnston [Mon, 7 Mar 2022 13:43:42 +0000 (08:43 -0500)]
linker: Simplify CTF container handling

Use sys/ctf.h to provide various definitions required to parse the CTF
header.  No functional change intended.

Approved by: re (gjb)
Reviewed by: Domagoj Stolfa, emaste
Sponsored by: The FreeBSD Foundation

(cherry picked from commit cab9382a2cdf88b3027370cbdf73b095598eb7c1)
(cherry picked from commit 24597a09b946ccaec4c7e43eae45c81b21d247a3)

2 years agoctf: Import ctf.h from OpenBSD
Mark Johnston [Mon, 7 Mar 2022 13:42:57 +0000 (08:42 -0500)]
ctf: Import ctf.h from OpenBSD

Use it instead of the existing ctf.h from OpenSolaris.  This makes it
easier to use CTF in the core kernel, and to extend the CTF format to
support wider type IDs.

The imported ctf.h is modified to depend only on _types.h, and also to
provide macros which use the "parent" bit of a type ID to refer to types
in a parent CTF container.

No functional change intended.

Approved by: re (gjb)
Reviewed by: Domagoj Stolfa, emaste
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2d5d2a986ce1a93b8567dbdf3f80bc2b545d6998)
(cherry picked from commit 3681c4f065f1028ff84b654cfbfb238f2723b78c)

2 years agoisci(4): Remove a double word in an error message
Gordon Bergling [Sun, 3 Apr 2022 14:07:20 +0000 (16:07 +0200)]
isci(4): Remove a double word in an error message

- s/is is/is/

Approved by: re@ (gjb)

(cherry picked from commit 756220b5152526a5a89ca16df31d8acf0a7795bb)

2 years agotty(4): Add a HISTORY section to the manual page
Gordon Bergling [Sun, 3 Apr 2022 13:12:41 +0000 (15:12 +0200)]
tty(4): Add a HISTORY section to the manual page

Note that a console typewriter device /dev/tty
and asynchronous communication interfaces /dev/tty[0-5]
first appeared in VersionĀ 1 AT&T UNIX.

Obtained from: OpenBSD
Approved by: re@ (gjb)

(cherry picked from commit b988af5b439220f37159ed18318e8e4baeedc6a7)

2 years agopass(4): Fix a typo in the manual page
Gordon Bergling [Wed, 6 Apr 2022 16:46:26 +0000 (18:46 +0200)]
pass(4): Fix a typo in the manual page

- s/modfied/modified/

Approved by: re@ (gjb)

(cherry picked from commit 3dcfd6c266d492075e8f8481a60170b22866db56)

2 years agomt(3): Fix a typo in the manual page
Gordon Bergling [Wed, 6 Apr 2022 16:41:08 +0000 (18:41 +0200)]
mt(3): Fix a typo in the manual page

- s/mulitple/multiple/

Approved by: re@ (gjb)

(cherry picked from commit 656d68a711952ac2b92ed258502978c5ba1dbc73)

2 years agoown(9): Fix a typo in a function name in the manual page
Gordon Bergling [Sat, 2 Apr 2022 13:26:40 +0000 (15:26 +0200)]
own(9): Fix a typo in a function name in the manual page

- s/own_commmand_wait/own_command_wait/

Approved by: re@ (gjb)

(cherry picked from commit a95850f10af4fb4102f4c4f7c16775dbcd6568e6)

2 years agohtu21(4): Correct a typo in the manual page
Gordon Bergling [Sat, 2 Apr 2022 12:06:14 +0000 (14:06 +0200)]
htu21(4): Correct a typo in the manual page

- s/measurment/measurement/

Approved by: re@ (gjb)

(cherry picked from commit 0d40cd15240503931f493c0c97d8db0914bfbfbd)

2 years agoipf(5): Fix a typo in the manual page
Gordon Bergling [Sat, 2 Apr 2022 12:50:45 +0000 (14:50 +0200)]
ipf(5): Fix a typo in the manual page

- s/accomodate/accommodate/

Approved by: re@ (gjb)

(cherry picked from commit 8a3568b584cb9e1abab94c047172fc99421e99a9)

2 years agocrypto(9): Fix a typo in the manual page
Gordon Bergling [Sat, 2 Apr 2022 12:35:55 +0000 (14:35 +0200)]
crypto(9): Fix a typo in the manual page

- s/faciliate/facilitate/

Approved by: re@ (gjb)

(cherry picked from commit 8e8d2a722e82eaaaab7a63704285a23166775904)

2 years agoloader.4th(8): Fix a typo in the manual page
Gordon Bergling [Sat, 2 Apr 2022 13:11:59 +0000 (15:11 +0200)]
loader.4th(8): Fix a typo in the manual page

- s/commmand/command/

Approved by: re@ (gjb)

(cherry picked from commit ad49d7c54cca4906179369e2196c1edbcf509342)

2 years agopnfsserver(4): Fix a typo in the manual page
Gordon Bergling [Sat, 2 Apr 2022 13:12:51 +0000 (15:12 +0200)]
pnfsserver(4): Fix a typo in the manual page

- s/commmand/command/

Approved by: re@ (gjb)

(cherry picked from commit a16977209bc261239022fac2cab6956a8e9676b5)

2 years ago13.1: update to RC3
Glen Barber [Thu, 14 Apr 2022 01:15:25 +0000 (21:15 -0400)]
13.1: update to RC3

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agoSwitch RELNOTES to 13.1
Mike Karels [Tue, 12 Apr 2022 00:02:14 +0000 (19:02 -0500)]
Switch RELNOTES to 13.1

Truncate entries from 13.0; change 13.0 to 13.1.

This is a direct commit.

Approved by: re (gjb)

2 years agonet: Fix LLE lock leaks
Mark Johnston [Fri, 8 Apr 2022 15:46:19 +0000 (11:46 -0400)]
net: Fix LLE lock leaks

Historically, lltable_try_set_entry_addr() would release the LLE lock
upon failure.  After some refactoring, it no longer does so, but
consumers were not adjusted accordingly.

Also fix a leak that can occur if lltable_calc_llheader() fails in the
ARP code, but I suspect that such a failure can only occur due to a code
bug.

Approved by: re (gjb)
Reviewed by: bz, melifaro
Reported by: pho
Fixes: 0b79b007ebfc ("[lltable] Restructure nd6 code.")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit dd91d8448665dd31df5be7341756394293c6e36c)
(cherry picked from commit 078d50f9dd14ac77145b2cf8f143d49329b2c4f7)

2 years agoi386: Fix the nodevice apic build
Mark Johnston [Fri, 8 Apr 2022 15:47:52 +0000 (11:47 -0400)]
i386: Fix the nodevice apic build

Approved by: re (gjb)
PR: 263124
Fixes: 62d09b46ad75 ("x86: Defer LAPIC calibration until after timecounters are available")
Reviewed by: kib, jhb, emaste
Sponsored by: The FreeBSD Foundation

(cherry picked from commit aa597d4049ffee69d413ea2154f4b312ffbaf646)
(cherry picked from commit 4f659ce4daf82ac3335abf3aab7181f2ac90a4cd)

2 years agoinstallworld: handle ldd including preloaded objects
Ed Maste [Fri, 1 Apr 2022 13:58:47 +0000 (09:58 -0400)]
installworld: handle ldd including preloaded objects

The installworld target makes a temporary copy of binaries to be used
during the install.  Libraries that they depend on are also included,
found by using `ldd`.

After commit 0913953c9ed0 ldd started listing preloaded objects,
including [vdso], under a [preloaded] header.  Skip ldd output that is
enclosed in square brackets.

Reviewed by: cy, kib [earlier version]
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34734

(cherry picked from commit b3b462229f972e2ed24d450d7d2f8855cdd58a87)
(cherry picked from commit e10026a406b21b3f1581ee15a88def2b640dffe7)

Approved by: re (gjb)

2 years agolibarchive: fix zstd compression support
Martin Matuska [Fri, 8 Apr 2022 08:09:32 +0000 (10:09 +0200)]
libarchive: fix zstd compression support

The commit 833a452e9 introduced a change that detached
the zstd compression (not decompression) support from base build.

Reported by: kevans
Approved by: re (delphij)

(cherry picked from commit 7f815d4f128f063c1bac361c8f26b52ab7df1e6c)
(cherry picked from commit 3caf7dd45d08a5b7b7fafe39e7aae7d7f8d1a684)

2 years ago13.1: update to RC2
Glen Barber [Thu, 7 Apr 2022 00:07:08 +0000 (20:07 -0400)]
13.1: update to RC2

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agovfs: fixup WANTIOCTLCAPS on open
Mateusz Guzik [Sat, 2 Apr 2022 18:35:58 +0000 (20:35 +0200)]
vfs: fixup WANTIOCTLCAPS on open

In some cases vn_open_cred overwrites cn_flags, effectively nullifying
initialisation done in NDINIT. This will have to be fixed.

In the meantime make sure the flag is passed.

Reported by: jenkins
Noted by: Mathieu <sigsys@gmail.com>
Approved by: re (gjb)

(cherry picked from commit b7262756e2f471f6481070e2473af7853506b150)
(cherry picked from commit 792ebbb1557e290805d84b87653110681c7338a0)

2 years agovfs: fix memory leak on lookup with fds with ioctl caps
Mateusz Guzik [Thu, 24 Mar 2022 20:51:03 +0000 (21:51 +0100)]
vfs: fix memory leak on lookup with fds with ioctl caps

Reviewed by: markj
PR: 262515
Noted by: firk@cantconnect.ru
Differential Revision: https://reviews.freebsd.org/D34667
Approved by: re (gjb)

(cherry picked from commit 0c805718cbd3709e3ffc1a0d41612168c8242360)
(cherry picked from commit 838d8e6fb60e12e610701ae10be717309f3ea935)

2 years agofix integer overflow bugs in *stosbt
Warner Losh [Wed, 6 Apr 2022 03:35:27 +0000 (21:35 -0600)]
fix integer overflow bugs in *stosbt

68f57679d660 Fixed another class of integer overflows, but introduced a
boundary condition for 2-4s in ns conversion, 2-~4000s in us conversions
and 2-~4,000,000s in ms conversions. This was because we bogusly used
SBT_1S for the notion of 1 second, instead of the appropriate power of
10. To fix, just use the appropriate power of 10, which avoids these
overflows.

This caused some sleeps in ZFS to be on the order of an hour.

Approved by: re@ (gjb)
MFC: 1 day
PR: 263073
Sponsored by: Netflix
Reviewed by: asomers
Differential Revision: https://reviews.freebsd.org/D34790

(cherry picked from commit 4c30b9ecd47a2d92565731082a6a4f2bd1e6e051)
(cherry picked from commit c43786cc37641cef02171a3c5be5a588d850e6ab)

2 years agomrsas: if controller reset is in progress, refrain from firing DCMDs to
Chandrakanth Patil [Fri, 21 Jan 2022 09:24:37 +0000 (14:54 +0530)]
mrsas: if controller reset is in progress, refrain from firing DCMDs to
firmware in shutdown

If controller reset is in progress, at same time if system shutdown is
issued then corresponding shutdown function in driver will be invoked
where driver is waiting 15 seconds to complete the controller reset.

If the reset is not complteted within that time frame driver will go
ahead and fire cache flush and shutdown DCMDs which will end up
accessing the the queues which are not initialized due to undergoing
reset leads to FMU error in firmware.

Fix:
In shutdown function, if controller reset is not finished within 15
seconds than driver will return to the OS without firing any DCMDs.

Approved by: re@ (gjb)
Reviewed by: imp
PR: 261375

(cherry picked from commit 79c4c4be9618470711480f46ef2cd3a15c00cdd2)
(cherry picked from commit 09e161a29ee5b0e52494c861f451de35b286e327)

2 years agomrsas: remove additional MPT command allocation for R1 FP command
Chandrakanth Patil [Fri, 21 Jan 2022 12:11:49 +0000 (17:41 +0530)]
mrsas: remove additional MPT command allocation for R1 FP command

There is an additional MPT command allocation for R1 fp command which
will lead to MPT command unavailablity in case of rigorous R1 FP IOs.

Remove additional MPT command allocation for R1 FP.

Approved by: re@ (gjb)
Reviewed by: imp
PR: 261377

(cherry picked from commit 241bb95552a39d440519162b544c776adcb7cf57)
(cherry picked from commit 2ebe51859723fd3cb4cf02dc560441fc0ec50dc1)

2 years agolinuxkpi: move io_mapping_create_wc to .c
Warner Losh [Tue, 5 Apr 2022 05:06:37 +0000 (23:06 -0600)]
linuxkpi: move io_mapping_create_wc to .c

Move io_mapping_create_wc to .c because it encodes the size of struct
io_mapping so we move this from the client module to the linuxkpi
module.

Approved by: re@ (gjb)
Sponsored by: Netflix
Reviewed by: hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D34776

(cherry picked from commit 132b00f90613d8cc797137d4c3d2dcb99ba3c690)
(cherry picked from commit 4e94b3542dd6a5c3f60431e811013f4dbf603227)

2 years agolinuxkpi: Move lkpi_pcim_iomap_devres_find to .c file
Warner Losh [Tue, 5 Apr 2022 05:06:29 +0000 (23:06 -0600)]
linuxkpi: Move lkpi_pcim_iomap_devres_find to .c file

lkpi_pcim_iomap_devres_find encodes the size of struct pcim_iomap_devres
in the code, so move from .h to .c to move from client driver to
linuxkpi module.

Approved by: re@ (gjb)
Sponsored by: Netflix
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34775

(cherry picked from commit 2bf3361d56f70d87a19f5d2bc8d258d418fb7a24)
(cherry picked from commit 211621030e19553c7bd321b05694418920517736)

2 years agolinuxkpi: Move pci_alloc_irq_vectors to .c file
Warner Losh [Tue, 5 Apr 2022 05:06:21 +0000 (23:06 -0600)]
linuxkpi: Move pci_alloc_irq_vectors to .c file

pci_alloc_irq_vectors encodes the size of struct msix_entry
into its code. Move from .h to .c to move this knowledge from
client modules to linuxkpi module.

Approved by: re@ (gjb)
Sponsored by: Netflix
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34774

(cherry picked from commit 36b5c440028b44b22cfc0596125f575ca513656f)
(cherry picked from commit bc01b383945ca4f327ddb5cc940dcbafa3aaff7c)

2 years agolinuxkpi: Move pci_request_region and _lkpi_pci_iomap into .c
Warner Losh [Tue, 5 Apr 2022 05:06:14 +0000 (23:06 -0600)]
linuxkpi: Move pci_request_region and _lkpi_pci_iomap into .c

Both pci_request_region and _lkpi_pci_iomap encode the size of struct
pci_mmio_region into their code. Move from .h to .c files to move that
knowledge from the client drivers into the linuxkpi module.

Approved by: re@ (gjb)
Sponsored by: Netflix
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34773

(cherry picked from commit 1cdb25340f8ee5dd145b0dc370cbab1bd7bdca65)
(cherry picked from commit 4859994c42950600b57e9d2259bd027562eefbe3)

2 years agolinuxkpi: Move lkpi_pci_devres_get_alloc into .c file
Warner Losh [Tue, 5 Apr 2022 05:06:06 +0000 (23:06 -0600)]
linuxkpi: Move lkpi_pci_devres_get_alloc into .c file

lkpi_pci_devres_get_alloc encodes the struct pci_devres into its
code. Move from .h file to .c file to move this knowledge into linuxkpi
module.

Approved by: re@ (gjb)
Sponsored by: Netflix
Reviewed by: hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D34772

(cherry picked from commit 3ea682e21eed92f31dcfb8a34409580d36c452f7)
(cherry picked from commit 2cd55de380d3d6f02c9b40ea53a319b477268f1c)

2 years agolinuxkpi: Move cdev_alloc into .c file
Warner Losh [Tue, 5 Apr 2022 05:05:59 +0000 (23:05 -0600)]
linuxkpi: Move cdev_alloc into .c file

Move cdev_alloc into linux_compat.c since it encodes the size of struct
linux_cdev into the client modules otherwise.

Approved by: re@ (gjb)
Sponsored by: Netflix
Reviewed by: hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D34771

(cherry picked from commit aca0bcbca344b39f2a448e8c1c0d80bac8c0d6de)
(cherry picked from commit d1f93d6721a6c51c0cb49078ad5c5d535a383964)

2 years agolinuxkpi: Move class_create to .c file
Warner Losh [Tue, 5 Apr 2022 05:05:43 +0000 (23:05 -0600)]
linuxkpi: Move class_create to .c file

class_create encodes the size of struct class into the generated
code. Move from .h file to .c file to move this knowledge from the
client modules that call this into the linuxkpi module.

Approved by: re@ (gjb)
Sponsored by: Netflix
Reviewed by: hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D34769

(cherry picked from commit 1341ac9f9c111bba4e1ca046c479f32f2d4989c0)
(cherry picked from commit 98d2b4a158f15d6d971a88315c5c5987036f89a3)

2 years agolinuxkpi: Move device_create_groups_vargs to linux_compat.c
Warner Losh [Tue, 5 Apr 2022 05:05:36 +0000 (23:05 -0600)]
linuxkpi: Move device_create_groups_vargs to linux_compat.c

device_create_groups_vargs encodes the size of struct device. Move
definition from .h to .c to move this size into the linuxkpi module
rather than encoding it in all client driver modules.

Approved by: re@ (gjb)
Sponsored by: Netflix
Reviewed by: hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D34768

(cherry picked from commit 702b6875035921252d0f2b72171c7662f28766fb)
(cherry picked from commit 417f1c81491ae26643ea7e3f3fc5c08b8e8944a9)

2 years agolinuxkpi: move kobject_create to .c file
Warner Losh [Tue, 5 Apr 2022 05:05:26 +0000 (23:05 -0600)]
linuxkpi: move kobject_create to .c file

kobject_create knows the size of struct kobject. Move it to
linux_compat.c so this knowledge is confined to the loadable module and
not the clients.

Approved by: re@ (gjb)
Sponsored by: Netflix
Reviewed by: hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D34767

(cherry picked from commit 36929b55849c8f553a744d6e4fbc8b1a5ff73f66)
(cherry picked from commit 2f3d11894be6fb727be77184d232de24bf5551ba)

2 years agolinuxkpi: add padding to struct pci_driver
Warner Losh [Tue, 5 Apr 2022 04:54:49 +0000 (22:54 -0600)]
linuxkpi: add padding to struct pci_driver

Add 32 or 64 bytes of padding to struct pci_driver at the end in the
_spare field like we should have done when we branched stable/13, but
neglected to do so since we didn't properly anticipate the need.

We cannot safely use these spare fields until after 13.0 EOL since
drivers compiled on 13.0 won't have that space reserved and we'll step
on something else using them. This isn't 100% KBI compatible through the
13.x release branch, but is compatible enough so that drm packages built
on the oldest supported release will work on the latest stable/13 and
any newer releases. It's not ideal, but makes the best of a bad
situation and is a pragmatic approach that belatedly builds in some
future proofing.

Direct commit to stable/13 because this is not relevant to main in this
exact form.

Approved by: re@ (gjb)
Sponsored by: Netflix
Reviewed by: bz
Differential Revision: https://reviews.freebsd.org/D34754

(cherry picked from commit 86d5c66106610f083deda03ce0c661a51b2dd723)

2 years agolinuxkpi: Restore the KBI for struct pci_driver
Warner Losh [Sat, 2 Apr 2022 19:52:53 +0000 (13:52 -0600)]
linuxkpi: Restore the KBI for struct pci_driver

The size of the 13.0 version of struct pci_driver was 92 or 184 bytes on
32- or 64-bit systems respectively. We recently added bsd_probe_return
at the end of this struct, breaking the KBI on the stable/13 branch.

Fix this by removing the isdrm member. We don't need it because we can
do a strcmp in the few places that need it as they aren't performance
critical. Move the newly added bsd_probe_return to that slot. It's the
same size in all our supported KBIs as bool and fits into that slot due
to padding rules.

Direct commit to stable/13 because this is not relevant to main.

Approved by: re@ (gjb)
Sponsored by: Netflix
Reviewed by: bz
Differential Revision: https://reviews.freebsd.org/D34754

(cherry picked from commit aa61c28b4242ce3f86f1ae7807ae95887cbe9d11)

2 years agobectl: push space-in-name check down into libbe
Kyle Evans [Sun, 3 Apr 2022 02:04:31 +0000 (21:04 -0500)]
bectl: push space-in-name check down into libbe

This check was previously in `create` only, not applying to renames.  It
should really be applied at the libbe level, so that we can avoid
writing about this restriction over and over again.

While we're here: `bectl rename` always succeeds, even when it doesn't.
Start returning the error.

Approved by: re (gjb)
Reported By: Christian McDonald <cmcdonald netgate com>

(cherry picked from commit dadb9c70938c4ae2c260f6af65752c67ac752284)
(cherry picked from commit 227e52a9c0b0be9656757fec47a2648f5619bf67)

2 years agobectl: add some discussion about boot environment layouts
Kyle Evans [Thu, 31 Mar 2022 22:41:53 +0000 (17:41 -0500)]
bectl: add some discussion about boot environment layouts

Discuss the standard type of layout, as well as the "deep" BE layout,
and some of the properties of both.  Point the various -r flags at this
new section, to help users understand which they're working with and
what the -r flag is actually doing. Note that we may just deprecate the
-r flag in future versions, but the flag will be recognized as a NOP at
that point.

Approved by: re (gjb)

(cherry picked from commit c0f846ff235296249271b1235ff6a52b7d23cefb)
(cherry picked from commit 0e90da6549d177874437dc2e7bab085873538da2)

2 years agolibbe: fix be_mounted_at() with props after bootonce
Kyle Evans [Thu, 31 Mar 2022 19:18:14 +0000 (14:18 -0500)]
libbe: fix be_mounted_at() with props after bootonce

propinfo.bootonce was filled with garbage, leading to a segfault later
during prop building.  Initialize it to NULL.

Approved by: re (gjb)

(cherry picked from commit d155d8e138563c0b39c658684e6a4fe6e2e36f8a)
(cherry picked from commit 6ce8e35cead46048d9ae3c1dabafe1ef4ed26f97)

2 years agolibbe: pull props for the correct dataset in be_mounted_at()
Kyle Evans [Thu, 31 Mar 2022 19:19:52 +0000 (14:19 -0500)]
libbe: pull props for the correct dataset in be_mounted_at()

The props feature to this API was added as a "just in case", with no
planned consumer.  It turns out that it was implemented incorrectly,
tapping out props for the BE root (BE's parent) rather than the BE
itself in all cases.

Fetch properties for the dataset that's actually mounted at the queried
path.

Approved by: re (gjb)
Reported by: Christian McDonald <cmcdonald netgate com>

(cherry picked from commit 31190aa02eef05b1b58ba89212dc8c8738770e37)
(cherry picked from commit bed9c972aee7aa5ac916f24d60d9dbd109897856)

2 years agolibarchive: merge vendor bugfixes
Martin Matuska [Sun, 3 Apr 2022 12:21:28 +0000 (14:21 +0200)]
libarchive: merge vendor bugfixes

Bugfixes:
  IS #1685 and OSS-Fuzz #38764 (security):
    (ISO reader) fix possible heap buffer overflow in read_children()
  IS #1715 and OSS-Fuzz #46279 (security):
    (RARv4 reader) fix heap-use-after-free in run_filters()

Approved by: re (gjb)

(cherry picked from commit 9f690fcfdc050f566466ac10cca29ff43bf4fe92)
(cherry picked from commit 43a449f2f1feae53a1302821db6940fd364fa171)

2 years agoBump newvers.sh for 13.1-RC1 advisories
Ed Maste [Wed, 6 Apr 2022 03:28:15 +0000 (23:28 -0400)]
Bump newvers.sh for 13.1-RC1 advisories

Approved by: so, re (implicit)

2 years agonetmap: Fix TOCTOU vulnerability in nmreq_copyin
Vincenzo Maffione [Wed, 16 Mar 2022 06:58:50 +0000 (06:58 +0000)]
netmap: Fix TOCTOU vulnerability in nmreq_copyin

The total size of the user-provided nmreq was first computed and then
trusted during the copyin. This might lead to kernel memory corruption
and escape from jails/containers.

Reported by: Lucas Leong (@_wmliang_) of Trend Micro Zero Day Initiative
Security: CVE-2022-23084
MFC after: 3 days

(cherry picked from commit 393729916564ed13f966e09129a24e6931898d12)
(cherry picked from commit 9f600a260a738d87015b2e9722b7b4f228cbd47d)

Approved by: so, re (implicit)

2 years agonetmap: Fix integer overflow in nmreq_copyin
Vincenzo Maffione [Wed, 16 Mar 2022 06:57:54 +0000 (06:57 +0000)]
netmap: Fix integer overflow in nmreq_copyin

An unsanitized field in an option could be abused, causing an integer
overflow followed by kernel memory corruption. This might be used
to escape jails/containers.

Reported by: Reno Robert and Lucas Leong (@_wmliang_) of Trend Micro
Zero Day Initiative
Security: CVE-2022-23085

(cherry picked from commit 694ea59c7021c25417e6d516362d2f59b4e2c343)
(cherry picked from commit 9df8dd3ea36c8b3abe8fc182647472ca9cd83efd)

Approved by: so, re (implicit)

2 years agonet80211: validate Mesh ID length in ieee80211_parse_beacon
Bjoern A. Zeeb [Tue, 5 Apr 2022 22:51:19 +0000 (22:51 +0000)]
net80211: validate Mesh ID length in ieee80211_parse_beacon

Reported by: m00nbsd working with Trend Micro Zero Day Initiative

(cherry picked from commit fb8c87b4f3bfdfac014f9d894fe75fbad0391b24)
(cherry picked from commit 72617f9246e3a4be28eeafeae1bdd983143eef3e)

Approved by: so, re (implicit)

2 years agobhyve: validate e82545 checksum offset field
Mark Johnston [Tue, 5 Apr 2022 22:51:19 +0000 (22:51 +0000)]
bhyve: validate e82545 checksum offset field

Reported by: Mehdi Talbi, Synacktiv

(cherry picked from commit b0aa20bec5db244980a0248e24dd6b8e1e68c4d0)
(cherry picked from commit 53f72209479885dfa6a7e6ed68cbc82c68464f4b)

Approved by: so, re (implicit)

2 years agoLinuxKPI: 802.11: fix RSSI (and NF)
Bjoern A. Zeeb [Fri, 1 Apr 2022 22:31:23 +0000 (22:31 +0000)]
LinuxKPI: 802.11: fix RSSI (and NF)

As in 4a22cd6c4e5f4fc4a38aa7400742d4005c5ae3de nf and rss should be
signed and not unsigned.  Change the types in the header and while
here change a magic number to a define as done elsewhere (value does
not change).

When calculating c_rssi we need to make it relative so subtract nf.
And while here improve the debug output.

This will hopefully fix ifconfig wlanN list scan S:N output which
tools use to chose a BSSID and help net80211 internal calculations.

Sponsored by: The FreeBSD Foundation
Approved by: re (gjb)

(cherry picked from commit 60970a328e280b25b05f1d9a9de1ef91af573c4a)
(cherry picked from commit 7b9d8e33bc4ee0b8cc22ab28a1f09a062e103bd5)

2 years agonet80211: correct types for nf and rssi
Bjoern A. Zeeb [Fri, 1 Apr 2022 22:30:02 +0000 (22:30 +0000)]
net80211: correct types for nf and rssi

NF and RSSI should be signed and not unsigned to avoid problems.
Change the type accordingly.

Sponsored by: The FreeBSD Foundation
Approved by: re (gjb)

(cherry picked from commit 4a22cd6c4e5f4fc4a38aa7400742d4005c5ae3de)
(cherry picked from commit 7311128e69b8927d866f9db8c9fa7c5d54eff692)

2 years agoLinuxKPI: 802.11: fix compat code for i386
Bjoern A. Zeeb [Thu, 31 Mar 2022 17:29:53 +0000 (17:29 +0000)]
LinuxKPI: 802.11: fix compat code for i386

Compiling another driver on i386 revealed two problems:
- ieee80211_tx_info.status.status_driver_data space needs to be
  calculated.  While a pointer is 32bit vm_paddr_t is 64 bit on i386
  so we didn't fit more than one of these in but needed more space.
- the arguments to ieee80211_txq_get_depth() are expected to
  unsigned long and not uint64_t.

No user noticable changes.

Sponsored by: The FreeBSD Foundation
Approved by: re (gjb)

(cherry picked from commit 86220d3cbd500b1018dcdabb0ba70644db438cfd)
(cherry picked from commit 2a8e509ba30c6546ceeec49f9447c2e3d21a1d22)

2 years agofstyp: detect Raspberry Pi Pico boot filesystem as FAT
Ed Maste [Mon, 28 Mar 2022 21:03:10 +0000 (17:03 -0400)]
fstyp: detect Raspberry Pi Pico boot filesystem as FAT

fstyp looks for a 0x55 0xAA signature at offset 510, but this is not
required by specifications and is not provided by the Raspberry Pi Pico
bootloader.

We should really remove the signature check and implement a more
comprehensive BPB validation instead, but it will require more
investigation and testing.  For now just add a special case for the
Raspberry Pi Pico bootloader, to avoid introducing regressions or new
false positives.

PR: 262896
Reviewed by: delphij
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34699

(cherry picked from commit 868c1b8431f297ade8deba5baf903f73cf5e11c6)
(cherry picked from commit 27c2f016b86744aa5d4c6031b4ef2fc16bbf6546)
(cherry picked from commit e06ce938ddc0222c6ed10a70108f71685923bd45)

Approved by: re (gjb)

2 years agopowerpc: implement __clear_cache
Piotr Kubaj [Fri, 1 Apr 2022 19:13:13 +0000 (21:13 +0200)]
powerpc: implement __clear_cache

Merge LLVM commit 81f5c6270cdfcdf80e6296df216b696a7a37c8b5.

This fixes runtime of most notably pcre libraries (currently patched in ports),
and probably also other ports since currently __clear_cache() just calls
SIGABRT on powerpc.

Reviewed by: dim
Differential Revision: https://reviews.freebsd.org/D34736
Approved by: re (gjb)

(cherry picked from commit 57b6ac48a96c99e684ab4dc85b8a87097797dc9f)
(cherry picked from commit 16c3f5d03e984a6039a888eec5bcc58735a7d965)

2 years agouart(4): Add a concept of "unique" serial devices
Colin Percival [Tue, 29 Mar 2022 07:41:37 +0000 (00:41 -0700)]
uart(4): Add a concept of "unique" serial devices

FreeBSD detects serial ports twice: First, very early in the boot
process, in order to obtain a usable console; and second, during
the device probe/attach process.  When a UART is discovered during
device probing, FreeBSD attempts to determine whether it is a
device which was already being used as a console; without this,
the console doesn't work in userland.

Unfortunately it's possible for a UART to be mapped to a different
location in memory when it is discovered on a bus than it has when
it is announced via the ACPI SPCR table; this breaks the matching
process, which relies on comparing bus addresses.

To address this, we introduce a concept of "unique" serial devices,
i.e. devices which are guaranteed to be present *only once* on any
system.  If we discover one of these during device probing, we can
match it to a same-PCI-vendor-and-device-numbers console which was
announced via the ACPI SPCR table, regardless of the differing bus
addresses.

At present, the only unique serial device is the "Amazon PCI serial
device" (vendor 0x1d0f, device 0x8250) found in some EC2 instances.
This unbreaks the serial console on those systems.

Reviewed by: imp
Approved by: re (gjb)
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D34703

(cherry picked from commit ad93649d230428561db983153c546b39336fa4f1)
(cherry picked from commit 5cc5cd739ef15cc762d2f417bccb44daefc86d56)

2 years agocxgbe: fix enabling lro & rxtimestamps
Andrew Gallatin [Wed, 26 May 2021 13:54:26 +0000 (09:54 -0400)]
cxgbe: fix enabling lro & rxtimestamps

A recent change caused iq flags, like LRO, to be set before
init_iq(). However, init_iq() clears those flags, so they
became effectively impossible to set.   This change moves
the initializion of these flags to after the call to init_iq().
This fixes LRO.

Differential Revision: https://reviews.freebsd.org/D30460
Reviewed by: np, rrs
Sponsored by: Netflix
Fixes: 43bbae19483fbde0a91e61acad8a6e71e334c8b8
(cherry picked from commit df8437a93dd5268e5bfd06411c01a5cbdb38c6ac)
(cherry picked from commit 392d7f026962b273cdcd3b230403efaa05f29efe)

Approved by: re@ (gjb@)

2 years agolib/libz: remove ZLIBprivate_1.0 namespace.
Xin LI [Sun, 3 Apr 2022 18:32:47 +0000 (11:32 -0700)]
lib/libz: remove ZLIBprivate_1.0 namespace.

These symbols were hidden and no longer exposed, and were never exposed in headers.

MFC after: 3 days

(cherry picked from commit a7f127b653c939976ac492595a8283b5de08ed0d)
(cherry picked from commit c4727a47f18cb54ebbab951157e57b019db09fc0)

Approved by: re (gjb)

2 years agosys/contrib/zlib: Always define Z_U8 and Z_U4
Xin LI [Sun, 3 Apr 2022 18:45:38 +0000 (11:45 -0700)]
sys/contrib/zlib: Always define Z_U8 and Z_U4

This is a temporary hack for zlib to make sure that the library
still builds when building with Z_SOLO (used in kernel and loader),
as zlib is depending on limits.h which is only available in STDC
case.

PR: kern/262977
MFC after: 3 days

(cherry picked from commit 0a21252adf11f7e839eabeb530e75cd1f9cd5386)

Approved by: re (gjb, early MFC)

(cherry picked from commit 9587a10b420f9ef243f578b6938662ff6b558e86)

Approved by: re (gjb)

2 years agoMFV 7b495a2a7abf (zlib): Correct incorrect inputs provided to the CRC
Xin LI [Thu, 31 Mar 2022 22:35:58 +0000 (15:35 -0700)]
MFV 7b495a2a7abf (zlib): Correct incorrect inputs provided to the CRC
functions.

MFC after: 3 days

(cherry picked from commit c61bc1110c90cb67a60cb08c4f3bc24f75d0b385)
(cherry picked from commit 6b0e0c9e9534149d932fc8b71d1d21a09fe31ffc)

Approved by: re (gjb)

2 years agoMFV c144cc54795d: zlib 1.2.12.
Xin LI [Thu, 31 Mar 2022 14:25:53 +0000 (07:25 -0700)]
MFV c144cc54795d: zlib 1.2.12.

MFC after: 3 days
Relnotes: yes

(cherry picked from commit cd8822075a38d0734e74b1735e4b5dbef9789170)
(cherry picked from commit 6349675deca1fbe704086287bdd941940410799c)

Approved by: re (gjb)

2 years agompr/mps/mpt: verify cfg page ioctl lengths
Ed Maste [Mon, 28 Mar 2022 13:33:54 +0000 (09:33 -0400)]
mpr/mps/mpt: verify cfg page ioctl lengths

*_CFG_PAGE ioctl handlers in the mpr, mps, and mpt drivers allocated a
buffer of a caller-specified size, but copied to it a fixed size header.
Add checks that the size is at least the required minimum.

Note that the device nodes are owned by root:operator with 0640
permissions so the ioctls are not available to unprivileged users.

This change includes suggestions from scottl, markj and mav.

Two of the mpt cases were reported by Lucas Leong (@_wmliang_) of
Trend Micro Zero Day Initiative; scottl reported the third case in mpt.
Same issue found in mpr and mps after discussion with imp.

Reported by: Lucas Leong (@_wmliang_), Trend Micro Zero Day Initiative
Reviewed by: imp, mav
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34692

(cherry picked from commit 8276c4149b5fc7c755d6b244fbbf6dae1939f087)
(cherry picked from commit 0b29e1b9f9df3bde6402cccc49cb850c0dcc35fb)

Approved by: re (gjb)

2 years agopf: Initialize the table entry zone limit at initialization time
Mark Johnston [Wed, 30 Mar 2022 19:41:44 +0000 (15:41 -0400)]
pf: Initialize the table entry zone limit at initialization time

The limit may later be updated by the "set limit" directive in pf.conf.
UMA does not permit a limit to be set on a zone after any items have
been allocated from a zone.

Other UMA zones used by pf do not appear to be susceptible to this
problem: they either set a limit at zone creation time or never set one
at all.

Approved by: re (gjb)
PR: 260406
Reviewed by: kp
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7d1ab866911a2b29e041d64bc83a93638533f957)
(cherry picked from commit 1487f84223ce1341ebdfc87e50fbcddedc6d1de8)

2 years agoTreat cache write as a read in arm64 data faults
Andrew Turner [Sat, 26 Mar 2022 15:59:34 +0000 (15:59 +0000)]
Treat cache write as a read in arm64 data faults

On arm64 we can ask the hardware to perform cache operations from
userspace. These require read permission however when the memory is
unmapped the kernel will receive a write exception. Add a check to
see if the cause of the exception is from the cache and pass a memory
read fault type to the vm subsystem.

PR: 262836
Reported by: dch
Approved by: re (gjb)
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 029c1c4828aab451ba262cd4e2e1d9362cf18b76)
(cherry picked from commit 004da2d51f8427745c0d1287781d5ba546b19000)

2 years agoMFS 26e8bb3: MFC cc68614, ac69e5d, 7ed8e14: Update contrib/expat to 2.4.7.
Xin LI [Mon, 28 Mar 2022 05:22:07 +0000 (22:22 -0700)]
MFS 26e8bb3: MFC cc68614ac69e5d7ed8e14: Update contrib/expat to 2.4.7.

(cherry picked from commit cc68614da8232d8baaca0ae0d0dd8f890f06623e)
(cherry picked from commit ac69e5d471014c95070cd6294db315089a62725b)
(cherry picked from commit 7ed8e142a00d4b711dd2021b37b84a6e7f86516e)
(cherry picked from commit 26e8bb3a4e104a24d07743c1670513abaa5c6cbd)
Approved by: re (gjb)

2 years agobsd-family-tree: macOS 11 and macOS 12
Warner Losh [Fri, 1 Apr 2022 04:24:16 +0000 (22:24 -0600)]
bsd-family-tree: macOS 11 and macOS 12

Sponsored by: Netflix
Approved by: re@ (delphij@)

(cherry picked from commit 4fc5a607fdf47ce5148e01d62ea474a4b6b0b238)
(cherry picked from commit 6292dace827a1ef0b9a0b4b58336c128cc159015)

2 years agobsd-family-tree: Dragonfly 6.2.1 release
Warner Losh [Fri, 1 Apr 2022 04:14:56 +0000 (22:14 -0600)]
bsd-family-tree: Dragonfly 6.2.1 release

Sponsored by: Netflix
Approved by: re@ (delphij@)

(cherry picked from commit d2cc7bff4d8874937a97f8b74024cce6aaa9a750)
(cherry picked from commit 137ef89271baa49c4cc3040440569afb110e49e7)

2 years agobsd-family-tree: Add OpenBSD 7.0
Warner Losh [Fri, 1 Apr 2022 04:09:56 +0000 (22:09 -0600)]
bsd-family-tree: Add OpenBSD 7.0

Sponsored by: Netflix
Approved by: re@ (delphij@)

(cherry picked from commit 754cf44d99f624d9e7888f6e074ae39e2eb26d8f)
(cherry picked from commit b54988faf9c6facc5ca04b56c553ea797984c4e8)

2 years agobsd-family-tree: Add FreeBSD 12.3
Warner Losh [Fri, 1 Apr 2022 03:11:20 +0000 (21:11 -0600)]
bsd-family-tree: Add FreeBSD 12.3

FreeBSD 12.3 wasn't added when it was released. Add it now.

Sponsored by: Netflix
Approved by: re@ (delphij@)

(cherry picked from commit 58e6bbc5acb2d8c623cfbec37bfdda8b03d15a1f)
(cherry picked from commit af0b54d42aab4085966ce17259650105ca075979)

2 years agobsd-family-tree: Add 2.8BSD relationship to Research 7th edition
Warner Losh [Fri, 25 Jun 2021 17:03:17 +0000 (11:03 -0600)]
bsd-family-tree: Add 2.8BSD relationship to Research 7th edition

In the 2BSD line, the 2.8BSD tapes were the first ones to include a
kernel, both source and a bootable tape. This was an AT&T V7 kernel,
with a number of bug fixes; new features in use at Berkeley; performance
enhancements that were circulating to V7 in the licensee community; and
build system changes. Based on the TUHS archives, it contains none of
the V32 changes, however.

In addition to the source code analysis, Mike Karels relates the story
of how his group lost a customizes to V6 on a PDP-11/40 due to a disk
crash. Since V7 just came out and Bill Jolitz had just brought that up
elsewhere, they replaced their customized V6 with a V7 system, and that
base would eventually become 2.8BSD. (Quarter Century of Unix)

Given both lines of evidence, add a direct line from V7 Unix to 2.8BSD.

Also confirmed that the V6 line to 1BSD and 2BSD was appropriate. 1BSD
and 2BSD included ashell(1) and ex(1). ashell(1) was derived from v6
hell. ex(1) was an enhanced v6 ed.  2.8BSD included process control and
user-land utilities from 4.1BSD

Discussed with: Clem Cole, Diomidis Spinellis (dds)
Differential Revision: https://reviews.freebsd.org/D30883
Approved by: re@ (delphij@)

(cherry picked from commit 520a2401a65f94a2a6766d3a253baa2a1af0e54b)
(cherry picked from commit b811e00246df3dc22035d2d12c2bc440588140a0)

Sponsored by: Netflix

2 years agobsd-family-tree: add DragonFly 6.0.0
Warner Losh [Thu, 24 Jun 2021 16:42:36 +0000 (10:42 -0600)]
bsd-family-tree: add DragonFly 6.0.0

Tagged on May 8, 2021.

Sponsored by: Netflix
Approved by: re@ (delphij@)

(cherry picked from commit 779b70a2264fa187beb232dad2f018d41c31e34a)
(cherry picked from commit 79afe5598283eaf34cd3dcac5e78e64738d5f592)

2 years agobsd-family-tree: Add NetBSD 9.2
Warner Losh [Wed, 19 May 2021 21:29:11 +0000 (15:29 -0600)]
bsd-family-tree: Add NetBSD 9.2

NetBSD 9.2 was released on May 12, 2021

Submitted by: Martin Husemann
Sponsored by: Netflix
Approved by: re@ (delphij@)

(cherry picked from commit 71a071be1c5ae971421a830d76ee30186ffdd199)
(cherry picked from commit 127f5e8969b12e8f96921d26f08b0f060cf9a254)

2 years agoReleases history update
Maxim Konovalov [Fri, 7 May 2021 19:50:10 +0000 (19:50 +0000)]
Releases history update

Add DragonFly 5.8.1, OpenBSD 6.7, FreeBSD 11.4, DragonFly 5.8.2,
DragonFly 5.8.3, OpenBSD 6.8, NetBSD 9.1, FreeBSD 13.0, OpenBSD 6.9.

Approved by: re@ (delphij@)

(cherry picked from commit f0c914baacc7f0eefe9ff47ed04aeb500b7bdcd5)
(cherry picked from commit 04324346c979f187ef0ecd7c70c0f7cc65b30e2d)

2 years agolibc: Restore fp state upon flush error in fputc
Mark Johnston [Fri, 25 Mar 2022 14:46:24 +0000 (10:46 -0400)]
libc: Restore fp state upon flush error in fputc

This is akin to commit bafaa70b6f9098d83d074968c8e6747ecec1e118.

Approved by: re (gjb)
Reported by: Guy Yur <guyyur@gmail.com>
Fixes: 86a16ada1ea6
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6e13794fbe6e82c21365d0fd66769bf8b19c0197)
(cherry picked from commit 7be0c792c46c5a1faf46b611058953aa85b192d6)

2 years ago13.1: update to RC1
Glen Barber [Thu, 31 Mar 2022 00:17:39 +0000 (20:17 -0400)]
13.1: update to RC1

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agoarm64: Add explicit barrier after address translation instruction
D Scott Phillips [Fri, 25 Mar 2022 16:04:47 +0000 (09:04 -0700)]
arm64: Add explicit barrier after address translation instruction

Following ARMARM sec D5.2.11, which says:

> Where an instruction results in an update to a System register,
> as is the case with the AT * address translation instructions,
> explicit synchronization must be performed before the result is
> guaranteed to be visible to subsequent direct reads of the
> PAR_EL1.

Approved by: re (gjb)
Reviewed By: andrew
MFC after: 3 weeks
Sponsored by: Ampere Computing
Differential Revision: https://reviews.freebsd.org/D34665

(cherry picked from commit 7be7bd67758520ea2f9784a81ad244e99a7632f0)
(cherry picked from commit 0e19a22dd145c3e508978500a3b78592c84db5d0)

2 years agoarm64: pmap: Mask VA operand in TLBI instructions
D Scott Phillips [Fri, 25 Mar 2022 16:04:11 +0000 (09:04 -0700)]
arm64: pmap: Mask VA operand in TLBI instructions

Bits 43:0 of the TLBI operand are bits 55:12 of the VA.  Leaving
bits 63:55 of the VA in bits 51:44 of the operand might wind up
setting the TTL field (47:44) and accidentally restricting which
translation levels are flushed in the TLB.

Approved by: re (gjb)
Reviewed By: andrew
MFC after: 3 days
Sponsored by: Ampere Computing
Differential Revision: https://reviews.freebsd.org/D34664

(cherry picked from commit a693a30038278b1ccd3e67b98d76e259ca1b405d)
(cherry picked from commit 2c013d142b146ed42d0fe6458ee8a394161ad370)

2 years agoFix arm64 TLB invalidation with non-4k pages
Andrew Turner [Thu, 10 Mar 2022 14:39:03 +0000 (14:39 +0000)]
Fix arm64 TLB invalidation with non-4k pages

When using 16k or 64k pages atop will shift the address by more than
the needed amount for a tlbi instruction. Replace this with a new macro
to shift the address by 12 and use PAGE_SIZE in the for loop to let the
code work with any page size.

Approved by: re (gjb)
Reviewed by: alc, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34516

(cherry picked from commit 813738fabaaea43503724b8371faf5bab73a3047)
(cherry picked from commit 89166c063a9a136ba3780bb069e03e6049c53fd5)

2 years agoFix kernel build without INET or INET6
Ed Maste [Thu, 30 Dec 2021 21:49:35 +0000 (16:49 -0500)]
Fix kernel build without INET or INET6

Reported by: Gary Jennejohn
Fixes: ff3a85d32411 ("[lltable] Add per-family lltable ...")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 818952c638a72bd677345fd8ddd05c31b34a2aee)
(cherry picked from commit 85f3c0a1c3762f32dd133deea5951de205e2450b)

Reviewed by: brooks, melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33718

(cherry picked from commit a6668e31aa3cc855bfb37d6edc05122514592a47)
(cherry picked from commit 1c487a5d3daccb8489c710d8cfabaa83fde1ca58)

Approved by: re (gjb)

2 years agoLinuxKPI: 802.11: various updates for iwlwifi stability and upcoming rtw
Bjoern A. Zeeb [Tue, 22 Mar 2022 15:02:45 +0000 (15:02 +0000)]
LinuxKPI: 802.11: various updates for iwlwifi stability and upcoming rtw

Various updates to the internals of the LinuxKPI 802.11 implementation.
Most notably improving state machine handling for de-assoc/de-auth and
always creating a new station as net80211 does and mac80211 seems to
do.  This avoids firmware crashes for iwlwifi and often panics and
lead to more stability.
Some other secondary changes are in order to support upcoming drivers
so that we could possibly provide them out-of-tree for 13.1.

- implement ieee80211_beacon_loss()

Sponsored by: The FreeBSD Foundation

(cherry picked from commit bb81db90f7e00f56df9ea14132a54ee983e7177f)
(cherry picked from commit 24c2117bafdba3c6998ddd407d643e142c5deda5)

- factor out lkpi_lsta_alloc() from lkpi_ic_node_alloc()

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4f61ef8b78b25761b1b859ce39213f92fcbb24ce)
(cherry picked from commit 34f8e38ea7a5fccdf7f5de2cdcfabbdf68825480)

- factor out dtim/tsf updates

Sponsored by: The FreeBSD Foundation

(cherry picked from commit fa8f007de913623c066bf8f09213f92ee8cbca3a)
(cherry picked from commit bc472e0a3ef06cb8eb309b00e7fbdae64a21626a)

- rework sta state machine compatibility

Sponsored by: The FreeBSD Foundation

(cherry picked from commit d9f59799fc3e7940c47aa674c25994e640eae45e)
(cherry picked from commit 67674c1cb11512f09873c6d8e463af31548ef87f)
(cherry picked from commit 471a438a007eff18df3d0bd9dd8849faa9f2d6ff)

- improve lkpi_80211_mo_sta_state() for non (*sta_state)

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 878fb1e5754cc5bfbec57bc24859b07936f82a41)
(cherry picked from commit eb580265974013be43fa17d37e22124174a7ef86)

- use cfg80211_chandef_create()

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4a07abdeb8ce5271996d85f648832e3d7bc741a7)
(cherry picked from commit 4836b8ac0ed3a3b155a7fb5f2322221f48c81687)

- make lkpi_ic_set_channel() unconditional

Sponsored by: The FreeBSD Foundation

(cherry picked from commit b2cf3c2125bf6f34cb01296e7eda93f73bc4b715)
(cherry picked from commit beaed0d4b5d0f901f78fc196f4b86d426a589792)

- check IEEE80211_FEXT_SCAN_OFFLOAD on vap

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 768dd32a164b35fb2f66fc8a0250cee84c79471e)
(cherry picked from commit 39bc4b2949e2ac32ad211aa6f1859559e21c7eb2)

- remove special handling for (*ic_scan_curchan)

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 321735f451d1eaa710a768d9e35ff87acb089d35)
(cherry picked from commit 5f88604cf7d9df1edbc662c4278e01476534f3ef)

- improve hw_scan fallback to sw_scan

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 196cfd0b2eb640a63d007a7e9c3a74e4256255f3)
(cherry picked from commit a1272e7d9621f95ca53f1bdef5ed78be12cac277)

- 802.11: cleanup debugging

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 9d9ba2b79b3196935431879efd9094eb9bfedd95)
(cherry picked from commit e269958566ff0df8d479996507636ed14ff6078a)

Approved by: re (gjb)

2 years agoLinuxKPI: skbuff: fix skb_queue_splice_init()
Bjoern A. Zeeb [Wed, 23 Mar 2022 17:05:43 +0000 (17:05 +0000)]
LinuxKPI: skbuff: fix skb_queue_splice_init()

In skb_queue_splice_init() we set a next value and then used that new
value to further update the remaining linking rather than the original
value.  Introduce another temporary variable 'n' to hold the original
value and use that.
While here rename q and h to from and to as otherwise it was too
confusing to read.

Also initialize skb->prev and skb->next to point to skb itself if
for nothing else at least to aid debugging.

Approved by: re (gjb)
Reported by: phk (panic in iwl_txq_reclaim)
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6a8973c3324c0c6c270ae4ad371e50c0ec5761da)
(cherry picked from commit 32d1d7fee61328e65ae944836d1027335ccb979c)

2 years agoLinuxKPI: allow bsddriver name to be set for PCI
Bjoern A. Zeeb [Thu, 24 Mar 2022 01:45:36 +0000 (01:45 +0000)]
LinuxKPI: allow bsddriver name to be set for PCI

Allow a driver to overwrite the bsddriver name (we use for pci and
for wlan parent devices).  This allows us to to set
.bsddriver.name in struct pci_driver passed to module_pci_driver()
and with that set the BSD driver name while retaining the Linux .name
one.

This is helpful for divers which have different parts depending on
chipset and with that would change driver names which is highly
confusing especially for configuration.   One example is an upcoming
rtw88 driver which would be rtw_8822be or rtw_8822ce depending on
chipset.

Approved by: re (gjb)
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste, hselasky
Differential Revision: https://reviews.freebsd.org/D34653

(cherry picked from commit 81d058df6d255b7f551564f6d29a03692b51fe5a)
(cherry picked from commit 00450eeab2465d6dc800680158b2cc67c1a7d9fc)

2 years agoLinuxKPI: pci: implement pci_upstream_bridge()
Bjoern A. Zeeb [Wed, 16 Feb 2022 18:04:08 +0000 (18:04 +0000)]
LinuxKPI: pci: implement pci_upstream_bridge()

Allow drivers to query the "upstream PCI bridge".
Currently we point back to ourselves on pdev->bus->self rather than
to the parent PCI bridge.
We keep this as status-quo with an extra comment and only on-demand
allocate a pci_dev for the parent bridge if we are asked for in
pci_upstream_bridge().
When releasing the pci_dev we check if pdev->bus->self has changed
and call pci_dev_put() to release the reference count on the parent
bridge as well.

This code moves pci_is_root_bus() higher up in pci.h but no functional
change there.

Approved by: re (gjb)
Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky, (jhb some earlier)
Thanks to: wulf for handling drm-kmod
Differential Revision: https://reviews.freebsd.org/D34305

(cherry picked from commit b3b836251f9fefa817d158784189f6d336917f7a)
(cherry picked from commit 50136233846e59eeb53c95498fdd4f3e1acf0a16)

2 years agoiwlwifi: update man pages
Bjoern A. Zeeb [Fri, 4 Mar 2022 00:27:00 +0000 (00:27 +0000)]
iwlwifi: update man pages

Update man pages given auto-loading is now enabled by default and
no user configuration is needed to load the driver.
Also note that the iwlwifi driver will appear the first time in 13.1-R.

Sponsored by: The FreeBSD Foundation
Relnotes: yes
Approved by: re (gjb)

(cherry picked from commit abf6e1a49e944f9fb635a6aed55f01af832da06c)
(cherry picked from commit 8ed3b807ca45da1e3dfbe38f92e60a5ddf2c571c)

2 years agoLinuxKPI: pci.h MODULE_DEVICE_TABLE to MODULE_PNP_INFO
Bjoern A. Zeeb [Fri, 4 Mar 2022 00:06:34 +0000 (00:06 +0000)]
LinuxKPI: pci.h MODULE_DEVICE_TABLE to MODULE_PNP_INFO

Implement MODULE_PNP_INFO() support in LinuxKPI for the Linux
MODULE_DEVICE_TABLE.

This will allow us to auto-load LinuxKPI PCI drivers (drm-kmod do
not currently as they attach to vgapci0 which in turn grabs the PCI
to my understanding) and make any loading from loader or kld_list in
rc.conf unnecessary; see devmatch(8) for more information.

We need to ensure there is a DRIVER_MODULE() (or probably just
a DECLARE_MODULE but that makes not much difference) before the
MODULE_PNP_INFO (which we otherwise would not need).

Approved by: re (gjb)
Sponsored by: The FreeBSD Foundation
Reviewed by: imp, hselasky, manu
Differential Revision: https://reviews.freebsd.org/D26651

(cherry picked from commit 5493c6277a264e91ea4bdc7e2d4ee69fe4210918)
(cherry picked from commit a94b233d5d718258e2e57e114aab00714441a79f)

2 years agoiwlwifi: adjust the LinuxKPI pci return for now
Bjoern A. Zeeb [Thu, 3 Mar 2022 22:24:13 +0000 (22:24 +0000)]
iwlwifi: adjust the LinuxKPI pci return for now

Rather than having LinuxKPI return BUS_PROBE_DEFAULT, return
"one less" so that on conflict of IDs others would be preferred.

This means that iwm(4) will attach instead of iwlwifi(4) for the
chipsets iwm(4) supports and iwlwifi(4) only for the other--in iwm(4)
unsupported--chipsets.  This is done so that we can enable auto-loading
of drivers but for the upcoming 13.1-Release people with working iwm(4)
will not yet be affected by iwlwifi(4).

Sponsored by: The FreeBSD Foundation
Approved by: re (gjb)

(cherry picked from commit 3d248a914d923b444f72fb27ba621c0ab2ef464e)
(cherry picked from commit fd2c8fe44cfae7ced0ae3d142038dc71e537dbd4)

2 years agoLinuxKPI: allow a driver to override the default pci probe result
Bjoern A. Zeeb [Fri, 18 Feb 2022 21:58:01 +0000 (21:58 +0000)]
LinuxKPI: allow a driver to override the default pci probe result

Add bsd_probe_return which a driver can set in their 'struct pci_driver'
definition to set a driver-sepcific LinuxKPI pci return value.
This is helpful in case of multiple drivers with overlapping IDs,
such as iwlwifi(4) and iwm(4).

Contrary to an earlier version we now assume 0 is not BUS_PROBE_SPECIFIC
(which no driver should really return these days) but the bss initialized
value (bsd_probe_return unset) and we will return BUS_PROBE_DEFAULT.

Approved by: re (gjb)
Suggested by: jhb
Reviewed by: jhb
Reviewed by: hselasky, imp (earlier versions)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33915

(cherry picked from commit b91dd79ba32122e6adb28073c534224bc78a7b58)
(cherry picked from commit 3166cea632449ce6c6dad699a812b9813a9531ef)

2 years agoLinuxKPI: remove duplicate include
Bjoern A. Zeeb [Fri, 4 Mar 2022 00:04:19 +0000 (00:04 +0000)]
LinuxKPI: remove duplicate include

Remove a duplicate bus.h include from pci.h.

Sponsored by: The FreeBSD Foundation
Approved by: re (gjb)

(cherry picked from commit fbedd9d708d06e3cc064d9e6f053649c0cf30c9c)
(cherry picked from commit a8c3d6b71645b6b16715b3a07013779b296e7ca7)

2 years agonet80211: introduce (*iv_update_bss)()
Bjoern A. Zeeb [Tue, 22 Mar 2022 14:46:51 +0000 (14:46 +0000)]
net80211: introduce (*iv_update_bss)()

Introduce (*iv_update_bss)() with a default implementation to allow
drivers to overload/intercept the time when we swap iv_bss.

This helps firmware based drivers to synchronize state with firmware.
Otherwise, for some state changes, we begin with one ni (and in
LinuxKPI lsta) and try to finish with another ni (and a new lsta
in different state) and may no longer have access to the previous state.
This also saves us from constantly checking for ni changes complicating
code.

No functional changes intended.

Sponsored by: The FreeBSD Foundation
Approved by: re (gjb)

(cherry picked from commit 91b4225aa1d81155668db6deed22084abf2ce23c)
(cherry picked from commit dd39ea27f356f660736d5eb45b0a5aece63698bb)

2 years agonet80211: improve one debug logging
Bjoern A. Zeeb [Tue, 22 Mar 2022 14:40:12 +0000 (14:40 +0000)]
net80211: improve one debug logging

When forcing DEUATH in ieee80211_sta_join1() log the current state
we are coming from as well.  Note this isn't always the state we
are expecting as iv_state was updated already, so contrary to the
comment we usually do not see RUN there.
Leave a comment earlier with regards to this as well.

Sponsored by: The FreeBSD Foundation
Approved by: re (gjb)

(cherry picked from commit 453d1a90f8f46637404adc0278d6f3f068542733)
(cherry picked from commit f39c5ab3503cb963cc9f22b2bf82b5bc87a70e21)

2 years agobhyve: Do not remove guest physical addresses from IOMMU host domain
Bjoern A. Zeeb [Fri, 18 Mar 2022 20:39:06 +0000 (20:39 +0000)]
bhyve: Do not remove guest physical addresses from IOMMU host domain

This permits I/O devices on the host to directly access wired memory
dedicated to guests using passthru devices.  Note that wired memory
belonging to guests that do not use passthru devices has always been
accessible by I/O devices on the host.

bhyve maps guest physical addresses into the user address space of
the bhyve process by mmap'ing /dev/vmm/<vmname>.  Device models pass
pointers derived from this mapping directly to system calls such as
preadv() to minimize copies when emulating DMA.  If the backing store
for a device model is a raw host device (e.g. when exporting a raw disk
device such as /dev/ada<n> as a drive in the guest), the host device
driver (e.g. ahci for /dev/ada<n>) can itself use DMA on the host
directly to the guest's memory.  However, if the guest's memory is
not present in the host IOMMU domain, these DMA requests by the host
device will fail without raising an error visible to the host device
driver or to the guest resulting in non-working I/O in the guest.

It is unclear why guest addresses were removed from the IOMMU host domain
initially, especially only for VM's with a passthru device as the
host IOMMU domain does not affect the permissions of passthru devices,
only devices on the host.

A considered alternative was using bounce buffers instead (D34535
is a proof of concept), but that adds additional overhead for unclear
benefit.

This solves a long-standing problem when using passthru devices and
physical disks in the same VM.

Approved by: re (gjb)
Thanks to: grehan (patience and help)
Thanks to: jhb (for improving the commit message)
PR: 260178, 215740
Reviewed by: grehan, jhb
Differential Revision: https://reviews.freebsd.org/D34607

(cherry picked from commit 246c398145674e4a9337fd933a6e6da7f160118e)
(cherry picked from commit dd113f67dfb5bdaf5d8b3a87bb19924ad447494c)

2 years agoClear non-x86 compat stat syscall kernel stack memory disclosure
Ed Maste [Tue, 29 Mar 2022 17:55:21 +0000 (13:55 -0400)]
Clear non-x86 compat stat syscall kernel stack memory disclosure

32-bit architectures other than i386 have 64-bit time_t which results
in a struct timespec with 12 bytes for tv_sec and tv_nsec, and 4 bytes
of padding.  Zero the padding holes in struct stat32 and struct
freebsd11_stat32.

i386 has 32-bit time_t; struct timespec is 8 bytes and has no padding.

Found by inspection, prompted by a report by Reno Robert of Trend Micro
Zero Day Initiative.  The originally reported issue (ZDI-CAN-14538) is
already fixed in all supported FreeBSD versions (it was addressed
incidentally as part of the 64-bit inode project).

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34709

(cherry picked from commit f90cd1ae30b5f49e9f6ea58a0628ce1c8d8822bc)
(cherry picked from commit ccd701d27a747ea7266f434170169072e8686f30)

Approved by: re (gjb)

2 years agodevd: Add rtw to wireless list
Warner Losh [Mon, 28 Mar 2022 14:16:14 +0000 (08:16 -0600)]
devd: Add rtw to wireless list

rtw88 and rtw89 are coming soon, so add them here now

Approved by: re@ (gjb)
Sponsored by: Netflix
MFC After: 1 day

(cherry picked from commit dea368bc5e7905e7456b052c545dcfd935341083)
(cherry picked from commit cba6eb5d31e825cbf6e8694b5a934db75d380fc4)

2 years agodevd: correct wifi regexp
Warner Losh [Sun, 9 Jan 2022 17:16:31 +0000 (10:16 -0700)]
devd: correct wifi regexp

Correct the wifi regexp to include iwlwifi and remove wi driver that was
has been retired.

Approved by: re@ (gjb)
Sponsored by: Netflix

(cherry picked from commit e0ab0ff104cb0e817d47a1a2a235f915ec1a31f4)
(cherry picked from commit eeec49e0b30a3faf2985e27f163a4c2f7b511e7c)

2 years agodevd: remove the scsi regexp
Warner Losh [Sun, 9 Jan 2022 17:13:58 +0000 (10:13 -0700)]
devd: remove the scsi regexp

We don't really use the scsi regexp for anything. The rescan was a
workaround that was fixed a long time ago and has been disabled for
ages. And the regexp was incomplete.

Approved by: re@ (gjb)
Sponsored by: Netflix

(cherry picked from commit 926e825ef823f49e371f61780634475a1f19c812)
(cherry picked from commit cb95daaa91895a74a2f6d2db0d0773517a34ab99)

2 years agolibarchive: merge vendor bugfixes
Martin Matuska [Sat, 26 Mar 2022 10:04:36 +0000 (11:04 +0100)]
libarchive: merge vendor bugfixes

Bugfixes:
  IS #1672 and OSS-Fuzz #38766:
    (zip reader) fix possible out-of-bounds read in zipx_lzma_alone_init()
  PR #1676: (mtree reader) remove the unused variable "detected_bytes"
  PR #1674: (doc) fix use of At mdoc(7) macro in cpio.5

Approved by: re (gjb)

(cherry picked from commit 0c9c2eb394b4a5694bc5ea11b326f334c735c813)
(cherry picked from commit 60338b80693000ed0f9812b90ca54d35fd077cd0)

2 years agozfs: merge openzfs/zfs@52bad4f23 (zfs-2.1-release) into stable/13
Martin Matuska [Tue, 29 Mar 2022 10:41:53 +0000 (12:41 +0200)]
zfs: merge openzfs/zfs@52bad4f23 (zfs-2.1-release) into stable/13

OpenZFS release 2.1.4

Notable upstream pull request merges:
  #13219 FreeBSD: add missing replay check to an assert in zfs_xvattr_set
  #13220 module: freebsd: avoid a taking a destroyed lock in zfs_zevent bits
  #13221 Fix ACL checks for NFS kernel server

Obtained from: OpenZFS
OpenZFS tag: zfs-2.1.4
OpenZFS commit: 52bad4f23daaa5f827f802c8d05785a27b80275d
Relnotes: yes
Approved by: re (gjb)

(cherry picked from commit c088e4d539e4cc947896a3b156646b831d932539)

2 years agoamd64: bring back asm bcmp, shared with memcmp
Mateusz Guzik [Fri, 25 Mar 2022 15:04:04 +0000 (15:04 +0000)]
amd64: bring back asm bcmp, shared with memcmp

Turns out clang converts "memcmp(foo, bar, len) == 0" and similar to
bcmp calls.

Reviewed by: emaste (previous version), jhb (previous version)
Differential Revision: https://reviews.freebsd.org/D34673
Approved by: re (gjb)

(cherry picked from commit fbc002cb72d2d9bb435cce99630d5d7da9f59390)
(cherry picked from commit c5890784f6d315c501586b39cf8c0c80b609be5b)

2 years agoriscv: actually enable sanitizers
Piotr Kubaj [Sun, 13 Mar 2022 03:31:35 +0000 (04:31 +0100)]
riscv: actually enable sanitizers

1. Backport https://github.com/llvm/llvm-project/commit/b475ce39e8b1de3a70ea242473f136a567be46e3.
2. Enable libclang_rt for riscv.

Previous commit missed it.

Reviewed by: dim
Differential Revision: https://reviews.freebsd.org/D34543
Approved by: re (gjb)

(cherry picked from commit 3781e77995e9b81afcbf7b3dc84b33b864c48794)
(cherry picked from commit e58a146c5d24172b53f18b953b3d29ee25bdb90c)

2 years agoriscv: fix riscv64sf build
Piotr Kubaj [Thu, 24 Mar 2022 14:24:21 +0000 (15:24 +0100)]
riscv: fix riscv64sf build

The library needs to have sf suffix cut off.

Differential revision: https://reviews.freebsd.org/D34561
Reviewed by: dim
Approved by: re (gjb)

(cherry picked from commit 18f71c9b2779999a9492b42c325524651a1b6909)
(cherry picked from commit 78e68a3d10216db2b3a6ddb0d4591358987c033e)

2 years agou3g: Add support Quectel EM12-G modem.
Alexander V. Chernikov [Sat, 29 Jan 2022 09:53:38 +0000 (09:53 +0000)]
u3g: Add support Quectel EM12-G modem.

Submitted by: <tda.77793 at gmail.com>
PR: 260218
Approved by:    re(gjb)
MFC after: 2 weeks

(cherry picked from commit 217481a3332783d03366c4512b0b164764aa6c6e)
(cherry picked from commit 453b4f81939b5853b8ab493c0eeb4af7b1bbb3fc)

2 years agoifconfig: remove debug printf introduced in 779fd0534466
Alexander V. Chernikov [Sat, 29 Jan 2022 11:18:13 +0000 (11:18 +0000)]
ifconfig: remove debug printf introduced in 779fd0534466

Reported by: jhb
Approved by:    re(gjb)

(cherry picked from commit 656f5031c39108d2418454f12b52931c32514741)
(cherry picked from commit b5b97a95aa5ded84de9ce707ed5c6d0d5f73fe57)