Commit Graph

272286 Commits

Author SHA1 Message Date
John Baldwin
bca92be683 Remove more quotes around Makefile .error/.warn/.info strings.
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D34175
2022-02-04 15:59:53 -08:00
John Baldwin
6bea696af2 linux_copyout_strings: Use PROC_PS_STRINGS().
Reviewed by:	markj
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D34173
2022-02-04 15:57:57 -08:00
John Baldwin
ffe74ab77f bsd.compat.mk: A few cosmetic fixes.
- Add a missing ')' to a warning.

- Consistently use {} when expanding variables.

- Remove a spurious blank line.

Reviewed by:	imp, emaste
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D34172
2022-02-04 15:57:28 -08:00
John Baldwin
74fea8eb4f cxgbei: Rework parsing of pre-offload PDUs.
sbcut() returns mbufs in reverse order so is not suitable for reading
data from the socket buffer.  Instead, check for already-received data
in the receive worker thread before passing offload PDUs up to the
iSCSI layer.  This uses soreceive() to read data from the socket and
is also to use M_WAITOK since it now runs from a worker thread instead
of an interrupt thread.

Also, fix decoding of the data segment length for pre-offload PDUs.

Reported by:	Jithesh Arakkan @ Chelsio
Fixes:		a8c4147edc cxgbei: Parse all PDUs received prior to enabling offload mode.
Sponsored by:	Chelsio Communications
2022-02-04 15:38:49 -08:00
Alan Somers
00134a0789 fusefs: require FUSE_NO_OPENDIR_SUPPORT for NFS exporting
FUSE file systems that do not set FUSE_NO_OPENDIR_SUPPORT do not
guarantee that d_off will be valid after closing and reopening a
directory.  That conflicts with NFS's statelessness, that results in
unresolvable bugs when NFS reads large directories, if:

* The file system _does_ change the d_off field for the last directory
  entry previously returned by VOP_READDIR, or
* The file system deletes the last directory entry previously seen by
  NFS.

Rather than doing a poor job of exporting such file systems, it's better
just to refuse.

Even though this is technically a breaking change, 13.0-RELEASE's
NFS-FUSE support was bad enough that an MFC should be allowed.

MFC after:	3 weeks.
Reviewed by:	rmacklem
Differential Revision: https://reviews.freebsd.org/D33726
2022-02-04 16:31:05 -07:00
Alan Somers
4a6526d84a fusefs: optimize NFS readdir for FUSE_NO_OPENDIR_SUPPORT
In its lowest common denominator, FUSE does not require that a directory
entry's d_off field is valid outside of the lifetime of the directory's
FUSE file handle.  But since NFS is stateless, it must reopen the
directory on every call to VOP_READDIR.  That means reading the
directory all the way from the first entry.  Not only does this create
an O(n^2) condition for large directories, but it can also result in
incorrect behavior if either:

* The file system _does_ change the d_off field for the last directory
  entry previously seen by NFS, or
* The file system deletes the last directory entry previously seen by
  NFS.

Handily, for file systems that set FUSE_NO_OPENDIR_SUPPORT d_off is
guaranteed to be valid for the lifetime of the directory entry, there is
no need to read the directory from the start.

MFC after:	3 weeks
Reviewed by:	rmacklem
2022-02-04 16:30:58 -07:00
Alan Somers
d088dc76e1 Fix NFS exports of FUSE file systems for big directories
The FUSE protocol does not require that a directory entry's d_off field
outlive the lifetime of its directory's file handle.  Since the NFS
server must reopen the directory on every VOP_READDIR call, that means
it can't pass uio->uio_offset down to the FUSE server.  Instead, it must
read the directory from 0 each time.  It may need to issue multiple
FUSE_READDIR operations until it finds the d_off field that it's looking
for.  That was the intention behind SVN r348209 and r297887, but a logic
bug prevented subsequent FUSE_READDIR operations from ever being issued,
rendering large directories incompletely browseable.

