]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
9 months agofrag6: Avoid a possible integer overflow in fragment handling
Jonathan T. Looney [Tue, 1 Aug 2023 14:58:34 +0000 (10:58 -0400)]
frag6: Avoid a possible integer overflow in fragment handling

Reviewed by: kp, markj, bz
Approved by: so
Security: FreeBSD-SA-23:06.ipv6
Security: CVE-2023-3107

9 months agobhyve: Fully reset the fwctl state machine if the guest requests a reset.
John Baldwin [Thu, 29 Jun 2023 18:27:12 +0000 (11:27 -0700)]
bhyve: Fully reset the fwctl state machine if the guest requests a reset.

If a guest tries to reset the fwctl device while a pending request was
in flight, the fwctl state machine can be left in an incomplete state.
Specifically, rinfo is not cleared.

Normally the state machine for fwctl alternates between REQ (receiving
request) and RESP (sending response) and ignores port writes while in
RESP or port reads while in REQ.  Once a guest completes the writes to
the port to send a request, the state machine transitions to RESP and
ignores future writes.

However, if a guest writes a full request and then resets the fwctl
device, the state would transition to REQ without draining the pending
response or discarding the received request.  Instead, additional
port writes after the reset were treated as new payload bytes, but
were appended to the previously-received request and could overflow
the fget_str buffer.

To fix, fully reset the fwctl state machine if the guest requests a
reset.

admbugs: 998
Approved by: so
Reviewed by: markj
Reported by: Omri Ben Bassat <t-benbassato@microsoft.com>
Security: FreeBSD-SA-23:07.bhyve
Security: CVE-2023-3494

9 months agodtrace: remove dead code for PR_REQUESTED
Eric van Gyzen [Thu, 27 Jul 2023 22:06:33 +0000 (17:06 -0500)]
dtrace: remove dead code for PR_REQUESTED

libproc's PR_REQUESTED is not implemented on FreeBSD.  Remove dead code
in dtrace that would handle it.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D41225

9 months agoproc_detach: use ptrace(PT_KILL) to kill the tracee
Eric van Gyzen [Tue, 25 Jul 2023 16:58:11 +0000 (11:58 -0500)]
proc_detach: use ptrace(PT_KILL) to kill the tracee

When MFC'ing commit dad11f990e2 to stable/12, the child would dump core
when dtrace exited.  It was getting SIGTRAP, even though proc_detach
sent a SIGKILL.  I could not find the reason for this difference in
behavior from main (and stable/13).  The present change, however, works
as expected, probably due the proc_wkilled special case in kern_ptrace.
It also seems like a more obvious approach.

While I'm here, fix two other issues in the previous code:

It would SIGKILL a tracee even in read-only mode.

It would SIGSTOP/SIGCONT the tracee if ptrace succeeded but errno happened
to be EBUSY for some other reason.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D41122

9 months agodtrace: do not overload libproc flags
Eric van Gyzen [Tue, 25 Jul 2023 16:59:07 +0000 (11:59 -0500)]
dtrace: do not overload libproc flags

dtrace stored its PR_RLC and PR_KLC flags in the proc_handle's flags,
where they collided with PATTACH_FORCE and PATTACH_RDONLY, respectively.
Thus, Psetflags(PR_KLC) effectively also set the PATTACH_RDONLY flag.

Since the flags are private to dtrace (at least on FreeBSD), store them in
dtrace's own dt_proc structure instead.

On FreeBSD, either PR_RLC or PR_KLC was always set, so remove code that
would handle the case where neither was set.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D41121

9 months agodtrace: remove illumos code from dt_proc.c
Eric van Gyzen [Tue, 25 Jul 2023 16:58:47 +0000 (11:58 -0500)]
dtrace: remove illumos code from dt_proc.c

The illumos #ifdef's in this file make it harder to read and maintain.
There is little change upstream, and increasing changes for FreeBSD.
Remove the illumos code with `unifdef`.  The only manual changes here
are the #includes and #defines at the top, and removing blank lines.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D41173

9 months agoinet.3: remove mention of VAX endianness
Ed Maste [Tue, 1 Aug 2023 17:20:12 +0000 (13:20 -0400)]
inet.3: remove mention of VAX endianness

Machine endianness is not very important in understanding the inet*
functions; the endianness of the VAX is especially so.

PR: 272728
Sponsored by: The FreeBSD Foundation

9 months agodtrace: Revert the addition of WITH_DTRACE_ASAN
Mark Johnston [Tue, 1 Aug 2023 17:01:37 +0000 (13:01 -0400)]
dtrace: Revert the addition of WITH_DTRACE_ASAN

The follow-up fix triggers a lib32 build failure, revert everything
until the problem is addressed.

9 months agosrc.conf.5: regen after armv6 demotion
Ed Maste [Tue, 1 Aug 2023 15:19:37 +0000 (11:19 -0400)]
src.conf.5: regen after armv6 demotion

Fixes: 98d03dca9ac8 ("universe: Demote armv6 to an extra architecture.")
Sponsored by: The FreeBSD Foundation

9 months agofilemon(4): Better error checking in code example
Pau Amma [Tue, 1 Aug 2023 14:24:44 +0000 (11:24 -0300)]
filemon(4): Better error checking in code example

Discussed with: dim
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D38367

9 months agolibdtrace: Explicitly set SHLIBDIR and SHLIB_MAJOR
Mark Johnston [Tue, 1 Aug 2023 14:11:23 +0000 (10:11 -0400)]
libdtrace: Explicitly set SHLIBDIR and SHLIB_MAJOR

They were previously being defined by cddl/lib/Makefile.inc, and as of
commit 4ae699122810 were being overridden by defaults in bsd.own.mk,
which changed SHLIBDIR to /usr/lib.

Reported by: Domagoj Stolfa <ds815@cam.ac.uk>
Fixes: 4ae699122810 ("dtrace: Add WITH_DTRACE_ASAN")

9 months agovm_map: Add a macro to fetch a map entry's split boundary index
Mark Johnston [Tue, 9 May 2023 14:07:15 +0000 (10:07 -0400)]
vm_map: Add a macro to fetch a map entry's split boundary index

The resulting code is a bit more concise.  No functional change
intended.

