Commit Graph

19597 Commits

Author SHA1 Message Date
Dag-Erling Smørgrav
0a9b374ecc chown: see also chmod.
Sponsored by:	Klara, Inc.
MFC after:	1 week
2022-08-24 20:21:39 +02:00
Brooks Davis
e9ad2964f5 pkg: Add limited --debug/-d support
Add an internal debug level global:
 - Level 1 (-d) currently does nothing.

 - Level 2 (-d -d) enables libfetch debugging (quite verbose) so it's
   possible to see what pkg is attempting to download without having
   to sniff traffic.

Reviewed by:	debdrup, bapt
Differential Revision:	https://reviews.freebsd.org/D35756
2022-08-24 18:32:09 +01:00
Navdeep Parhar
f6cc21e8e1 cxgbetool: remove unnecessary vertical whitespace.
No functional change.

MFC after:	3 days
2022-08-19 15:38:13 -07:00
John Baldwin
baf753cc19 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
2022-08-19 14:58:55 -07:00
Alexander Motin
3b7935f33b Decode couple arrays in NFIT table.
MFC after:	1 week
2022-08-18 21:30:38 -04:00
Jessica Clarke
c6890399fc makefs: Fix issues building as a cross-tool on non-FreeBSD
This adds missing includes, uses the standard dirent.h rather than the
BSD-specific sys/dirent.h subset (which works on macOS but not Linux)
and works around Linux's lack of st_birthtim.

This allows usr.sbin/makefs to be added to LOCAL_XTOOL_DIRS again on
macOS and Linux so that disk images can be cross-built.

Reviewed by:	markj
Fixes:		240afd8c1f ("makefs: Add ZFS support")
Differential Revision:	https://reviews.freebsd.org/D36135
2022-08-18 02:46:28 +01:00
Jessica Clarke
b0ce7dfc5e makefs: Fix 32-bit issues in ZFS time attributes setting
Currently the code copies a struct timespec's raw bits as a pair of
uint64_t. On 64-bit systems this has the same representation, but on
32-bit issues there are two issues:

1. tv_sec is a time_t which is 32-bit on i386 specifically
2. tv_nsec is a long not a 64-bit integer

On i386, this means the assertion should fire as the size doesn't match.
On other 32-bit systems there are 4 bytes of padding after tv_nsec,
which in practice are probably 0, as this data is ultimately coming from
the kernel, so it's deterministic (though the padding bytes are not
required to be preserved by the compiler, so are strictly unspecified).
However, on 32-bit big-endian systems, the padding bytes are in the
wrong half to be harmless, resulting in the nanoseconds being multiplied
by 2^32.

Fix this all by marshalling via a real uint64_t pair like is done by the
real ZFS_TIME_ENCODE.

Reviewed by:	markj
Fixes:		240afd8c1f ("makefs: Add ZFS support")
Differential Revision:	https://reviews.freebsd.org/D36131
2022-08-18 02:46:27 +01:00
Mark Johnston
8502144d7a makefs tests: Add test cases for handling of multiple staging dirs
Sponsored by:	The FreeBSD Foundation
2022-08-17 17:28:01 -04:00
Mark Johnston
582ce32ff8 makefs tests: Whitespace fixes
Sponsored by:	The FreeBSD Foundation
2022-08-17 17:28:00 -04:00
Mark Johnston
8eca320798 makefs: Handle multiple staging directories when creating ZFS pools
The fsnode tree traversal routines used in ZFS mode assume that all
children of a (directory) fsnode can be accessed using a directory fd
for the parent and the child name.  This is true when populating the
image using an mtree manifest or from a single staging directory, but
doesn't work when multiple staging directories are specified.

Change the traversal routines to use absolute path lookups when an mtree
manifest is not in use.  This isn't ideal, but it's the simplest way to
fix the problem.

