Commit graph

292989 commits

Author SHA1 Message Date
Mark Johnston 1c64b3aba3 hptiop: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-07-14 14:29:15 -04:00
Mark Johnston d254651de3 axgbe: Remove a nonsensical use of kernel_sysctlbyname()
No functional change intended.

MFC after:	1 week
2024-07-14 14:29:15 -04:00
Mark Johnston dc8357de60 gnop tests: Serialize
Some of these tests make use of test disk devices, but then they can't
run in parallel.

MFC after:	2 weeks
2024-07-14 14:29:15 -04:00
Mark Johnston 498b3b494b lockf tests: Fix a race
The test launches lockf(1) in the background and races with it, so it
shouldn't be using atf_check to check that lockf won the race.

MFC after:	1 week
2024-07-14 14:29:14 -04:00
Mark Johnston ab27e232b1 socket tests: Serialize sonewconn_overflow
It relies on being able inspect the dmesg buffer to see whether the
kernel logged certain messages.  If it's interleaved with tests that
generate large amounts of console output (e.g., GELI tests), then it can
fail spuriously.

MFC after:	2 weeks
2024-07-14 14:29:14 -04:00
Mark Johnston 5b98bd3068 sched tests: Avoid underflow when maxcpuid == 0
MFC after:	1 week
2024-07-14 14:29:14 -04:00
Mark Johnston 7cd9131591 vmm: Conditionalize addition of opt_*.h headers
These are only included in the amd64 vmm code, so it doesn't make sense
to list them unconditionally.

PR:		280171
Reviewed by:	wosch, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D45964
2024-07-14 14:29:14 -04:00
Warner Losh 82dfbaf7e7 rtld-elf: Fix signed conversion for %hh
While char is signed on some of FreeBSD's architecutres, it's unsigned
on others. So the naked 'char' cast here needs to be 'signed char'
because in this context, we want the signed interpretation.

We don't really use %hh conversions in the run time linker, so this is
likely a nop. However, for correctness, we need this, like we did in the
kernel in fc3e5334ab. It's a nop on x86 and riscv due to defaults as
well, but does fix a bug on arm and powerpc where char is unsigned.

Suggested by: kib
Sponsored by: Netflix
2024-07-14 12:01:43 -06:00
Warner Losh 60f098f841 arch: Update to remove armv6
There were two stray places where armv6 remained that shouldn't be
there. Remove them. Replace one with aarch64 and update MACHINE_ARCH
description of amd64 while I'm here. Eliminate a near-by contraction
igor noted.

Sponsored by:		Netflix
2024-07-13 23:59:31 -06:00
Konstantin Belousov 10a6ae0ddf amd64 pmap_allocpte_nosleep(): stop testing tautological condition
Enabled PTI for given pmap is equivalent to pm_ucr3 being valid is
equivalent to root userspace page table page pm_pmltopu being
allocated.

Reviewed by:	alc, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D45966
2024-07-14 06:22:45 +03:00
Konstantin Belousov 616dd88a2e amd64 pmap_allocpte_nosleep(): fix indent
Reviewed by:	alc, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D45966
2024-07-14 06:22:45 +03:00
Alan Cox 772ae9eddf vm ASLR: Handle VM_NRESERV_LEVEL == 0
Some flavors of powerpc don't enable superpage reservations.

Fixes: 3e00c11a4f ("arm64: Support the L3 ATTR_CONTIGUOUS page ...")
2024-07-13 14:40:43 -05:00
Alan Cox 3e00c11a4f arm64: Support the L3 ATTR_CONTIGUOUS page size in pagesizes[]
Update pagesizes[] to include the L3 ATTR_CONTIGUOUS (L3C) page size,
which is 64KB when the base page size is 4KB and 2MB when the base page
size is 16KB.

Add support for L3C pages to shm_create_largepage().

Add support for creating L3C page mappings to pmap_enter(psind=1).

Add support for reporting L3C page mappings to mincore(2) and
procstat(8).

Update vm_fault_soft_fast() and vm_fault_populate() to handle multiple
superpage sizes.

Declare arm64 as supporting two superpage reservation sizes, and
simulate two superpage reservation sizes, updating the vm_page's psind
field to reflect the correct page size from pagesizes[].  (The next
patch in this series will replace this simulation.  This patch is
already big enough.)

