Commit Graph

285260 Commits

Author SHA1 Message Date
Dmitry Chagin
03eab865aa man: Link _Fork(2) man page
Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D41221
MFC after:		1 week
2023-07-28 11:54:20 +03:00
Warner Losh
98d03dca9a universe: Demote armv6 to an extra architecture.
Per discussions over how to lighten the load of armv6, move it to an
extra arch. You can still build TARGET_ARCH=armv6 if you desire, but
it won't be built as part of 'make universe' without -DEXTRA_TARGETS.

Sponsored by:		Netflix
2023-07-27 22:30:41 -06:00
Warner Losh
7872131605 cam: Fail 2/0 asc/ascq return code
This asc/ascq code 2/0 ("No seek complete") is a fatal error on modern
drives indicating a sensor failure. One of our vendors noticed we
retried 2/0 so many times in their failure analysis and asked why (no
other OS else does). They've indicated that this failures means the
track couldn't be located (something that's not going to change, except
if the environment changes significantly, which won't happen on a
timescale useful to retries).

Sponsored by:		Netflix
2023-07-27 22:28:01 -06:00
Jessica Clarke
8a6ab0f71f Pre-quote macros passed to .incbin to avoid unwanted substitution
Currently for the MFS, firmware and VDSO template assembly files we pass
the path to include with .incbin unquoted and use __XSTRING within the
assembly file to stringify it. However, __XSTRING doesn't just perform a
single level of expansion, it performs the normal full expansion of the
macro, and so if the path itself happens to tokenise to something that
includes a defined macro in it that will itself be substituted. For
example, with #define MACRO 1, a path like /path/containing/MACRO/in/it
will expand to /path/containing/1/in/it and then, when stringified, end
up as "/path/containing/1/in/it", not the intended string. Normally,
macros have names that start or end witih underscores and are unlikely
to appear in a tokenised path (even if technically they could), but now
that we've switched to GNU C as of commit ec41a96daa ("sys: Switch the
kernel's C standard from C99 to GNU99.") there are a few new macros
defined which don't start or end with underscores: unix, which is always
defined to 1, and i386, which is defined to 1 on i386. The former
probably doesn't appear in user paths in practice, but the latter has
been seen to and is likely quite common in the wild.

Fix this by defining the macro pre-quoted instead of using __XSTRING.
Note that technically we don't need to do this for vdso_wrap.S today as
all the paths passed to it are safe file names with no user-controlled
prefix but we should do it anyway for consistency and robustness against
future changes.

This allows make tinderbox to pass when built with source and object
directories inside ~/path-with-unix, which would otherwise expand to
~/path-with-1 and break.

PR:	272744
Fixes:	ec41a96daa ("sys: Switch the kernel's C standard from C99 to GNU99.")
2023-07-28 05:08:43 +01:00
Jessica Clarke
9f81119276 Makefile.inc1: Fix list-old-libs by deleting stray pipe
Reported by:	Yuri <yuri@aetern.org>
Fixes:		264594efbe ("Makefile.inc1: Automatically generate _LIBCOMPATS and list-old-* libcompats")
2023-07-28 00:14:19 +01:00
Kevin Bowling
cbcab907f8 e1000: Corrections for lem(4)/em(4) txcsum offload
Explicitly set ipcss/ipcse/ipcso for IPv6 per intel SDM as indicated in
inline comments.

Fix and consolidate 82543/82547 hwcsum exemption.

While here rearrange and expand some commentary.
2023-07-27 15:58:05 -07:00
Przemyslaw Lewandowski
04d4e34538
iflib: Fix panic during driver reload stress test
During a driver reload stress test, after 50-300 reloads a panic occurs.
After adding sleeps in between loading and unloading the driver, the
issue does not occur.  It's possible that loading/unloading too fast may
cause the gt_taskqueue pointer to be freed earlier than expected;
checking for a null pointer first fixes it.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>

Reviewed by:	erj@
Tested by:	jeffrey.e.pieper@intel.com
MFC after:	3 days
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D39457
2023-07-27 15:47:12 -07:00
Kirk McKusick
831b1ff791 UFS/FFS: Migrate to modern uintXX_t from u_intXX_t.
As per https://lists.freebsd.org/archives/freebsd-scsi/2023-July/000257.html
move to the modern uintXX_t. While here also migrate u_char to uint8_t.
Where other kernel interfaces allow, migrate u_long to uint64_t.

No functional changes intended.

MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-07-27 15:27:36 -07:00
Val Packett
da6620e495 mk: fix unnecessary library relinking with incremental builds
Initial libs such as csu are always built (.PHONY), and their
installation to WORLDTMP was causing all the subsequent libraries to
be considered out-of-date even when in reality they were not. Use
install -C more consistently everywhere to avoid unnecessarily
updating the mtimes in WORLDTMP, fixing this problem.

This cut down my no-change buildworld time from 30 to 15 seconds.

Fixes: https://lists.freebsd.org/pipermail/freebsd-current/2016-May/061481.html
TODO.1

Reviewed by: sjg
Sponsored by: https://www.patreon.com/valpackett
Differential Revision:  https://reviews.freebsd.org/D39980
2023-07-27 14:55:16 -07:00
Domagoj Stolfa
4ae6991228 dtrace: Add WITH_DTRACE_ASAN
This option is a blanket for all the DTrace-related software. The option
when enabled passes in -fsanitize=address -fsanitize=undeifned, enabling
ASAN and UBSAN in the following components:

 - libdtrace
 - dtrace(1)
 - lockstat(1)
 - plockstat(1)

The option defaults to "no" and is intended as a developer aid.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D41157
2023-07-27 16:07:34 -04:00
Mark Johnston
1083a8cd85 pcpu: Remove unused definitions of ALT_STACK_SIZE
This was added originally for the sparc64 port and apparently copied to
other platforms.  No functional change intended.

MFC after:	1 week
2023-07-27 16:02:03 -04:00
Mark Johnston
ca6cd604c8 kmsan: Use the correct origin bytes in kmsan_check_arg()
Upon discovering a violation kmsan_check_arg() passes a pointer to
function parameter shadow state to kmsan_report_hook().
kmsan_report_hook() uses that address to find the origin cells, assuming
that the passed address belongs to the kernel map.  This has two
problems:
1) Function parameter origin state is also located in TLS, not in the
   origin map, but kmsan_report_hook() doesn't know this.
2) KMSAN TLS for thread0 is statically allocated and thus isn't shadowed
   (because the kernel itself is not shadowed).

These bugs could result in inaccuracies in KMSAN reports, or a page
fault when trying to report a KMSAN violation (which by default panics
the kernel anyway).

Fix the problem by making callers of kmsan_report_hook() provide a
pointer to origin cells.

Sponsored by:	The FreeBSD Foundation
2023-07-27 16:02:03 -04:00
Mark Johnston
640e5cb304 kmsan: Add a comment explaining why KMSAN doesn't shadow above KERNBASE
Sponsored by:	The FreeBSD Foundation
2023-07-27 16:01:58 -04:00
Mark Johnston
96c2538121 opencrypto: Respect alignment constraints in xor_and_encrypt()
Copy operands to an aligned buffer before performing operations which
require alignment.  Otherwise it's possible for this code to trigger an
alignment fault on armv7.

Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D41211
2023-07-27 15:44:52 -04:00
Mark Johnston
1be56e0bb1 arm/unwind: Check stack pointer boundaries before dereferencing
If the unwinder somehow ends up with a stack pointer that lies outside
the stack, then an attempt to dereference can lead to a fault, which
causes the kernel to panic again and unwind the stack, which leads to a
fault...

Add kstack_contains() checks at points where we dereference the stack
pointer.  This avoids the aforementioned infinite loop in one case I hit
where some OpenSSL assembly code apparently confuses the unwinder.

Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D41210
2023-07-27 15:44:00 -04:00
Jose Luis Duran
81a7ce4404 src.conf.5: Regen
Regenerate makeman after enabling the building of lib32 on arm64.

Fixes: a1b6757313 ("arm64 lib32: enable building of lib32 on arm64")
Pull Request: https://github.com/freebsd/freebsd-src/pull/804
2023-07-27 14:02:14 -04:00
Michael Tuexen
cf32543fa4 tcp: document that conditional fields in tcpcb should be at the end
Reviewed by: 	rscheff, Peter Lei
Sponsored by:	Netflix, Inc.
2023-07-27 09:02:19 +02:00
Jessica Clarke
32a79e8557 release: Fix make :@ modifier syntax
This spits out errors but seemingly isn't actually fatal, so was missed.

Fixes:	6853d893c7 ("release: Automatically generate MK_LIB${LIBCOMPAT} and lib${libcompat}-dbg lists")
2023-07-27 08:36:12 +01:00
Jessica Clarke
309ec6ab28 etcupdate: Remove redundant semicolons
Fixes:	03e62670c3 ("etcupdate: Consolidate nobuild cases and make more robust")
2023-07-27 07:55:13 +01:00
Shailend Chand
74861578d9 gve: Fix Tx tcpdump panic
Ringing the doorbell before making the BPF call can result in the
mbuf being freed before the BPF call.

