Commit graph

285323 commits

Author SHA1 Message Date
Warner Losh cf0a543f1f cam: Log more error codes
Log CAM_DEV_NOT_THERE status CCBs because they get dropped if a drive
disappears and these requests timeout or are cancelled. It's useful to
know the outstanding commands for failure analysis. Log
CAM_NVME_STATUS_ERROR status CCBs to bring in NVMe errors (this will be
more important in future commits that expand the information logged).

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D41168
2023-08-01 14:51:54 -06:00
Dmitry Chagin 5a7e48dddf tests: Add MAP_32BIT flag test
Reviewed by:		kib, markj
Differential Revision:	https://reviews.freebsd.org/D41236
MFC after:		1 month
2023-08-01 23:23:15 +03:00
Kirk McKusick 344b5bf825 Support background fsck_ffs(8) on filesystems using journaled soft updates
An earlier addition of code to fsck_ffs(8) allowed it to support
snapshots when running with journalled soft updates. Further
functionality has now been added to fsck_ffs(8) to allow it to use
snapshots to run in background on live filesystems running with
journaled soft updates. This commit enables the use of this functionality.

Tested-by:    Peter Holm
Sponsored-by: The FreeBSD Foundation
MFC-after:    2 weeks
2023-08-01 13:17:02 -07:00
Jonathan T. Looney ff3d1a3f9d 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
2023-08-01 15:45:41 -04:00
John Baldwin bed3ae1d78 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
2023-08-01 15:45:41 -04:00
Eric van Gyzen 1112883e19 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
2023-08-01 12:28:50 -05:00
Eric van Gyzen be1dd8e65b proc_detach: use ptrace(PT_KILL) to kill the tracee
When MFC'ing commit dad11f990e 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
2023-08-01 12:28:50 -05:00
Eric van Gyzen bcbce2a29b 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
2023-08-01 12:28:50 -05:00
Eric van Gyzen 837f6ecd88 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
2023-08-01 12:28:50 -05:00
Ed Maste 89c762c815 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
2023-08-01 13:23:42 -04:00
Mark Johnston 5cdaac92e1 dtrace: Revert the addition of WITH_DTRACE_ASAN
The follow-up fix triggers a lib32 build failure, revert everything
until the problem is addressed.
2023-08-01 13:03:10 -04:00
Ed Maste 391e1f23b3 src.conf.5: regen after armv6 demotion
Fixes: 98d03dca9a ("universe: Demote armv6 to an extra architecture.")
Sponsored by:	The FreeBSD Foundation
2023-08-01 11:20:15 -04:00
Pau Amma 258c6d5e9b filemon(4): Better error checking in code example
Discussed with:	dim
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38367
2023-08-01 11:30:38 -03:00
Mark Johnston 848ff9bc1b libdtrace: Explicitly set SHLIBDIR and SHLIB_MAJOR
They were previously being defined by cddl/lib/Makefile.inc, and as of
commit 4ae6991228 were being overridden by defaults in bsd.own.mk,
which changed SHLIBDIR to /usr/lib.

Reported by:	Domagoj Stolfa <ds815@cam.ac.uk>
Fixes:		4ae6991228 ("dtrace: Add WITH_DTRACE_ASAN")
2023-08-01 10:11:42 -04:00
Mark Johnston d0e4e53ebd 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
2023-08-01 10:10:02 -04:00
Gordon Bergling 135c2b7156 sk(4): Fix a typo in a source code comment
- s/nomral/normal/

