Commit graph

19871 commits

Author SHA1 Message Date
Kyle Evans 6b23df1a39 bhyveload: add CAP_SEEK to our dirfd rights
In the case of hostbase_fd, this is infact a bug fix; we have a seek
callback that the host: filesystem may use in loader, and we really
don't have a good excuse to break it.

bootfd-derived fds will only be used with fdlopen(3) and rtld doesn't
seem to need pread / lseek at all for it today, but there's no reason to
break if it finds a good reason to later.

Suggested by:	markj

(cherry picked from commit cef5e56f3f)
2024-01-22 11:17:53 -06:00
Kyle Evans 979c1cdb40 bhyveload: make error printing consistent
Previously we used a mix of perror(3) + exit(3) and err(3); standardize
on the latter instead.  This does remove one free() in an error path,
because we're decidedly leaking a lot more than just the loader name
there (loader handle, vcpu, vmctx...) anyways.

Reviewed by:	markj

(cherry picked from commit a4a838a31a)
2024-01-22 11:17:52 -06:00
Kyle Evans 482ab31c64 bhyveload: support guest rebooting from the loader
userboot has a EXIT_REBOOT code that it uses when the 'reboot' loader
command is executed.  Use that and longjmp back to reinit the VM
entirely with a reboot request.  This fixes the 'reboot' option in the
loader menu to actually reboot rather than shutdown the VM.

The JMP_* constants are introduced to keep track of why we're doing a
longjmp, though they aren't currently used.  We'll notably still do a
complete reload of the interpreter to give the rebooted VM that new
loader smell.  It just seemed forward thinking to just keep track of the
different setjmp points.

While we're here, we don't actually need to keep the fd we passed to
fdlopen(3), so let's avoid leaking it.

Reviewed by:	markj

(cherry picked from commit 24cd5c26fe)
2024-01-22 11:17:52 -06:00
Kyle Evans 20e06202f1 bhyveload: limit rights on the dirfds we create
In neither case do we need write access to the directories we're working
with; userboot doesn't support fo_write on the host device, and the
bootfd is only ever needed for loader loading.

This improves on 8bf0882e18 ("bhyveload: enter capability mode [...]")
so that arbitrary code in the loader can't open writable fds to either
of the directories we need to maintain access to.

Reviewed by:	imp

(cherry picked from commit c067be72e8)
(cherry picked from commit f9b17005bf)
2024-01-22 11:17:52 -06:00
Kyle Evans c6989de2e7 bhyveload: enter capability mode after we setup the vcpu
Reviewed by:	allanjude (earlier version), emaste, markj

(cherry picked from commit 8bf0882e18)
2024-01-22 11:17:52 -06:00
Kyle Evans b7390f6f84 bhyveload: hold /boot and do relative lookups for the loader
The next change will push bhyveload into capability mode right after we
allocate vcpu state, before we've setup or entered the loader, to limit
the surface area that a rogue loader script can touch.

With an explicit -l loader, we don't need to preopen /boot because
changing interpreters isn't allowed.  We'll just dlopen() entirely in
advance in that case to eliminate some complexity.

Reviewed by:	allanjude (earlier version), markj

(cherry picked from commit bf7c4fcbbb)
(cherry picked from commit 67082f077f)
2024-01-22 11:17:48 -06:00
Stéphane Rochoy d8d0ecd973 makefs: Handle missing link keyword in mtree spec
PR:		241178
Reviewed by:	emaste
Pull Request:	https://github.com/freebsd/freebsd-src/pull/850

(cherry picked from commit d26c1a0f8b)
(cherry picked from commit be31bd5989)
2024-01-22 09:28:57 -05:00
Alan Somers c2ec8038a7 Fix multiple bugs with ctld's UCL parsing
* Don't segfault when parsing a misformatted auth-group section
* If the config file specifies a chap section within a target but no
  auth-group, create a new anonymous auth-group.  That matches the
  behavior with non-UCL config files.
* Protect some potential segfaults with assertions

PR:		274380
Sponsored by:	Axcient
Reviewed by:	jhb
Differential Revision: https://reviews.freebsd.org/D43198

(cherry picked from commit 2391e536c0)
2024-01-19 13:21:40 -07:00
John Baldwin 96d7c770ef ctladm: Fix a typo and add a FALLTHROUGH annotation
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D42934

(cherry picked from commit e8d8354834)
2024-01-18 14:41:30 -08:00
John Baldwin 0827fecb4a cltadm.8: Correct documentation of -r arg to port command
-r does not take a target port argument

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

(cherry picked from commit f12d378f4f)
2024-01-18 14:41:13 -08:00
John Baldwin cad6775d96 kldxref: Workaround incorrect PT_DYNAMIC in existing powerpc kernels
Existing powerpc kernels include additional sections beyond .dynamic
in the PT_DYNAMIC segment.  Relax the requirement for an exact size
match of the section and segment for PowerPC files as a workaround.

Reported by:	jrtc27
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43123

(cherry picked from commit 6631e2f9b4)
2024-01-18 13:32:10 -08:00
John Baldwin fb4c8b2d89 kldxref: Correct contract number in license ACK
Reviewed by:	brooks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43371

