Commit graph

137377 commits

Author SHA1 Message Date
Kristof Provost
5a1bc5f902 altq: Fix typo in features sysctl description
Reported by:	Jose Luis Duran

(cherry picked from commit 35dabb7b9c)
2021-07-31 10:12:01 +02:00
Kristof Provost
b0e7f371cd Add FEATURE sysctls for ALTQ disciplines
This will allow userspace to more easily figure out if ALTQ is built
into the kernel and what disciplines are supported.

Reviewed by:		donner@
Differential Revision:	https://reviews.freebsd.org/D28302

(cherry picked from commit e111d79806)
2021-07-31 10:12:01 +02:00
Mark Johnston
057275e4be ktrace: Zero request structures when populating the pool
Otherwise uninitialized pad bytes may be copied into the ktrace log
file.

Reported by:	KMSAN
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 5c18bf9d5f)
2021-07-29 20:32:59 -04:00
Mark Johnston
3e148d6029 select: Define select_flags[] as const
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit cae3f9dd01)
2021-07-29 20:32:59 -04:00
Mark Johnston
d364264b29 cdefs: Add a default definition for __nosanitizememory
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 4cd7e82a4c)
2021-07-29 20:32:58 -04:00
Mark Johnston
9ac0aec3a3 lio_listio: Don't post a completion notification if none was requested
One is allowed to use LIO_NOWAIT without specifying a sigevent.  In this
case, lj->lioj_signal is left uninitialized, but several code paths
examine liov_signal.sigev_notify to figure out which notification to
post.  Unconditionally initialize that field to SIGEV_NONE.

Add a dumb test case which triggers the bug.

Reported by:	KMSAN+syzkaller
Reviewed by:	asomers
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2e5f615295)
2021-07-29 20:32:58 -04:00
Mark Johnston
24c558ca3c imgact_elf: Avoid redefining suword()
Otherwise this interferes with the definition for sanitizer
interceptors.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit ebf9886654)
2021-07-29 20:32:58 -04:00
Mark Johnston
fdeacf8fdf acct: Zero pad bytes in accounting records
Reported by:	KMSAN
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 90959dd1e5)
2021-07-29 20:32:58 -04:00
Mark Johnston
a67749ac45 vfs: Initialize "lastfail" in vfs_mountroot_wait()
This variable is only used to rate-limit "Root mount waiting for: ..."
messages using ppsratecheck().

Reported by:	KMSAN
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 048cd371f3)
2021-07-29 20:32:58 -04:00
Mark Johnston
b76e41fca9 Add required sysctl name length checks to various handlers
Reported by:	KMSAN
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 0dcef81de9)
2021-07-29 20:32:58 -04:00
Kevin Bowling
fe6803c18e ixgbe: Clean up ix_txrx
The intention here is to reduce differences with D30072.
The only functional change is logical simplification in
ixgbe_rx_checksum.

Reviewed by:	gallatin
Differential Revision:	https://reviews.freebsd.org/D30074

(cherry picked from commit 51e46835e1)
2021-07-29 17:27:24 -07:00
Kevin Bowling
ebdd2bc441 ixgbe: Print FW NVM and Option ROM versions
It can be useful for system operators to see this kind of information
when correlating issues or requesting support from the OEM or Intel for
hardware and firmware issues.

Reviewed by:	gallatin
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D30178

(cherry picked from commit 7660e4ea5c)
2021-07-29 17:26:45 -07:00
Mitchell Horne
862ea25915 hwpmc_arm64: add a PMCDBG to the interrupt handler
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 13f5a3076b)
2021-07-29 12:05:55 -03:00
Mitchell Horne
83166f8714 arm64 support for pmu-events
8cc3815f:
hwpmc_arm64: accept raw event codes for PMC_OP_PMCALLOCATE

Make it possible to specify event codes without an offset of
PMC_EV_ARMV8_FIRST, by setting a machine-dependent flag. This is
required to make use of event definitions from pmu-events.

Reviewed by:	ray (slightly earlier version)
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D30602