MFC after:	3 days
2023-08-01 07:50:45 +02:00
Doug Moore c2cbd7ffa7 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
2023-07-31 21:02:56 -05:00
Konstantin Belousov fa3cf6cdc6 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
2023-08-01 01:55:13 +03:00
John Baldwin f561c2ec08 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
2023-07-31 13:24:44 -07:00
John Baldwin 56e9a0136f 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
2023-07-31 13:24:18 -07:00
Michael Reifenberger dd262a8273 Delete i386 support since I dont have a i386 system to rescue and test. 2023-07-31 20:26:14 +02:00
Jessica Clarke 01718a2e94 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:		65f28f63a7 ("tools/build: Create toolchain symlinks for non-absolute compiler/linker")
Differential Revision:	https://reviews.freebsd.org/D41238
2023-07-31 18:28:08 +01:00
Kevin Bowling e1353dcb63 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
2023-07-31 08:19:14 -07:00
Mark Johnston 15e564e408 ggate tests: Serialize 2023-07-31 11:01:53 -04:00
Mark Johnston 9c3f6368b1 gmirror tests: Serialize 2023-07-31 11:01:49 -04:00
Mark Johnston a94158d255 dhclient tests: Serialize pcp tests 2023-07-31 11:01:43 -04:00
Mark Johnston 2682a15527 xargs tests: Disable the test added in commit eab91d0081
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.
2023-07-31 10:44:32 -04:00
Vladimir Kondratyev fc14525044 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)
2023-07-31 17:33:14 +03:00
Vladimir Kondratyev d101156ec6 intelspi(4): Add missing driver mutex unlock in NO_SLEEP mode
Fixes: 1f40866feb ("intelspi: add PCI attachment (Lynx/Wildcat/Sunrise Point)")

MFC after:	1 week
2023-07-31 17:30:24 +03:00
Martin Matuska d91bfe0fb7 libarchive: merge from vendor branch
Changes to not yet connected unzip only.

MFC after:	1 week
2023-07-31 13:15:12 +02:00
Martin Matuska f8035ed8e5 Update vendor/libarchive to libarchive/libarchive@27ca5119f
Changes to not yet connected unzip command only.

Obtained from:		libarchive
Libarchive commit:	27ca5119f754d2d359a3cf4ac66c6672260a74d3
2023-07-31 13:09:09 +02:00
Peter Holm 896809e296 stress2: Added killpg(2) scenarios 2023-07-31 09:07:06 +02:00
Doug Moore ac0572e660 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
2023-07-30 15:12:06 -05:00
Mark Johnston 5ad29bc8d4 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
2023-07-30 11:12:35 -04:00
Doug Moore 38f5cb1bfb 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
2023-07-30 01:20:07 -05:00
Martin Matuska 64884e0d4c 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
2023-07-29 23:05:34 +02:00
Stefan Eßer 382af2f8d7 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>
2023-07-29 20:57:32 +02:00
Martin Matuska 70968ea087 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
2023-07-29 20:19:08 +02:00
Dmitry Chagin dbac8474fe vfs: Deleting a doubled inclusion of sys/capsicum.h
Reviewed by:
Differential Revision:	https://reviews.freebsd.org/D41223
MFC after:		1 week
2023-07-29 11:21:58 +03:00
Dmitry Chagin 67116c6905 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
2023-07-29 11:21:35 +03:00
Kevin Bowling 38588749af 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
2023-07-28 18:17:35 -07:00
Michael Tuexen c620788150 sctp: keep sb_acc and sb_ccc in sync
PR:		260116
MFC after:	1 week
2023-07-28 15:16:23 +02:00
Michael Tuexen b279e84a47 sctp: improve consistency
This is simplifying a patch to address PR 260116.

PR:		260116
MFC after:	1 week
2023-07-28 14:36:11 +02:00
Alan Cox 3d7c37425e 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.
2023-07-28 15:13:13 -05:00
Warner Losh e474a8e243 cam: Log errors from passthru commands
Since a30ecd42b8 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
2023-07-28 12:11:21 -06:00
Jessica Clarke 2d01ce7f85 mk: Install bsd.compat.pre.mk
Reported by:	dchagin
Fixes:		5d6cb793d0 ("bsd.compat.mk Extract _ALL_LIBCOMPATS and add related variables")
2023-07-28 17:52:38 +01:00
Doug Moore 2d2bcba7ba 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
2023-07-28 11:39:52 -05:00
Mark Johnston dd24d475d5 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
2023-07-28 09:34:38 -04:00
Andrew Turner 53e1af5a10 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
2023-07-28 12:53:02 +01:00
Andrew Turner 8c111e5b37 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
2023-07-28 12:53:02 +01:00