MFC after:	3 weeks
Reviewed by:	rmacklem
2022-02-04 16:30:49 -07:00
Stefan Eßer
c454c57163 whereis: fix fetching of user.cs_path sysctl variable
The current implementation of sysctlbyname() does not support the user
sub-tree. This function exits with a return value of 0, but sets the
passed string buffer to an empty string.

As a result, the whereis program did not use the value of the sysctl
variable "user.cs_path", but only the value of the environment
variable "PATH".

This update makes whereis use the sysctl function with a fixed OID,
which already supports the user sub-tree.

MFC after:	3 days
2022-02-04 23:44:34 +01:00
Warner Losh
7510633e76 style(9): Default to omitting $FreeBSD$
Advise people to omit $FreeBSD$ (in both comments and macros) unless the
code is definitely going to be merged to stable/12. This strengthens
previous statements and is appropriate now that stable/11 is no longer
supported. If people are wrong and things are unexpected merged to 12,
tags can be added before that merge. No sense adding a tag that will
never be expanded and removed later on the off chance it might wind up
in stable/12.

The next step is likely to weaken this to apply just to mergemaster
managed files, but not today.

Reviewed by:	rpokala, cem, erj, hselasky, brooks, kib
Differential Revision:	https://reviews.freebsd.org/D34152
2022-02-04 15:38:15 -07:00
Kirk McKusick
9583be047b Properly fix parameter to sysctlnametomib(). 2022-02-04 14:04:12 -08:00
Kirk McKusick
504cb544e2 Fix parameter to sysctlnametomib(); 2022-02-04 14:00:38 -08:00
Kirk McKusick
c0bfa109b9 Have fsck_ffs(8) properly correct superblock check-hash failures.
Part of the problem was that fsck_ffs would read the superblock
multiple times complaining and repairing the superblock check hash
each time and then at the end failing to write out the superblock
with the corrected check hash. This fix reads the superblock just
once and if the check hash is corrected ensures that the fixed
superblock gets written.

Tested by:    Peter Holm
PR:           245916
MFC after:    1 week
Sponsored by: Netflix
2022-02-04 11:47:48 -08:00
Ed Maste
930a7c2ac6 compiler-rt: re-exec with ASLR disabled when necessary
Some sanitizers (at least msan) currently require ASLR to be disabled.
When we detect that ASLR is enabled, re-exec with it disabled rather
than exiting with an error.  See LLVM GitHub issue 53256 for more
detail: https://github.com/llvm/llvm-project/issues/53256

No objection:	dim
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33934
2022-02-04 11:20:00 -05:00
Ed Maste
96fe7c8ab0 compiler-rt: support ReExec() on FreeBSD
Based on getMainExecutable() in llvm/lib/Support/Unix/Path.inc.
This will need a little more work for an upstream change as it must
support older FreeBSD releases that lack elf_aux_info() / AT_EXEC_PATH.

No objection:	dim
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33934
2022-02-04 11:18:12 -05:00
Emmanuel Vadot
867b4decb4 lindebugfs: Fix write
For write operation pseudofs creates an sbuf with the data.
Use this data instead of the uio as it's not usable anymore after
uiomove.

Reviewed by:	hselasky
MFC after:	1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D34114
2022-02-04 14:31:08 +01:00
Stefan Eßer
e11ad014d1 libc: return partial sysctl() result if buffer is too small
Testing of a new feature revealed that calling sysctl() to retrieve
the value of the user.localbase variable passing too low a buffer size
could leave the result buffer unchanged.

The behavior in the normal case of a sufficiently large buffer was
correct.

All known callers pass a sufficiently large buffer and have thus not
been affected by this issue. If a non-default value had been assigned
to this variable, the result was as documented, too.

Fix the function to fill the buffer with a partial result, if the
passed in buffer size is too low to hold the full result.