Reviewed by: alc, dougm, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D41249

9 months agosk(4): Fix a typo in a source code comment
Gordon Bergling [Tue, 1 Aug 2023 05:50:45 +0000 (07:50 +0200)]
sk(4): Fix a typo in a source code comment

- s/nomral/normal/

MFC after: 3 days

9 months agoisa_common: find next bit faster
Doug Moore [Tue, 1 Aug 2023 02:02:56 +0000 (21:02 -0500)]
isa_common: find next bit faster

Since ffs is no longer implemented with a linear search, find_next_bit
can work in constant time, with masking.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D41251

9 months agocd9660: do not leak buffers in cd9660_rrip_loop()
Konstantin Belousov [Mon, 31 Jul 2023 22:55:13 +0000 (01:55 +0300)]
cd9660: do not leak buffers in cd9660_rrip_loop()

Reported by:  Robert Morris <rtm@lcs.mit.edu>
PR: 272856
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

9 months agomemdesc: Add routines for copying data to/from memory descriptors
John Baldwin [Mon, 31 Jul 2023 20:24:44 +0000 (13:24 -0700)]
memdesc: Add routines for copying data to/from memory descriptors

These are modeled on the API used for m_copydata/m_copyback and the
crypto buffer APIs.  One day it might be nice to reduce the
proliferation of these by adding cursors and using memdesc directly
for crypto request buffers.

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D40615

9 months agogsb_crc32: Fix a warning when compiled in userland.
John Baldwin [Mon, 31 Jul 2023 20:24:18 +0000 (13:24 -0700)]
gsb_crc32: Fix a warning when compiled in userland.

crc32_tab[] is only exposed as a global in <sys/gsb_crc32.h> for the
kernel, not for userland.

Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D40614

9 months agoDelete i386 support since I dont have a i386 system to rescue and test.
Michael Reifenberger [Mon, 31 Jul 2023 18:26:14 +0000 (20:26 +0200)]
Delete i386 support since I dont have a i386 system to rescue and test.

9 months agotools/build: Work around broken Clang FreeBSD resource dir logic pre-13
Jessica Clarke [Mon, 31 Jul 2023 17:28:08 +0000 (18:28 +0100)]
tools/build: Work around broken Clang FreeBSD resource dir logic pre-13

Prior to Clang 13 (e.g. in the Clang 11 present in 13.0-RELEASE), the
resource directory logic for FreeBSD was broken and would not resolve
symlinks, meaning symlinks would only work if in a directory next to the
containing lib directory. Therefore we cannot even use a symlink for
worldtmp, we have to make a wrapper script that execs the real binary
via an absolute path.

Reported by: markj
Reviewed by: markj
Fixes: 65f28f63a73d ("tools/build: Create toolchain symlinks for non-absolute compiler/linker")
Differential Revision: https://reviews.freebsd.org/D41238

9 months agoe1000: Fix lem(4)/em(4) TSO6
Kevin Bowling [Mon, 31 Jul 2023 15:16:24 +0000 (08:16 -0700)]
e1000: Fix lem(4)/em(4) TSO6

* Fix TSO6 by specializing IP checksum insertion and following Intel SDM
  values for IPv6.
* Remove unnecessary 82544 IP-bit handling
* Remove TSO6 from lem(4) capabilitities

Reviewed by: erj (earlier version)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D41170

9 months agoggate tests: Serialize
Mark Johnston [Tue, 20 Jun 2023 13:09:52 +0000 (09:09 -0400)]
ggate tests: Serialize

9 months agogmirror tests: Serialize
Mark Johnston [Tue, 20 Jun 2023 13:05:53 +0000 (09:05 -0400)]
gmirror tests: Serialize

9 months agodhclient tests: Serialize pcp tests
Mark Johnston [Tue, 20 Jun 2023 13:04:07 +0000 (09:04 -0400)]
dhclient tests: Serialize pcp tests

9 months agoxargs tests: Disable the test added in commit eab91d008165
Mark Johnston [Mon, 31 Jul 2023 14:44:32 +0000 (10:44 -0400)]
xargs tests: Disable the test added in commit eab91d008165

This test has been triggering OOM kills in CI runs since it triggers an
allocation of 16GB.  Temporarily disable the test until the problem is
solved one way or another.

9 months agonvme(4): detect S3X NVMe controller in 2016-2017 MacBooks
Vladimir Kondratyev [Mon, 31 Jul 2023 14:33:14 +0000 (17:33 +0300)]
nvme(4): detect S3X NVMe controller in 2016-2017 MacBooks

Adds support for detection of the S3X NVMe controller found in the
13" MacBook Pro 2017 without Touch Bar (MacBook14,1)
It is known to be used in following MacBooks:
- Retina MacBook 2016 (MacBook9,1)
- 13" MacBook Pro 2016 without Touch Bar (MacBook13,1)
- 13" MacBook Pro 2016 with Touch Bar (MacBook13,2)

9 months agointelspi(4): Add missing driver mutex unlock in NO_SLEEP mode
Vladimir Kondratyev [Mon, 31 Jul 2023 14:30:24 +0000 (17:30 +0300)]
intelspi(4): Add missing driver mutex unlock in NO_SLEEP mode

Fixes: 1f40866feb21 ("intelspi: add PCI attachment (Lynx/Wildcat/Sunrise Point)")
MFC after: 1 week

9 months agolibarchive: merge from vendor branch
Martin Matuska [Mon, 31 Jul 2023 11:13:30 +0000 (13:13 +0200)]
libarchive: merge from vendor branch

Changes to not yet connected unzip only.

MFC after: 1 week

9 months agoUpdate vendor/libarchive to libarchive/libarchive@27ca5119f
Martin Matuska [Mon, 31 Jul 2023 11:09:09 +0000 (13:09 +0200)]
Update vendor/libarchive to libarchive/libarchive@27ca5119f

Changes to not yet connected unzip command only.

Obtained from: libarchive
Libarchive commit: 27ca5119f754d2d359a3cf4ac66c6672260a74d3

9 months agostress2: Added killpg(2) scenarios
Peter Holm [Mon, 31 Jul 2023 07:07:06 +0000 (09:07 +0200)]
stress2: Added killpg(2) scenarios

