Commit graph

287067 commits

Author SHA1 Message Date
Mark Johnston
c07ebf5bec kmsan: Add kmsan_check_uio()
This was handy for some ad-hoc debugging and fits in with other
kmsan_check_*() routines which operate on some kind of data container.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit be5464ae23)
2023-12-14 09:44:38 -05:00
Mark Johnston
40993deee7 bhyve: Split backends into separate files
Currently the net_backend structure definition is private to
net_backends.c, so all of the backend definitions are there.  While
adding a new backend to use libslirp, it was noted that this file is
somewhat cluttered.  Move the netmap and netgraph backends to their own
files and clean up includes a bit.  No functional change intended.

Reviewed by:	corvink, jhb
MFC after:	3 weeks
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D42689

(cherry picked from commit be74aede49)
2023-12-14 09:43:02 -05:00
Mark Johnston
df81b15118 tty: Avoid a kernel memory discloure via kern.ttys
Four pad bytes at the end of each xtty structure were not being cleared
before being copied out.  Fix this by clearing the whole structure
before populating fields.

MFC after:	3 days
Reported by:	KMSAN

(cherry picked from commit 3c0fb026b2)
2023-12-14 09:29:15 -05:00
Kristof Provost
daaaeb3051 vnet: (read) lock the vnet list while iterating it
Ensure that the vnet list cannot be modified while we're running through
it.

Reviewed by:	mjg (previous version), zlei (previous version)
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42927

(cherry picked from commit bd7b2f9501)
2023-12-14 12:20:25 +01:00
Richard Scheffenegger
35707083c6 tcp: shift PRR sending cadence slightly left
Don't let PRR pass up on the opportunity of clocking
out packets on arrival of ACKs - by pulling sends
forward by about half a packet. Prevents unexpectedly
long runs of incoming ACKs without eliciting a
packet transmission.

MFC after:             1 week
Reviewed By:           #transport, tuexen
Sponsored by:          NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D42918

(cherry picked from commit 9276ad23b8)
2023-12-14 11:13:09 +01:00
Brooks Davis
cc77811bf0 sysvipc: Fix 32-bit compat on !i386
The various time fields are time_t's which are only 32-bit on i386.

Fixing the old versions is probably of little use, but it's more correct
and in theory there could be powerpc binaries from 6.x.

PR:		240035
Fixes:		fbb273bc05 Properly support for FreeBSD 4 32bit System V shared memory.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D42870

(cherry picked from commit 957f014dc0)
2023-12-13 23:10:53 +00:00
Brooks Davis
edcdfc5b68 x86emu: remove localy added __FBSDID
This partially reverts 0a2e9846fd.

Reviewed by:	imp, delphij
Differential Revision:	https://reviews.freebsd.org/D42705

(cherry picked from commit 3faba3002f)
2023-12-13 23:08:51 +00:00
Brooks Davis
9d39900498 telnet: remove locally added __FBSDID
This partially reverts 77b7cdf199.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42704

(cherry picked from commit a3c858005c)
2023-12-13 23:08:51 +00:00
Brooks Davis
80e123a3c3 smbfs: remove locally added __FBSDID
Differential Revision:	https://reviews.freebsd.org/D42703

(cherry picked from commit a159b74a5d)
2023-12-13 23:08:51 +00:00
Brooks Davis
a9bc0a5a08 pnpinfo: remove locally added __FBSDID
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42702

(cherry picked from commit 78e6a1bd06)
2023-12-13 23:08:50 +00:00
Brooks Davis
4fe486b8c8 ee: remove locally added __FBSDID
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42701

(cherry picked from commit 3f944f3bb7)
2023-12-13 23:08:50 +00:00
Brooks Davis
74b8927f82 bzip2: remove locally added __FBSDID
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42700

(cherry picked from commit ae477ca7da)
2023-12-13 23:08:50 +00:00
Brooks Davis
83c9481db9 libc: remove some obsolete VCS data
These wide char support files were copied from the previous versions
with expanded $FreeBSD$ strings in #if 0 blocks.  Remove them and the
scssid definitions in the same #if 0 blocks.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42688

(cherry picked from commit 9fc0ff9d85)
2023-12-13 23:08:50 +00:00
Brooks Davis
5136530bc4 ps: s/kern.max_pid/kern.pid_max/ in a comment
Sponsored by:	DARPA

(cherry picked from commit 1818f3fda9)
2023-12-13 23:08:50 +00:00
Brooks Davis
cbbe7c135b pf: Remove __FBSDID() macro use
These are local additions that no longer make sense with the transition
to git.