Reviewed-by:		markj
MFC-after:		3 days
Differential Revision: https://reviews.freebsd.org/D41189
2023-07-26 22:36:42 -07:00
Alan Cox
5ec2d94ade vm_mmap_object: Update the spelling of true/false
Since fitit is already a bool, use true/false instead of TRUE/FALSE.

MFC after:	2 weeks
2023-07-27 00:25:53 -05:00
Jessica Clarke
2a4d73f3cf Makefile.inc1: Reinstate kbdcontrol bootstrap for BUILD_WITH_STRICT_TMPPATH
During BUILD_WITH_STRICT_TMPPATH builds we need to symlink the host's
kbdcontrol into WORLDTMP/legacy/bin so that it can be used. For
completeness, also check if the host has it, since technically the host
could have been built with WITHOUT_LEGACY_CONSOLE (though given nobody's
screamed since this code was removed that's likely not something that
gets hit in practice), and handle BOOTSTRAP_ALL_TOOLS (especially since
that case will cover cross-building if and when kbdcontrol can be built
on non-FreeBSD).

This allows a BUILD_WITH_STRICT_TMPPATH tinderbox to pass.

This partially reverts commit 33550b4739.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41202
2023-07-27 05:10:49 +01:00
Jessica Clarke
246364454f etcupdate: Use new buildetc and installetc targets when available
These new targets avoid the need to invoke internal build system targets
or set internal variables when building, and also have the added benefit
of working with BUILD_WITH_STRICT_TMPPATH. Old source trees lacking such
targets will not work with BUILD_WITH_STRICT_TMPPATH; they could be made
to work by copying the steps, but it's not worth doing so, as they never
have worked in the past. The primary goal of this is to support changing
the default of BUILD_WITH_STRICT_TMPPATH to enabled.

Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D41206
2023-07-27 05:10:49 +01:00
Jessica Clarke
d81da4c983 Makefile.inc1: Add new buildetc and installetc targets
These implement the steps that etcupdate (and mergemaster) need in order
to build their pristine trees, avoiding the need to use internal targets
and variables. Additionally, buildetc includes the steps needed to build
with BUILD_WITH_STRICT_TMPPATH enabled, since we need some host tools to
be available during the various build and install steps.

Reviewed by:	jhb, imp
Differential Revision:	https://reviews.freebsd.org/D41205
2023-07-27 05:10:49 +01:00
Jessica Clarke
03e62670c3 etcupdate: Consolidate nobuild cases and make more robust
The distrib-dirs and distribution steps are shared between the two, the
only difference is whether MAKEOBJDIRPREFIX is in the environment for
the latter. Having in the environment for the former is currently not
needed but does no harm and will be needed in future, so we can just
export it up-front in the subshell. When we do distrib-dirs relative to
_obj and everything also doesn't matter, so move it next to distribution
where it makes more sense. Finally, to avoid complicated && chains, use
"|| exit 1" everywhere to make the subshell fail, and add an extra one
on to the cd $SRCDIR to handle that failing (otherwise we'd go on and
try to build the current directory after cd prints its error, which is
unhelpful).

These changes will make it easier to bundle these steps up into new
top-level targets to allow the build system to manage the steps rather
than etcupdate, which will also handle BUILD_WITH_STRICT_TMPPATH, which
currently does not work with etcupdate.

Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D41204
2023-07-27 05:10:48 +01:00
Jessica Clarke
8fc3059b00 Makefile.inc1: Split _cleanworldtmp out from _worldtmp
This mirrors _cleanobj vs _obj, and will be used by etcupdate to ensure
its build tree has host tools available when BUILD_WITH_STRICT_TMPPATH
is enabled by default (whether in the source tree, like CheriBSD, or in
a system config file).

Note that due to line length the .MAKE .PHONY dependency line is split
into two, one for the filtered WMAKE_TGTS and one for the filtered
.ALLTARGETS.

Reviewed by:	brooks, jhb
Differential Revision:	https://reviews.freebsd.org/D41190
2023-07-27 05:10:48 +01:00
Jessica Clarke
65f28f63a7 tools/build: Create toolchain symlinks for non-absolute compiler/linker
If any of the toolchain variables are not absolute then we need to
create a symlink in WORLDTMP/legacy/bin in order to make them available
during a BUILD_WITH_STRICT_TMPPATH build.