Reported by:	imp
Sponsored by:	The FreeBSD Foundation
2022-08-17 17:28:00 -04:00
Jens Schweikhardt
3c405c7e83 Indicate which port gdb.1 and kgdb.1 come from. 2022-08-17 19:13:22 +02:00
John Baldwin
fa46f3704b 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
2022-08-17 10:01:16 -07:00
John Baldwin
e7439f6aeb 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
2022-08-17 10:00:36 -07:00
John Baldwin
bcab868a65 bhyve: Style fix for read/write_config. 2022-08-17 10:00:09 -07:00
Chuck Tuffli
6391be3089 bhyve nvme: Switch to POSIX standard functions
Switch bzero to memset and bcopy to memcpy

Reviewed by:	imp, jhb
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D36215
2022-08-16 17:23:27 -07:00
Brad Davis
17f4ded551 bsdinstall: add variables to allow skipping over some phases of the install
Reviewed by:	allanjude, dteske
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D35357
2022-08-16 15:11:44 -06:00
Emmanuel Vadot
0c6b2a9179 pkgbase: Put accounting utilities in the acct package 2022-08-16 21:15:19 +02:00
Jens Schweikhardt
1f5e2d569d Oops, wlan(4) is not the removed an(4). Restore that paragraph. 2022-08-16 21:08:17 +02:00
Jens Schweikhardt
1b9ad57f7f The wi(4) and an(4) drivers have been removed. Delete dead xrefs. 2022-08-16 21:05:01 +02:00
Jens Schweikhardt
e1ae2a285a Indicate the port where the referenced man pages come from. 2022-08-16 20:57:30 +02:00
Mark Johnston
d06bf11c06 bhyve: Sprinkle const qualifiers where appropriate
No functional change intended.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-08-16 14:21:44 -04:00
Mark Johnston
37045dfa89 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.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-08-16 14:21:44 -04:00
Mark Johnston
75ce327a2c bhyve: Use "void" instead of empty parameter lists
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-08-16 14:21:44 -04:00
Mark Johnston
c4d26f027b makefs: Style
Reported by:	rpokala
Fixes:		187084dddd ("makefs: Align the block buffer used in ZFS mode")
Sponsored by:	The FreeBSD Foundation
2022-08-16 14:21:44 -04:00
Chuck Tuffli
715f82e4f5 bhyve nvme: Support minimal Controller list
Controllers must support the Identify Controller list if they support
Namespace Management. But the UNH NVMe tests use this command regardless
of whether the device under test supports Namespace Management.

This implementation returns an empty Controller list (i.e., Number of
Identifiers is zero).

Fixes UNH Test 1.1.2

Reviewed by:	jhb
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D36193
2022-08-16 09:15:53 -07:00
Chuck Tuffli
ec0efe34dd bhyve nvme: Fix reported SANICAP value
The NVMe specification only allows Controllers compliant with the
revision 1.3 and earlier specification to report a value of 0x0 in the
No-Deallocate Modifies Media After Sanitize (NODMMAS) field.

For our revision 1.4 Controller, report that media is not modified after
Sanitize as the implementation does not implement Sanitize.

Fixes UNH Test 1.1.2

Reviewed by:	jhb
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D36192
2022-08-16 09:14:43 -07:00
Mark Johnston
0726cde8ea makefs tests: Re-enable the ZFS snapshot test
This reverts commit 35b587464a.

PR:		265849
Sponsored by:	The FreeBSD Foundation
2022-08-16 11:02:52 -04:00
Mark Johnston
4f816f5b11 makefs: Fix space accounting for the root DSL directory
Space used by the MOS is summed after all on-disk data structures are
finalized, so the MOS DSL directory represents a special case when
counting bytes used for each directory.  The DSL layer failed to update
the MOS DSL directory's parent, the root directory, accordingly, so the
root directory reported less space used than was used in reality.  Be
careful to update the root directory after the MOS is finalized.

PR:		265849
Sponsored by:	The FreeBSD Foundation
2022-08-16 11:02:51 -04:00
Mark Johnston
187084dddd makefs: Align the block buffer used in ZFS mode
For some dnode types, particularly ZAPs, we want the buffer to have
uint64_t alignment.