28dd6730:
libpmc: enable pmu_utils on arm64

This allows supported libpmc to query/select from the pmu-events table,
which may have a more complete set of events than what we define
manually. A future update to these definitions should greatly improve
this support. The alias table is empty for now, until this future import
is complete.

Add the Foundation's copyright for recent work on this file.

Reviewed by:	ray (slightly earlier version)
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D30603

27ea55fc:
libpmc/hwpmc: fix issues with arm64 pmu-events support

Due to a mis-merge, the changes committed to libpmc never called
pmu_parse_event(), or set pm->pm_ev. However, this field shouldn't be
used to carry the actual pmc event code anyway, as it is expected to
contain the index into the pmu event array (otherwise, it breaks event
name lookup in pmclog_get_event()). Add a new MD field,
pm_md.pm_md_config, to pass the raw event code to arm64_allocate_pmc().

Additionally, the change made to pmc_md_op_pmcallocate was incorrect, as
this is a union, not a struct. Restore the proper padding size.

Reviewed by:	luporl, ray, andrew
Fixes:		28dd6730a5 ("libpmc: enable pmu_utils on arm64")
Fixes:		8cc3815f02 ("hwpmc_arm64: accept raw event codes...")
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31221

(cherry picked from commit 8cc3815f02)
(cherry picked from commit 28dd6730a5)
(cherry picked from commit 27ea55fc65)
2021-07-29 12:02:05 -03:00
Mitchell Horne
d876c5a052 hwpmc_arm64: fill kern.hwpmc.cpuid
This will be used to detect supported pmu events. The expected format is
the MIDR register with the revision and variant fields masked. See also:
lib/libpmc/pmu-events/arch/arm64/mapfile.csv.

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

(cherry picked from commit 5867cccdc4)
2021-07-29 12:01:11 -03:00
Mitchell Horne
a2d252f89f hwpmc_arm64.c: fix return style
In accordance to style(9).

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2129c8f677)
2021-07-29 12:01:10 -03:00
Mitchell Horne
96da64391d hwpmc: fix PMC_CPU_LAST
It is unused, but incorrect.

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit f59127dac5)
2021-07-29 12:01:09 -03:00
Andrew Turner
19135e372f arm64: Fix finding the pmc event ID
The lower pmc event bits were masked off to find the PMC event ID.
The doesn't work when there are more events. Switch it to use the
offser relative to the first event while also checking the ID is
in the expected range.

Reviewed by:	gnn, ray
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D29600

(cherry picked from commit 24b2f4ea49)
2021-07-29 12:00:37 -03:00
Mark Johnston
90ffac35b7 eli: Zero pad bytes that arise when certain auth algorithms are used
When authentication is configured, GELI ensures that the amount of data
per sector is a multiple of 16 bytes.  This is done in
eli_metadata_softc().  When the digest size is not a multiple of 16
bytes, this leaves some extra pad bytes at the end of every sector, and
they were not being zeroed before being written to disk.  In particular,
this happens with the HMAC/SHA1, HMAC/RIPEMD160 and HMAC/SHA384 data
authentication algorithms.

This change ensures that they are zeroed before being written to disk.

Reported by:	KMSAN
Reviewed by:	delphij, asomers
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 0fcafe8516)
2021-07-29 08:12:22 -04:00
Mark Johnston
822c62b7db Assert that valid PTEs are not overwritten when installing a new PTP
amd64 and 32-bit ARM already had assertions to this effect.  Add them to
other pmaps.

Reviewed by:	alc, kib
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit b092c58c00)
2021-07-29 08:12:12 -04:00
Mark Johnston
9f43633dd0 pf: Constify tag name and queue name helper functions
No functional change intended.

Reviewed by:	kp
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 81f95106b8)
2021-07-29 08:12:01 -04:00
Yang Zhong
50b26566c7 mmc: Drain the intrhook in mmc_detach()
Buggy SD card drivers may attach and detach a mmc(4) driver instance in
quick succession.  In this case mmc(4) must disestablish its intrhook
callback during detach.  Thus, this change adds a call to
config_intrhook_drain(), which blocks or does nothing if the intrhook is
running or has already ran (the SD card was plugged in), and
disestablishes the hook if it hasn't ran yet (the SD card was not
plugged in).