(cherry picked from commit 78258ee013)
2024-01-18 13:32:04 -08:00
Alex Richardson b13e59714f kldxref: fix bootstrapping on Linux with Clang 16
The glibc fts_open() callback type does not have the second const
qualifier and it appears that Clang 16 errors by default for mismatched
function pointer types. Add an ifdef to handle this case.

(cherry picked from commit 30887c7d48)
2024-01-18 13:31:52 -08:00
John Baldwin 319092aaac kldxref: Appease a Coverity warning
While parsing .dynamic, nsym is set when parsing the symbol table from
.dynsym.  That parsing also sets ef->ef_symtab to a non-NULL value.
The value of nsym isn't validated until after a check for
ef->ef_symtab being NULL, so nsym always has a valid value when it is
read.  However, that chain of events is a bit much for static analysis
to follow, so initialize nsym to 0 before parsing sections to quiet
the warning.

Reported by:	Coverity Scan
CID:		1532339
Sponsored by:	DARPA

(cherry picked from commit d281fece43)
2024-01-18 13:31:39 -08:00
John Baldwin 21dec6c48f kldxref: Simplify handling of ELF object files
Unlike the backend for ELF DSOs, the object file backend allocated an
aligned chunk of memory and read all of the in-memory sections from
the file into this memory even though most of the file contents were
never used.  Instead, just track a set of virtual addresses (based at
0) that each loaded section would be loaded at and only read the
necessary bits from the backing file when needed.

Reviewed by:	imp
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43126

(cherry picked from commit 0d557cdf6f)
2024-01-18 13:31:32 -08:00
John Baldwin ea71737682 kldxref: Simplify elf_read_raw_data
Use pread as a valid offset is always passed now.  Originally the DSO
code read the .hash section in two separate requests and relied on the
implicit offset for the second read, but now the hash table is fetched
in a single call.

Reviewed by:	imp
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43125

(cherry picked from commit ed96fd7fc6)
2024-01-18 13:31:22 -08:00
John Baldwin f7e181afba kldxref: Tidy error handling for invalid addresses
- Don't print an offset value that's always zero.

- ef_get_offset can't return -1.

Reviewed by:	imp
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43124

(cherry picked from commit 6d46e2e0a7)
2024-01-18 13:31:14 -08:00
Jessica Clarke 1dde3d8d7b kldxref: Reduce divergence between per-architecture files
Note that relbase is always 0 for DSOs so its omission for __KLD_SHARED
architectures was not a bug in practice.

Whilst here, also parenthesise the dest offset for where to avoid
transiently creating an out-of-bounds pointer, which is UB (though even
on CHERI architectures, where capability bounds compression can result
in that creating invalid capabilities that will trap on dereference,
optimisation will reassociate to the correct form in practice and thus
work just fine).

(cherry picked from commit 2a622f14e8)
2024-01-18 13:31:00 -08:00
Jessica Clarke 09371fa662 kldxref: Implement aarch64 R_AARCH64_AB64 relocation
Doing nothing seems to be sufficient but is strange, inconsistent with
other architectures, and not necessary when it's easy to support
properly.

(cherry picked from commit aaba1490ec)
2024-01-18 13:30:49 -08:00
Jessica Clarke 8b3c539a20 kldxref: Fix MIPS Elf_Rel addend computation
Fixes:	0299afdff1 ("kldxref: Make use of libelf to be a portable cross tool")
(cherry picked from commit ae7925cafe)
2024-01-18 13:30:40 -08:00
Jessica Clarke 3ab67201a2 kldxref: Add arm support
(cherry picked from commit c88f7d8fb5)
2024-01-18 13:30:32 -08:00
Jessica Clarke 8db082ca31 kldxref: Put each ef_CPUARCH.c on its own line to prepare for ef_arm.c
Adding ef_arm.c would push this past 80 columns, so prepare for its
addition by splitting the line up.

(cherry picked from commit ada9d12f95)
2024-01-18 13:30:23 -08:00
Jessica Clarke e33e621428 kldxref: Fix for 32-bit powerpc
R_PPC_RELATIVE lost its 32-bit handling in the libelf conversion.

Reported by:	bapt
Fixes:		0299afdff1 ("kldxref: Make use of libelf to be a portable cross tool")

(cherry picked from commit d1ce87ae0d)
2024-01-18 13:30:15 -08:00
John Baldwin d18406a120 kldxref: Cast rtype to int in ef_aarch64.c in warning
This is consistent with the other architecture-specific relocation
handlers.

Reported by:	mjg
Sponsored by:	DARPA

(cherry picked from commit 894f3f48c3)
2024-01-18 13:30:06 -08:00
Baptiste Daroussin a77717659b kldxref: fix build on 32 bits arches
(cherry picked from commit 97530894fc)
2024-01-18 13:29:42 -08:00
John Baldwin 8054480839 kldxref: Make use of libelf to be a portable cross tool
This allows kldxref to operate on kernel objects from any
architecture, not just the native architecture.  In particular, this
will permit generating linker.hints files as part of a cross-arch
release build.

- elf.c is a new file that includes various wrappers around libelf
  including routines to read ELF data structures such as program and
  section headers and ELF relocations into the "generic" forms
  described in <gelf.h>.  This file also provides routines for
  converting a linker set into an array of addresses (GElf_Addr)
  as well as reading architecture-specific mod_* structures and
  converting them into "generic" Gmod_* forms where pointers are
  replaced with addresses.

