Commit graph

256926 commits

Author SHA1 Message Date
Wei Hu
2fbdbfaa0c Hyper-V: hn: Initialize the internal field of per packet info on tx path
The RSC support feature introduced a bit field "rm_internal" in
struct rndis_pktinfo with total size unchanged.

The guest does not use this field in the tx path. However we need to
initialize it to zero in case older hosts which are not aware of this
field.

Fixes:		a491581f ("Hyper-V: hn: Enable vSwitch RSC support")
MFC after:	2 weeks
Sponsored by:	Microsoft

(cherry picked from commit 805dbff6c3)
2021-03-29 03:21:30 -07:00
Wei Hu
cdc59163ff Hyper-V: hn: Enable vSwitch RSC support in hn netvsc driver
Receive Segment Coalescing (RSC) in the vSwitch is a feature available in
Windows Server 2019 hosts and later. It reduces the per packet processing
overhead by coalescing multiple TCP segments when possible. This happens
mostly when TCP traffics are among different guests on same host.
This patch adds netvsc driver support for this feature.

The patch also updates NVS version to 6.1 as needed for RSC
enablement.

MFC after:	2 weeks
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D29075

(cherry picked from commit a491581f3f)
2021-03-29 03:20:03 -07:00
Wei Hu
a86be0da9a Hyper-V: hn: Store host hash value in flowid
When rx packet contains hash value sent from host, store it in
the mbuf's flowid field so when the same mbuf is on the tx path,
the hash value can be used by the host to determine the outgoing
network queue.

MFC after:	2 weeks
Sponsored by:	Microsoft

(cherry picked from commit 80f39bd95f)
2021-03-29 03:18:20 -07:00
Alexander V. Chernikov
823a80f4f9 Zero struct weightened_nhop fields in nhgrp_get_addition_group().
`struct weightened_nhop` has spare 32bit between the fields due to
 the alignment (on amd64).
Not zeroing these spare bits results in duplicating nhop groups
 in the kernel due to the way how comparison works.

(cherry picked from commit 6f43c72b47)
2021-03-28 20:41:56 +00:00
Glen Barber
1048c56784 Makefile.inc1: unbreak bootstrap when kbdcontrol does not exist
Submitted by:		Evgeniy Khramtsov
Reviewed by:		arichardson
Sponsored by:		Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 50179c5ec7)
2021-03-28 13:49:34 -04:00
Mark Johnston
c7d10e7ec8 accept_filter: Fix filter parameter handling
For filters which implement accf_create, the setsockopt(2) handler
caches the filter name in the socket, but it also incorrectly frees the
buffer containing the copy, leaving a dangling pointer.  Note that no
accept filters provided in the base system are susceptible to this, as
they don't implement accf_create.

Reported by:	Alexey Kulaev <alex.qart@gmail.com>
Discussed with:	emaste
Security:	kernel use-after-free
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 653a437c04)
2021-03-27 20:24:15 -04:00
Mark Johnston
41a8dc3619 pf: Handle unmapped mbufs when computing checksums
PR:		254419
Reviewed by:	gallatin, kp
Tested by:	Igor A. Valkov <viaprog@gmail.com>
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29378

(cherry picked from commit b93a796b06)
2021-03-27 20:23:57 -04:00
Rick Macklem
85ad493677 mountd(8): generate a syslog message when the "V4:" line is missing
Daniel reported that NFSv4 mounts were not working despite having
set "nfsv4_server_enable=YES" in /etc/rc.conf.  Mountd was logging a
message that there was no /etc/exports file.
He noted that creating a /etc/exports file with a "V4:" line in it
was needed make NFSv4 mounts work.
At least one "V4:" line in one of the exports(5) file(s) is needed to
make NFSv4 mounts work. This patch fixes mountd.c so that it logs a
message indicting that there is no "V4:" line in any exports(5)
file when NFSv4 mounts are enabled.
To avoid this message being generated erroneously, /etc/rc.d/mountd
is updated to make sure vfs.nfsd.server_max_nfsvers is properly set
before mountd(8) is started.