Co-authored-by:	Eliot Solomon <ehs3@rice.edu>
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D45766
2024-07-13 12:43:42 -05:00
Strahinja Stanišić f0d1236f0f libc: Add memset test for int-to-char conversion
Test case to check if an implementation of memset correctly
handles the value passed being wider than a byte

Approved by:	emaste
Reviewed By:	fuz (GSoC mentor), emaste
Sponsored by:	Google LLC (GSoC 2024)
Differential Revision: https://reviews.freebsd.org/D45738
2024-07-13 15:07:49 +02:00
Peter Lei 69dace892d tcp: fix number in comment
Fixes:		e18b97bd63 ("Update to bring the rack stack with all its fixes in.")
MFC after:	1 week
Sponsored by:	Netflix, Inc.
2024-07-13 13:53:48 +02:00
Wolfram Schneider e5a0202f96 Makefile.inc1: show time for `make installworld'
For years we display the time in seconds how long it takes to
run `make buildworld' (see PR 224433). Now we will display the
time for "installworld" and "installkernel" as well.

e.g.:
--------------------------------------------------------------
>>> Installing everything completed on Sun Jul  7 16:11:37 UTC 2024
>>> Install world completed in 110 seconds, ncpu: 2, make -j2
--------------------------------------------------------------

PR: 280187
Approved by: imp
Differential Revision: https://reviews.freebsd.org/D45912
2024-07-13 10:37:14 +00:00
Michael Tuexen 859f0f0d6b tcp: refactor register_tcp_functions_as_names()
Refactor register_tcp_functions_as_names() such that either all or
no (in error cases) registrations happen atomically (while holding
the tcp_function_lock write lock). Also ensure that the TCP function
block is not already registered.
This avoids situations, where some registrations were performed and
then they were removed without holding a lock in between or checking
ref counts.

Reviewed by:		cc
MFC after:		1 week
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D45947
2024-07-13 12:22:25 +02:00
Kyle Evans 1f155d48f8 include: ssp: fortify <sys/socket.h>
The entire recv*() implementation set is ripe for opportunities to
validate, so do what we can with what we have.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45686
2024-07-13 00:16:26 -05:00
Kyle Evans 2aba0eea3f include: ssp: fortify <sys/select.h>
Notably sanity check indices passed to the FD_*() macros against the
size of the fd_set itself.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45685
2024-07-13 00:16:25 -05:00
Kyle Evans 1ace24b30c include: ssp: fortify <sys/uio.h>
Check both the buffer size of the iov object itself, as well as that
of each indidvidually io base.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45684
2024-07-13 00:16:25 -05:00
Kyle Evans 062d9380b9 include: ssp: fortify <sys/random.h>
That is to say, fortify getrandom(2).

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45683
2024-07-13 00:16:25 -05:00
Kyle Evans b53d7aa88f include: ssp: fortify <wchar.h>
This includes all of the w*() equivalents to str*()/mem*() implemented
in more or less the same way.  For these ones, we'll just use
header-only implementations from the start to stop further cluttering
the libc symbol table.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45682
2024-07-13 00:16:25 -05:00
Kyle Evans d0b7445904 include: ssp: fortify <stdlib.h>
The immediately obvious and attractive targets from <stdlib.h> are
arc4random_buf(3) and realpath(3) -- scraping the header didn't reveal
much else of interest.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45681
2024-07-13 00:16:24 -05:00
Kyle Evans 88276dfbf1 include: ssp: fortify poll/ppoll from <poll.h>
For poll/ppoll we just need to bounds-check the poll array that we're
about to write out to.

Reviewed by:	kib, markj (earlier version)
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45680
2024-07-13 00:16:24 -05:00
Kyle Evans cf8e5289a1 include: ssp: round out fortification of current set of headers
ssp/ssp.h needed some improvements:
 - `len` isn't always a size_t, it may need casted
 - In some cases we may want to use a len that isn't specified as a
    parameter (e.g., L_ctermid), so __ssp_redirect() should be more
    flexible.
 - In other cases we may want additional checking, so pull all of the
    declaration bits out of __ssp_redirect_raw() so that some functions
    can implement the body themselves.