- The various architecture-specific reloc handlers now use GElf_*
  types for most values (including GElf_Rel and GElf_Rela for
  relocation structures) and use routines from <sys/endian.h> to read
  and write target values.  A new linker set matches reloc handlers
  to specific ELF (class, encoding, machine) tuples.

- The bits of kldxref.c that write out linker.hints now use the
  encoding (ELFDATA2[LM]SB) of the first file encountered in a
  directory to set the endianness of the output file.  Input files
  with a different architecture in the same directory are skipped with
  a warning.  In addition, the initial version record for the file
  must be deferred until the first record is finished since the
  architecture of the output file is not known until then.

- Various places that used 'sizeof(void *)' throughout now use
  'elf_pointer_size()' to determine the size of a pointer in the
  target architecture.

Tested by:	amd64 binary on both amd64 and i386 /boot/kernel
Reviewed by:	imp
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42966

(cherry picked from commit 0299afdff1)
2024-01-18 13:29:12 -08:00
John Baldwin b2cc5745dc kldxref: Refactor PNP entry parsing, no functional change
- Add a free_pnp_list to complement parse_pnp_list.  Add freeing
  of 'new_desc' which was previously leaked.

- Move body of loop that checked a single pnp list element against a
  table entry into a parse_pnp_entry function to reduce indentation
  and split parse_entry into a smaller function.

- Similarly, split out a record_pnp_info function from parse_entry
  which builds the pnp_list and walks a table.

Reviewed by:	imp
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42965

(cherry picked from commit c40fa3dc98)
2024-01-18 13:24:53 -08:00
Kyle Evans 78345dbd7a bhyveload: use a dirfd to support -h
Don't allow lookups from the loader scripts, which in rare cases may be
in guest control depending on the setup, to leave the specified host
root.  Open the root dir and strictly do RESOLVE_BENEATH lookups from
there.

cb_open() has been restructured a bit to work nicely with this, using
fdopendir() in the directory case and just using the fd we already
opened in the regular file case.

hostbase_open() was split out to provide an obvious place to apply
rights(4) if that's something we care to do.

Reviewed by:	allanjude (earlier version), markj

(cherry picked from commit 6779d44bd8)
2024-01-15 17:11:38 -06:00
Navdeep Parhar f0eedbcd80 cxgbetool(8): Add support for tracing loopback traffic for a port.
Use lo<n> to tap the loopback for port <n>.

Sponsored by:	Chelsio Communications

(cherry picked from commit 4913a24e79)
2024-01-10 21:06:58 -08:00
Ed Maste 0b0e479d05 efibootmgr: provide explicit error message if run as non-root
This should be less confusing for new users.

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

(cherry picked from commit c08ba4a588)
(cherry picked from commit 01641167c9)
2024-01-10 20:28:27 -05:00
Ed Maste 47c22dcb5e efibootmgr: add missing break for 'u' case
Reviewed by:	imp, zlei
Reported by:	Coverity
CID:		1505695
Fixes:		9a79152994 ("efibootmgr: Add --efidev (-u) to dis...")
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D38747

