Commit graph

271364 commits

Author SHA1 Message Date
Konstantin Belousov
066b09c2b1 libc: split scandir() into scandir_dirp() and proper scandir()
(cherry picked from commit cb6e97f4da)
2022-08-31 04:20:28 +03:00
Konstantin Belousov
628b801a8d Link scandir_b(3) to scandir(3)
(cherry picked from commit ea448a0a43)
2022-08-31 04:20:28 +03:00
Konstantin Belousov
c5b0a30c46 scandir.3: Use .Fo instead of .Fn for long args
(cherry picked from commit aa5e19a9b3)
2022-08-31 04:20:28 +03:00
Konstantin Belousov
1ba0642c01 fork_exit(): style comment
(cherry picked from commit fce3b1c327)
2022-08-31 04:20:28 +03:00
Konstantin Belousov
6a959c68c9 x86: improve machdep.uprintf_signal
(cherry picked from commit ff32a05554)
2022-08-31 04:20:28 +03:00
Konstantin Belousov
d96dc612b3 x86: print trap name in addition of trap number
(cherry picked from commit 01a33b2af5)
2022-08-31 04:20:28 +03:00
Konstantin Belousov
49c6968c12 i386: print all GPRs, PSL, and CR3 on double fault
(cherry picked from commit 0f906b30e6)
2022-08-31 04:20:27 +03:00
Konstantin Belousov
bf71e2e267 i386: simplify flow control in irettraps
(cherry picked from commit 54e1546e09)
2022-08-31 04:20:27 +03:00
Konstantin Belousov
79ceb5107b i386 doreti: stop saving/restoring %ecx around calls into C
(cherry picked from commit e8b2980e4a)
2022-08-31 04:20:27 +03:00
Konstantin Belousov
cd304fdbe9 i386: do not allow userspace to set tf_trapno on sigreturn(2)
PR:	265889

(cherry picked from commit dc4a2d1d0e)
2022-08-31 04:20:27 +03:00
Konstantin Belousov
3416c2f3c5 irettraps: i386 does not push %ss/%esp when exception does not switch rings
(cherry picked from commit a03e4799e7)
2022-08-31 04:20:27 +03:00
Konstantin Belousov
836fcf8461 i386 copyout_fast: improve detection of a fault on accessing userspace
(cherry picked from commit 95f773e594)
2022-08-31 04:20:27 +03:00
Cy Schubert
01c6fb9da2 sqlite3: Vendor import of sqlite3 3.39.2
Changes at https://www.sqlite.org/releaselog/3_39_2.html.

Security:       CVE-2022-35737
Obtained from:  https://www.sqlite.org/2022/sqlite-autoconf-3390200.tar.gz
MFC after:      immediately

Merge commit '1545dd7d6cc54bdfca9bc9f74c42745b514b60c9' into sqlite3/main3

(cherry picked from commit 2a63683b5d)
2022-08-30 15:57:55 -07:00
Gordon Bergling
3cc226cd9c bhnd(4): Correct a typo in a source code comment
- s/in he/in the/

(cherry picked from commit ce99e4fa44)
2022-08-30 14:07:39 +02:00
Mark Johnston
b8e33d1abe bhyve: Address uses of uninitialized variables in pci_nvme.c
The debug print in nvme_opc_get_log_page() would print an uninitialized
local variable.

In nvme_opc_write_read(), a failed LBA bounds check would cause
pci_nvme_stats_write_read_update() to be called with an uninitialized
variable as a parameter.  Although the parameter is unused when the
check fails (and so status != 0), LLVM 14 emits some bogus machine code
in this path, which happens to result in a segfault when it gets
executed.

PR:		265749
Reviewed by:	chuck, emaste
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit b6ecef28bf)
2022-08-29 11:01:01 -04:00
Mark Johnston
e6b7a23d7f bhyve: Address -Wunused* warnings in pci_nvme.c
Currently these are not reported because bhyve is compiled with WARNS=2.
Let's start taking small steps towards enabling more warnings.

No functional change intended.

Reviewed by:	chuck, imp, emaste
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit af86d12c80)
2022-08-29 11:00:51 -04:00
Hans Petter Selasky
eacf0dba23 ibcore: Add support for RDMA/RoCE using VLAN(4) devices.
Classify VLAN devices as ethernet in rdma_copy_addr().
This fixes the following error message:

rdma_bind_addr: No such file or directory

Submitted by:	Piotr Kubaj <pkubaj@FreeBSD.org>
Differential Revision:	https://reviews.freebsd.org/D36120
Sponsored by:	NVIDIA Networking

(cherry picked from commit 57af517ac4)
2022-08-29 14:03:57 +02:00
Hans Petter Selasky
d02aaf5325 uftdi(4): Add new USB ID.
PR:		265514
Sponsored by:	NVIDIA Networking

(cherry picked from commit 9f35dbfdc6)
2022-08-29 14:03:49 +02:00
Ed Maste
ff6ab85fc9 gpio: mark INVARIANTS variables as __diagused
Fixes INVARIANTS build with Clang 15, which previously failed due to
set-but-not-used variable warnings.

Reviewed by:	dim
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36097

(cherry picked from commit 7dc4d5118c)
2022-08-28 21:04:31 -04:00
Ed Maste
9f45a241fc acpi: mark INVARIANTS variables as __diagused
Fixes INVARIANTS build with Clang 15, which previously failed due to
set-but-not-used variable warnings.

Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36096

(cherry picked from commit 0fd8d3589a)
2022-08-28 21:04:19 -04:00
Ed Maste
6aa98b826f opencrypto: mark INVARIANTS variables as __diagused
Fixes INVARIANTS build with Clang 15, which previously failed due to
set-but-not-used variable warnings.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 3471fcf3a4)
2022-08-28 21:03:48 -04:00
Ed Maste
7468304f7b pf: Reduce diffs against OpenBSD in pf_if.c
Use memset instead of bzero, memcpy instead of bcopy, and add some
optional {}s.

Reviewed by:	kp
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36267

(cherry picked from commit 6b598e263b)
2022-08-28 19:16:19 -04:00
Konstantin Belousov
e59d99e6e6 amd64: update comment for casueword/casueword32, mentioning return value 1
(cherry picked from commit c1a0ab5ec5)
2022-08-28 03:41:23 +03:00
Doug Moore
5fbc2eb92c iommu_gas: avoid pointless augmentation
iommu_gas_augment_entry updates a map entry element. Invoked as
RB_AUGMENT in RB tree code, it is applied from the point where the
tree is modified, all the way up to the root, and is also applied when
rotation moves a node down in the tree.

There are several opportunities to invoke it less. The automatic
augmentation with every rotation is a mistake.  Delaying these
augmentations until RB_INSERT_COLOR or RB_REMOVE_COLOR are finishing
allows the augmentation code to be duplicated less, to work when there
is less register pressure, and to be skipped when conditions allow it:

    In the double-rotate case of RB_INSERT_COLOR, augmentation after
    the first rotation is not necessary when the element being moved
    down the tree becomes a leaf. It was in the tree, and was a leaf,
    before the RB_INSERT operation began, and so recomputing
    augmentation for it would do nothing.

    In the final (possibly only) rotation of RB_REMOVE_COLOR, both the
    elements - the one moving up and the one moving down - end up in
    the path from the deletion point to the tree root, so there's no
    need to augment either of them immediately.

    In RB_REMOVE, when the right child of the removed node replaces it
    in tree, it began with a null left child. Replacement creates a
    non-NULL left child, and then rotation may put a NULL node back in
    that place. If that happens, start the augmenting-up-to-root with
    the parent of that node, since augmentation would do nothing.

Adjust to avoid these needless augmentations.

Reviewed by:	alc
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D35502

(cherry picked from commit 7f2ec173e4)
2022-08-27 16:05:50 -05:00
Alexander Motin
9644bc4a11 Decode couple arrays in NFIT table.
MFC after:	1 week

(cherry picked from commit 3b7935f33b)
2022-08-25 22:49:39 -04:00
John Baldwin
c1434fd2de bhyve: Validate host PAs used to map passthrough BARs.
Reject attempts to map host physical address ranges that are not
subsets of a passthrough device's BAR into a guest.

Reviewed by:	markj, emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36238

(cherry picked from commit c94f30ea85)
2022-08-25 09:38:56 -07:00
John Baldwin
9a647d96eb pci: Add helper routines to iterate over a device's BARs.
Reviewed by:	imp, markj, emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36237

