]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoOpenSSL: Regen manual pages for OpenSSL 1.1.1o
Jung-uk Kim [Tue, 3 May 2022 19:12:42 +0000 (15:12 -0400)]
OpenSSL: Regen manual pages for OpenSSL 1.1.1o

Approved by: re (gjb, implicit, security)

(cherry picked from commit 9a3583bfbd1740a158b3916432286190e0f2bf60)
(cherry picked from commit 225a1494a5538364cddf9080b57d65277c6bfdf4)

2 years agoOpenSSL: Merge OpenSSL 1.1.1o
Jung-uk Kim [Tue, 3 May 2022 19:07:06 +0000 (15:07 -0400)]
OpenSSL: Merge OpenSSL 1.1.1o

Approved by: re (gjb, implicit, security)

(cherry picked from commit 34252e89a96c8d498d7537ade16d20602bf2106a)
(cherry picked from commit 1b7b799f9ebaa6d558523498005ca0e698051274)

2 years ago13.1: Update to RC5
Glen Barber [Thu, 28 Apr 2022 00:06:34 +0000 (20:06 -0400)]
13.1: Update to RC5

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

2 years agoxhci(4): Ensure the so-called data toggle gets properly reset.
Hans Petter Selasky [Thu, 21 Apr 2022 14:59:09 +0000 (16:59 +0200)]
xhci(4): Ensure the so-called data toggle gets properly reset.

Use the drop and enable endpoint context commands to force a reset of
the data toggle for USB 2.0 and USB 3.0 after:
 - clear endpoint halt command (when the driver wishes).
 - set config command (when the kernel or user-space wants).
 - set alternate setting command (only affected endpoints).

Some XHCI HW implementations may not allow the endpoint reset command when
the endpoint context is not in the halted state.

Reported by: Juniper and Gary Jennejohn
Approved by: re (gjb)
Sponsored by: NVIDIA Networking

(cherry picked from commit cda31e734925346328fd2369585ab3f6767ec225)

2 years agolibcxxrt: Insert padding in __cxa_dependent_exception
Ed Maste [Wed, 27 Apr 2022 13:15:09 +0000 (09:15 -0400)]
libcxxrt: Insert padding in __cxa_dependent_exception

Padding was added to __cxa_exception in 45ca8b19 and
__cxa_dependent_exception needs the same layout.
Add some static_asserts to detect this in the future.

Merge of libcxxrt commit b00c6c564357

(cherry picked from commit c40e4349889b32500e51e60f9529dbcc080f468b)
(cherry picked from commit 69a40d924128b88ff2c82a35ab1b4509e1bdca56)

Approved by: re (gjb)

2 years agoStop using the kmem for PCPU memory on arm64
Andrew Turner [Wed, 27 Apr 2022 13:42:21 +0000 (14:42 +0100)]
Stop using the kmem for PCPU memory on arm64

When allocating memory with a kernel memory allocator we may get
memory that will later be promoted to a superpage. If this happens
while another CPU is using the pointer they can race and when the
promotion passes through the break-before-make sequence the pointer
will be invalid for a short length of time.

Revert the commit that added the use of the kernel allocator and
subsequent fixes to the original change.

Revert "Pass the ACPI ID when reading the ACPI domain"

This reverts commit aa3b5d79b2acc508cca63c24251d65f4d2d76fa5.

Revert "Stop reading the arm64 domain when it's known"

This reverts commit b7c23efd7428256f69ccfd65a9c5e9f50585bf66.

Revert "Allocate arm64 per-CPU data in the correct domain"

This reverts commit f51997c6e410e2413686983d8fd57c1877f8c0ad.

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

2 years agoif_bnxt: Allow bnxt interfaces to use vlans
Misho [Thu, 21 Apr 2022 08:24:04 +0000 (09:24 +0100)]
if_bnxt: Allow bnxt interfaces to use vlans

When VLAN HW filter is disabled, the NIC does not pass any vlan tagged
traffic. Setting these flags on the device allows vlan tagged traffic to
pass.