Sponsored by:	The FreeBSD Foundation
2022-08-16 11:02:51 -04:00
Mateusz Piotrowski
f9572577cf exports.5: Clean up EXAMPLES and STANDARDS
There was a missing sentence in the description of the second mount
entry in the example. Fix that and some other bits in the EXAMPLES
section.

Also, make the STANDARDS section a bit more readable.

MFC after:	1 week
Sponsored by:	Klara Inc.
2022-08-16 15:04:44 +02:00
Jens Schweikhardt
20f68c5f2d Indicate that xrefs to *roff,tbl,eqn et al are found in ports/textproc/groff. 2022-08-15 22:15:18 +02:00
Mark Johnston
35b587464a makefs tests: Skip a ZFS regression test in CI
It triggers panics after the latest OpenZFS import.

PR:		265849
2022-08-14 21:37:41 -04:00
Wanpeng Qian
9f678cfcb4 bhyve nvme: Fix firmware read only initialization
Summary:
Code was using the mask value without the shift.

Test Plan: Within FreeBSD/Linux guest, Identify NVMe controller to check the result.

Reviewed by:	chuck, imp
MFC after:	2 weeks
Signed-off-by:	Wanpeng Qian <wanpengqian@gmail.com>
Differential Revision: https://reviews.freebsd.org/D32659
2022-08-14 09:59:36 -07:00
WanpengQian
3cae10048d bhyve nvme: Fix Active Firmware Info
Summary:
Currently Active Firmware Info is not initialized.

Fix is to initialize the Active Firmware Info to Slot 1.

Test Plan: Within FreeBSD/Linux guests, show the Firmware Logpage to confirm.

Reviewed By:	chuck
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D32658
2022-08-14 09:59:36 -07:00
WanpengQian
eae0210cdd bhyve: Fix Number of Power States Supported value
Summary:
Set Number of Power States Supported to indicate 1 power state. Keep the
Power State Descriptor data structures as zero to indicate "Not
reported".

Test Plan:
Within FreeBSD/Linux guests, list the number of power states and check
the Max Power value.

Reviewed By:	markj, chuck
MFC after:	2 weeks
Signed-off-by:	Wanpeng Qian <wanpengqian@gmail.com>
Differential Revision: https://reviews.freebsd.org/D32657
2022-08-14 09:59:36 -07:00
Jens Schweikhardt
016aeb7ca0 The fdformat man page is in section 8 (not 1). 2022-08-14 18:14:52 +02:00
Mark Johnston
b6ecef28bf 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
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36119
2022-08-14 11:59:01 -04:00
Mark Johnston
af86d12c80 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
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36118
2022-08-14 11:56:33 -04:00
Chuck Tuffli
7376c08cc6 bhyve nvme: Fix uninitialized pointer
The Dataset Management code could free an uninitialized pointer if the
device doesn't support the Dataset Management command.

PR:		264548
Reported by:	Robert Morris <rtm@lcs.mit.edu>
2022-08-14 07:53:22 -07:00
Chuck Tuffli
d7d1becad4 bhyve nvme: Fix Controller init error cases
Fuzzing of bhyve uncovered an assertion failure in the NVMe emulation.
Investigation uncovered several corner cases the code did not handle.
This change handles several Controller initialization errors, including
 - bad AQ sizes
 - bad AQ vm_map_gpa
 - doorbell writes prior to RDY
 - doorbell writes to uninitialized queue
 - CSTS.RDY if CFS set

PR:		256317,256319,256320,256322
Reported by:	Cheolwoo Myung <cwmyung@snu.ac.kr>
Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D35453
2022-08-14 07:47:34 -07:00
Chuck Tuffli
3d3678627c bhyve nvme: Check return value of mapped memory
Fuzzing of bhyve using hyfuzz discovered a way to cause a segmentation
fault in the NVMe emulation. If a guest specifies a physical address in
either the PRP1 or PRP2 field of a command that cannot be mapped from
guest to host, the function paddr_guest2host() returns a NULL pointer.
The NVMe emulation did not check for this error case, which allowed for
the segmentation fault to occur.