strlcat/strlcpy should be the last of the fortified functions that get
their own __*_chk symbols, and these cases are only done to be
consistent with the rest of the str*() set.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45679
2024-07-13 00:16:24 -05:00
Kyle Evans c10d567ea0 include: de-macro __ssp_overlap(), improve semantics and checking
Switch away from pointer arithmetic to provide more obvious semantics
for checking overlap on pointer ranges.  This lets us remove some casts
that need not exist and removes some possible fragility in its use.

While we're here, check for overflow just in case; sometimes we use a
caller-supplied size if __builtin_object_size(3) can't deduce the buffer
size, and we should fail the check if the size is nonsensical for the
provided buffers.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
2024-07-13 00:16:23 -05:00
Kyle Evans 020d003c86 libc: tests: add testing infrastructure for _FORTIFY_SOURCE
The _FORTIFY_SOURCE tests will be generated by a lua script to avoid a
lot of redundancy in writing these tests.  For each function that we're
fortifying, the plan is to test at least the following three scenarios:

 - Writing up to one byte before the end of the buffer,
 - Writing up to the end of the buffer,
 - Writing one byte past the end of the buffer

The buffer is shoved into a struct on the stack to guarantee a stack
layout in which we have a valid byte after the buffer so that level 2
fortification will trip and we can have confidence that it wasn't some
other stack/memory protection instead.

The generated tests are divided roughly into which header we're
attributing them to so that we can parallelize the build -- the full set
is a bit over 9000 lines of C and takes 11s to build on the hardware
that I'm testing on if it's a single monolothic file.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45678
2024-07-13 00:16:23 -05:00
Kyle Evans 4719366192 libc: move __ssp_overlap back out into <ssp/ssp.h>
We'll be using it in some upcoming definitions in headers, so move it
back now but slap a warning on it.  Our upcoming uses will all be inside
of inline functions, so we're not overly concerned about double
evaluation immediately.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45677
2024-07-13 00:16:23 -05:00
Kyle Evans 41c233dec6 Prepare some build fixes in advance of more _FORTIFY_SOURCE
ZFS' libspl needs to be made aware that we have strlcat(3) and
strlcpy(3) to avoid some more complicated declaration duplication, so
go ahead and define these HAVE_ macros now.

libprocstat has to define `_KERNEL` and include kernel headers in order
to get what it wants, but this results in sys/cdefs.h being included too
late and we pick up the build breaking version of the __RENAME
definition.  Just explicitly include sys/cdefs.h earlier rather than
disabling _FORTIFY_SOURCE.  The zfs/ subdir only builds an object that
holds some structures and sizes, so just disable _FORTIFY_SOURCE there
entirely rather than trying to move #define _KERNEL into the file..

While we're here, make sure that we disable _FORTIFY_SOURCE in the
bootloader because we don't have the symbol renaming support today to do
it as cleanly as we'd like.  ssp/ssp.h needs to be pulled into the libsa
environment so that other bits can understand that ssp is disabled in
the consistent __SSP_FORTIFY_LEVEL way that we try to do.

Reviewed by:	allanjude (previous version), markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45676
2024-07-13 00:16:23 -05:00
Jason A. Harmening 9b505845a3 unionfs: fix LINT build
Fix a stale variable name that snuck into a tracepoint from an earlier
version of the change.

Fixes:		eb60ff1e "unionfs: rework locking scheme to only lock a single
vnode"
Reported by:	jenkins
2024-07-12 22:41:17 -05:00
Danilo Egea Gondolfo a6ca6dfd60 p9fs: remove duplicated code
This code is using the vnode after it has been released and causing a
panic when a p9fs shared volume is unmounted. In fact, it seems like it's
just duplicated code left behind from a bad merge.

PR:		279887
Reported by:	Michael Dexter

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1323
2024-07-12 21:40:09 -06:00
Alexander Ziaee c55f56de9d networking.7: remove confusing caveat
+ service routing restart breaks on dhcp
+ change my copyright from inbox to home