PR:	253901

(cherry picked from commit 09673fc0f3)
2021-03-27 12:52:15 -07:00
Piotr Pawel Stefaniak
0e9d4b8b75 security.7: fix typo in sysctl name
It is machdep.syscall_ret_flush_l1d.

(cherry picked from commit 4233882f4e)
2021-03-27 19:45:33 +01:00
Emmanuel Vadot
08639983e0 release: amd64: Fix ISO/USB hybrid image
Recent mkimg changes forces to have partitions given in explicit order.
This is so we can have the first partition starting at a specific offset
and the next ones starting after without having to specify an offset.
Switch the partition in the mkisoimage.sh script so the first one created
is the isoboot one.

PR:    254490
Reported by:	Michael Dexter <editor@callfortesting.org
Tested by:	Vincent Milum Jr <freebsd@darkain.com>
MFC after:	Right now

(cherry picked from commit 90d2f7c413)
2021-03-27 12:09:22 +01:00
Jessica Clarke
a20427cc03 elftoolchain: Support building on Arm-based Macs
Currently macOS and DragonFlyBSD get their own special case and only
handle x86. Since all the FreeBSD cases should be general enough for
macOS and DragonFlyBSD (and the x86 ones are identical to the existing
ones) we can just delete the special cases and reuse the FreeBSD ones.

Note that upstream has since removed all the architecture-specific
checks in this file, with the only code relevant to us being an
endianness check that uses the generic compiler-provided macros. Thus
this patch will not be upstreamed, and will be dropped in a future
vendor import.

(cherry picked from commit 839fdcfc0c)
2021-03-27 02:10:29 +00:00
Jessica Clarke
5a9fe096f1 tools/build: Improve host-symlinks failure mode
Since set -e is enabled by sys.mk, if the tool cannot be found in PATH
then the entire shell command line fails, causing us to not print the
error message below and instead silently (due to the @) fail, only
getting the usual "Error code 1" print from bmake. Thus, provide a dummy
default that will never exist (the same as is used by meta2deps.sh) if
which fails so that we get the error message as intended.

(cherry picked from commit 8c9e45503f)
2021-03-27 02:10:29 +00:00
D Scott Phillips
7590d7800c bhyve: support relocating fbuf and passthru data BARs
We want to allow the UEFI firmware to enumerate and assign
addresses to PCI devices so we can boot from NVMe[1]. Address
assignment of PCI BARs is properly handled by the PCI emulation
code in general, but a few specific cases need additional support.
fbuf and passthru map additional objects into the guest physical
address space and so need to handle address updates. Here we add a
callback to emulated PCI devices to inform them of a BAR
configuration change. fbuf and passthru then watch for these BAR
changes and relocate the frame buffer memory segment and passthru
device mmio area respectively.

We also add new VM_MUNMAP_MEMSEG and VM_UNMAP_PPTDEV_MMIO ioctls
to vmm(4) to facilitate the unmapping needed for addres updates.

[1]: https://github.com/freebsd/uefi-edk2/pull/9/

Originally by:	scottph
Sponsored by:	Intel Corporation
Reviewed by:	grehan
Approved by:	philip (mentor)
Differential Revision:	https://reviews.freebsd.org/D24066

(cherry picked from commit f8a6ec2d57)
2021-03-26 21:50:41 +08:00
Ka Ho Ng
c4a34bb3f8 bhyve amd: Small cleanups in amdvi_dump_cmds
Bump offset with MOD_INC instead in amdvi_dump_cmds.

Reviewed by:	jhb
Approved by:	philip (mentor)
Differential Revision:	https://reviews.freebsd.org/D28862

(cherry picked from commit be97fc8dce)
2021-03-26 21:50:36 +08:00
Alexander V. Chernikov
47c00a9835 Plug nexthop group refcount leak.
In case with batch route delete via rib_walk_del(), when
 some paths from the multipath route gets deleted, old
 multipath group were not freed.