9 months agoradix_tree: compute slot from keybarr
Doug Moore [Sun, 30 Jul 2023 20:12:06 +0000 (15:12 -0500)]
radix_tree: compute slot from keybarr

The computation of keybarr(), the function that determines when a
search has failed at a non-leaf node, can be done in a way that
computes the 'slot' value when keybarr() fails, which is exactly when
slot() would next be invoked. Computing things this way saves space in
search loops.

This reduces the amd64 coding of the search loop in vm_radix_lookup
from 40 bytes to 28 bytes.

Reviewed by: alc
Tested by: pho (as part of a larger change)
Differential Revision: https://reviews.freebsd.org/D41235

9 months agoamd64: Fix TLB invalidation routines in !SMP kernels
Mark Johnston [Sun, 30 Jul 2023 15:12:35 +0000 (11:12 -0400)]
amd64: Fix TLB invalidation routines in !SMP kernels

amd64 is special in that its implementation of zpcpu_offset_cpu() is not
the identity transformation, even in !SMP kernels.  Because the pm_pcidp
array of amd64's struct pmap is allocated from a pcpu UMA zone, this
means that accessing pm_pcidp directly, as is done in !SMP
implementations of pmap_invalidate_*, does not work.  Specifically, I
see occasional unexplicable crashes in userspace when PCIDs are enabled.

Apply a minimal patch to fix the problem.  While it would also make
sense to provide separate implementations of zpcpu_* for !SMP kernels,
fixing it this way makes the SMP and !SMP implementations of
pmap_invalidate_* more similar.

Reviewed by: alc, kib
MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D41230

9 months agoradix_tree: redefine the clev field
Doug Moore [Sun, 30 Jul 2023 06:20:07 +0000 (01:20 -0500)]
radix_tree: redefine the clev field

The clev field in the node struct is almost always multiplied by
WIDTH; occasionally, it is incremented and then multiplied by
WIDTH. Instructions can be saved by storing it always multiplied by
WIDTH.

For the computation of slot(), this just eliminates a
multiplication. For trimkey(), where the caller always adds one to
clev before passing it as an argument, this change has the caller, not
the caller, do that. Trimkey() handles it not by adding WIDTH to the
input parameter, but by shifting COUNT, and not 1. That produces the
same result, and it relieves keybarr of the need to test to avoid
shifting by more than 63 bits, since level is always <= 63.

This takes 3 instrutions and 14 bytes out of the basic lookup loop on
amd64.

Reviewed by: kib
Tested by: pho (as part of a larger change)
Differential Revision: https://reviews.freebsd.org/D41226

9 months agolibarchive: merge from vendor branch
Martin Matuska [Sat, 29 Jul 2023 20:43:36 +0000 (22:43 +0200)]
libarchive: merge from vendor branch

Libarchive 3.7.1

Important changes (relevant to FreeBSD):
  ISSUE #1934: stack buffer overflow in cpio verbose mode
  ISSUE #1935: SEGV in cpio verbose mode
  PR #1731 tar: respect --strip-components and -s patterns in cru modes

MFC after: 1 week

9 months agousr.bin/gh-bc: fix Makefile for WITHOUT_NLS_CATALOGS case
Stefan Eßer [Sat, 29 Jul 2023 18:52:53 +0000 (20:52 +0200)]
usr.bin/gh-bc: fix Makefile for WITHOUT_NLS_CATALOGS case

Some macro definitions had been moved into a Makefile section
that depends on MK_NLS_CATALOGS != "no", leading to LTO and the
installation of tests being disabled in the WITHOUT_NLS_CATALOGS
case.

Reported by: Yuri <yuri@aetern.org>

9 months agoUpdate vendor/libarchive to libarchive/libarchive@0e1e2b926
Martin Matuska [Sat, 29 Jul 2023 18:13:53 +0000 (20:13 +0200)]
Update vendor/libarchive to libarchive/libarchive@0e1e2b926

Important bugfixes (relevant to FreeBSD):
  ISSUE #1934: stack buffer overflow in cpio verbose mode
  ISSUE #1935: SEGV in cpio verbose mode
  PR #1731 tar: respect --strip-components and -s patterns in cru modes

Obtained from: libarchive
Libarchive commit: 0e1e2b926aad81512a79a05c791b9dc7e0fa8715
Libarchive tag: v3.7.1

10 months agovfs: Deleting a doubled inclusion of sys/capsicum.h
Dmitry Chagin [Sat, 29 Jul 2023 08:21:58 +0000 (11:21 +0300)]
vfs: Deleting a doubled inclusion of sys/capsicum.h

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

10 months agolinux(4): Fix control message size calculation
Dmitry Chagin [Sat, 29 Jul 2023 08:21:35 +0000 (11:21 +0300)]
linux(4): Fix control message size calculation

To determine the size in bytes needed to hold a control message
and its contents of length len, CMSG_SPACE should be used.

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

10 months agoe1000: HWCSUM excemption fixes
Kevin Bowling [Sat, 29 Jul 2023 01:14:29 +0000 (18:14 -0700)]
e1000: HWCSUM excemption fixes

Also disable IPV6 checksum offload.

Spell hw->mac.type < e1000_82543 as e1000_82542.  Confusingly, chips
like 82540 and 82541 come later and do not have these issues.  There
is no functional change here, as the enum was defined in such a way
it worked correctly.  But this reads literally.

MFC after: 1 week

10 months agosctp: keep sb_acc and sb_ccc in sync
Michael Tuexen [Fri, 28 Jul 2023 13:16:23 +0000 (15:16 +0200)]
sctp: keep sb_acc and sb_ccc in sync

PR: 260116
MFC after: 1 week

10 months agosctp: improve consistency
Michael Tuexen [Fri, 28 Jul 2023 12:36:11 +0000 (14:36 +0200)]
sctp: improve consistency

This is simplifying a patch to address PR 260116.

PR: 260116
MFC after: 1 week

10 months agoamd64 pmap: Catch up with pctrie changes
Alan Cox [Fri, 28 Jul 2023 20:13:13 +0000 (15:13 -0500)]
amd64 pmap: Catch up with pctrie changes

Recent changes to the pctrie code make it necessary to initialize the
kernel pmap's rangeset for PKU.