Fix is to check for a return value of NULL and indicate an error back to
the guest (Data Transfer error). While in the area, slightly refactor
the write/read blockif function to use a common error exit path.

PR:		256321
Reported by:	Cheolwoo Myung <cwmyung@snu.ac.kr>
Reviewed by:	imp, jhb
Differential Revision:	https://reviews.freebsd.org/D35452
2022-08-14 07:45:21 -07:00
Jens Schweikhardt
4ee44ffcca Indicate that kgdb.1 is from ports/devel/gdb. 2022-08-14 15:17:29 +02:00
Jens Schweikhardt
9356efa8c8 Indicate that X(7) cross refs are satisfied by ports/x11/xorg-docs. 2022-08-14 12:01:30 +02:00
Jens Schweikhardt
7c20397b72 In man page cross refs to sudo, indicate it comes from ports/security/sudo. 2022-08-14 11:44:43 +02:00
Chuck Tuffli
88951aaaee bhyve nvme: Fix out-of-bound IOV array access
Summary:
NVMe operations indicate the memory region(s) associated with a command
via physical region pages (PRPs). Since each PRP has a fixed size,
contiguous memory regions larger than the PRP size require multiple PRP
entries.

Instead of issuing a blockif call for each PRP, the NVMe emulation
concatenates multiple contiguous PRP entries into a single blockif
request. The test for contiguous regions has a bug such that it
mistakenly treats an initial PRP address of zero as a contiguous range
and concatenates it with the previous. But because there is no previous
IOV, the concatenation code corrupts the IO request structure and leads
to a segmentation fault when the blockif request completes.

Fix is to test for the existence of a previous range before trying to
concatenate the current range with the previous one.

While in the area, rename pci_nvme_append_iov_req()'s lba parameter to
offset to match its usage.

PR:             264177
Reported by:    Robert Morris <rtm@lcs.mit.edu>
Reviewed by:	jhb
MFC after:      2 weeks
Differential Revision:	https://reviews.freebsd.org/D35328
2022-08-13 12:16:02 -07:00
Maxim Sobolev
6b3ad1d737 When -u option is used also set USER, HOME and SHELL variables.
This is consistent with what other uid-morphing utilities
do, i.e. jexec(1), su(1) etc.

MFC after:      2 weeks
Reviewed by:    gbe
Differential Revision:  https://reviews.freebsd.org/D36148
2022-08-12 10:07:56 -07:00
Alexander Motin
5244006fea ctladm: Fix typo in command line help.
MFC after:	1 week
2022-08-11 16:53:50 -04:00
Mark Johnston
78d7704b7c makefs: Fix a memory leak in fs_layout_one()
Check the canmount property before building the mountpoint string.

Reported by:	Coverity
Fixes:		240afd8c1f ("makefs: Add ZFS support")
Sponsored by:	The FreeBSD Foundation
2022-08-11 10:18:13 -04:00
Mark Johnston
e225983737 makefs: Fix memory leaks in dsl_dir_finalize_props()
nvstring_get() returns a copy of the string, not a pointer into the
nvlist's internal buffer.

Reported by:	Coverity
Fixes:		240afd8c1f ("makefs: Add ZFS support")
Sponsored by:	The FreeBSD Foundation
2022-08-11 10:18:06 -04:00
Jessica Clarke
febca0e643 etcupdate: Add a -N flag to perform a NO_ROOT build
This is in preparation for including an etcupdate tree when performing a
-DNO_ROOT release image build. Although -DNO_ROOT can be passed via -M,
to be useful we need to mangle the resulting METALOG to mirror the
various cleanups to the tree that are done after the build (removing
generated files, empty files and empty directories), so etcupdate needs
its own flag.

Reviewed by:	jhb, pauamma
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D35857
2022-08-09 22:57:47 +01:00