(cherry picked from commit 16bedf532c)
2022-08-25 09:38:49 -07:00
John Baldwin
e5217bedc9 bhyve: Support other schemes for naming pass-through devices.
Permit naming pass through devices using the syntax accepted by
pciconf (pci[<domain>:]<bus>:<slot>:<func>) as well as by device name
(e.g. "ppt0").

While here, fix an error in the manpage that had the bus and slot
arguments for the original /-delimited scheme swapped.

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

(cherry picked from commit baf753cc19)
2022-08-25 09:38:33 -07:00
John Baldwin
ff5d46d7f9 bhyve e1000: Skip packets with a small header.
Certain operations such as checksum insertion and VLAN insertion
require the device model to rewrite the packet header.  The first step
in rewriting the packet header is to copy the existing packet header
from the source packet.  This copy is done by copying data from an
iovec array that corresponds to the S/G entries described by transmit
descriptors.  However, if the total packet length is smaller than the
headers that need to be copied as the initial template, this copy can
overflow the iovec array and use garbage values as the source pointer
to memcpy.  The PR used a single descriptor with a length of 0 in its
PoC.

To fix, track the total packet length and drop requests to transmit
packets whose payload is smaller than the required header length.

While here, fix another issue where the final descriptor could have an
invalid length (too short) that could underflow 'len' when stripping
the checksum.  Skip those requests instead, too.

PR:		264372
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Reviewed by:	grehan, markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36182

(cherry picked from commit fa46f3704b)
2022-08-25 09:37:38 -07:00
Robert Wing
574f636503 bhyve: fix -Wunused-but-set-variable warning
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D33306

(cherry picked from commit 2616ee608c)
2022-08-25 09:36:56 -07:00
John Baldwin
ecfbefc91e bhyve xhci: Cache the value of MaxPStreams when initializing an endpoint.
This avoids type confusion where a malicious guest could rewrite the
MaxPStreams field in an endpoint context after the endpoint was
initialized causing the device model to interpret a guest provided
address (stored in ep_ringaddr of the "software" endpoint state) as a
bhyve host process address (ep_sctx_trbs).  It also prevents a malicious
guest from triggering overflows of ep_sctx_trbs[] by increasing the
number of streams after the endpoint has been initialized.

Rather than re-reading the MaxPStreams value out of the endpoint context
in guest memory on subsequent operations, cache the value in the software
endpoint state.  Possibly the device model should raise errors if the
value of MaxPStreams changes while an endpoint is running.  This approach
simply ignores any such changes by the guest.

PR:		264294, 264347
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Reviewed by:	markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36181

(cherry picked from commit e7439f6aeb)
2022-08-25 09:35:12 -07:00
John Baldwin
a88b3991e2 bhyve: Style fix for read/write_config.
(cherry picked from commit bcab868a65)
2022-08-25 09:35:02 -07:00
John Baldwin
1a26ebd6d5 ktls_test: Add a require_toe option similar to require_ifnet.
This skips tests that send and receive records that do not use TOE TLS.

Sponsored by:	Chelsio Communications

(cherry picked from commit cc13c98302)
2022-08-25 09:33:57 -07:00
John Baldwin
39b724b727 cxgbe TOE TLS: Fix handling of unusual record types.
This doesn't matter for real traffic but fixes failures in the KTLS
unit tests that use unusual record types.

Sponsored by:	Chelsio Communications

(cherry picked from commit 782db2881b)
2022-08-25 09:33:04 -07:00
John Baldwin
7252457be7 gcore: Trim stale bits from elf32core.c.
These should have been removed in
d95657a1a7.

Reviewed by:	markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D35748

(cherry picked from commit a6c3e5fa39)
2022-08-25 09:31:03 -07:00
John Baldwin
cb85a1815f cxgbei: Adjust the calculation for the maximum ISO payload.
Round down the maximim ISO payload by the current MSS.  Otherwise the
round up by MSS when calculating the 16-bit maximum payload len passed
along in the FLOWC work request can overflow.

Discussed with:	np
Sponsored by:	Chelsio Communications

(cherry picked from commit 8020c05683)
2022-08-25 09:30:09 -07:00
John Baldwin
84fc080266 cxgbe: Deactivate upper layer drivers (like TOE) during detach.
Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D35237