PR:		254373
Reviewed by:	imp, manu, markj
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d5341d72a1)
2021-07-29 08:11:50 -04:00
Mark Johnston
f9d3c6f4b5 nfsclient: Avoid copying uninitialized bytes into statfs
hst will be nul-terminated but the remaining space in the buffer is left
uninitialized.  Avoid copying the entire buffer to ensure that
uninitialized bytes are not leaked via statfs(2).

Reported by:	KMSAN
Reviewed by:	rmacklem
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 44de1834b5)
2021-07-29 08:11:16 -04:00
Mark Johnston
e504e98ab5 arm64: Print CPU features slightly earlier
In particular, print them before we release APs.  Otherwise they tend to
get mixed with other kernel messages.

Reviewed by:	andrew, manu
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit fa46a46a82)
2021-07-28 08:40:25 -04:00
Alan Somers
c7fe00ae40 fusefs: correctly set lock owner during FUSE_SETLK
During FUSE_SETLK, the owner field should uniquely identify the calling
process.  The fusefs module now sets it to the process's pid.
Previously, it expected the calling process to set it directly, which
was wrong.

libfuse also apparently expects the owner field to be set during
FUSE_GETLK, though I'm not sure why.

PR:		256005
Reported by:	Agata <chogata@moosefs.pro>
Reviewed by:	pfg
Differential Revision: https://reviews.freebsd.org/D30622

(cherry picked from commit 18b19f8c6e)
2021-07-27 11:44:28 -06:00
Kristof Provost
7d226e964a pf: clean up syncookie callout on vnet shutdown
Ensure that we cancel any outstanding callouts for syncookies when we
terminate the vnet.

MFC after:	1 week
Sponsored by:	Modirum MDPay

(cherry picked from commit 32271c4d38)
2021-07-27 09:45:41 +02:00
Kristof Provost
00b005036b pf: remove stray debug line
MFC after:	1 week
Sponsored by:	Modirum MDPay

(cherry picked from commit 84db87b8da)
2021-07-27 09:45:31 +02:00
Kristof Provost
eae9481e86 pf: fix LINT build
We failed to list the new pf_syncookies.c file in sys/conf/files. This
worked for the usual configurations, where pf is a module, but not for
LINT builds.

Reported by:	lwhsu
MFC after:	1 week
Sponsored by:	Modirum MDPay

(cherry picked from commit b972a7fa9e)
2021-07-27 09:45:23 +02:00
Kristof Provost
2987a3643b pf: syncookie ioctl interface
Kernel side implementation to allow switching between on and off modes,
and allow this configuration to be retrieved.

MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D31139

(cherry picked from commit 231e83d342)
2021-07-27 09:42:52 +02:00
Kristof Provost
c3d03672e1 pf: syncookie support
Import OpenBSD's syncookie support for pf. This feature help pf resist
TCP SYN floods by only creating states once the remote host completes
the TCP handshake rather than when the initial SYN packet is received.

This is accomplished by using the initial sequence numbers to encode a
cookie (hence the name) in the SYN+ACK response and verifying this on
receipt of the client ACK.

Reviewed by:	kbowling
Obtained from:	OpenBSD
MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D31138

(cherry picked from commit 8e1864ed07)
2021-07-27 09:42:25 +02:00
Kristof Provost
0df576d98e pf: factor out pf_synproxy()
MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D31137

(cherry picked from commit ee9c3d3803)
2021-07-27 09:42:13 +02:00
Mark Johnston
82b475c654 gmirror: Zero the metadata block before writing
The mirror metadata fields contain string buffers and pad bytes, neither
were being zeroed before metadata was written to disk.  Also, the
metadata structure is smaller than the sector size, and in one case
gmirror was failing to zero-fill the full buffer before writing.