10 months agocam: Log errors from passthru commands
Warner Losh [Fri, 28 Jul 2023 18:11:21 +0000 (12:11 -0600)]
cam: Log errors from passthru commands

Since a30ecd42b8e09 we've logged almost all unexpected errors from
commands. However, some passthru commands were not logged via devctl. To
fix this, pass all requests through passerror (which calls
cam_periph_error), but flag those requests that didn't want error
recovery as SF_NO_RECOVERY, like we do for device probing. By doing this
we get identical behavior to the current code, but log these errors.

We have had hangs on drives that seems to show no error. Vendor analysis
of the drive found an illegal command that happen to hang the drive. In
verifying their analysis, we discovered that the pass through commands
from things like smartctl that encountered errors or timeouts weren't
logged.

Sponsored by: Netflix
Reviewed by: ken, mav
Differential Revision: https://reviews.freebsd.org/D41167

10 months agomk: Install bsd.compat.pre.mk
Jessica Clarke [Fri, 28 Jul 2023 16:52:38 +0000 (17:52 +0100)]
mk: Install bsd.compat.pre.mk

Reported by: dchagin
Fixes: 5d6cb793d0d5 ("bsd.compat.mk Extract _ALL_LIBCOMPATS and add related variables")

10 months agoEvery path in a radix trie ends with a leaf or a NULL. By replacing
Doug Moore [Fri, 28 Jul 2023 16:39:52 +0000 (11:39 -0500)]
Every path in a radix trie ends with a leaf or a NULL. By replacing
NULL (non-leaf) pointers with NULL leaves, there is a NULL test
removed from every iteration of an index-based search loop.

This speeds up radix trie searches by few percent. If there are any
radix tries that are not initialized with the init() function, but
instead depend on zeroing everything being proper initialization, this
will break those tries.

Reviewed by: alc, kib
Tested by: pho (as part of a larger change)
Differential Revision: https://reviews.freebsd.org/D41171

10 months agoarm64: Add constants for decoding ISS fields for WF* exceptions
Mark Johnston [Fri, 28 Jul 2023 13:32:45 +0000 (09:32 -0400)]
arm64: Add constants for decoding ISS fields for WF* exceptions

WFI and WFIT trap to EL2 when executed in a vmm guest.  (Currently
WFE/WFET are not configured to trap.)  We only handle WFI at the moment,
so these constants are useful when handling the exception.

Reviewed by: andrew
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D41199

10 months agoarm64: Decode the ID_AA64PFR2_EL1 register
Andrew Turner [Thu, 6 Jul 2023 14:48:42 +0000 (15:48 +0100)]
arm64: Decode the ID_AA64PFR2_EL1 register

No fields have been defined, but it has been documented in the
Architecture Reference Manual.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40897

10 months agoarm64: Update the ID_AA64PFR1_EL1 fields
Andrew Turner [Thu, 6 Jul 2023 14:40:01 +0000 (15:40 +0100)]
arm64: Update the ID_AA64PFR1_EL1 fields

While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40896

10 months agoarm64: Update the ID_AA64PFR0_EL1 fields
Andrew Turner [Thu, 6 Jul 2023 14:02:35 +0000 (15:02 +0100)]
arm64: Update the ID_AA64PFR0_EL1 fields

While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40895

10 months agoarm64: Decode the ID_AA64MMFR4_EL1 register
Andrew Turner [Thu, 6 Jul 2023 13:51:52 +0000 (14:51 +0100)]
arm64: Decode the ID_AA64MMFR4_EL1 register

No fields have been defined, but it has been documented in the
Architecture Reference Manual.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40894

10 months agoarm64: Decode the ID_AA64MMFR3_EL1 register
Andrew Turner [Thu, 6 Jul 2023 13:28:23 +0000 (14:28 +0100)]
arm64: Decode the ID_AA64MMFR3_EL1 register

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40893

10 months agoarm64: Don't use hex for ID_AA64MMFR2_EL1_op/CR*
Andrew Turner [Thu, 6 Jul 2023 13:15:12 +0000 (14:15 +0100)]
arm64: Don't use hex for ID_AA64MMFR2_EL1_op/CR*

It breaks a future macro that creates the alternative register name
for old compilers.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40892

10 months agoarm64: Update the ID_AA64MMFR1_EL1 fields
Andrew Turner [Thu, 6 Jul 2023 13:11:29 +0000 (14:11 +0100)]
arm64: Update the ID_AA64MMFR1_EL1 fields

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40891

10 months agoarm64: Update the ID_AA64MMFR0_EL1 fields
Andrew Turner [Thu, 6 Jul 2023 12:34:28 +0000 (13:34 +0100)]
arm64: Update the ID_AA64MMFR0_EL1 fields

While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40890

10 months agoarm64: Update the ID_AA64ISAR1_EL1 fields
Andrew Turner [Thu, 6 Jul 2023 10:01:11 +0000 (11:01 +0100)]
arm64: Update the ID_AA64ISAR1_EL1 fields

While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40889

10 months agoarm64: Update the ID_AA64ISAR0_EL1 fields
Andrew Turner [Thu, 6 Jul 2023 09:19:21 +0000 (10:19 +0100)]
arm64: Update the ID_AA64ISAR0_EL1 fields

While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40888

10 months agoarm64: Update the ID_AA64DFR0_EL1 fields
Andrew Turner [Mon, 13 Mar 2023 09:17:32 +0000 (09:17 +0000)]
arm64: Update the ID_AA64DFR0_EL1 fields

While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40887

10 months agomroute: avoid calling if_allmulti with the lock held
Kristof Provost [Thu, 27 Jul 2023 06:03:25 +0000 (08:03 +0200)]
mroute: avoid calling if_allmulti with the lock held

Avoid locking issues when if_allmulti() calls the driver's if_ioctl,
because that may acquire sleepable locks (while we hold a non-sleepable
rwlock).

Fortunately there's no pressing need to hold the mroute lock while we
do this, so we can postpone the call slightly, until after we've
released the lock.

This avoids the following WITNESS warning (with iflib drivers):