(cherry picked from commit 17a5a29003)
2024-01-10 20:28:27 -05:00
Ceri Davies 677a7402ce sys/*/conf/*, docs: fix links to handbook
While here, fix all links to older en_US.ISO8859-1 documentation
in the src/ tree.

PR:             255026
Reported by:    Michael Büker <freebsd@michael-bueker.de>
Reviewed by:    dbaio
Differential Revision: https://reviews.freebsd.org/D30265

(cherry picked from commit c1a148873d)
2024-01-09 22:07:46 -05:00
Ed Maste ec5e6781b3 freebsd-update: for rollback, first create directories
rollback_files() tried to install files before creating the directories
for those files.  In some cases this is due to special handling to
install certain classes of files earlier than others.

Just create all directories up front when performing rollback.

PR:		273950
Reviewed by:	dim
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42020

(cherry picked from commit 6b27e1f2ea)
(cherry picked from commit 2b79df0ad9)
2024-01-07 15:41:48 -05:00
Ed Maste 01e31d1d87 freebsd-update: handle directories changing to files
Further to f6d37c9ca1 ("freebsd-update: handle file -> directory on
upgrade"), handle the reverse case of a directory changing to a file.
We may not encounter this case on upgradess (before freebsd-update is
retired) but it is needed to support rollback.

PR:		273950
Reviewed by:	dim
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41945

(cherry picked from commit c0f5244316)
(cherry picked from commit 1cf8528fec)
2024-01-07 15:41:48 -05:00
Ed Maste 72e6ffc21c freebsd-update: allow user to break out of conflict resolution loop
When a conflict marker is found during update allow the user to confirm
they want it to remain in the file.

Suggested by:	Tim Hogard
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Fixes: ceb5f28ba5 ("freebsd-update: re-edit files if merge confli...")
Differential Revision: https://reviews.freebsd.org/D38896

(cherry picked from commit 3d44241546)
(cherry picked from commit 6561fec386)
2024-01-07 15:41:48 -05:00
Marius Strobl f35b3d1171 mergemaster(8): Remove support for sparc64
(cherry picked from commit 9ec7a595ed)
2024-01-05 22:58:23 +01:00
John Baldwin 7da77f0266 Stop #defining FREEBSD_ELF
This was originally used (along with FREEBSD_AOUT) to prefer the use
of ELF in various tools instead of a.out as part of the a.out to ELF
transition in the 3.x days.  The last use of it was removed from
<link.h> in commit 66422f5b7a back in
2002, but various files still #define it.

Reviewed by:	kevans, imp, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42964

(cherry picked from commit 4a3cf5f329)
2024-01-04 16:28:53 -08:00
John Baldwin de09d07a10 kldxref: Add a copyright and license statement to ef.h
This uses the statement from other files in kldxref when the tool was
first imported in commit 9c6f92408c.

Reviewed by:	kevans
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42963

(cherry picked from commit 087c4c90d1)
2024-01-04 16:28:39 -08:00
John Baldwin 57238e6d03 bsdinstall.8: Clarify the description of ZFSBOOT_FORCE_4K_SECTORS
This variable does not set the exact sector size of the pool, but
controls the minimum sector size.  The sector size of the underlying
disks can always be larger than the minium controlled by this knob.

PR:		274513
Reported by:	Albin "a12l" Otterhäll <bugs.freebsd.org@a12l.xyz>

(cherry picked from commit 84f773037e)
2024-01-04 16:22:09 -08:00
John Baldwin a463db46a1 bsdinstall zfsboot: Don't override ZFSBOOT_FORCE_4K_SECTORS if it is null.
Only set a default value of 1 if the shell variable is unset.  This allows
installer scripts to disable the variable.

PR:		274513
Reported by:	Albin "a12l" Otterhäll <bugs.freebsd.org@a12l.xyz>
Differential Revision:	https://reviews.freebsd.org/D42319

(cherry picked from commit de82aed119)
2024-01-04 16:21:59 -08:00
Brad Davis e0f29ad461 bsdinstall: add missing init of fd variable
Missed breaking this commit into smaller pieces

Approved by:		kp

(cherry picked from commit 2c4499dcd7)
2024-01-04 16:20:33 -08:00
Brad Davis 2f47321e3f bsdinstall: Filter out devices that cannot be opened
Devices that cannot be opened are most likely the install media and
should not be listed as destinations.

Reviewed by:		allanjude
Approved by:		allanjude
Differential Revision:	https://reviews.freebsd.org/D34879
Sponsored by:		Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 964ad27f1e)
2024-01-04 16:18:53 -08:00
John Baldwin 91a736d701 bsdinstall partedit: Use snprintf instead of sprintf for error messages
When generating a message for a dialog box into a static buffer, use
snprintf instead of sprintf to avoid buffer overflows.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42240

(cherry picked from commit 6e8bf24073)
2024-01-04 16:16:24 -08:00
John Baldwin a403492f96 bsdinstall partedit: Use asprintf to build wrapper command for newfs
Don't abuse the message[] static buffer used elsewhere for error
messages to generate the command that actually newfs's each
filesystem.  Use asprintf to a more aptly-named 'char *command'
variable to construct the string instead.  This avoids potential bugs
from truncation of the command string.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42239

(cherry picked from commit a8676bf367)
2024-01-04 16:11:11 -08:00
John Baldwin 653e8fb20e bsdinstall partedit: Replace malloc + sprintf with asprintf
This avoids potential bugs with the length passed to malloc not
matching the string written via sprintf.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42238

(cherry picked from commit 51749e05e9)
2024-01-04 16:08:25 -08:00
John Baldwin a78807a2fa bsdinstall partedit: Avoid potential buffer overflow in newfs_command
Allocate the buffer holding the newfs command string dynamically
(building the string via open_memstream) rather than storing the
command into a caller-supplied buffer of unknown length.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42237

(cherry picked from commit ae2fc74fe7)
2024-01-04 15:51:34 -08:00
John Baldwin c81bdb4998 bsdinstall partedit: Apply changes from scripted installs
I got a check inverted in a previous cleanup commit and as a result
partedit was only applying GEOM changes (and generating an /etc/fstab)
if it got an error reading the current GEOM mesh.  Instead, it needed
to do those actions if it succeeded in reading the mesh.

The lack of /etc/fstab meant that bsdinstall mount didn't mount
anything in a scripted install.

PR:		273723
Reported by:	Andrey Fesenko <andrey@bsdnir.info>
Reported by:	Michal Nowak <mnowak@startmail.com>
Reviewed by:	cognet, brooks
Fixes:		2309909919 bsdinstall: Handle errors from geom_gettree.
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42236

(cherry picked from commit 5307bbcc03)
2024-01-04 15:43:33 -08:00
John Baldwin 70f7bf34e3 bsdinstall: Handle errors from geom_gettree.
geom_gettree probably never fails, and if it does there isn't much of
a fallback other than aborting partitioning.  However, a few places
were checking the return value and not doing anything with it
triggering a unused-but-set-variable warning.  Checking the errors
resolves the warning.

While here, check for errors in other places that weren't checking for
them at all, remove a spurious double call (the second call overwrote
the mesh structure leaking all the pointers from the first), and close
a few resource leaks on error paths.

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

(cherry picked from commit 2309909919)
2024-01-04 15:42:26 -08:00
John Baldwin 3c94050525 bsdinstall: Replace correct, but fragile, string builder with open_memstream.
The old one triggered a false positive -Warray-bounds from GCC (the
compiler assumed len was always 0), but it was also fragile with
manually computed lengths paired with strcat vs using a string
builder.

Differential Revision:	https://reviews.freebsd.org/D40658

(cherry picked from commit f66a8328c3)
2024-01-04 15:16:48 -08:00
Konstantin Belousov 42b80d160b bhyve.8: add missed dot
(cherry picked from commit 59a35b7c6b)
2023-12-25 05:58:04 +02:00
Gordon Bergling f5f993f6c9 iostat.8: Better wording for some use cases
The iostat(8) manual page should be more specific when using
options. Also extented the BUGS section.

PR:	153012
Reviewed by:	bcr
Differential Revision:	https://reviews.freebsd.org/D42633

(cherry picked from commit 502e8f44fc)
2023-12-17 15:52:21 +01:00
Jessica Clarke 7c9a6ac58c bsdinstall: Encode dists to valid variable names in checksum script
Currently we just strip the .txz of the dist name (and add a status_
prefix) to get the shell variable name for its status, but this doesn't
give a valid result for dists like base-dbg, kernel-dbg and lib32-dbg,
or even kernel.KERNCONF (or, combining the two, kernel.KERNCONF-dbg). As
a result, four things go wrong for such dists:

1. If there is a dot and/or a dash in the name, writing to the variable
   fails and spits an error out on stderr to the log
3. If there is a dot in the name before any dash, the syntax is always
   invalid, reading the variable fails, spits an error out on stderr to
   the log, the result is the empty string and that is interpreted as
   being 0%
2. If there is a dash in the name before any dot, and there is a dist
   whose name is the substring up to that first dash, and it has already
   had its status written to, reading the variable instead reads that
   dist's variable and so the status of that dist is displayed instead
3. If there is a dash in the name before any dot, and either there is
   not a dist whose name is the substring up to that first dash or there
   is such a dist but it has not already had its status written to,
   reading the varaible instead results in the substring after the first
   dash, including any additional string expansion syntax that follows
   (i.e. ${status_kernel-dbg:--11}, the expression used to read the
   variable, is interpreted as reading status_kernel with a default
   value of "dbg:--11")

For example, in a default install with base, kernel, kernel-dbg and
lib32, the following sequence of displays happens:

1. base is In Progress, kernel is Pending, kernel-dbg is 0% (what shows
   for the garbage input "dbg:--11") and lib32 is Pending
2. base is Passed, kernel is In Progress, kernel-dbg is In Progress
   (since kernel has now had its status written to) and lib32 is
   Pending
3. base is Passed, kernel is Passed, kernel-dbg is Passed (again, since
   that is the status of kernel, despite that kernel-dbg is being
   verified at this point) and lib32 is Pending
4. base is Passed, kernel is Passed, kernel-dbg is Passed and lib32 is
   In Progress

Fix this with a crude encoding scheme. More special characters can
easily be added if needed in future.

Note that, prior to bsddialog being used (and thus for branches this is
MFC'ed to where dialog is still used), the same problem existed but
displayed slightly differently due to a combination of different default
values and different behaviour for unintended inputs.

Fixes:		b70047d413 ("Add generation of an installation manifest containing SHA256 checksums as ...")
MFC after:	1 week

(cherry picked from commit 47d669f10e)
2023-12-13 21:52:48 +00:00
Dag-Erling Smørgrav 70bf48a72a daemon: Disable stdio buffering.
The daemon utility already does its own buffering and retransmits its
child's output line by line.  There's no need for stdio to add its own
buffering on top of this.

MFC after:	1 week
Sponsored by:	Modirum MDPay
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D42111

(cherry picked from commit cec8e6ba64)
2023-12-13 17:21:13 +01:00
Kyle Evans 0147143008 daemon: EINTR from kevent(2) is not a fatal error
Simply resume waiting for events rather than exiting if we took a signal
here.

This at least fixes running programs under daemon(8) in the face of
suspend/resume, which I suspect hits us with a spurious EINTR rather
than a signal anyways.

Reported and tested by:	manu
Fixes:	8935a39932 ("daemon: use kqueue for all events")

(cherry picked from commit 494e7dfdbe)
2023-12-13 17:21:09 +01:00
Ihor Antonov b64f569e5c daemon: use kqueue for all events
Refactor daemon to use kqueue/kevent instead of signals.

This changes allows to simplify the code in several ways:
- the execution flow is now linear, no async events.
- several variables became redundant and got removed.
- all event handling is now concentrated inside of the event loop, which
  makes code reading and comprehension easier.
- new kqueuex(2) call is used for CLOEXEC, but maintained closing the
  kq fd prior to execve() to ease later MFC

No UX/API changes are intended.

Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/701

(cherry picked from commit 8935a39932)
2023-12-13 17:21:03 +01:00
Xin LI 3ef596c6e8 periodic/daily/480.leapfile-ntpd: only attempt to refresh leap-seconds.list
when ntpd is enabled.

The leap-seconds.list is used exclusively by ntpd, therefore, do not bother
to perform the fetch when ntpd is not enabled.

PR:		conf/275419
Reviewed by:	cy, michaelo, imp
Differential Revision: https://reviews.freebsd.org/D42875

(cherry picked from commit 3b3195f676)
2023-12-05 22:34:26 -08:00
Xin LI b1d3826ede Update leap-seconds to leap-seconds.3676924800
Obtained from:  ftp://ftp.boulder.nist.gov/pub/time/leap-seconds.3676924800
(cherry picked from commit 832c63f5e0)
2023-11-28 20:29:49 -08:00
Cy Schubert 17b51a12dc Unbound: Manually update version strings
This was missed earlier today.

Reported by:	"Herbert J. Skuhra" <herbert@gojira.at>
Fixes:		16fd0b2491

(cherry picked from commit 6726773431)
2023-11-28 07:15:54 -08:00
Kyle Evans faf527b730 crunchgen: fix "keep" for an ELF world, break it out
"keep" currently adds a leading underscore, which hasn't been useful or
accurate since a.out days.  Preserve the symbol name as it's given
rather than mangle it to match ELF-style symbol names.

This was partially fixed back in
6cd35234a0 ("Assume ELF-style symbol names now.") for crunchgen, but
the keeplist wasn't changed to match it.

While we're here, break it out to bsd.crunchgen.mk for later use in
bsdbox.

Reviewed by:	adrian, imp

(cherry picked from commit 8f2848eafa)
2023-11-25 22:07:17 -06:00
Mark Johnston e26e6a98d4 crashinfo: Get local variable values in the gdb backtrace
This should make crash reports a bit more useful without having to ask
for additional information.

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

(cherry picked from commit 3e356fb885)
2023-11-13 10:20:50 -05:00
Alexander Motin 88770f0c69 mpsutil: Add higher PCIe speeds.
There are already PCIe Gen4 HBAs, reported improperly.

MFC after:	1 week

(cherry picked from commit 7bca09e2bb)
2023-11-09 19:57:58 -05:00
Gleb Smirnoff ef161a3501 bhyve: fix arguments to ioctl(VMIO_SIOCSIFFLAGS)
ioctl(2)'s with integer argument shall pass command argument by value,
not by pointer.  The ioctl(2) manual page is not very clear about that.
See sys/kern/sys_generic.c:sys_ioctl() near IOC_VOID.

Reviewed by:		markj
Differential Revision:	https://reviews.freebsd.org/D42366
Fixes:			fd8b9c73a5

(cherry picked from commit f407a72a50)
2023-10-27 13:33:34 -04:00
John Baldwin 506890a652 bhyve: Replace many fprintf(stderr, ...) calls with EPRINTLN
EPRINTLN handles newlines appropriately when stdout/stderr have been
reused as the backend for a serial port.

For bhyverun.c itself, the rule this attempts to follow is to use
regular fprintf/perror/warn/err prior to init_pci() (which is when
serial ports are configured) and to switch to EPRINTLN afterwards.

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D42182

(cherry picked from commit b0936440b8)
2023-10-24 11:58:15 -07:00
John Baldwin 0e0d2636d4 bhyve ahci: Replace WPRINTF with EPRINTLN
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D42181

(cherry picked from commit edd2a9b887)
2023-10-24 11:44:14 -07:00
John Baldwin 148119e858 bhyve: Some fwctl simplifications.
- Collapse IDENT_SEND/IDENT_WAIT states down to a single state.

- Remove unused 'len' argument to op_data callback.  The value passed
  in (total amount of remaining data to receive) didn't seem very useful
  and no op_data implementations used it.

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D41286

(cherry picked from commit f0852344e7)
2023-10-24 11:43:49 -07:00
Yuri Pankov a6a75fc137 bhyve: Document the hw.vmm.maxcpu tunable and the current limit on vCPUs
Reviewed by:	corvink (original version)
Co-authored-by: John Baldwin <jhb@FreeBSD.org>
Differential Revision:	https://reviews.freebsd.org/D40074

(cherry picked from commit da202b0fe6)
2023-10-24 11:42:53 -07:00
John Baldwin 37ba303aa0 Trim various $FreeBSD$
Approved by:	markj (cddl/contrib changes)
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41961

(cherry picked from commit f53355131f)
2023-10-24 11:23:57 -07:00
John Baldwin de270f81b2 Purge more stray embedded $FreeBSD$ strings
These do not use __FBSDID but instead use bare char arrays.

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

(cherry picked from commit eba230afba)
2023-10-24 11:13:18 -07:00
John Baldwin 7ccea130e8 lpr: Remove now unused fallback definition for __FBSDID
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41956

(cherry picked from commit e4c68414d0)
2023-10-24 11:13:18 -07:00
Jan Bramkamp bc6372602a bhyve: Use VMIO_SIOCSIFFLAGS instead of SIOCGIFFLAGS
Creating an IP socket to invoke the SIOCGIFFLAGS ioctl on is the only
thing preventing bhyve from working inside a bhyve jail with IPv4 and
IPv6 disabled restricting the jailed bhyve process to only access the
host network via a tap/vmnet device node.

PR:		273557
Fixes:		56be282bc9 ("bhyve: net_backends, automatically IFF_UP tap devices")
Reviewed by:	markj
MFC after:	1 week

(cherry picked from commit fd8b9c73a5)
2023-10-24 09:21:26 -04:00
R. Christian McDonald 8bfa084a4b ndp: fix timestamp display output
The current xo_format string is incorrect. This restores the display
format prior to libxo-ification work while also explicitly marking
tv_sec and tv_usec as encoded output only.

MFC after:	1 week
Reviewed by:	kp
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42269

(cherry picked from commit 2bb78b46e0)
2023-10-24 09:45:38 +02:00
Konstantin Belousov 2746fc0a5c automount(8): when flushing autofs, specify fsid
PR:	272446

(cherry picked from commit 56c44bd92e)
2023-10-24 03:47:20 +03:00
Andrew Gierth 29dae977ae automount: check for mounted-over autofs instances on flush
PR:	272446

(cherry picked from commit 21b8e363c4)
2023-10-24 03:47:20 +03:00
Kyle Evans 80f747781f freebsd-update: create deep BEs by default
The -r flag to bectl needs to go away, and we need to just do the right
thing.  In the meantime, we can apply an -r in freebsd-update as a
minimal fix to stop creating partial backups in these (non-default) deep
BE setups.

PR:		267535
(cherry picked from commit 989c5f6da9)
2023-10-23 19:04:18 -05:00
Ed Maste 4dd8132fc5 freebsd-update: add a note about when files may be deleted
Files under /var/db/freebsd-update are required during the upgrade
process, and to support rollback.  They may be deleted if no upgrade is
in progress and rollback will not be required.

PR:		273601
Reviewed by:	bcr
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42022

(cherry picked from commit 30beebe444)
(cherry picked from commit ffe4456d7d)
2023-10-13 13:27:03 -04:00
Danilo G. Baio 1595a4087b jexec.8: Add examples section
MFC after:	3 days
Reviewed by:	gbe, 0mp, danfe, pauamma_gundo.com
Differential Revision: https://reviews.freebsd.org/D40831

(cherry picked from commit 04c8bfc176)
2023-10-10 20:18:58 -03:00
Gleb Popov f069e9868d jexec man: Explain how PATH is adjusted.
Add a sentence that explains that PATH is set to `/bin:/usr/bin`.
I had to dive into `jexec.c` to find this out.

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

(cherry picked from commit 7eb6a92e3f)
2023-10-10 20:16:24 -03:00
Alan Somers 51426ad9c7 mprutil: "fix user reply buffer (64)..." warnings
Depending on the card's firmware version, it may return different length
responses for MPI2_FUNCTION_IOC_FACTS.  But the first part of the
response contains the length of the rest, so query it first to get the
length and then use that to size the buffer for the full response.

Also, correctly zero-initialize MPI2_IOC_FACTS_REQUEST.  It only worked
by luck before.

PR:		264848
Reported by:	Julien Cigar <julien@perdition.city>
Sponsored by:	Axcient
Reviewed by:	scottl, imp
Differential Revision: https://reviews.freebsd.org/D38739

(cherry picked from commit 7d154c4dc6)
2023-10-05 11:35:27 -06:00
Mateusz Piotrowski aafabde86e jail.conf.5: List configuration and example files
MFC after:	3 days

(cherry picked from commit ccee95df52)
2023-10-04 13:15:18 +02:00
Felix Johnson 873117aefd swapinfo.8: Mention BLOCKSIZE in the ENVIRONMENT section
Copy the ENVIRONMENT section from df(1) to swapinfo(8), except
that the --si option is removed for swapinfo.

PR:		235225
Reported by:	0mp
MFC after:	3 days

(cherry picked from commit 39ad6e289f)
2023-10-04 13:14:57 +02:00
Mateusz Piotrowski 4f9dbf7d5d pw.8: Refernece to openssl-passwd(1) and crypt(3)
It may be unclear how to generate an encrypted password hash for -H,
so point users to openssl-passwd(1) and crypt(3).

MFC after:	2 weeks

(cherry picked from commit adf9cd56fa)
2023-10-04 13:13:24 +02:00
Mateusz Piotrowski 6d5f98380e 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.

(cherry picked from commit f9572577cf)
2023-10-04 13:11:13 +02:00
Mateusz Piotrowski f15d8ede51 powerd.8: Provide a whole path to power_profile for clarity
MFC after:	3 weeks

(cherry picked from commit 28111ddf9e)
2023-10-04 13:10:42 +02:00
Cy Schubert 4f4adb0576 unbound: Vendor import 1.18.0
Release notes at
    https://www.nlnetlabs.nl/news/2023/Aug/30/unbound-1.18.0-released/

Merge commit '401770e05c71ecb5ae61a59d316069b4b78bf622' into main

(cherry picked from commit 8f76bb7dad)
2023-10-03 18:01:51 -07:00
Juraj Lutter ef295f69ab freebsd-update: Allow for upper/lowercase y/n
Allow for upper/lowercase y/n in "Does this look right?" question.

Reviewed by:		emaste
Approved by:		emaste
Differential revision:	https://reviews.freebsd.org/D40434

(cherry picked from commit 39f4633b3d)
2023-10-01 13:30:35 -04:00
Ed Maste 774cc6348a freebsd-update: handle file -> directory on upgrade
Upgrading from FreeBSD 13.2 to 14.0 failed with
  install: ///usr/include/c++/v1/__string exists but is not a directory
because __string changed from a file to a directory with an LLVM
upgrade.

Now, remove the existing file when the type conflicts.  Note that this
is only an interim fix to facilitate upgrades from 13.2 for 14.0 BETA
testing.  This change does not handle the directory -> file case and
further work is needed.

PR:		273661
Reviewed by:	dim, gordon
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41893

(cherry picked from commit f6d37c9ca1)
2023-10-01 12:33:03 -04:00
Ed Maste 6ac81f5bb6 Add deprecation notices to publickey(5) tools
Reviewed by:	imp, manu
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40144

(cherry picked from commit d5ef73a71f)
2023-09-24 10:07:40 -04:00
Garance A Drosehn ca927128bf When parsing a rule to rotate log files on a specific week day,
parseDWM() can advance the time to the next week. If the next week is
in the next month, then tm_mon is incremented. However, the increment
was failing to handle the wraparound from December to January, so when
parsing a rule during the last week of the December, the month would
advance to month 12. This triggered an out-of-bounds read of the
mtab[] array in days_pmonth() after parseDWM() returned.  To fix,
this change resets the month to January and increment the year when
the month increment wraps.

The default rule for /var/log/weekly.log triggers this during the
last week of December each year.
Reported by:	CHERI
Obtained from:	CheriBSD
Reviewed by:	jhb
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	<https://reviews.freebsd.org/D33687>

(cherry picked from commit b7b447fd4c)
2023-09-23 21:04:40 +00:00
Mateusz Piotrowski 6ed98c185a daemon.8: Document -u sets HOME, USER, and SHELL
Fixes:	6b3ad1d737 When -u option is used also set USER, HOME and SHELL
MFC after:	3 days

(cherry picked from commit c1207678f7)
2023-09-22 17:07:28 +02:00
Mateusz Piotrowski 53512a06ab daemon.8: Sort options in DESCRIPTION
MFC after:	3 days

(cherry picked from commit ee23e1e496)
2023-09-22 17:07:28 +02:00
Mateusz Piotrowski 488064449b daemon.8: Use Cm where appropriate
MFC after:	3 days

(cherry picked from commit a5bc8e8a58)
2023-09-22 17:07:28 +02:00
Mateusz Piotrowski ab77ddea33 daemon.8: Use Dv for signal names
MFC after:	3 days

(cherry picked from commit 735637f7d6)
2023-09-22 17:07:28 +02:00
Mateusz Piotrowski 24a3cb7501 bsdinstall.8: Document BSDINSTALL_SKIP_* variables
Fixes:	17f4ded551 bsdinstall: add variables to allow skipping
MFC after:	3 days

(cherry picked from commit fea2cffb86)
2023-09-22 17:07:28 +02:00
Mateusz Piotrowski e43a460322 bsdinstall.8: Set Bl's -width correctly
MFC after:		3 days

(cherry picked from commit a8f5c9d330)
2023-09-22 17:07:28 +02:00
Ed Maste 877d15d579 freebsd-update: do not restart sshd when updating jail/basedir
In 6cd1bc5316 for PR 263489 I changed freebsd-update to restart sshd
after upgrade, to avoid an upgrade-related incompatibility that made it
impossible to login.

This is intended to avoid losing access to remote hosts, and ought not
apply to upgrading jails (from outside).

PR:		263489, 272282
Reported by:	otis
Reviewed by:	otis, kevans
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Fixes: 6cd1bc5316 ("freebsd-update: restart sshd after upgrade")
Differential Revision: https://reviews.freebsd.org/D41890

(cherry picked from commit 8ee97b1928)
(cherry picked from commit cce342e213)
2023-09-21 10:40:03 -04:00
Dag-Erling Smørgrav 62d509951c iostat: getopt() / usage() cleanup.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D41636

(cherry picked from commit 09c45b089d)
2023-09-14 16:59:52 +02:00
Eugene Grosbein 4cc4afd666 MFC: unbreak BEGEMOT-LM75-MIB.txt
The MIB has several bugs making it unusable. Fix it.

Reported-by:	Eugene M. Zheganin <eugene@zhegan.in>

(cherry picked from commit 872e894056)
2023-09-14 18:58:23 +07:00
Mike Karels 79ce96abd6 mountd: do not warn about using class mask with -mask
The previous code would warn that the mask was being defaulted to
an obsolete class mask even if -mask was present after -network.
Import a fix from Peter Much with a little tweaking, deferring the
warning until after all parameters are processed.

PR:		263011
Obtained from:	pmc at citilink.dinoex.sub.org
Reviewed by:	rmacklem
Differential Revision:	https://reviews.freebsd.org/D41774

(cherry picked from commit 48514c5724)
2023-09-12 09:18:33 -05:00
Kristof Provost 84983bf364 snmp_pf: use libpfctl's pfctl_get_status() rather than DIOCGETSTATUS
Prefer libpfctl functions over direct access to the ioctl whenever
possible. This will allow subsequent removal of DIOCGETSTATUS (in 15) as
there already is an nvlist-based alternative.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D41650

(cherry picked from commit 6fbb9fbf7d)
2023-09-07 21:23:07 +02:00
John Baldwin a11b9463ff bhyve: Store the FreeBSD OUI in little-endian in the controller data
Section 7.10.3 of the NVME 1.4b specification states that the IEEE OUI
in the identify controller structure is stored in little-endian format
(unlike the embedded OUI in EUI64 identifiers).

Reviewed by:	corvink, chuck, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D41487

(cherry picked from commit 18974bd616)
2023-09-06 14:56:10 -07:00