(cherry picked from commit 12b37f8f9c)
2022-08-25 09:29:22 -07:00
Piotr Pawel Stefaniak
6480563d06 sh: accept fc options grouped behind one '-'
As per Utility Syntax Guidelines, accept both forms: -l -n and -ln.

To do that, anticipate the source string for the next option that will
be parsed by nextopt(). It's not always *argptr, sometimes it is
nextopt_optptr.

To simplify the check for not_fcnumber, slightly modify nextopt() to
always nullify nextopt_optptr in cases where it would have been set
to point to a NUL character.

(cherry picked from commit 755a1be6d0)
2022-08-24 20:21:23 +02:00
Piotr Pawel Stefaniak
ead0fe475c sh: nullify ENV in tests
This is to avoid loading .shrc which may contain commands that would
result in output different than expected.

(cherry picked from commit a142345641)
2022-08-24 20:21:08 +02:00
Xin LI
09f390a215 arc4random(3): Reduce diff with OpenBSD.
The main change was v1.57 by djm@:

  Randomise the rekey interval a little. Previously, the chacha20
  instance would be rekeyed every 1.6MB. This makes it happen at a
  random point somewhere in the 1-2MB range.

Reviewed by:	csprng (markm, cem)
Differential Revision: https://reviews.freebsd.org/D36088

(cherry picked from commit e9a2e4d1d2)
2022-08-23 22:11:09 -07:00
Mark Johnston
b66ab4c8b7 tests: Handle platforms with MAXPAGESIZES < 2
Reported by:	Jenkins
Fixes:		1dfa8b73f6 ("tests: Add more shared shadow regression tests")

(cherry picked from commit 4b8feb5d61)
2022-08-23 19:59:34 -04:00
Eric van Gyzen
ff481f2202 Fix shared_shadow_inval_test when superpages are disabled
In that case, there is only one page size.

Reviewed by:	kib
Sponsored by:	Dell EMC Isilon

(cherry picked from commit 3d268c19ef)
2022-08-23 16:15:49 -04:00
Mark Johnston
fdb52057a4 tests: Add more shared shadow regression tests
The new tests exercise simulated COW that occurs when the protections on
a wired, copy-on-write mapping are changed from read-only to read-write.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 1dfa8b73f6)
2022-08-23 16:15:40 -04:00
Mark Johnston
1579c6e2dc bhyve: Sprinkle const qualifiers where appropriate
No functional change intended.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d06bf11c06)
2022-08-23 16:06:19 -04:00
Mark Johnston
976ed044fb bhyve: Mark variables and functions as static where appropriate
Mark them const as well when it makes sense to do so.  No functional
change intended.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 37045dfa89)
2022-08-23 16:06:14 -04:00
Mark Johnston
974a015fb0 bhyve: Use "void" instead of empty parameter lists
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 75ce327a2c)
2022-08-23 16:05:29 -04:00
Mark Johnston
761d4d350d dtrace/amd64: Implement emulation of call instructions
Here, the provider is responsible for updating the trapframe to redirect
control flow and for computing the return address.  Once software-saved
registers are restored, the emulation shifts the remaining context down
on the stack to make space for the return address, then copies the
address provided by the invop handler.  dtrace_invop() is modified to
allocate temporary storage space on the stack for use by the provider to
return the return address.

This is to support a new provider for amd64 which can instrument
arbitrary instructions, not just function entry and exit instructions as
FBT does.

In collaboration with:	christos
Sponsored by:	Google, Inc. (GSoC 2022)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 3ba8e9dc4a)
2022-08-23 16:05:07 -04:00
Mark Johnston
edf2d935b5 fbt/x86: Extract arg1 for return probes from the trapframe
dtrace invop handlers have access to the whole trapframe, just use that
to extract %rax/%eax for return probes instead of relying on an
additional parameter to the handler.  No functional change intended.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit a7aa3d4d75)
2022-08-23 16:03:02 -04:00
Konstantin Belousov
926b4724ea reap_kill_proc_locked(): remove outdated part of the comment
(cherry picked from commit 5c78797e42)
2022-08-22 16:37:10 +03:00
Konstantin Belousov
d521c27c34 exit1(): update comment about thread_single()
(cherry picked from commit 30b16a6bcf)
2022-08-22 16:37:10 +03:00