lock order reversal: (sleepable after non-sleepable)
 1st 0xffffffff82f64960 IPv4 multicast forwarding (IPv4 multicast forwarding, rw) @ /usr/src/sys/netinet/ip_mroute.c:1050
 2nd 0xfffff8000480f180 iflib ctx lock (iflib ctx lock, sx) @ /usr/src/sys/net/iflib.c:4525
lock order IPv4 multicast forwarding -> iflib ctx lock attempted at:
#0 0xffffffff80bbd6ce at witness_checkorder+0xbbe
#1 0xffffffff80b56d10 at _sx_xlock+0x60
#2 0xffffffff80c9ce5c at iflib_if_ioctl+0x2dc
#3 0xffffffff80c7c395 at if_setflag+0xe5
#4 0xffffffff82f60a0e at del_vif_locked+0x9e
#5 0xffffffff82f5f0d5 at X_ip_mrouter_set+0x265
#6 0xffffffff80bfd402 at sosetopt+0xc2
#7 0xffffffff80c02105 at kern_setsockopt+0xa5
#8 0xffffffff80c02054 at sys_setsockopt+0x24
#9 0xffffffff81046be8 at amd64_syscall+0x138
#10 0xffffffff8101930b at fast_syscall_common+0xf8

See also: https://redmine.pfsense.org/issues/12079
Reviewed by: mjg
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D41209

10 months agotests: Test libexecinfo backtrace call througth signal trampoline
Dmitry Chagin [Fri, 28 Jul 2023 09:10:27 +0000 (12:10 +0300)]
tests: Test libexecinfo backtrace call througth signal trampoline

It should fails on Aarch64 until https://reviews.llvm.org/D155066
is not merged.

Reviewed by:
Differential Revision: https://reviews.freebsd.org/D41129

10 months agolinux(4): Add elf_hwcap2 to x86
Dmitry Chagin [Fri, 28 Jul 2023 08:56:59 +0000 (11:56 +0300)]
linux(4): Add elf_hwcap2 to x86

On x86 Linux via AT_HWCAP2 the user controlled (by tunables) processor
capabilities are exposed.

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

10 months agoi386: Don't use static DPCPU and VNET defines in i386 modules
Dmitry Chagin [Fri, 28 Jul 2023 08:55:31 +0000 (11:55 +0300)]
i386: Don't use static DPCPU and VNET defines in i386 modules

As of c84617e8 a similar to 4802a2cb and b6ea4c5a fix should be
applied to i386 too.

Reviewed by:
Differential Revision: https://reviews.freebsd.org/D41195

10 months agoman: Link _Fork(2) man page
Dmitry Chagin [Fri, 28 Jul 2023 08:54:20 +0000 (11:54 +0300)]
man: Link _Fork(2) man page

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D41221
MFC after: 1 week

10 months agouniverse: Demote armv6 to an extra architecture.
Warner Losh [Fri, 28 Jul 2023 04:21:44 +0000 (22:21 -0600)]
universe: Demote armv6 to an extra architecture.

Per discussions over how to lighten the load of armv6, move it to an
extra arch. You can still build TARGET_ARCH=armv6 if you desire, but
it won't be built as part of 'make universe' without -DEXTRA_TARGETS.

Sponsored by: Netflix

10 months agocam: Fail 2/0 asc/ascq return code
Warner Losh [Thu, 27 Jul 2023 22:05:29 +0000 (16:05 -0600)]
cam: Fail 2/0 asc/ascq return code

This asc/ascq code 2/0 ("No seek complete") is a fatal error on modern
drives indicating a sensor failure. One of our vendors noticed we
retried 2/0 so many times in their failure analysis and asked why (no
other OS else does). They've indicated that this failures means the
track couldn't be located (something that's not going to change, except
if the environment changes significantly, which won't happen on a
timescale useful to retries).

Sponsored by: Netflix

10 months agoPre-quote macros passed to .incbin to avoid unwanted substitution
Jessica Clarke [Fri, 28 Jul 2023 04:08:43 +0000 (05:08 +0100)]
Pre-quote macros passed to .incbin to avoid unwanted substitution

Currently for the MFS, firmware and VDSO template assembly files we pass
the path to include with .incbin unquoted and use __XSTRING within the
assembly file to stringify it. However, __XSTRING doesn't just perform a
single level of expansion, it performs the normal full expansion of the
macro, and so if the path itself happens to tokenise to something that
includes a defined macro in it that will itself be substituted. For
example, with #define MACRO 1, a path like /path/containing/MACRO/in/it
will expand to /path/containing/1/in/it and then, when stringified, end
up as "/path/containing/1/in/it", not the intended string. Normally,
macros have names that start or end witih underscores and are unlikely
to appear in a tokenised path (even if technically they could), but now
that we've switched to GNU C as of commit ec41a96daaa6 ("sys: Switch the
kernel's C standard from C99 to GNU99.") there are a few new macros
defined which don't start or end with underscores: unix, which is always
defined to 1, and i386, which is defined to 1 on i386. The former
probably doesn't appear in user paths in practice, but the latter has
been seen to and is likely quite common in the wild.

Fix this by defining the macro pre-quoted instead of using __XSTRING.
Note that technically we don't need to do this for vdso_wrap.S today as
all the paths passed to it are safe file names with no user-controlled
prefix but we should do it anyway for consistency and robustness against
future changes.

This allows make tinderbox to pass when built with source and object
directories inside ~/path-with-unix, which would otherwise expand to
~/path-with-1 and break.

PR: 272744
Fixes: ec41a96daaa6 ("sys: Switch the kernel's C standard from C99 to GNU99.")

10 months agoMakefile.inc1: Fix list-old-libs by deleting stray pipe
Jessica Clarke [Thu, 27 Jul 2023 23:14:19 +0000 (00:14 +0100)]
Makefile.inc1: Fix list-old-libs by deleting stray pipe

Reported by: Yuri <yuri@aetern.org>
Fixes: 264594efbe69 ("Makefile.inc1: Automatically generate _LIBCOMPATS and list-old-* libcompats")

10 months agoe1000: Corrections for lem(4)/em(4) txcsum offload
Kevin Bowling [Thu, 27 Jul 2023 22:50:32 +0000 (15:50 -0700)]
e1000: Corrections for lem(4)/em(4) txcsum offload