PR:    254496
Reported by:   Zhenlei Huang <zlei.huang@gmail.com>

(cherry picked from commit 66f138563b)
2021-03-25 20:22:58 +00:00
Alexander V. Chernikov
af85312e8a Fix panic when destroying interface with ECMP routes.
Reported by:	Zhenlei Huang <zlei.huang at gmail.com>
PR:		254496

(cherry picked from commit a0308e48ec)
2021-03-25 20:22:21 +00:00
Alexander V. Chernikov
42f997d9b7 Fix kassert panic when inserting multipath routes from multiple threads.
Reported by:	Marco Zec <zec at fer.hr>

(cherry picked from commit 2476178e6b)
2021-03-25 20:07:42 +00:00
Jung-uk Kim
280d35ab5b OpenSSL: Regen manual pages for 1.1.1k
(cherry picked from commit 7595394130)
2021-03-25 12:22:21 -04:00
Jung-uk Kim
2c7061d852 OpenSSL: Merge OpenSSL 1.1.1k
Merge commit '94fa08a4bcdfbb3434b025d67d014af3b18e5380'

(cherry picked from commit b6c1fdcdf5)
2021-03-25 12:21:51 -04:00
Robert Watson
ba08ba5226 Teach DTrace that unaligned accesses are OK on aarch64, not just x86.
MFC after:	3 days
Reviewed:	andrew
Differential Revision:	https://reviews.freebsd.org/D29369
2021-03-25 09:17:38 -04:00
Robert Watson
fcc700abe4 Tune DTrace 'aframes' for the FBT and profile providers on arm64.
In both cases, too few frames were trimmed, leading to exception handling
or DTrace internals being exposed in stack traces exposed by D's stack()
primitive.

Reviewed by:	emaste, andrew
Differential Revision:	https://reviews.freebsd.org/D29356

(cherry picked from commit 599fb1d198)
2021-03-25 09:16:41 -04:00
Lawrence Stewart
828e6b5f5e random(9): Restore historical [0,2^31-1] output range and related man documention.
Commit SVN r364219 / Git 8a0edc914f changed random(9) to be a shim around
prng32(9) and inadvertently caused random(9) to begin returning numbers in the
range [0,2^32-1] instead of [0,2^31-1], where the latter has been the documented
range for decades.

The increased output range has been identified as the source of numerous bugs in
code written against the historical output range e.g. ipfw "prob" rules and
stats(3) are known to be affected, and a non-exhaustive audit of the tree
identified other random(9) consumers which are also likely affected.

As random(9) is deprecated and slated for eventual removal in 14.0, consumers
should gradually be audited and migrated to prng(9).

Submitted by:		Loic Prylli <lprylli@netflix.com>
Obtained from:		Netflix
Reviewed by:		cem, delphij, imp
MFC after:		1 day
MFC to:			stable/13, releng/13.0
Differential Revision:	https://reviews.freebsd.org/D29385

(cherry picked from commit dbbf3e3f37)
2021-03-25 17:57:02 +11:00
Ed Maste
6acecf247f mn: bump deprecation version to 14 in man page as well
Fixes: 66e75d9e2ddd ("mn: report that this driver is removed in 14, not 13")
2021-03-24 22:38:49 -04:00
Ed Maste
a66e75d9e2 mn: report that this driver is removed in 14, not 13 2021-03-24 22:35:38 -04:00
Ed Maste
db50c81234 arm64: implement COMPAT_FREEBSD32 fill/set dbregs/fpregs
On FreeBSD/arm fill_fpregs, fill_dbregs are stubs that zero the reg
struct and return success. set_fpregs and set_dbregs do nothing and
return success.

Provide the same implementation for arm64 COMPAT_FREEBSD32.

Reviewed by:	andrew
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29314