Fix these problems by pre-zeroing the metadata structure and the sector
buffer.

Reported by:	KMSAN
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 7f053a44ae)
2021-07-26 21:47:45 -04:00
Mark Johnston
f065d0bb29 blist: Correct the node count computed in blist_create()
Commit bb4a27f927 added the ability to allocate a span of blocks
crossing a meta node boundary.  To ensure that blst_next_leaf_alloc()
does not walk past the end of the tree, an extra all-zero meta node
needs to be present at the end of the allocation, and
blst_next_leaf_alloc() is implemented such that the presence of this
node terminates the search.

blist_create() computes the number of nodes required.  It had two
problems:
1. When the size of the blist is a power of BLIST_RADIX, we would
   unnecessarily allocate an extra level in the tree.
2. When the size of the blist is a multiple of BLIST_RADIX, we would
   fail to allocate a terminator node.  In this case,
   blst_next_leaf_alloc() could scan beyond the bounds of the
   allocation.  This was found using KASAN.

Modify blist_create() to handle these cases correctly.

Reported by:	pho
Reviewed by:	dougm

(cherry picked from commit 2783335cae)
2021-07-26 21:47:20 -04:00
Mark Johnston
a938bfca7a graid3: Zero the metadata block before writing
Ensure that string buffers and pad bytes are zero-filled before writing
graid3 metadata.

Reported by:	KMSAN
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 39552dff7b)
2021-07-26 21:47:12 -04:00
Mark Johnston
b88a1996e2 fifo: Explicitly initialize generation numbers when opening
The fi_rgen and fi_wgen fields are generation numbers used when sleeping
waiting for the other end of the fifo to be opened.  The fields were not
explicitly initialized after allocation, but this was harmless.  To
avoid false positives from KMSAN, though, ensure that they get
initialized to zero.

Reported by:	KMSAN
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit b9ca419a21)
2021-07-26 21:46:45 -04:00
Mark Johnston
9788041842 uart: Fix an out-of-bounds read in ns8250_bus_probe()
The problem is that ns8250_bus_probe() accesses a field from the
ns8250_softc, which embeds the generic UART softc, but the ns8250_softc
hasn't yet been allocated because we're still probing.

This is a regression from commit 0aefb0a63c.  This fixed a problem
where one of the upper four IER bits, which are usually reserved, needs
to be set in order to get RX interrupts before the RX FIFO is full.  At
the same time, we avoid clearing those reserved bits (see commit
58957d8717, though other UART drivers I looked at do not bother with
this).

So, copy what ns8250_init() does to disable interrupts, since we don't
know what the "right" mask is at this point.

Reported by:	syzbot+f256beefd0df9eb796e7@syzkaller.appspotmail.com
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 4a9a41650c)
2021-07-26 21:46:34 -04:00
Navdeep Parhar
6e405dd9e4 cxgbe(4): Remove some dead code.
(cherry picked from commit 3965469eaa)
2021-07-26 10:49:25 -07:00
Hans Petter Selasky
9661887500 Fix mismerge in OFED update
When OFED was upgraded to Linux v4.9, a bunch of Linux-specific
netlink changes were dropped.  Unfortunately, there was a mismerge
in this process and as a result ib_sa_cancel_query() would fail to
cancel an outstanding MAD.

This was causing rdma_destroy_id() to hang indefinitely waiting
for the MAD to complete and release the final reference.

Sponsored by: Dell Inc.
Differential Revision:	https://reviews.freebsd.org/D28421
Reviewed by: hselasky, kib

(cherry picked from commit 8a06ca2f73)
2021-07-26 18:12:35 +02:00
Hans Petter Selasky
5f23486df9 ipoib: Fix for accessing uninitialized pointers and freed memory during attach and detach.
Call infiniband_ifdetach() early to stop ifioctl(9) calls from user-space
during device removal. Also make sure that ifioctl(9) calls are blocked from
executing until the device is fully initialized. Ideally we would delay the
infiniband_ifattach() call, but because part of the initialization is to update
the link level address, that is not possible without more significant changes.

