Commit Graph

266334 Commits

Author SHA1 Message Date
Alex Richardson
31dddc6a19 truss: minor cleanup and pedantic warning fixes
Noticed while porting the recent truss compat32 changes to CheriBSD.
This also fixes i386 tracing by zero-extending user addresses instead
of sign-extending them.

Reviewed By:	jhb
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D30211
2021-06-16 16:35:55 +01:00
Alex Richardson
8ba2e89e98 truss: fix handling of 64-bit arguments/return values for compat32
Deciding whether to combine two values to a 64-bit one should be based on
the process ABI, and not dependent on whether truss is compiled for an
LP64 ABI. This is a follow-up cleanup for D27625. I found this while
looking for uses of the `__LP64__` macro (since using this is wrong for
CHERI systems).

Test Plan: truss still works. Since I tested on AMD64 and all syscalls
in the trace have their quad argument last there was no difference
in the output. Should fix output for compat32 on MIPS64 though.

Reviewed By:	jhb
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D27637
2021-06-16 16:29:57 +01:00
Alex Richardson
1a3a57d745 kdump: use VIS_NOLOCALE when printing output
Attempting to parse the output as UTF-8 exposed an out-of-bounds read
in vis(3) (see https://reviews.freebsd.org/D30771). However, I don't
think it makes much sense to decode this output at all. Additionally,
passing one byte at a time will almost certainly result in incorrect
output for multi-byte characters.

Reviewed By:	brooks
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D30772
2021-06-16 16:28:27 +01:00
Alex Richardson
1a2f06d0f2 vis(3): avoid out-of-bounds stack buffer reads
I found this while running kdump(1) on a CheriBSD system due to a
capability length violation when printing the /etc/libmap.conf read()
system call: it crashed immediately after printing the first line.

Found by:	CHERI
Reviewed By:	jhb
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D30771
2021-06-16 16:27:13 +01:00
Mark Johnston
bc6a2267ff ipfw: Update the pfil mbuf pointer in ipfw_check_frame()
ipfw_chk() might call m_pullup() and thus can change the mbuf chain
head.  In this case, the new chain head has to be returned to the pfil
hook caller, otherwise the pfil hook caller is left with a dangling
pointer.

Note that this affects only the link-layer hooks installed when the
net.link.ether.ipfw sysctl is set to 1.

PR:		256439, 254015, 255069, 255104
Fixes:		f355cb3e6
Reviewed by:	ae
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D30764
2021-06-16 09:46:56 -04:00
Edward Tomasz Napierala
a397b55083 linux: implement set_cloned_tls() on arm64
This fixes random segfaults on "git commit --amend".

Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D30508
2021-06-16 10:32:39 +00:00
Edward Tomasz Napierala
e505c3066b linux: implement set_upcall on aarch64
This fixes "git diff" (git-1:2.25.1-1ubuntu3).

Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D30509
2021-06-16 05:13:17 +00:00
Ceri Davies
3e4946f0aa date.1: Remove mention of -d and -f flags
These flags were removed in 2019.

PR:		256631
Submitted by:	David Fiander <david@fiander.info>
MFC After:	3 days
2021-06-16 09:18:56 +00:00
Rick Macklem
aed98fa5ac nfscl: Make NFSv4.0 client acquisition NFSv4.1/4.2 compatible
When the NFSv4.0 client was implemented, acquisition of a clientid
via SetClientID/SetClientIDConfirm was done upon the first Open,
since that was when it was needed.  NFSv4.1/4.2 acquires the clientid
during mount (via ExchangeID/CreateSession), since the associated
session is required during mount.

This patch modifies the NFSv4.0 mount so that it acquires the
clientid during mount.  This simplifies the code and makes it
easy to implement "find the highest minor version supported by
the NFSv4 server", which will be done for the default minorversion
in a future commit.
The "start_renewthread" argument for nfscl_getcl() is replaced
by "tryminvers", which will be used by the aforementioned
future commit.

MFC after:	2 weeks
2021-06-15 17:48:51 -07:00
John Baldwin
18c69734e9 cxgbe: De-duplicate some of the code for managing TLS key contexts.
The NIC TLS and TOE TLS modes in cxgbe(4) both work with TLS key
contexts.  Previously, TOE TLS supported TLS key contexts created by
two different methods, and NIC TLS had a separate bit of code copied
from NIC TLS but specific to KTLS.  Now that TOE TLS only supports
KTLS, pull common code for creating TLS key contexts and programming
them into on-card memory into t4_keyctx.c.

Sponsored by:	Chelsio Communications
2021-06-15 17:45:32 -07:00
John Baldwin
789f2d4b3f cxgbe tom: Remove support for non-KTLS TLS offload.
TOE TLS offload was first supported via a customized OpenSSL developed
by Chelsio with proprietary socket options prior to KTLS being present
either in FreeBSD or upstream OpenSSL.  With the addition of KTLS in
both places, cxgbe's TOE driver was extended to support TLS offload
via KTLS as well.  This change removes the older interface leaving
only the KTLS bindings for TOE TLS.

Since KTLS was added to TOE TLS second, it was somehat shoe-horned
into the existing code.  In addition to removing the non-KTLS TLS
offload, refactor and simplify the code to assume KTLS, e.g. not
copying keys into a helper structure that mimic'ed the non-KTLS mode,
but using the KTLS session object directly when constructing key
contexts.

This also removes some unused code to send TX keys inline in work
requests for TOE TLS.  This code was never enabled, and was arguably
sending the wrong thing (it was not sending the raw key context as we
do for NIC TLS when using inline keys).

Sponsored by:	Chelsio Communications
2021-06-15 17:45:26 -07:00
John Baldwin
faf0224ff2 ktls: Don't mark existing received mbufs notready for TOE TLS.
The TOE driver might receive decrypted TLS records that are enqueued
to the socket buffer after ktls_try_toe() returns and before
ktls_enable_rx() locks the receive buffer to call sb_mark_notready().
In that case, sb_mark_notready() would incorrectly treat the decrypted
TLS record as an encrypted record and schedule it for decryption.
This always resulted in the connection being dropped as the data in
the control message did not look like a valid TLS header.

To fix, don't try to handle software decryption of existing buffers in
the socket buffer for TOE TLS in ktls_enable_rx().  If a TOE TLS
driver needs to decrypt existing data in the socket buffer, the driver
will need to manage that in its tod_alloc_tls_session method.

Sponsored by:	Chelsio Communications
2021-06-15 17:45:21 -07:00
Konstantin Belousov
870e197d52 Add quirks for Linux ABI signals handling
Require queueing of the signals with default action, and disable
dequeueing SIGCHLD on wait for live process.

Reported and tested by:	dchagin
Reviewed by:	dchagin, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D30675
2021-06-16 02:01:35 +03:00
Konstantin Belousov
a12e901a5a Add a knob to disable dequeueing SIGCHLD on waiting for live process
It seems that Linux does not dequeue siginfo for SIGCHLD when wait*(2)
reports status of the running process.  In particular, sigwaitinfo(2)
and other signal querying syscalls can observe the siginfo after wait.

FreeBSD dequeued siginfo from the beginning, so we cannot change the
default ABI to be more compatible.  Still, add a knob to enable to
change to the other behavior for debugging purposes.

Reported by:	dchagin
Reviewed by:	dchagin, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D30675
2021-06-16 02:00:19 +03:00
Konstantin Belousov
bc38762474 Add a knob to not drop signal with default ignored or ignored actions
Traditionally, BSD drops signals with the default action during send,
not even putting them to the destination process queue.  This semantic
is not shared with other operating systems (Linux), which do queue
such signals.  In particular, sigtimedwait(2) and related syscalls can
observe the delivery.

Add a global knob kern.sig_discard_ign which can be set to false to force
enqueuing of the signals with default action.  Also add an ABI flag to
indicate that signals should be queued.

Note that it is not practical to run with the knob turned on, because almost
all software that care about the delivery of such signals, is aware of the
difference, and misbehaves if the signals are actually queued.  The purpose
of the knob as is is to allow for easier diagnostic of the programs that
need the adjustments, to confirm the cause of problem.

Reported by:	dchagin
Reviewed by:	dchagin, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D30675
2021-06-16 02:00:19 +03:00
Konstantin Belousov
acced8b043 sigwait: add comment explaining EINTR/ERESTART details
Reviewed by:	dchagin, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D30675
2021-06-16 02:00:19 +03:00
Konstantin Belousov
afb36e289c sigwait(2) and sigtimedwait(2) must not be restarted.
Reported by:	dchagin
Reviewed by:	dchagin, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D30675
2021-06-16 02:00:18 +03:00
Alan Somers
fcb5a0a2ad vn_fullpath.9: update args after rev 364633
MFC after:	2 weeks
Sponsored by:	Axcient
Reviewed by:	imp
Differential Revision: https://reviews.freebsd.org/D30779
2021-06-15 15:42:30 -06:00
Vincenzo Maffione
950cf4a29a netmap: pkt-gen: fix compilation issue
Remove stray characters preventing the source code from being
compiled.

Fixes: 20d684ecc9 ("pkt-gen: Allow limiting received packets").
Submitted by:	ar_semihalf.com
Reviewed by:	vmaffione
Differential Revision:	<https://reviews.freebsd.org/D###>
2021-06-15 21:33:07 +00:00
Alan Somers
d63e6bc256 fusefs: delete dead code
Delete two fields in the per-mountpoint struct that have never been
used.

MFC after:	2 weeks
Sponsored by:	Axcient
2021-06-15 13:34:01 -06:00
Warner Losh
1fbd574e87 u3g: Note range of GOBI devices
Qualcomm makes the GOBI devices, and gobi_loader port supports all the
Qualcomm GOBI 1000 and 2000 devices with the MDM1000 and MDM2000
chipsets. And likely the 3000 as well, though that's not been tested
on FreeBSD.

Submitted by:		zarychtam@plan-b.pwste.edu.pl
Sponsored by:		Netflix
2021-06-15 10:21:20 -06:00
Alan Somers
4a06e93773 id: sanitize arguments better
The -[AMc] flags ignore the user argument.  Better if id rejects
invocations that include a user argument along with any of those flags.

PR:		256554
MFC after:	2 weeks
Reviewed by:	trasz
Sponsored by:	Axcient
Differential Revision: https://reviews.freebsd.org/D30734
2021-06-15 06:51:16 -06:00
Edward Tomasz Napierala
7d681ad774 crypt_r(3): fix reentrancy problems with DES
This code was originally written for non-reentrant crypt(3).
In 5f521d7ba7, a thread-safe crypt_r(3) was introduced.  However,
it looks like the DES implementation is still not re-entrant;
routines like setup_salt() or des_setkey() still use global
variables.

Instead of something drastic, eg removing DES support altogether,
just mark those variables as thread-local.  This adds about 30kB
of data per thread.

Given that this only applies to DES, I think the impact is minimal.

Reviewed By:	markj
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D30674
2021-06-15 11:06:40 +01:00
Edward Tomasz Napierala
9d167945e8 linux: improve reporting for unsupported syscall flags
Filter out the flags we do support; previously we would print
out the flag value verbatim.

Reviewed By:	dchagin
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D30693
2021-06-15 10:18:18 +01:00
Peter Holm
afce583571 stress2: Added a new verified syzkaller reproducer, update the exclude list and remove a few syscalls from the ignore list 2021-06-15 07:33:58 +02:00
Jessica Clarke
d5c1296234 spl: Unbreak crossbuild after f20893853e
Summary:
f20893853e made getexecname no longer guarded by BOOTSTRAPPING, but it
does not build on non-FreeBSD as it tries to use KERN_PROC_PATHNAME and
related constants.

Reviewers: mm, imp

Reviewed By: imp

Subscribers: imp

Differential Revision: https://reviews.freebsd.org/D30763
2021-06-15 01:23:04 +01:00
Jessica Clarke
5720b8de48 riscv: Add an hw.ncpu tunable to limit the number of cores
Based on a similar change to arm64 in 01a8235ea6.

Reviewed by:	mhorne
MRC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30655
2021-06-15 01:22:13 +01:00
Nathaniel Filardo
7ef082733b makefs: Cast daddr_t to off_t before multiplication
Apparently some large-file systems out there, such as my powerpc64le
Linux box, define daddr_t as a 32-bit type, which is sad and stymies
cross-building disk images.  Cast daddr_t to off_t before doing
arithmetic that overflows.

Reviewed by:	arichardson, jrtc27, imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D27458
2021-06-15 01:22:04 +01:00
Warner Losh
df4e978765 relnotes: fix wording for gconcat entry. 2021-06-14 17:52:59 -06:00
Jung-uk Kim
e80145525b bsd.cpu.mk: Correct MACHINE_CPU for Intel Alder Lake
Apparently Intel Alder Lake lacks AVX-512 instructions.

Fixes:		09e7341c5e "Catch up with Clang 12"
2021-06-14 19:06:03 -04:00
Jung-uk Kim
09e7341c5e Catch up with Clang 12.
Add "znver3" for AMD and "alderlake" and "sapphirerapids" for Intel.
2021-06-14 18:42:59 -04:00
Dan Nelson
87799c5f85 cpucontrol: fix extended signature matching code to avoid fallthough
PR:		256502
MFC after:	1 week
2021-06-14 17:34:07 -04:00
Mark Johnston
a100217489 Consistently use the SOCKBUF_MTX() and SOCK_MTX() macros
This makes it easier to change the socket locking protocols.  No
functional change intended.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-06-14 17:32:32 -04:00
Mark Johnston
f4bb1869dd Consistently use the SOLISTENING() macro
Some code was using it already, but in many places we were testing
SO_ACCEPTCONN directly.  As a small step towards fixing some bugs
involving synchronization with listen(2), make the kernel consistently
use SOLISTENING().  No functional change intended.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-06-14 17:32:27 -04:00
Mark Johnston
70dd5eebc0 amd64: Fix propagation of LDT updates
When a process has used sysarch(2) to specify descriptors for its
private LDT, upon rfork(RFMEM) descriptors are copied into the new child
process.  Any updates to the descriptors are thus reflected to all other
processes sharing the vmspace.  However, this is incorrect in the rather
obscure case where the child process was created before the LDT was
modified.  Fix this by only modifying other processes which already
share the LDT.

Reported by:	syzkaller
Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-06-14 17:32:18 -04:00
Mark Johnston
86461b646d gconcat: Add some simple regression tests for the new append verb
Sponsored by:	The FreeBSD Foundation
2021-06-14 17:31:28 -04:00
Dimitry Andric
790a6be5a1 Export various 128 bit long double functions from libgcc_s.so.1
These were already compiled for some time on aarch64 and riscv, by
including lib/libcompiler_rt/Makefile.inc, but never exported in the
shared library. Since gcc exports these under version GCC_4.6.0, we do
the same.

This review should replace D11482 for now. For e.g. amd64 more work is
still to be done, as compiler-rt does not seem to support 128 bit long
double math for that architecture.

Reviewed by:	cem
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D28690
2021-06-14 21:17:05 +02:00
Emmanuel Vadot
6bc8fe8a9f arm: allwinner: Add mmc_pwrseq support
If a pwrseq is found, set power accordingly.

Sponsored by:	Diablotin Systems
2021-06-14 20:47:37 +02:00
Emmanuel Vadot
bc805293d8 arm: allwinner: dtb: Add overlays to disable SD/MMC node
Useful for dev

Sponsored by:	Diablotin Systems
2021-06-14 20:47:37 +02:00
Dimitry Andric
d099db2546 Apply upstream libc++ fix to allow building with devel/xxx-xtoolchain-gcc
Merge commit 52e9d80d5db2 from llvm git (by Jason Liu):

  [libc++] add `inline` for __open's definition in ifstream and ofstream

  Summary:

  When building with gcc on AIX, it seems that gcc does not like the
  `always_inline` without the `inline` keyword.
  So adding the inline keywords in for __open in ifstream and ofstream.
  That will also make it consistent with __open in basic_filebuf
  (it seems we added `inline` there before for gcc build as well).

  Differential Revision: https://reviews.llvm.org/D99422

PR:		255570
MFC after:	6 weeks
2021-06-14 20:44:09 +02:00
Warner Losh
dd3fd6b85b gconcat append: should be in release notes
Note that d575e81fbc should be in the release notes. First cut at some
useable text.
2021-06-14 11:45:11 -06:00
Noah Bergbauer
d575e81fbc gconcat: Implement new online append feature
Implement the "gconcat append" command which can be used
to append a disk to the end of an existing gconcat device
without unmounting.

If the gconcat device is using the "automatic" method, i.e.,
stores metadata on the devices, new metadata is written
to all existing components, as well as to the newly added one.

Pull Request:	https://github.com/freebsd/freebsd-src/pull/472
Reviewed by:	imp@
2021-06-14 11:42:03 -06:00
Dimitry Andric
715df83abc Disable strict-fp for powerpcspe, as it does not work properly yet
Merge commit 5c18d1136665 from llvm git (by Qiu Chaofan)

  [SPE] Disable strict-fp for SPE by default

  As discussed in PR50385, strict-fp on PowerPC SPE has not been
  handled well. This patch disables it by default for SPE.

  Reviewed By: nemanjai, vit9696, jhibbits

  Differential Revision: https://reviews.llvm.org/D103235

PR:		255570
MFC after:	6 weeks
2021-06-14 18:10:03 +02:00
Alex Richardson
9bb8a4091c Reduce code duplication in machine/_types.h
Many of these typedefs are the same across all architectures or can
be set based on an architecture-independent compiler-provided macro
(e.g. __SIZEOF_SIZE_T__). These macros have been available since GCC 4.6
and Clang sometime before 3.0 (godbolt.org does not have any older clang
versions installed).

I originally considered using the compiler-provided `__FOO_TYPE__` directly.
However, in order to do so we have to check that those match the previous
typedef exactly (not just that they have the same size) since any change
would be an ABI break. For example, changing `long` to `long long` results
in different C++ name mangling. Additionally, Clang and GCC disagree on
the underlying type for some of (u)int*_fast_t types, so this change
only moves the definitions that are identical across all architectures
and does not touch those types.

This de-deduplication will allow us to have a smaller diff downstream in
CheriBSD: we only have to only change the (u)intptr_t definition in
sys/_types.h in CheriBSD instead of having to change machine/_types.h for
all CHERI-enabled architectures (currently RISC-V, AArch64 and MIPS).

Reviewed By: imp, kib
Differential Revision: https://reviews.freebsd.org/D29895
2021-06-14 16:30:16 +01:00
Andrew Turner
15fa52a564 Add more GIC and GICv3 registers
These aren't used by either driver, however they will be needed by
bhyve on arm64 to emulate a GICv3 interrupt controller.

Sponsored by:	Innovate UK
2021-06-14 14:53:11 +00:00
Andrew Turner
e7f369b1c1 Use the correct length when copying arm64 vfp registers
We passed the wrong length into memcpy in the arm64 get_fpcontext and
set_fpcontext. This caused us to copy two status registers we didn't
expect to copy.

These are safe as they exist in both the source and destination, although
in a different order, and we copy the correct values after the memcpy.

Obtained from:	CheriBSD
Sponsored by:	Innovate UK
2021-06-14 14:53:10 +00:00
Andrew Gallatin
ed5e13cfc2 ktls: Fix interaction with RATELIMIT
uipc_ktls.c was missing opt_ratelimit.h, so it was
never noticing that RATELIMIT was enabled.  Once it was
enabled, it failed to compile as  ktls_modify_txrtlmt()
had accrued a compilation error when it was not being
compiled in.

Sponsored by: Netflix
2021-06-14 10:51:16 -04:00
Lutz Donnerhacke
4c3280e587 netgraph/bridge: malloc without flags
During tests an assert was triggered and pointed to missing flags in
the newlink function of ng_bridge(4).

Reported by:	markj
Reviewed by:	markj
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D30759
2021-06-14 15:41:46 +02:00
Kristof Provost
d38630f619 pf: store L4 headers in pf_pdesc
Rather than pointers to the headers store full copies. This brings us
slightly closer to what OpenBSD does, and also makes more sense than
storing pointers to stack variable copies of the headers.

Reviewed by:	donner, scottl
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D30719
2021-06-14 14:22:06 +02:00
Kristof Provost
8b5f4e692b pf: don't hold a lock during copyout()
copyout() can trigger page faults, so it may potentially sleep.

Reported by:	avg
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-06-14 14:17:31 +02:00