(cherry picked from commit 5be27cbf16)
2021-03-24 14:37:34 -04:00
Mark Johnston
e4bdf7ac2a rtsold: Fix validation of RDNSS options
The header specifies the size of the option in multiples of eight bytes.
The option consists of an eight-byte header followed by one or more IPv6
addresses, so the option is invalid if the size is not equal to 1+2n for
some n>0.  Check this.

The bug can cause random stack data to be formatted as an IPv6 address
and passed to resolvconf(8), but a host able to trigger the bug may also
specify arbitrary addresses this way.

Reported by:	Q C <cq674350529@gmail.com>
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 1af332a7d8)
2021-03-24 09:27:59 -04:00
Cy Schubert
7b3ff601f9 MFC eeb26cf52c:
wpa: import fix for P2P provision discovery processing vulnerability

Latest version available from: https://w1.fi/security/2021-1/

Vulnerability

A vulnerability was discovered in how wpa_supplicant processes P2P
(Wi-Fi Direct) provision discovery requests. Under a corner case
condition, an invalid Provision Discovery Request frame could end up
reaching a state where the oldest peer entry needs to be removed. With
a suitably constructed invalid frame, this could result in use
(read+write) of freed memory. This can result in an attacker within
radio range of the device running P2P discovery being able to cause
unexpected behavior, including termination of the wpa_supplicant process
and potentially code execution.

Vulnerable versions/configurations

wpa_supplicant v1.0-v2.9 with CONFIG_P2P build option enabled

An attacker (or a system controlled by the attacker) needs to be within
radio range of the vulnerable system to send a set of suitably
constructed management frames that trigger the corner case to be reached
in the management of the P2P peer table.

Note: FreeBSD base does not enable P2P.
(cherry picked from commit eeb26cf52c)
2021-03-24 01:55:49 -07:00
Hans Petter Selasky
ff2e2bca31 MFC 1acf24a044:
Implement pci_get_relaxed_ordering_enabled() helper function.

Discussed with:	kib@
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 1acf24a044)
2021-03-24 08:54:52 +01:00
Alexander Motin
ed407c92e4 nvme: Replace potentially long DELAY() with pause().
In some cases like broken hardware nvme(4) may wait minutes for
controller response before timeout.  Doing so in a tight spin loop
made whole system unresponsive.

Reviewed by:	imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D29309
Sponsored by:	iXsystems, Inc.

(cherry picked from commit 4fbbe52365)
2021-03-23 21:26:00 -04:00
Dag-Erling Smørgrav
c6aa83342e MFC: Fix post-start check when unbound.conf has moved.
On behalf of:	des
Reported by:	phk@
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 409388cfac)
2021-03-23 20:56:33 -04:00
Dag-Erling Smørgrav
34e12e9a17 MFC: Fix local-unbound setup for some IPv6 deployments.
On behalf of:	des
PR:		250984

(cherry picked from commit e5f02c140b)
2021-03-23 20:53:35 -04:00
Vincenzo Maffione
3e4127f8f2 netmap: fix issues in nm_os_extmem_create()
- Call vm_object_reference() before vm_map_lookup_done().
- Use vm_mmap_to_errno() to convert vm_map_* return values to errno.
- Fix memory leak of e->obj.

Reported by:	markj
Reviewed by:	markj
MFC after:	1 week