MFC after:	3 days
2022-02-04 13:44:20 +01:00
Konstantin Belousov
9596b349bb x86 atomic.h: remove obsoleted comment
Modules no longer call kernel functions for atomic ops, and since the
previous commit, we always use lock prefix.

Submitted by:	Elliott Mitchell <ehem+freebsd@m5p.com>
Reviewed by:	jhb, markj
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34153
2022-02-04 14:01:39 +02:00
Konstantin Belousov
9c0b759bf9 x86 atomics: use lock prefix unconditionally
Atomics have significant other use besides providing in-system
primitives for safe memory updates.  They are used for implementing
communication with out of system software or hardware following some
protocols.

For instance, even UP kernel might require a protocol using atomics to
communicate with the software-emulated device on SMP hypervisor.  Or
real hardware might need atomic accesses as part of the proper
management protocol.

Another point is that UP configurations on x86 are extinct, so slight
performance hit by unconditionally use proper atomics is not important.
It is compensated by less code clutter, which in fact improves the
UP/i386 lifetime expectations.

Requested by:	Elliott Mitchell <ehem+freebsd@m5p.com>
Reviewed by:	Elliott Mitchell, imp, jhb, markj, royger
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34153
2022-02-04 14:01:39 +02:00
Konstantin Belousov
cbf999e75d x86 atomic.h: cleanup comments for preprocessor directives
Reviewed by:	Elliott Mitchell, imp, jhb, markj, royger
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34153
2022-02-04 14:01:39 +02:00
Andrew Turner
664640ba6c Sort the names of the arm64 debug registers
While here clean up the names for the naming convention of the other
registers in this file.

Reviewed by:	kib, mhorne (earlier version)
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34060
2022-02-04 10:49:27 +00:00
Sylvian Meygret
cd7306bb1f ip_mroute: split mrouter interface deactivation and if_free
Move if_free outside MRW_LOCK. This will silence LOR message
which might appere during deinitialization.
2022-02-04 10:25:07 +01:00
Adrian Chadd
e388de98bd ar40xx_switch: add initial switch for the IPQ4018/IPQ4019.
Summary:

This switch is based off of the AR8327/AR8337 external switch/PHY.
However unlike the AR8327/AR8337 it itself doesn't have any PHYs;
instead an external PHY connects to it using the PSGMII port.

Differential Revision: https://reviews.freebsd.org/D34112
Reviewed by: manu

This code is inspired by the ar40xx code in openwrt, which itself
is based on the Qualcomm QCA-SSDK.  Both of these sources are, amusingly,
BSD licenced - and thus I have included some of the comments in the
hardware workaround paths to document some of the magic numbers.
2022-02-03 21:27:13 -08:00
Adrian Chadd
b509e53896 dts: add IPQ4018/IPQ4019 ethernet MAC and ethernet switch definitions
This adds the ethernet MAC and ethernet switch definitions.

I've rewritten the header file and the DTS based on documentation
and the required driver fields rather than the GPL'ed
ones from openwrt.