Explicitly set ipcss/ipcse/ipcso for IPv6 per intel SDM as indicated in
inline comments.

Fix and consolidate 82543/82547 hwcsum exemption.

While here rearrange and expand some commentary.

10 months agoiflib: Fix panic during driver reload stress test
Przemyslaw Lewandowski [Thu, 27 Jul 2023 22:47:12 +0000 (15:47 -0700)]
iflib: Fix panic during driver reload stress test

During a driver reload stress test, after 50-300 reloads a panic occurs.
After adding sleeps in between loading and unloading the driver, the
issue does not occur.  It's possible that loading/unloading too fast may
cause the gt_taskqueue pointer to be freed earlier than expected;
checking for a null pointer first fixes it.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Reviewed by: erj@
Tested by: jeffrey.e.pieper@intel.com
MFC after: 3 days
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D39457

10 months agoUFS/FFS: Migrate to modern uintXX_t from u_intXX_t.
Kirk McKusick [Thu, 27 Jul 2023 22:26:01 +0000 (15:26 -0700)]
UFS/FFS: Migrate to modern uintXX_t from u_intXX_t.

As per https://lists.freebsd.org/archives/freebsd-scsi/2023-July/000257.html
move to the modern uintXX_t. While here also migrate u_char to uint8_t.
Where other kernel interfaces allow, migrate u_long to uint64_t.

No functional changes intended.

MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
10 months agomk: fix unnecessary library relinking with incremental builds
Val Packett [Thu, 27 Jul 2023 21:55:16 +0000 (14:55 -0700)]
mk: fix unnecessary library relinking with incremental builds

Initial libs such as csu are always built (.PHONY), and their
installation to WORLDTMP was causing all the subsequent libraries to
be considered out-of-date even when in reality they were not. Use
install -C more consistently everywhere to avoid unnecessarily
updating the mtimes in WORLDTMP, fixing this problem.

This cut down my no-change buildworld time from 30 to 15 seconds.

Fixes: https://lists.freebsd.org/pipermail/freebsd-current/2016-May/061481.html
TODO.1

Reviewed by: sjg
Sponsored by: https://www.patreon.com/valpackett
Differential Revision:  https://reviews.freebsd.org/D39980

10 months agodtrace: Add WITH_DTRACE_ASAN
Domagoj Stolfa [Thu, 27 Jul 2023 18:27:42 +0000 (20:27 +0200)]
dtrace: Add WITH_DTRACE_ASAN

This option is a blanket for all the DTrace-related software. The option
when enabled passes in -fsanitize=address -fsanitize=undeifned, enabling
ASAN and UBSAN in the following components:

 - libdtrace
 - dtrace(1)
 - lockstat(1)
 - plockstat(1)

The option defaults to "no" and is intended as a developer aid.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D41157

10 months agopcpu: Remove unused definitions of ALT_STACK_SIZE
Mark Johnston [Mon, 24 Jul 2023 15:26:08 +0000 (11:26 -0400)]
pcpu: Remove unused definitions of ALT_STACK_SIZE

This was added originally for the sparc64 port and apparently copied to
other platforms.  No functional change intended.

MFC after: 1 week

10 months agokmsan: Use the correct origin bytes in kmsan_check_arg()
Mark Johnston [Mon, 17 Jul 2023 13:34:57 +0000 (09:34 -0400)]
kmsan: Use the correct origin bytes in kmsan_check_arg()

Upon discovering a violation kmsan_check_arg() passes a pointer to
function parameter shadow state to kmsan_report_hook().
kmsan_report_hook() uses that address to find the origin cells, assuming
that the passed address belongs to the kernel map.  This has two
problems:
1) Function parameter origin state is also located in TLS, not in the
   origin map, but kmsan_report_hook() doesn't know this.
2) KMSAN TLS for thread0 is statically allocated and thus isn't shadowed
   (because the kernel itself is not shadowed).

These bugs could result in inaccuracies in KMSAN reports, or a page
fault when trying to report a KMSAN violation (which by default panics
the kernel anyway).

Fix the problem by making callers of kmsan_report_hook() provide a
pointer to origin cells.

Sponsored by: The FreeBSD Foundation

10 months agokmsan: Add a comment explaining why KMSAN doesn't shadow above KERNBASE
Mark Johnston [Sat, 15 Jul 2023 18:04:55 +0000 (14:04 -0400)]
kmsan: Add a comment explaining why KMSAN doesn't shadow above KERNBASE

Sponsored by: The FreeBSD Foundation

10 months agoopencrypto: Respect alignment constraints in xor_and_encrypt()
Mark Johnston [Thu, 27 Jul 2023 19:44:52 +0000 (15:44 -0400)]
opencrypto: Respect alignment constraints in xor_and_encrypt()

Copy operands to an aligned buffer before performing operations which
require alignment.  Otherwise it's possible for this code to trigger an
alignment fault on armv7.

Reviewed by: jhb
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D41211

10 months agoarm/unwind: Check stack pointer boundaries before dereferencing
Mark Johnston [Thu, 27 Jul 2023 19:44:00 +0000 (15:44 -0400)]
arm/unwind: Check stack pointer boundaries before dereferencing

If the unwinder somehow ends up with a stack pointer that lies outside
the stack, then an attempt to dereference can lead to a fault, which
causes the kernel to panic again and unwind the stack, which leads to a
fault...

Add kstack_contains() checks at points where we dereference the stack
pointer.  This avoids the aforementioned infinite loop in one case I hit
where some OpenSSL assembly code apparently confuses the unwinder.

Reviewed by: jhb
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D41210

10 months agosrc.conf.5: Regen
Jose Luis Duran [Thu, 27 Jul 2023 15:40:42 +0000 (15:40 +0000)]
src.conf.5: Regen

Regenerate makeman after enabling the building of lib32 on arm64.

Fixes: a1b675731301 ("arm64 lib32: enable building of lib32 on arm64")
Pull Request: https://github.com/freebsd/freebsd-src/pull/804

10 months agotcp: document that conditional fields in tcpcb should be at the end
Michael Tuexen [Thu, 27 Jul 2023 07:02:19 +0000 (09:02 +0200)]
tcp: document that conditional fields in tcpcb should be at the end