(cherry picked from commit ee7ffaa2e6)
2021-03-23 21:17:23 +00:00
Nathan Whitehorn
4601382e13 Fix scripted installs on EFI systems after default mounting of the ESP.
Because the ESP mount point (/boot/efi) is in mtree, tar will attempt to
extract a directory at that point post-mount when the system is installed.
Normally, this is fine, since tar can happily set whatever properties it
wants. For FAT32 file systems, however, like the ESP, tar will attempt to
set mtime on the root directory, which FAT does not support, and tar will
interpret this as a fatal error, breaking the install (see
https://github.com/libarchive/libarchive/issues/1516). This issue would
also break scripted installs on bare-metal POWER8, POWER9, and PS3
systems, as well as some ARM systems.

This patch solves the problem in two ways:
- If stdout is a TTY, use the distextract stage instead of tar, as in
  interactive installs. distextract solves this problem internally and
  provides a nicer UI to boot, but requires a TTY.
- If stdout is not a TTY, use tar but, as a stopgap for 13.0, exclude
  boot/efi from tarball extraction and then add it by hand. This is a
  hack, and better solutions (as in the libarchive ticket above) will
  obsolete it, but it solves the most common case, leaving only
  unattended TTY-less installs on a few tier-2 platforms broken.

In addition, fix a bug with fstab generation uncovered once the tar issue
is fixed that umount(8) can depend on the ordering of lines in fstab in a
way that mount(8) does not. The partition editor now writes out fstab in
mount order, making sure umount (run at the end of scripted, but not
interactive, installs) succeeds.

PR:		254395
Approved by:	re (gjb)
Reviewed by:	gjb, imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D29380

(cherry picked from commit c2f16c595e)
2021-03-23 15:21:33 -04:00
Kristof Provost
7d58861586 pf: pool/kpool conversion code
stuct pf_pool and struct pf_kpool are different. We should not simply
bcopy() them.

Happily it turns out that their differences were all pointers, and the
userspace provided pointers were overwritten by the kernel, so this did
actually work correctly, but we should fix it anyway.

Reviewed by:	glebius
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29216

(cherry picked from commit 15b82e00a1)
2021-03-23 13:23:55 +01:00
Michal Vanco
395e612b7b pchtherm: fix a wrong bit and a wrong register use
Probably just copy-paste errors that slipped in.

(cherry picked from commit 5084dde5f0)

PR:		253915
Reported by:	Michal Vanco <michal.vanco@gmail.com>
2021-03-23 13:01:20 +02:00
Hans Petter Selasky
3e4fe9ca73 MFC dfb33cb0ef:
Allocating the LinuxKPI current structure from a software interrupt thread
must be done using the M_NOWAIT flag after 1ae20f7c70 .

Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit dfb33cb0ef)
2021-03-23 11:54:01 +01:00
Hans Petter Selasky
093204e2d0 MFC d1cbe79089:
Allocating the LinuxKPI current structure from an interrupt thread must be
done using the M_NOWAIT flag after 1ae20f7c70 .

Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit d1cbe79089)
2021-03-23 11:51:22 +01:00
Hans Petter Selasky
dd426d6764 MFC 6eb60f5b7f:
Use the word "LinuxKPI" instead of "Linux compatibility", to not confuse with
user-space Linux compatibility support. No functional change.

Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 6eb60f5b7f)
2021-03-23 11:51:04 +01:00
Hans Petter Selasky
773811507d MFC ebe5cf355d:
Implement basic support for allocating memory from a specific numa node
in the LinuxKPI.

Differential Revision:	https://reviews.freebsd.org/D29077
Reviewed by:	markj@ and kib@
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit ebe5cf355d)
2021-03-23 11:50:47 +01:00
Hans Petter Selasky
7d7ed0223c MFC c743a6bd4f:
Implement mallocarray_domainset(9) variant of mallocarray(9).

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

(cherry picked from commit c743a6bd4f)
2021-03-23 11:50:29 +01:00
Mark Johnston
7cde0b06f9 stand: Load INIT_ARRAY and FINI_ARRAY sections
This is required for preloading modules into a KASAN-configured kernel.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 7b1b5aad95)
2021-03-22 21:32:08 -04:00
John Baldwin
30e25f9304 nlmrsa: Mark deprecated for 14.
This is the only in-tree driver for the asymmetric crypto support in
OCF that is already marked deprecated for 14.

Sponsored by:	Chelsio Communications