Reviewed by:	brooks, jhb
Differential Revision:	https://reviews.freebsd.org/D41188
2023-07-27 05:10:47 +01:00
Jessica Clarke
81805ec300 depend-cleanup.sh: Generalise lib32 code and avoid duplication
By passing through _ALL_libcompats we can avoid hard-coding the list of
libcompats in depend-cleanup.sh. This cleanup also makes clean_dep
shorter by using a loop instead of handling each case explicitly (at the
expense of slightly tweaked logging).

Reviewed by:	brooks, jhb
Differential Revision:	https://reviews.freebsd.org/D41187
2023-07-27 05:10:47 +01:00
Jessica Clarke
64140bb529 OptionalObsoleteFiles.inc: Automatically generate libcompat directories
Reviewed by:	brooks, jhb, emaste
Differential Revision:	https://reviews.freebsd.org/D41186
2023-07-27 05:10:46 +01:00
Jessica Clarke
87177389b7 bsd.lib.mk: Automatically generate libcompat TAGS
Note that the pattern for matching is made slightly more specific, so as
to permit libcompats where one is a prefix of another (e.g. CheriBSD has
lib64 and lib64c).

Reviewed by:	brooks, jhb, emaste
Differential Revision:	https://reviews.freebsd.org/D41185
2023-07-27 05:10:46 +01:00
Jessica Clarke
6853d893c7 release: Automatically generate MK_LIB${LIBCOMPAT} and lib${libcompat}-dbg lists
Reviewed by:	brooks, jhb
Differential Revision:	https://reviews.freebsd.org/D41184
2023-07-27 05:10:45 +01:00
Jessica Clarke
195e50541e libexec: Automatically generate rtld-elf list and generalise TAGS
Note that the pattern for matching is made slightly more specific, so as
to permit libcompats where one is a prefix of another (e.g. CheriBSD has
lib64 and lib64c).

Reviewed by:	brooks, jhb, emaste, imp, kib
Differential Revision:	https://reviews.freebsd.org/D41183
2023-07-27 05:10:45 +01:00
Jessica Clarke
949199a212 etc: Automatically generate BSD.lib${libcompat}.dist lists
Note that each libcompat still has its own file that must exist.

Reviewed by:	brooks, jhb
Differential Revision:	https://reviews.freebsd.org/D41182
2023-07-27 05:10:44 +01:00
Jessica Clarke
5e2bc2f60c ObsoleteFiles.inc: Automatically generate OpenSSL 3 obsoleted libcompat dirs
Older entries in this file are left alone as hard-coding lib32 as
they're not worth the churn; downstreams will have already moved past
them (in particular, CheriBSD, which adds additional libcompats).

Reviewed by:	brooks, jhb, emaste
Differential Revision:	https://reviews.freebsd.org/D41181
2023-07-27 05:10:44 +01:00
Jessica Clarke
264594efbe Makefile.inc1: Automatically generate _LIBCOMPATS and list-old-* libcompats
Reviewed by:	brooks, jhb
Differential Revision:	https://reviews.freebsd.org/D41180
2023-07-27 05:10:43 +01:00
Jessica Clarke
eafd028327 Makefile: Automatically generate list of libcompat targets
Reviewed by:	brooks, jhb
Differential Revision:	https://reviews.freebsd.org/D41179
2023-07-27 05:10:43 +01:00
Jessica Clarke
5d6cb793d0 bsd.compat.mk Extract _ALL_LIBCOMPATS and add related variables
Adding these to a new bsd.compat.pre.mk will allow other parts of the
tree to iterate over the set of possible libcompats (upper and/or lower)
rather than having to hard-code the list.

Reviewed by:	brooks, jhb, emaste
Differential Revision:	https://reviews.freebsd.org/D41178
2023-07-27 05:10:43 +01:00
Gleb Smirnoff
e3ba0d6add inpcb: do not copy so_options into inp_flags2
Since f71cb9f748 socket stays connnected with inpcb through latter's
lifetime and there is no reason to complicate things and copy these
flags.

Reviewed by:		markj
Differential Revision:	https://reviews.freebsd.org/D41198
2023-07-26 20:35:42 -07:00
Gleb Smirnoff
a43e7a96b6 inpcb: use internal flag to mark pcbs that are inserted into lbgroup
Using INP_REUSEPORT_LB is unsafe, as it is basically a copy of socket's
SO_REUSEPORT_LB flag, which can be cleared by userland after bind().