Differential Revision: https://reviews.freebsd.org/D34111
Reviewed by: manu
2022-02-03 21:26:45 -08:00
Adrian Chadd
29332c0dce qcom_mdio: add initial IPQ4018 MDIO support
This adds support for the IPQ4018/IPQ4019 MDIO bus.  This is used to
talk to external PHYs and switches.  (There's an internal switch
in the IPQ4018/IPQ4019 as well, but it's accessible via MMIO/AXI.)

Differential Revision: https://reviews.freebsd.org/D34110
Reviewed by: manu
2022-02-03 21:26:14 -08:00
Henri Hennebert
ad494d3b2d rtsx: Update driver version number to 2.1c
Differential Revision:	https://reviews.freebsd.org/D32154
2022-02-03 18:43:13 -05:00
Henri Hennebert
1e800a5934 rtsx: Do not display pci_read_config() errors during rtsx_init()
Differential Revision:	https://reviews.freebsd.org/D32154
2022-02-03 18:43:13 -05:00
Henri Hennebert
ec1f122b56 rtsx: Add CTLFLAG_STATS flag for read and write counters
Differential Revision:	https://reviews.freebsd.org/D32154
2022-02-03 18:43:12 -05:00
Henri Hennebert
7e5933b333 rtsx: Prefer __FreeBSD_version over __FreeBSD__
No functional change.

Differential Revision:	https://reviews.freebsd.org/D32154
2022-02-03 18:43:12 -05:00
Henri Hennebert
8e9740b62e rtsx: Convert driver to use the mmc_sim interface
A lot more generic cam related things were done in mmc_sim so this
simplifies the driver a lot.

Differential Revision:	https://reviews.freebsd.org/D32154
Reviewed by:		imp
2022-02-03 18:43:12 -05:00
Justin Hibbits
aa4736459e powerpc/atomic: Fix atomic_testand_*_long on powerpc64
After b5d227b0 FreeBSD was panicking on boot with "Duplicate free" in
UMA.  Analyzing the asm, the '1' mask was treated as an integer, rather
than a long, causing 'slw' (shift left word) to be used for the shifting
instruction, not 'sld' (shift left double).  This means the upper bits
of the bitfield were not getting used, resulting in corruption of the
bitfield.

While fixing this, the 'and' check of the mask does not need to be
recorded, so don't record (drop the '.').
2022-02-03 17:25:39 -06:00
Alexander Motin
3b248a2113 APEI: Make sure event data fit into the buffer.
There seem to be systems returning some garbage here.  I still don't
know why, but at least I hope this check fix indefinite printf loop.

MFC after:	2 weeks
2022-02-03 15:33:01 -05:00
Richard Scheffenegger
fd723975ec tcp: fix typo in commit f026275e26
missed one bitmask inversion while committing D34148

Differential Revision: https://reviews.freebsd.org/D34148
Differential Revision: https://reviews.freebsd.org/D34160
2022-02-03 21:05:09 +01:00
Richard Scheffenegger
3b0ee68050 tcp: Prevent setting of ECN bits with setsockopt()
setsockopt() grants full access to the deprecated
TOS byte. For TCP, mask out the ECN codepoint, so that
only the DSCP portion can be adjusted.

Reviewed By: tuexen, hselasky, #manpages, #transport, debdrup
Sponsored by:        NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D34154
2022-02-03 20:06:42 +01:00
Jesper Schmitz Mouridsen
ea07ba1170 sys/arm64/iommu/iommu_pmap.c readd sys/systm.h
after d950c5898a UINT64_C and bzero were no longer defined

Approved by:	kib
Differential Revision:	https://reviews.freebsd.org/D34155
2022-02-03 20:03:29 +01:00
Konstantin Belousov
529575be27 lnumeric.c: replace some space*8 by tabs
Reported by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-02-03 20:56:03 +02:00
John Baldwin
87c5d39f77 iwlwifi: Disable -Wformat when building with GCC.
GCC's -Wformat complains about NULL format strings passed to
iwl_fw_dbg_collect_trig (though the function handles NULL format
strings).  Curious that upstream iwlwifi in Linux is built with GCC
and explicitly opts into this warning via the __printf() attribute.

Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D34146
2022-02-03 10:48:18 -08:00
Wolfram Schneider
d43255b50c remove dead code
A lookup array is faster than a function with linear search.
The old function was not used for years - spring cleaning.
2022-02-03 17:02:37 +00:00
Wolfram Schneider
39a30a8097 better printf(3) format usage
Reported by: jhb
2022-02-03 16:57:25 +00:00
Hans Petter Selasky
c830e92924 mlx5ib: Fix whitespace.
Found by:	kib@
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-02-03 17:45:19 +01:00
Cy Schubert
5d4a348d0b ipfilter: Fix indentation error
Fixes:		064a5a9564
MFC after:	3 days
2022-02-03 08:37:11 -08:00
Hans Petter Selasky
12af59c2cf mlx5ib: Add missing auto generated header file to Makefile.
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-02-03 17:35:12 +01:00
Alexander Motin
1a8d8a3a90 CTL: Fix mode page trucation on HA synchronization.
Due to variable size of struct ctl_ha_msg_mode ctl_isc_announce_mode()
sent only first 4 bytes of modified mode page to the other HA side,
that caused its corruption there, noticeable only after failover.

I've found alike bug also in ctl_isc_announce_lun(), but there it was
sending slightly more than needed, that is a smaller problem.

MFC after:	1 week
Sponsored by:	iXsystems, Inc.
2022-02-03 11:10:12 -05:00
Kyle Evans
642701abc8 kern: harvest entropy from callouts
74cf7cae4d ("softclock: Use dedicated ithreads for running callouts.")
switched callouts away from the swi infrastructure.  It turns out that
this was a major source of entropy in early boot, which we've now lost.

As a result, first boot on hardware without a 'fast' entropy source
would block waiting for fortuna to be seeded with little hope of
progressing without manual intervention.

Let's resolve it by explicitly harvesting entropy in callout_process()
if we've handled any callouts.  cc/curthread/now seem to be reasonable
sources of entropy, so use those.

Discussed with:	jhb (also proposed initial patch)
Reported by:	many
Reviewed by:	cem, markm (both csprng)
Differential Revision:	https://reviews.freebsd.org/D34150
2022-02-03 10:05:06 -06:00
Richard Scheffenegger
f026275e26 tcp: set IP ECN header codepoint properly
TCP RACK can cache the IP header while preparing
a new TCP packet for transmission. Thus all the
IP ECN codepoint bits need to be assigned, without
assuming a clear field beforehand.

Reviewed By: tuexen, kbowling, #transport
MFC after:   3 days
Sponsored by:        NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D34148
2022-02-03 16:53:41 +01:00
Richard Scheffenegger
1ebf460758 tcp: Access all 12 TCP header flags via inline function
In order to consistently provide access to all
(including reserved) TCP header flag bits,
use an accessor function tcp_get_flags and
tcp_set_flags. Also expand any flag variable from
uint8_t / char to uint16_t.

Reviewed By: hselasky, tuexen, glebius, #transport
Sponsored by:        NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D34130
2022-02-03 16:21:58 +01:00
Mark Johnston
03399cd6e0 filemon.4: Document FILEMON_SET_FD errors and refine wording a bit
Reviewed by:	emaste, debdrup, Pau Amma
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34128
2022-02-03 09:46:34 -05:00
Mark Johnston
b84ed4e7f6 filemon: Reject FILEMON_SET_FD commands when the fd is a kqueue
When FILEMON_SET_FD is used, the filemon handle effectively wraps the
passed file.  In particular, the handle may be inherited by a child
process, or transferred over a unix domain socket, so we must verify
that the backing file permits this.

Reported by:	syzbot+36e6be9e02735fe66ca8@syzkaller.appspotmail.com
Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34128
2022-02-03 09:41:53 -05:00
Michael Tuexen
d51c80351f rack: fix compilation and small cleanup
Fix a function prototype missed in the last commit and whitespace
change.
Sponsored by:	Netflix, Inc.
2022-02-02 09:41:40 +01:00
Michael Tuexen
3b3c08c135 tcp: cleanup functions related to socket option handling
Consistently only pass the inp and the sopt around. Don't pass the
so around, since in a upcoming commit tcp_ctloutput_set() will be
called from a context different from setsockopt(). Also expect
the inp to be locked when calling tcp_ctloutput_[gs]et(), this is
also required for the upcoming use by tcpsso, a command line tool
to set socket options.
Reviewed by:		glebius, rscheff
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D34151
2022-02-02 09:27:59 +01:00
Peter Holm
8d72c409cd stress2: Fix "set but not used [-Wunused-but-set-variable]" warnings 2022-02-03 11:52:38 +01:00