This partially reverts a10f530f93.

Reviewed by:	kp, imp
Differential Revision:	https://reviews.freebsd.org/D42687

(cherry picked from commit bbde5c0725)
2023-12-13 23:08:50 +00:00
Brooks Davis
52b970f98d Remove __FBSDID from netbsd libc sources
I added them per then-current practice when I imported them, but now
they are just gratuious local diffs.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42686

(cherry picked from commit ea2be8ed28)
2023-12-13 23:08:50 +00:00
Brooks Davis
0f6bc5ca95 vis: relocate _DIAGASSERT() define
Other similar files from NetBSD define it unconditionally as a local
diff.

Reviewed by:	imp (as part of D42686)

(cherry picked from commit db94e7c3f9)
2023-12-13 23:08:49 +00:00
Brooks Davis
3ad2fd6fb1 makesyscalls: don't make syscall.mk by default
We only want to produce syscall.mk for the main syscall table so default
to not producing it (send it to /dev/null) and add a syscalls.conf to
sys/kern to trigger the creation of sys/sys/syscall.mk.  This eliminates
the need for entries in other syscalls.conf files and is a cleaner
pattern going forward.

Reviewed by:	kevans, imp
Differential Revision:	https://reviews.freebsd.org/D42663

(cherry picked from commit 54d487c4d0)
2023-12-13 23:07:06 +00:00
Brooks Davis
acf0f65f52 libc: remove unused stub vdso timecounter implementations
All supported architectures have shared page support so remove this
unused stub.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D42619

(cherry picked from commit 500bf0592c)
2023-12-13 22:08:14 +00:00
Brooks Davis
f695db9fba libc: centralize a few numeric symbols
fabs, __infinity, and __nan are universally implemented so declare them
in gen/Symbol.map.

We would also include __flt_rounds, but  it's under FBSD_1.3 on arm so
until that's gone we're stuck with it.  Likewise, everyone but i386
implements fp[gs]etmask.

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

(cherry picked from commit c704518681)
2023-12-13 22:08:14 +00:00
Brooks Davis
01edb548c5 libc: centralize makecontext symbols
Declare makecontext() and __makecontext() symbols centrally as they are
always implemented.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D42617

(cherry picked from commit 5d79b5445e)
2023-12-13 22:08:14 +00:00
Brooks Davis
ba1279da0f libc: centralize {_,sig,}{set,long}jmp symbols
These symbols are universally exposed and documented so declare them
centrally.  Double- and triple-underscore versions exist on some
platforms, but leave those alone for now.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D42616

(cherry picked from commit 1c656143be)
2023-12-13 22:08:14 +00:00
Brooks Davis
9d67dced83 libc: centralize ntoh symbols
These are implemented by net/ntoh.c via headers and compiler intrinsics
so declare them in net/Symbol.map.

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

(cherry picked from commit ff3a9d8e29)
2023-12-13 22:08:14 +00:00
Brooks Davis
e150833764 libc: further centralize syscall symbols
All architectures necessarily implement _exit(2) and vfork(2) so
declare them in sys/Symbol.map.

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

(cherry picked from commit e4a1800f06)
2023-12-13 22:08:13 +00:00
Brooks Davis
e0f6b29f6a lib{c,lzma,z}: remove -DSYMBOL_VERSIONING from CFLAGS
This was part of a libkse and libpthread transition aide when libc
gained symbol versions in e62165c8b0
(March 2006).  The code that cared about this macro was removed in
commit 00fb440c1a (May 2007) when symbol
versioning was enabled by default and libthr became the default
threading library.  For unknown reasons, it stayed in libc (which
seemingly never used it) and seems to have been copied to liblzma and
libz.

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

(cherry picked from commit e3e9c205ff)
2023-12-13 22:08:13 +00:00
Brooks Davis
695639d2f4 libc: Remove empty comments in Symbol.map
These were left over from $FreeBSD$ removal.

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

(cherry picked from commit 1ca63a8219)
2023-12-13 22:08:13 +00:00
Brooks Davis
9a2bee998b libc/<arch>/sys/Makefile.inc: remove cruft
Remove stray blank lines left over from $FreeBSD$ removal as well as
some CVS-era (perhaps pre-repocopy) version comments.

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