Reviewed by:  rscheff, Peter Lei
Sponsored by: Netflix, Inc.

10 months agorelease: Fix make :@ modifier syntax
Jessica Clarke [Thu, 27 Jul 2023 07:36:12 +0000 (08:36 +0100)]
release: Fix make :@ modifier syntax

This spits out errors but seemingly isn't actually fatal, so was missed.

Fixes: 6853d893c7fe ("release: Automatically generate MK_LIB${LIBCOMPAT} and lib${libcompat}-dbg lists")

10 months agoetcupdate: Remove redundant semicolons
Jessica Clarke [Thu, 27 Jul 2023 06:55:13 +0000 (07:55 +0100)]
etcupdate: Remove redundant semicolons

Fixes: 03e62670c33c ("etcupdate: Consolidate nobuild cases and make more robust")

10 months agogve: Fix Tx tcpdump panic
Shailend Chand [Thu, 27 Jul 2023 05:22:31 +0000 (22:22 -0700)]
gve: Fix Tx tcpdump panic

Ringing the doorbell before making the BPF call can result in the
mbuf being freed before the BPF call.

Reviewed-by: markj
MFC-after: 3 days
Differential Revision: https://reviews.freebsd.org/D41189

10 months agovm_mmap_object: Update the spelling of true/false
Alan Cox [Wed, 26 Jul 2023 05:58:51 +0000 (00:58 -0500)]
vm_mmap_object: Update the spelling of true/false

Since fitit is already a bool, use true/false instead of TRUE/FALSE.

MFC after: 2 weeks

10 months agoMakefile.inc1: Reinstate kbdcontrol bootstrap for BUILD_WITH_STRICT_TMPPATH
Jessica Clarke [Thu, 27 Jul 2023 04:10:49 +0000 (05:10 +0100)]
Makefile.inc1: Reinstate kbdcontrol bootstrap for BUILD_WITH_STRICT_TMPPATH

During BUILD_WITH_STRICT_TMPPATH builds we need to symlink the host's
kbdcontrol into WORLDTMP/legacy/bin so that it can be used. For
completeness, also check if the host has it, since technically the host
could have been built with WITHOUT_LEGACY_CONSOLE (though given nobody's
screamed since this code was removed that's likely not something that
gets hit in practice), and handle BOOTSTRAP_ALL_TOOLS (especially since
that case will cover cross-building if and when kbdcontrol can be built
on non-FreeBSD).

This allows a BUILD_WITH_STRICT_TMPPATH tinderbox to pass.

This partially reverts commit 33550b47391330362ea58984aa3fd691f6219ee0.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D41202

10 months agoetcupdate: Use new buildetc and installetc targets when available
Jessica Clarke [Thu, 27 Jul 2023 04:10:49 +0000 (05:10 +0100)]
etcupdate: Use new buildetc and installetc targets when available

These new targets avoid the need to invoke internal build system targets
or set internal variables when building, and also have the added benefit
of working with BUILD_WITH_STRICT_TMPPATH. Old source trees lacking such
targets will not work with BUILD_WITH_STRICT_TMPPATH; they could be made
to work by copying the steps, but it's not worth doing so, as they never
have worked in the past. The primary goal of this is to support changing
the default of BUILD_WITH_STRICT_TMPPATH to enabled.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D41206

10 months agoMakefile.inc1: Add new buildetc and installetc targets
Jessica Clarke [Thu, 27 Jul 2023 04:10:49 +0000 (05:10 +0100)]
Makefile.inc1: Add new buildetc and installetc targets

These implement the steps that etcupdate (and mergemaster) need in order
to build their pristine trees, avoiding the need to use internal targets
and variables. Additionally, buildetc includes the steps needed to build
with BUILD_WITH_STRICT_TMPPATH enabled, since we need some host tools to
be available during the various build and install steps.

Reviewed by: jhb, imp
Differential Revision: https://reviews.freebsd.org/D41205

10 months agoetcupdate: Consolidate nobuild cases and make more robust
Jessica Clarke [Thu, 27 Jul 2023 04:10:48 +0000 (05:10 +0100)]
etcupdate: Consolidate nobuild cases and make more robust

The distrib-dirs and distribution steps are shared between the two, the
only difference is whether MAKEOBJDIRPREFIX is in the environment for
the latter. Having in the environment for the former is currently not
needed but does no harm and will be needed in future, so we can just
export it up-front in the subshell. When we do distrib-dirs relative to
_obj and everything also doesn't matter, so move it next to distribution
where it makes more sense. Finally, to avoid complicated && chains, use
"|| exit 1" everywhere to make the subshell fail, and add an extra one
on to the cd $SRCDIR to handle that failing (otherwise we'd go on and
try to build the current directory after cd prints its error, which is
unhelpful).

These changes will make it easier to bundle these steps up into new
top-level targets to allow the build system to manage the steps rather
than etcupdate, which will also handle BUILD_WITH_STRICT_TMPPATH, which
currently does not work with etcupdate.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D41204

10 months agoMakefile.inc1: Split _cleanworldtmp out from _worldtmp
Jessica Clarke [Thu, 27 Jul 2023 04:10:48 +0000 (05:10 +0100)]
Makefile.inc1: Split _cleanworldtmp out from _worldtmp

This mirrors _cleanobj vs _obj, and will be used by etcupdate to ensure
its build tree has host tools available when BUILD_WITH_STRICT_TMPPATH
is enabled by default (whether in the source tree, like CheriBSD, or in
a system config file).

Note that due to line length the .MAKE .PHONY dependency line is split
into two, one for the filtered WMAKE_TGTS and one for the filtered
.ALLTARGETS.

Reviewed by: brooks, jhb
Differential Revision: https://reviews.freebsd.org/D41190

10 months agotools/build: Create toolchain symlinks for non-absolute compiler/linker
Jessica Clarke [Thu, 27 Jul 2023 04:10:47 +0000 (05:10 +0100)]
tools/build: Create toolchain symlinks for non-absolute compiler/linker

If any of the toolchain variables are not absolute then we need to
create a symlink in WORLDTMP/legacy/bin in order to make them available
during a BUILD_WITH_STRICT_TMPPATH build.