Reviewed by:		markj
Reported by:		syzbot+e7d2e451f89fb444319b@syzkaller.appspotmail.com
Differential Revision:	https://reviews.freebsd.org/D41197
2023-07-26 20:35:30 -07:00
Konstantin Belousov
474708c334 fork1(): properly track the state of the pg_killsx lock
Reported by:	dchagin
Fixes:	232b922cb3
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-07-27 02:33:58 +03:00
Michael Tuexen
ab65c64bc4 tcp: fix handling of <RST,ACK> segments in SYN-RCVD for RACK and BBR
This deals with TCP endpoints in the SYN-RCVD state coming from the
SYN-SENT state.

Reviewed by:		rscheff
MFC after:		3 days
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D41203
2023-07-26 16:22:13 +02:00
Richard Scheffenegger
b352ef58c2 tcp: Handle <RST,ACK> in SYN-RCVD
Patch base stack to correctly handle the RST bit independently
of other header flags per TCP RFC.

MFC after: 1 week
Reviewed By: tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D40982
2023-07-27 00:42:26 +02:00
Kirk McKusick
6f0ca273a3 Add diagnostics to fsck_ffs(8) for journaled soft-updates debugging.
MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-07-26 14:50:02 -07:00
Steve Kargl
f2c94ddd0a
msun: Fix typo in math_private.h comment
PR:		272738
MFC after:	3 days
2023-07-27 02:21:44 +08:00
Mike Karels
372e3d561d netstat -i: compute most field widths dynamically
The network and address fields were sometimes truncated for netstat -i
without -W, and often much too wide for netstat -i with the -W option.
Fields such as normal packet counts often overflowed.  As a result,
columns didn't line up, and large white spaces made it harder to
follow a line across the display.  Change the code to compute the
required field sizes for network, address, and various packet counts.
Hoist the code to format network and address into a subroutine that
can be called twice, once to measure the required field widths,
and once to emit the values.  Use separate field widths for input
and output packets, byte counts, and error and drop counters.
These are left at defaults (the preceding values) with the -h
option, in which case the fields have a limited total width.
An extra space is included between the Network and Address, which
otherwise seemed too close.

Change the mention of -W with -i in the man page to say that most
field widths are computed dynamically in this case.

MFC after:	1 week
Reviewed by:	sjg, glebius
Differential Revision:	https://reviews.freebsd.org/D41160
2023-07-26 10:56:52 -05:00
Konstantin Belousov
232b922cb3 killpg(): close a race with fork(), part 2
When we are sending terminating signal to the group, killpg() needs
to guarantee that all group members are to be terminated (it does not
need to ensure that they are terminated on return from killpg()).  The
pg_killsx change eliminates the largest window there, but still, if
a multithreaded process is signalled, the following could happen:
- thread 1 is selected for the signal delivery and gets descheduled
- thread 2 waits for pg_killsx lock, obtains it and forks
- thread 1 continue executing and terminates the process
This scenario allows the child to escape still.

Fix it by single-threading forking parent if a conflict with pg_killsx
is noted.  We try to lock pg_killsx without sleeping, and failure to
acquire it means that a parallel killpg(2) is executed.  Then, stop
other threads for running and in particular, receive signals, to avoid
the situation explained above.

Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D41128
2023-07-26 18:13:02 +03:00
Konstantin Belousov
dfe172484d sigtd(): prefer non-stopped thread as a target for signal queue
This should improve signal delivery latency and better expose the
process state to the executing threads.

Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D41128
2023-07-26 18:12:55 +03:00
Konstantin Belousov
aaa924138a Revert "killpg(): close a race with fork(), part 2"
This reverts commits 81a37995c7 and
565a343ae3.

There is still a leakage of the p_killpg_cnt, some but not all sources
of which were identified.

Second, and more important, is that there is a fundamental issue with
blocked signals having KSI_KILLPG flag set.  Queueing of such signal
increments p_killpg_cnt, but it cannot be decremented until the signal
is delivered.  If, for instance, a single-threaded process with blocked
signal receives killpg-kill and executes fork(2), the fork enter check
returns with ERESTART.  And since signal is blocked, the condition
cannot be cleared.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D41128
2023-07-26 18:12:55 +03:00
Konstantin Belousov
0a5c29a6ee thr_mutex.c: style
Reindend and re-fill the statement.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D41150
2023-07-26 17:24:51 +03:00
Konstantin Belousov
86c7368f2b rtld_malloc: add cp2op() helper
converting user allocation address into overhead pointer

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D41150
2023-07-26 17:24:18 +03:00