(cherry picked from commit b73eace889)
2023-12-13 22:08:13 +00:00
Jessica Clarke
019e6ffcc4 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:45:45 +00:00
Dag-Erling Smørgrav
7441705cae tail: Fix heap overflow in -F case.
The number of events we track can vary over time, but we only allocate
enough space for the exact number of events we are tracking when we
first begin, resulting in a trivially reproducable heap overflow.  Fix
this by allocating enough space for the greatest possible number of
events (two per file) and clean up the code a bit.

Also add a test case which triggers the aforementioned heap overflow,
although we don't currently have a way to detect it.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude, markj
Differential Revision:	https://reviews.freebsd.org/D42839

(cherry picked from commit 621f45532c)

tail: Clean up error messages.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D42842

(cherry picked from commit b70e57be2c)
2023-12-13 17:41:48 +01:00
Dag-Erling Smørgrav
90b5ddeca0 bitstring: Support large bit strings.
Replace int with either size_t or ssize_t (depending on context) in
order to support bit strings up to SSIZE_MAX bits in length.  Since
some of the arguments that need to change type are pointers, we must
resort to light preprocessor trickery to avoid breaking existing code.

MFC after:	3 weeks
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D42698

(cherry picked from commit c56f45f2a9)
2023-12-13 17:41:48 +01:00
Dag-Erling Smørgrav
6a2dd26311 hesiod: Modernize.
Reviewed by:	zlei
Differential Revision:	https://reviews.freebsd.org/D42190

(cherry picked from commit 64fc8a936c)
2023-12-13 17:41:48 +01:00
Dag-Erling Smørgrav
8b55607a7f ping: Simplify protocol selection.
* Interrupt the option loop as soon as we have an indication of which
  protocol is intended.
* If we end up having to perform a DNS lookup, loop over the entire
  result looking for either IPv4 or IPv6 addresses.

Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	rscheff, kevans, allanjude
Differential Revision:	https://reviews.freebsd.org/D42137

(cherry picked from commit 7fd2c91a29)

ping: Consistently use EX_NOHOST for DNS failures.

Traditionally, ping returned exit code EX_NOHOST if a DNS lookup failed.
That is still the case for the legacy code in the new merged ping, but
not for IPv6 targets, nor when a DNS lookup is performed in order to
determine which version of the tool to invoke.

While here, also make sure that the error message is consistent.

Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D42159

(cherry picked from commit c4ffb80ef1)

ping: Add missing ATF boilerplate.

Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D42161

(cherry picked from commit fc7143b483)
2023-12-13 17:41:46 +01:00
Dag-Erling Smørgrav
6d0ea82cc2 libfetch, fetch: Stop recommending the use of ca_root_nss.
MFC after:	3 days
Reviewed by:	kevans, emaste
Differential Revision:	https://reviews.freebsd.org/D42119

(cherry picked from commit 2821a7498f)
2023-12-13 17:23:57 +01:00
Dag-Erling Smørgrav
c7a0acd832 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:23:57 +01:00
Mina Galić
fdbd1da140 growfs: make exit codes more consistent
We have overused err(1), so it's hard to distinguish when an error is
very, very serious, and when it's just a user-error, or even harmless.

This patch changes the current behaviour to distinguish between the
following three:

1 for usage errors
2 for recoverable errors
3 or higher for unrecoverable errors

Reviewed by:	jilles, pauamma_gundo.com, des
Differential Revision:	https://reviews.freebsd.org/D27161

(cherry picked from commit 70a0fb43f9)
2023-12-13 17:23:57 +01:00
Mark Johnston
8d42f85d9d nfsclient: Propagate copyin() errors from nfsm_uiombuf()
Approved by:	so
Security:	SA-23:18.nfsclient
Reviewed by:	rmacklem
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 6fa843f6e6)
2023-12-12 14:11:51 -05:00
Mark Johnston
d264ddb9c7 bhnd: Correct the softc size in the siba_bhndb_driver definition
struct siba_bhndb_softc embeds struct siba_softc and adds an extra
field, "quirks".  In practice, this bug was harmless since "quirks" is
unconditionally initialized during driver attach and would have lived in
the redzone of the softc allocation, but KASAN catches the out-of-bounds
access.

PR:		275515
Reported by:	Frank Hilgendorf <frank.hilgendorf@posteo.de>
MFC after:	1 week

(cherry picked from commit 4c3aa00c0a)
2023-12-11 19:30:05 -05:00
Jose Luis Duran
8e41bbf245 zfs tests: Silence clang warning
"assigning to 'pattern_t *' from 'const pattern_t *' discards qualifiers"