Fixes:		75eda009
MFC after:	3 days
Reported by:	Graham Perrin, zlei
Reviewed by:	imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1316
2024-07-12 21:40:09 -06:00
Daniel Berlin f7d8b13336
Fix missing semicolon in trace_dbuf.h (#16281)
On fedora 40, on the 6.9.4 kernel (in updates-testing), assign_str
expands to a "do {<stuff> } while(0)" loop.  Without this semicolon,
the while(0) is unterminated, causing a cascade of useless errors.
With this semicolon, it compiles fine.  It also compiles fine on 6.8.11
(the previous kernel).  I have not tested earlier kernels than that, but
at worst it should add a pointless semicolon.

All other instances in the source tree are already terminated with
semicolons.

Signed-off-by: Daniel Berlin <dberlin@dberlin.org>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
2024-07-12 17:44:10 -07:00
a1ea321 398e675f58
one-word manpage correction: snapshot->rollback (#16294)
This commit fixes what is probably a copy-paste mistake. The
`dracut.zfs` manpage claims that the `bootfs.rollback` option executes
`zfs snapshot -Rf`. `zfs snapshot` does not have a `-R` option. `zfs
rollback` does.

Signed-off-by: Alphan Yılmaz <alphanyilmaz@gmail.com>
Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
2024-07-12 16:27:12 -07:00
Jason A. Harmening 53a777bb52 unionfs: do not create a new status object during vop_close()
Split the portion of unionfs_get_node_status() that searches for an
existing status object into a new helper function,
unionfs_find_node_status(), and use that in unionfs_close().

Additionally, modify unionfs_close() to accept a NULL status object
if unionfs_find_node_status() does not find a matching status
object.  This can happen due to the unconditional VOP_CLOSE()
operation issued by vgonel().

Differential Revision:	https://reviews.freebsd.org/D45398
Reviewed by:		olce
Tested by:		pho
2024-07-12 17:05:16 -05:00
Jason A. Harmening eb60ff1ee1 unionfs: rework locking scheme to only lock a single vnode
Instead of locking both the lower and upper vnodes, which is both
complex and deadlock-prone, only lock the upper vnode, or the lower
vnode if no upper vnode is present.

In most cases this is all that is needed; for the cases in which
both vnodes do need to be locked, this change also employs deadlock-
avoiding techniques such as LK_NOWAIT and vn_lock_pair().

There are still some corner cases in which the current implementation
ends up taking multiple vnode locks across different filesystems
without taking special steps to avoid deadlock; those cases have
been noted in the comments.

Differential Revision:	https://reviews.freebsd.org/D45398
Reviewed by:		olce
Tested by:		pho
2024-07-12 17:05:16 -05:00
Rob Norris cbd95a950a
ZTS: handle FreeBSD version numbers correctly (#16340)
FreeBSD patchlevel versions are optional and, if present, in a different
location in the version string.

Sponsored-by: https://despairlabs.com/sponsor/

Signed-off-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
2024-07-12 10:58:03 -07:00
Alexander Motin 6ac0f711ad nvmecontrol: Fix "Workloadd" typo
MFC after:	1 week
2024-07-12 11:36:40 -04:00
Alexander Ziaee cb18ba9df5 time.1: minor cleanup (alignment/macro/spdx)
+ shorter example filename to minimize line wrap
+ standards macro clarifying posix => posix.2
+ align options + tag spdx

Reviewed by:	mhorne
MFC after:	3 days
Pull-Request:	https://github.com/freebsd/freebsd-src/pull/1315
2024-07-12 11:16:39 -03:00
Andrew Turner f5c7644378 sys/arm: Remove armv6 kernel configs
Only the Raspberry Pi config was supported on armv6. Remove it in
preparation for removing armv6 support from the kernel.

Reviewed by:	manu, emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45646
2024-07-12 11:31:54 +00:00
Andrew Turner 97dbe3e7ac libclang_rt: Simplify the arm check
We just need to check we are building for arm.

Reviewed by:	manu, emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45644
2024-07-12 11:31:54 +00:00
Andrew Turner 06999c8a3a share/mk: Remove armv6 support
It is being removed from the tree. Remove the build infrastructure to
configure armv6 builds.

Reviewed by:	manu, imp, emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45643
2024-07-12 11:31:54 +00:00
Andrew Turner 7818c2d37c armv6: Remove support for building armv6
With it planned that armv7 will be the only 32-bit kernel when 15.0 is
released remove support for armv6.

Remove the top level build infrastructure. It was already removed from
universe, this just stops it from being built directly.

Reviewed by:	mmel, emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45634
2024-07-12 11:31:53 +00:00
Konstantin Belousov 7a296a86d1 IPSEC_OFFLOAD: add the option to GENERIC on amd64 and arm64
Sponsored by:	NVIDIA networking
2024-07-12 07:27:59 +03:00
Konstantin Belousov e6e2c0a5ef ipsec_offload: switch TF2_IPSEC_TSO on/off as appropriate on output
after the interface ipsec_accel method if_hwassist() is consulted.

Sponsored by:	NVIDIA networking
2024-07-12 07:27:59 +03:00
Konstantin Belousov 240b7bfe56 ipsec_offload: offload inner checksums calculations for UDP/TCP/TSO
and allow the interface driver to declare such support.

Sponsored by:	NVIDIA networking
Differential revision:	https://reviews.freebsd.org/D44221
2024-07-12 07:27:58 +03:00
Konstantin Belousov ef2a572bf6 ipsec_offload: kernel infrastructure
Inline IPSEC offload moves almost whole IPSEC processing from the
CPU/MCU and possibly crypto accelerator, to the network card.

The transmitted packet content is not touched by CPU during TX
operations, kernel only does the required policy and security
association lookups to find out that given flow is offloaded, and then
packet is transmitted as plain text to the card. For driver convenience,
a metadata is attached to the packet identifying SA which must process
the packet. Card does encryption of the payload, padding, calculates
authentication, and does the reformat according to the policy.

Similarly, on receive, card does the decapsulation, decryption, and
authentification.  Kernel receives the identifier of SA that was
used to process the packet, together with the plain-text packet.

Overall, payload octets are only read or written by card DMA engine,
removing a lot of memory subsystem overhead, and saving CPU time because
IPSEC algos calculations are avoided.

If driver declares support for inline IPSEC offload (with the
IFCAP2_IPSEC_OFFLOAD capability set and registering method table struct
if_ipsec_accel_methods), kernel offers the SPD and SAD to driver.
Driver decides which policies and SAs can be offloaded based on
hardware capacity, and acks/nacks each SA for given interface to
kernel.  Kernel needs to keep this information to make a decision to
skip software processing on TX, and to assume processing already done
on RX.  This shadow SPD/SAD database of offloads is rooted from
policies (struct secpolicy accel_ifps, struct ifp_handle_sp) and SAs
(struct secasvar accel_ipfs, struct ifp_handle_sav).

Some extensions to the PF_KEY socket allow to limit interfaces for
which given SP/SA could be offloaded (proposed for offload).  Also,
additional statistics extensions allow to observe allocation/octet/use
counters for specific SA.

Since SPs and SAs are typically instantiated in non-sleepable context,
while offloading them into card is expected to require costly async
manipulations of the card state, calls to the driver for offload and
termination are executed in the threaded taskqueue.  It also solves
the issue of allocating resources needed for the offload database.
Neither ipf_handle_sp nor ipf_handle_sav do not add reference to the
owning SP/SA, the offload must be terminated before last reference is
dropped.  ipsec_accel only adds transient references to ensure safe
pointer ownership by taskqueue.

Maintaining the SA counters for hardware-accelerated packets is the
duty of the driver.  The helper ipsec_accel_drv_sa_lifetime_update()
is provided to hide accel infrastructure from drivers which would use
expected callout to query hardware periodically for updates.

Reviewed by:	rscheff	(transport, stack integration), np
Sponsored by:	NVIDIA networking
Differential revision:	https://reviews.freebsd.org/D44219
2024-07-12 07:27:58 +03:00
Konstantin Belousov b6919741b7 ipsec_offload: handle TSO if supported
Allow for TSO to operate if network interface supports ipsec inline
offload and supports TSO over it.

Reviewed by:	tuexen
Sponsored by:	NVIDIA networking
Differential revision:	https://reviews.freebsd.org/D44222
2024-07-12 06:29:32 +03:00
Konstantin Belousov 9d269938e3 ipsec_offload: ifconfig support
Sponsored by:	NVIDIA networking
2024-07-12 06:29:32 +03:00
Konstantin Belousov 2131654bde sys/net: Add IPSEC_OFFLOAD interface cap and methods structure
Reviewed by:	glebius
Sponsored by:	NVIDIA networking
Differential revision:	https://reviews.freebsd.org/D44314
2024-07-12 06:29:32 +03:00