Reviewed by:	kib
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit cd2c05d323)
2021-07-26 18:04:33 +02:00
Hans Petter Selasky
5b803f6820 mlx5: Numa domain improvements.
Properly allocate all mlx5en(4) structures from correct numa domain.

While at it cleanup unused numa domain integers deriving from the
Linux version of mlx5en(4).

Reviewed by:	kib
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 7c3eff94bd)
2021-07-26 18:04:33 +02:00
Hans Petter Selasky
2b4db9bbc2 mlx5: Fix for uninitialized "uid" field.
Make sure the "uid" field gets properly set when destroying DCT and QP
objects by making a copy of the field when creating such objects.

Reviewed by:	kib
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit cbf6911e10)
2021-07-26 18:04:33 +02:00
Hans Petter Selasky
191a0e65a0 mlx4: Map core_clock page to user space only when allowed
Currently when we map the hca_core_clock page to the user space,
there are vulnerable registers, one of which is semaphore, on
this page as well. If user read the wrong offset, it can modify the
above semaphore and hang the device.

Hence, mapping the hca_core_clock page to the user space only when
user required it specifically.

After this patch, mlx4 core_clock won't be mapped to user space by
default. Oppose to current state, where mlx4 core_clock is always mapped
to user space.

Reviewed by:	kib
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit c8301cbb0f)
2021-07-26 18:04:33 +02:00
Hans Petter Selasky
fdab56d1f6 mlx5en: Allow binding channels to CPUs when RSS is not enabled.
Submitted by:	Netflix
Reviewed by:	kib
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit c8d16d1e08)
2021-07-26 18:04:33 +02:00
Hans Petter Selasky
9fe9a92ab6 ibcore: Add some functions and definitions for selecting and querying retryable ucontext cleanup.
Linux commit:
1c77483e4c50339b0306572167ccbff6b55d051b

Reviewed by:	kib
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit f60da09dbb)
2021-07-26 18:04:33 +02:00
Hans Petter Selasky
857966b357 mlx5en: Allocate per-channel doorbells.
To avoid congestion on the same PCI memory register space when
traffic consists mostly of small packets.

Reviewed by:	kib
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 9dfa21486e)
2021-07-26 18:04:33 +02:00
Hans Petter Selasky
0ebff67cab mlx5en: Wait for all TLS connections to terminate when unloading driver.
The driver expects all TLS tags to be returned to the driver before
it can free the UMA zone where the TLS tags reside.

Reviewed by:	kib
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 3a934ba7a3)
2021-07-26 18:04:33 +02:00
Hans Petter Selasky
cd08d4c537 mlx4ib and mlx5ib: Set slid to zero in Ethernet completion struct
IB spec says that a lid should be ignored when link layer is Ethernet,
for example when building or parsing a CM request message (CA17-34).
However, since ib_lid_be16() and ib_lid_cpu16()  validates the slid,
not only when link layer is IB, we set the slid to zero to prevent
false warnings in the kernel log.

Linux commit:
65389322b28f81cc137b60a41044c2d958a7b950

Reviewed by:	kib
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 30416d4e82)
2021-07-26 18:04:33 +02:00
Hans Petter Selasky
1554e2673b mlx5en: Configure relaxed PCI read and write ordering for ethernet.
This may improve performance in some configurations.

Reviewed by:	kib
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit de2437f199)
2021-07-26 18:04:32 +02:00
Hans Petter Selasky
c41403c5ca mlx5en: Check for pci_channel_offline() when draining sendqueue.
This speeds up detach in hypervisor environments.

Reviewed by:	kib
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 4692d9808e)
2021-07-26 18:04:32 +02:00
Hans Petter Selasky
763d239db2 mlx5ib: Implement support for enabling and disabling RoCE ECN.
RoCE is short for Remote direct memory access over Converged Ethernet.
ECN is short for Explicit Congestion Notification.

Reviewed by:	kib
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 8abf5ac0e6)
2021-07-26 18:04:32 +02:00