Approved by: re (gjb)
PR: 236983
Tested by: pi
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D34824

(cherry picked from commit 0c6a2fa33e36ac0b5d51cbae39a9c5564ad61788)
(cherry picked from commit e54505277c39cad32f999fd72033f6fa9594b130)

2 years agorelease: fix on-disc pkg binary symbolic links
Glen Barber [Tue, 26 Apr 2022 19:52:40 +0000 (15:52 -0400)]
release: fix on-disc pkg binary symbolic links

Approved by: re (kib)
PR: 263574
Reported by: loader
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 68b0a79b7c7ab75597e2511f880238fbf8cfad32)
(cherry picked from commit fab1a7b9b6210257c5c048cdf754ca201fae7669)

2 years agostand: zfs: handle holes at the tail end correctly
Kyle Evans [Thu, 21 Apr 2022 19:57:24 +0000 (14:57 -0500)]
stand: zfs: handle holes at the tail end correctly

This mirrors dmu_read_impl(), zeroing out the tail end of the buffer and
clipping the read to what's contained by the block that exists.

This fixes an issue that arose during the 13.1 release process; in
13.1-RC1 and later, setting up GELI+ZFS will result in a failure to
boot.  The culprit is this, which causes us to fail to load geom_eli.ko
as there's a residual portion after the single datablk that should be
zeroed out.

PR: 263407
Reviewed by: tsoome
Approved by: re (gjb)

(cherry picked from commit 914dc91d12198352b7878a88d30e2a6373a936e1)
(cherry picked from commit 0c9c8a4c6459a8cd1b7290ae7dcd9452d3a4dbc1)

2 years agotime(3): Refine history in the manual page
Gordon Bergling [Thu, 14 Apr 2022 08:04:14 +0000 (10:04 +0200)]
time(3): Refine history in the manual page

The time() system call first appeared in Version 1 AT&T UNIX.  Through
the Version 3 AT&T UNIX, it returned 60 Hz ticks since an epoch that
changed occasionally, because it was a 32-bit value that overflowed in a
little over 2 years.

In Version 4 AT&T UNIX the granularity of the return value was reduced to
whole seconds, delaying the aforementioned overflow until 2038.

Version 7 AT&T UNIX introduced the ftime() system call, which returned
time at a millisecond level, though retained the gtime() system call
(exposed as time() in userland).  time() could have been implemented as a
wrapper around ftime(), but that wasn't done.

4.1cBSD implemented a higher-precision time function gettimeofday() to
replace ftime() and reimplemented time() in terms of that.

Since FreeBSD 9 the implementation of time() uses
clock_gettime(CLOCK_SECOND) instead of gettimeofday() for performance
reasons.

With most valuable input from Warner (imp@).

Reviewed by: 0mp, jilles, imp
Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D34751

(cherry picked from commit 3e0f3678eca7c3f296b9f702992737356f1792da)

2 years ago13.1: update to RC4
Glen Barber [Thu, 21 Apr 2022 00:10:33 +0000 (20:10 -0400)]
13.1: update to RC4

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

2 years agoMostly revert a5970a529c2d95271: Make files opened with O_PATH to not block non-force...
Konstantin Belousov [Wed, 13 Apr 2022 00:47:45 +0000 (03:47 +0300)]
Mostly revert a5970a529c2d95271: Make files opened with O_PATH to not block non-forced unmount

Approved by: re (gjb)

(cherry picked from commit bf13db086b84c29ce901145f2800c561dcbf4d1e)
(cherry picked from commit 6daddc54debbf590cae17bead4864c7f640c07d0)