Reviewed by: brooks, jhb
Differential Revision: https://reviews.freebsd.org/D41188

10 months agodepend-cleanup.sh: Generalise lib32 code and avoid duplication
Jessica Clarke [Thu, 27 Jul 2023 04:10:47 +0000 (05:10 +0100)]
depend-cleanup.sh: Generalise lib32 code and avoid duplication

By passing through _ALL_libcompats we can avoid hard-coding the list of
libcompats in depend-cleanup.sh. This cleanup also makes clean_dep
shorter by using a loop instead of handling each case explicitly (at the
expense of slightly tweaked logging).

Reviewed by: brooks, jhb
Differential Revision: https://reviews.freebsd.org/D41187

10 months agoOptionalObsoleteFiles.inc: Automatically generate libcompat directories
Jessica Clarke [Thu, 27 Jul 2023 04:10:46 +0000 (05:10 +0100)]
OptionalObsoleteFiles.inc: Automatically generate libcompat directories

Reviewed by: brooks, jhb, emaste
Differential Revision: https://reviews.freebsd.org/D41186

10 months agobsd.lib.mk: Automatically generate libcompat TAGS
Jessica Clarke [Thu, 27 Jul 2023 04:10:46 +0000 (05:10 +0100)]
bsd.lib.mk: Automatically generate libcompat TAGS

Note that the pattern for matching is made slightly more specific, so as
to permit libcompats where one is a prefix of another (e.g. CheriBSD has
lib64 and lib64c).

Reviewed by: brooks, jhb, emaste
Differential Revision: https://reviews.freebsd.org/D41185

10 months agorelease: Automatically generate MK_LIB${LIBCOMPAT} and lib${libcompat}-dbg lists
Jessica Clarke [Thu, 27 Jul 2023 04:10:45 +0000 (05:10 +0100)]
release: Automatically generate MK_LIB${LIBCOMPAT} and lib${libcompat}-dbg lists

Reviewed by: brooks, jhb
Differential Revision: https://reviews.freebsd.org/D41184

10 months agolibexec: Automatically generate rtld-elf list and generalise TAGS
Jessica Clarke [Thu, 27 Jul 2023 04:10:45 +0000 (05:10 +0100)]
libexec: Automatically generate rtld-elf list and generalise TAGS

Note that the pattern for matching is made slightly more specific, so as
to permit libcompats where one is a prefix of another (e.g. CheriBSD has
lib64 and lib64c).

Reviewed by: brooks, jhb, emaste, imp, kib
Differential Revision: https://reviews.freebsd.org/D41183

10 months agoetc: Automatically generate BSD.lib${libcompat}.dist lists
Jessica Clarke [Thu, 27 Jul 2023 04:10:44 +0000 (05:10 +0100)]
etc: Automatically generate BSD.lib${libcompat}.dist lists

Note that each libcompat still has its own file that must exist.

Reviewed by: brooks, jhb
Differential Revision: https://reviews.freebsd.org/D41182

10 months agoObsoleteFiles.inc: Automatically generate OpenSSL 3 obsoleted libcompat dirs
Jessica Clarke [Thu, 27 Jul 2023 04:10:44 +0000 (05:10 +0100)]
ObsoleteFiles.inc: Automatically generate OpenSSL 3 obsoleted libcompat dirs

Older entries in this file are left alone as hard-coding lib32 as
they're not worth the churn; downstreams will have already moved past
them (in particular, CheriBSD, which adds additional libcompats).

Reviewed by: brooks, jhb, emaste
Differential Revision: https://reviews.freebsd.org/D41181

10 months agoMakefile.inc1: Automatically generate _LIBCOMPATS and list-old-* libcompats
Jessica Clarke [Thu, 27 Jul 2023 04:10:43 +0000 (05:10 +0100)]
Makefile.inc1: Automatically generate _LIBCOMPATS and list-old-* libcompats

Reviewed by: brooks, jhb
Differential Revision: https://reviews.freebsd.org/D41180

10 months agoMakefile: Automatically generate list of libcompat targets
Jessica Clarke [Thu, 27 Jul 2023 04:10:43 +0000 (05:10 +0100)]
Makefile: Automatically generate list of libcompat targets

Reviewed by: brooks, jhb
Differential Revision: https://reviews.freebsd.org/D41179

10 months agobsd.compat.mk Extract _ALL_LIBCOMPATS and add related variables
Jessica Clarke [Thu, 27 Jul 2023 04:10:43 +0000 (05:10 +0100)]
bsd.compat.mk Extract _ALL_LIBCOMPATS and add related variables

Adding these to a new bsd.compat.pre.mk will allow other parts of the
tree to iterate over the set of possible libcompats (upper and/or lower)
rather than having to hard-code the list.

Reviewed by: brooks, jhb, emaste
Differential Revision: https://reviews.freebsd.org/D41178

10 months agoinpcb: do not copy so_options into inp_flags2
Gleb Smirnoff [Thu, 27 Jul 2023 03:35:41 +0000 (20:35 -0700)]
inpcb: do not copy so_options into inp_flags2

Since f71cb9f74808 socket stays connnected with inpcb through latter's
lifetime and there is no reason to complicate things and copy these
flags.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D41198

10 months agoinpcb: use internal flag to mark pcbs that are inserted into lbgroup
Gleb Smirnoff [Thu, 27 Jul 2023 03:35:30 +0000 (20:35 -0700)]
inpcb: use internal flag to mark pcbs that are inserted into lbgroup

Using INP_REUSEPORT_LB is unsafe, as it is basically a copy of socket's
SO_REUSEPORT_LB flag, which can be cleared by userland after bind().

Reviewed by: markj
Reported by: syzbot+e7d2e451f89fb444319b@syzkaller.appspotmail.com
Differential Revision: https://reviews.freebsd.org/D41197

10 months agofork1(): properly track the state of the pg_killsx lock
Konstantin Belousov [Wed, 26 Jul 2023 23:24:30 +0000 (02:24 +0300)]
fork1(): properly track the state of the pg_killsx lock

Reported by: dchagin
Fixes: 232b922cb363e01ac0dd2a277d93cf74d8485e79
Sponsored by: The FreeBSD Foundation
MFC after: 1 week