Reviewed by:	asomers
Reported by:	clang
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D42791

(cherry picked from commit 5b36076d28)
2023-12-10 19:23:05 -05:00
Sergey A. Osokin
3b46583420 bsd-family-tree: add FreeBSD 14
(cherry picked from commit 25f37779bd)
2023-12-10 14:57:40 -05:00
Sergey A. Osokin
66182d944c bsd-family-tree: add OpenBSD 7.4
(cherry picked from commit 8c630381b4)
2023-12-10 14:57:30 -05:00
Sergey A. Osokin
0e2f61fc03 bsd-family-tree: add macOS 14
(cherry picked from commit 992ec09f37)
2023-12-10 14:56:59 -05:00
Mark Johnston
c2b39a756f OpenZFS: Ensure that zfs_getattr() initializes the va_rdev field
Otherwise the field is left uninitialized, leading to a possible kernel
memory disclosure to userspace or to the network.  Use the same
initialization value we use in zfsctl_common_getattr().

Reported-by: KMSAN
Sponsored-by: The FreeBSD Foundation
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ed Maste <emaste@FreeBSD.org>
Signed-off-by: Mark Johnston <markj@FreeBSD.org>

(cherry picked from commit 11656234b5)
2023-12-10 12:46:57 -05:00
Xin LI
29553f9e8c MFV: xz 5.4.5
(cherry picked from commit ca6a6373bd)
2023-12-10 01:06:26 -08:00
Ka Ho Ng
1ed12844a1 termcap.small: Include xterm-256color
MFC after:	7 days
Reviewed by:	imp, jhb
Differential Revision:	https://reviews.freebsd.org/D42784

(cherry picked from commit 1da7f3f6f7)
2023-12-09 22:15:08 -05:00
Kristof Provost
2c5e87862c pf tests: test that we validate sequence numbers on TCP RST
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 4c84c69ba3)
2023-12-09 11:43:11 +01:00
Alexander Motin
58f5c260a2 uma: Micro-optimize memory trashing
Use u_long for memory accesses instead of uint32_t.  On my tests on
amd64 this by ~30% reduces time spent in those functions thanks to
bigger 64bit accesses.  i386 still uses 32bit accesses.

MFC after:	1 month

(cherry picked from commit 7c566d6cfc)
2023-12-08 21:32:43 -05:00
Mitchell Horne
c27113379e kern_reboot(): don't clear kdb_active
It is possible to reach this function from ddb via the "reset" command.
When this happens, we don't actually exit kdb, meaning we never execute
the latter steps of kdb_break() to restore the system state (e.g.
re-enable scheduler).

Therefore, we should not clear the kdb_active flag in this function, as
the debugger is still active. Put differently, kern_reboot() is not an
authority on kdb state, and should not touch it. The original motivation
for this assignment is not clear; I have checked thoroughly and I am
convinced it is not required by any reset code.

This fixes an edge case where a panic can be triggered during reset from
ddb:
 1. Enter ddb via keyboard break sequence (KERNEL_PANICKED() == false &&
    td->td_critnest > 0)
 2. Execute the "reset" command
 3. kern_reboot() sets kdb_active = false
 4. A witness_checkorder() call via shutdown handler sees !kdb_active
    and panics

Reviewed by:	imp, markj
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D42684

(cherry picked from commit 4e78a766f6)
2023-12-08 18:02:45 -04:00
Mitchell Horne
08b952c56b shutdown: tweak kproc/kthread shutdown check
This is to handle the case where the system has not panicked but the
debugger is active, where we still can't wait for thread termination.

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

(cherry picked from commit 960612a19f)
2023-12-08 18:02:45 -04:00
Mitchell Horne
121656c2b1 pst: improve shutdown_post_sync handler
It is desirable to shut down the raid controller even in the face of a
panic. In the SCHEDULER_STOPPED() case, set the interrupt mask bits so
that we request a polled wait, rather than sleep(), from
iop_queue_wait_msg().

Tweak the function name and signature.

Reviewed by:	markj
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D42337

(cherry picked from commit c4dacfa7f4)
(cherry picked from commit f97aab7986)
2023-12-08 18:02:45 -04:00
Mitchell Horne
a8ba64ca91 iscsi: adjust shutdown_pre_sync handler
Don't attempt to service reconnections if RB_NOSYNC is set. More
crucially, don't do it if the scheduler is stopped, as the maintenance
thread will never run again.

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

(cherry picked from commit 2ce1c45b34)
2023-12-08 18:02:44 -04:00