2 years agoMerge libcxxrt commit 45ca8b1942090226ba9368caeeeabc0d4ee41ad6
Dimitry Andric [Tue, 19 Apr 2022 16:11:11 +0000 (18:11 +0200)]
Merge libcxxrt commit 45ca8b1942090226ba9368caeeeabc0d4ee41ad6

  Insert padding in __cxa_exception struct for compatibility

  Similar to https://github.com/llvm/llvm-project/commit/f2a436058fcb, the
  addition of __attribute__((__aligned__)) to _Unwind_Exception (in commit
  b9616964) causes implicit padding to be inserted before the unwindHeader
  field in __cxa_exception.

  Applications attempt to get at the earlier fields in __cxa_exception, so
  preserve the same negative offsets in __cxa_exception, by moving the
  padding to the beginning of the struct.

  The assumption here is that if the ABI is not aware of the padding
  before unwindHeader and put the referenceCount/primaryException in
  there, no padding should exist before unwindHeader.

This should make libreoffice's custom exception handling mechanisms work
correctly, even if it was built against an older cxxabi.h/unwind.h pair.

PR: 263370
Approved by: re (gjb)
MFC after: immediately

(cherry picked from commit 434215c26da3c6acf2423ab93ff2b41b2d823cc8)
(cherry picked from commit 06394327dd1fd77c66af06f6f89713c5142fe1b2)

2 years agolibctf: Fix recursive descent into anonymous SOU fields
Mark Johnston [Tue, 12 Apr 2022 19:24:40 +0000 (15:24 -0400)]
libctf: Fix recursive descent into anonymous SOU fields

Approved by: re (gjb)
PR: 262412
Tested by: dhw, gallatin
Fixes: a6fb86917362 ("libctf: Handle CTFv3 containers")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6e563a1b608438504d963c2d7c70e50d2e75af46)
(cherry picked from commit 8b01c3026b78152d9e0ca6f3758ea226f32e48b9)

2 years agoctf: Avoid passing a caddr_t to roundup2()
Mark Johnston [Mon, 7 Mar 2022 16:18:40 +0000 (11:18 -0500)]
ctf: Avoid passing a caddr_t to roundup2()

For some reason I can't reproduce this locally, but Jenkins complains.

Approved by: re (gjb)
Reported by: Jenkins
Fixes: bdf290cd3e1a ("ctf: Add v3 support to CTF tools, ctf{convert,dump,merge}")

(cherry picked from commit 3fe1f21fb364e38f2bf7e7100dad59b067b27080)
(cherry picked from commit fb89cf93a5c79f60e8eb38db77294f8c713c4081)

2 years agoctf: Fix a -Wunused-but-set-variable warning
Mark Johnston [Mon, 7 Mar 2022 15:34:11 +0000 (10:34 -0500)]
ctf: Fix a -Wunused-but-set-variable warning

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

(cherry picked from commit cb6f7225629301d3179f6e9f6d3be4d80f57a31f)
(cherry picked from commit d80faf878a4473c6136f06b774d9176ec9449479)

2 years agoctf: Add v3 support to CTF tools, ctf{convert,dump,merge}
Mark Johnston [Mon, 7 Mar 2022 13:54:18 +0000 (08:54 -0500)]
ctf: Add v3 support to CTF tools, ctf{convert,dump,merge}

ctfdump handles v2 and v3.  ctfconvert now emits only CTFv3, whereas
ctfmerge can merge v2 and v3 containers into v3 containers.

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

(cherry picked from commit bdf290cd3e1a69d41c2f8bb60bd415cfa78adba2)
(cherry picked from commit e5b54808f735f1a74716f1320916b8a961ddf92d)

2 years agolibctf: Handle CTFv3 containers
Mark Johnston [Mon, 7 Mar 2022 13:53:27 +0000 (08:53 -0500)]
libctf: Handle CTFv3 containers

In general, the patch adds indirection to minimize the amount of code
that needs to know about differences between v2 and v3.  Specifically,
some new ctf_get_ctt_* functions are added, and new LCTF_* macros are
added to use the underlying container's version to do the right thing.

CTF containers can have parent/child relationships, wherein a type ID in
one container refers to a type in the parent.  It is permitted for the
parent and child to have different versions.

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

(cherry picked from commit a6fb86917362e3f6d24e95e940e80845c2cfde8a)
(cherry picked from commit a49aa9da7835742aa455c7eec4493f0034b4e197)

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)