(cherry picked from commit 096a847216)
2021-03-22 15:52:52 -07:00
John Baldwin
6a1dbc8ba9 iscsi: Mark iSCSI CAM sims as non-pollable.
Previously, iscsi_poll() just panicked.  This meant if you got a panic
on a box when using the iSCSI initiator, the attempt to shutdown would
trigger a nested panic and never write out a core.  Now, CCB's sent to
iSCSI devices (such as the sychronize-cache request in dashutdown())
just fail with a timeout during a panic shutdown.

Sponsored by:	Chelsio

(cherry picked from commit 47769bc557)
2021-03-22 13:37:46 -07:00
John Baldwin
9df8f5a9c6 cam: Don't permit crashdumps on non-pollable devices.
If a disk's SIM doesn't support polling, then it can't be used to
store crashdumps.  Leave d_dump NULL in that case so that dumpon(8)
fails gracefully rather than having dumps fail at crash time.

Sponsored by:	Chelsio

(cherry picked from commit e07ac3f2fd)
2021-03-22 13:37:38 -07:00
John Baldwin
444aff3673 cam: Permit non-pollable sims.
Some CAM sim drivers do not support polling (notably iscsi(4)).
Rather than using a no-op poll routine that always times out requests,
permit a SIM to set a NULL poll callback.  cam_periph_runccb() will
fail polled requests non-pollable sims immediately as if they had
timed out.

Sponsored by:	Chelsio

(cherry picked from commit 447b3557a9)
(cherry picked from commit e6405c8c37)
2021-03-22 13:36:09 -07:00
Mitchell Horne
b3598ed444 armv8crypto: note derivation in armv8_crypto_wrap.c
This file inherits some boilerplate and structure from the analogous
file in aesni(4), aesni_wrap.c. Note the derivation and the copyright
holders of that file.

For example, the AES-XTS bits added in 4979620ece were ported from
aesni(4).

Requested by:	jmg
Reviewed by:	imp, gnn

(cherry picked from commit da45b46266)
2021-03-22 13:14:51 -03:00
Mark Johnston
46f44865e3 iflib: Make if_shared_ctx_t a pointer to const
This structure is shared among multiple instances of a driver, so we
should ensure that it doesn't somehow get treated as if there's a
separate instance per interface.  This is especially important for
software-only drivers like wg.

DEVICE_REGISTER() still returns a void * and so the per-driver sctx
structures are not yet defined with the const qualifier.

Reviewed by:	gallatin, erj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29102

(cherry picked from commit ffe3def903)
2021-03-22 11:42:18 -04:00
Leandro Lupori
3aa6cc000f ofwfb: fix boot on LE
Some framebuffer properties obtained from the device tree were not being
properly converted to host endian.
Replace OF_getprop calls by OF_getencprop where needed to fix this.

This fixes boot on PowerPC64 LE, when using ofwfb as the system console.

Reviewed by:    bdragon
Sponsored by:   Eldorado Research Institute (eldorado.org.br)
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D27475

(cherry picked from commit 043577b721)
2021-03-22 10:48:46 -03:00
Alexander Motin
0cb06bcc54 Include ccompile.h after opt_global.h.
This restores INVARIANTS enabling ZFS_DEBUG when built as module.

Discussed with:	freqlabs
MFC after:	1 week

(cherry picked from commit 8ea35c45d5)
2021-03-21 20:54:06 -04:00
Mike Karels
35e7b6bff0 genet: Fix problem with forwarding some TCP/IPv6 packets
TCP/IPv6 packets to be forwarded can be laid out with only the Ethernet
header in the first mbuf, and these packets are lost.  There was a
previous hack to pullup ICMPv6 packets with such a layout for the
same reason.  Generalize, and pullup any IPv6 packets with only the
Ethernet header in the first mbuf.  Possibly this should also include
IPv4, but that situation has not been observed to fail.

PR:		254060
Reported by:	denis at h3q.com
MFC after:	3 days

(cherry picked from commit 2bdcf62377)
2021-03-21 13:46:32 -05:00