]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoMark some sysctls as CTLFLAG_MPSAFE.
Alexander Motin [Wed, 11 Aug 2021 00:44:27 +0000 (20:44 -0400)]
Mark some sysctls as CTLFLAG_MPSAFE.

MFC after: 2 weeks

(cherry picked from commit b776de6796fa0cd1b7dfaad75402e10907d47f29)

3 years agogeom(4): Mark all sysctls as CTLFLAG_MPSAFE.
Alexander Motin [Wed, 11 Aug 2021 00:18:46 +0000 (20:18 -0400)]
geom(4): Mark all sysctls as CTLFLAG_MPSAFE.

This code does not use Giant lock for very long time.

MFC after: 2 weeks

(cherry picked from commit c2da954203c0feb933d3be304710e0346c9ed222)

3 years agocam(4): Mark all sysctls as CTLFLAG_MPSAFE.
Alexander Motin [Wed, 11 Aug 2021 00:05:40 +0000 (20:05 -0400)]
cam(4): Mark all sysctls as CTLFLAG_MPSAFE.

This code does not use Giant lock for very long time.

MFC after: 2 weeks

(cherry picked from commit 303477d3253007bb5732deed2daea86b2cbd9aa8)

3 years agobhyve: Fix vq_getchain() error handling bugs in various device models
Mark Johnston [Tue, 24 Aug 2021 18:10:08 +0000 (14:10 -0400)]
bhyve: Fix vq_getchain() error handling bugs in various device models

Reviewed by: grehan, khng
Approved by: so
Security: CVE-2021-29631
Security: FreeBSD-SA-21:13.bhyve

(cherry picked from commit 71fbc6faed62e8eb5864f7c40839740f5e9f5558)

3 years agoFix multiple OpenSSL vulnerabilities.
Gordon Tetlow [Tue, 24 Aug 2021 18:03:46 +0000 (11:03 -0700)]
Fix multiple OpenSSL vulnerabilities.

Approved by: so
Security: SA-21:16.openssl
Security: CVE-2021-3711
Security: CVE-2021-3712

(cherry picked from commit be158ffe54dcc4a633652685afc5e37894e10ea0)

3 years agoFix libfetch out of bounds read.
Gordon Tetlow [Tue, 24 Aug 2021 17:59:01 +0000 (10:59 -0700)]
Fix libfetch out of bounds read.

Approved by: so
Security: SA-21:15.libfetch
Security: CVE-2021-36159

(cherry picked from commit 3be62d49ae2b6f9050f39fe74210c88f35901fa5)

3 years agoFix remote code execution in ggatec(8).
Gordon Tetlow [Tue, 24 Aug 2021 17:40:49 +0000 (10:40 -0700)]
Fix remote code execution in ggatec(8).

Approved by:    so
Security:       SA-21:14.ggatec
Security:       CVE-2021-29630

(cherry picked from commit 515216929c40169cc72b62466ff9238682661613)

3 years agoipfw: fix possible data race between jump cache reading and updating.
Andrey V. Elsukov [Tue, 17 Aug 2021 08:08:28 +0000 (11:08 +0300)]
ipfw: fix possible data race between jump cache reading and updating.

Jump cache is used to reduce the cost of rule lookup for O_SKIPTO and
O_CALLRETURN actions. It uses rules chain id to check correctness of
cached value. But due to the possible race, there is the chance that
one thread can read invalid value. In some cases this can lead to out
of bounds access and panic.

Use thread fence operations to constrain the reordering of accesses.
Also rename jump_fast and jump_linear functions to jump_cached and
jump_lookup_pos respectively.

Submitted by: Arseny Smalyuk
Obtained from: Yandex LLC
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D31484

(cherry picked from commit 322e5efda8578bb9c0a0ab0ef785cd1e1c222c85)

3 years agonetinet tests: delete an interface with pending lookups
Kristof Provost [Tue, 17 Aug 2021 14:19:29 +0000 (16:19 +0200)]
netinet tests: delete an interface with pending lookups

This has been known to trigger panics. It currently doesn't, but we may
as well have a test for it.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit e86469075c5e391cc86e5bcd4f252712a69de37e)

3 years agoAdd arp/ndp tests in addition to rtsock ll tests.
Alexander V. Chernikov [Sat, 20 Feb 2021 18:20:24 +0000 (18:20 +0000)]
Add arp/ndp tests in addition to rtsock ll tests.

(cherry picked from commit f17f94cd1b99c61faa08aa988b47805c53b78ac7)

3 years agontb_hw_intel(4): Add CTLFLAG_MPSAFE flags.
Alexander Motin [Wed, 11 Aug 2021 00:03:12 +0000 (20:03 -0400)]
ntb_hw_intel(4): Add CTLFLAG_MPSAFE flags.

I should have added those in 50f16247a1.

MFC after: 2 weeks

(cherry picked from commit 94feb1f1eb4c3527efdbd0b3f556eb3cb37c3318)

3 years agontb_hw_intel(4): Remove CTLFLAG_NEEDGIANT flags.
Alexander Motin [Tue, 10 Aug 2021 20:24:48 +0000 (16:24 -0400)]
ntb_hw_intel(4): Remove CTLFLAG_NEEDGIANT flags.

Most of the sysctls just read hardware registers.  They don't need
any locking.

MFC after: 2 weeks

(cherry picked from commit 50f16247a110d2ace56f1120304616f3e6ad9763)

3 years agontb_transport(4): Mark callouts MP-safe.
Alexander Motin [Tue, 10 Aug 2021 20:30:12 +0000 (16:30 -0400)]
ntb_transport(4): Mark callouts MP-safe.

The only thing around NTB using Giant lock is NewBus, and these callouts
have nothing to do with it.

MFC after: 2 weeks

(cherry picked from commit c6902e7796bc78df011131a2b8b024faed884b8f)

3 years agoUPDATING: Add a note about OpenSSL defaulting KTLS to off.
John Baldwin [Tue, 17 Aug 2021 21:40:33 +0000 (14:40 -0700)]
UPDATING: Add a note about OpenSSL defaulting KTLS to off.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31444

(cherry picked from commit 671a35b176e4b3c445696a8b423db5f8de26c285)

3 years agoOpenSSL: Add support for Chacha20-Poly1305 to kernel TLS on FreeBSD.
John Baldwin [Tue, 17 Aug 2021 21:40:16 +0000 (14:40 -0700)]
OpenSSL: Add support for Chacha20-Poly1305 to kernel TLS on FreeBSD.

FreeBSD's kernel TLS supports Chacha20 for both TLS 1.2 and TLS 1.3.

NB: This commit has not yet been merged upstream as it is deemed a new
feature and did not make the feature freeze cutoff for OpenSSL 3.0.

Reviewed by: jkim
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31443

(cherry picked from commit 6372fd253e3266c6eb271f49159f1632d527c9bd)

3 years agoOpenSSL: Refactor KTLS tests to better support TLS 1.3.
John Baldwin [Tue, 17 Aug 2021 21:39:58 +0000 (14:39 -0700)]
OpenSSL: Refactor KTLS tests to better support TLS 1.3.

Most of this upstream commit touched tests not included in the
vendor import.  The one change merged in is to remove a constant
only present in an internal header to appease the older tests.

Reviewed by: jkim
Obtained from: OpenSSL (e1fdd5262e4a45ce3aaa631768e877ee7b6da21b)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31442

(cherry picked from commit d6e78ecb0bcd5af750c72745c4c51fe211046bff)

3 years agoOpenSSL: Update KTLS documentation
John Baldwin [Tue, 17 Aug 2021 21:39:32 +0000 (14:39 -0700)]
OpenSSL: Update KTLS documentation

KTLS support has been changed to be off by default, and configuration is
via a single "option" rather two "modes". Documentation is updated
accordingly.

Reviewed by: jkim
Obtained from: OpenSSL (6878f4300213cfd7d4f01e26a8b97f70344da100)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31441

(cherry picked from commit a208223130fb12daac9b4f52be1b3477b03ac521)

3 years agoOpenSSL: Only enable KTLS if it is explicitly configured
John Baldwin [Tue, 17 Aug 2021 21:39:03 +0000 (14:39 -0700)]
OpenSSL: Only enable KTLS if it is explicitly configured

It has always been the case that KTLS is not compiled by default. However
if it is compiled then it was automatically used unless specifically
configured not to. This is problematic because it avoids any crypto
implementations from providers. A user who configures all crypto to use
the FIPS provider may unexpectedly find that TLS related crypto is actually
being performed outside of the FIPS boundary.

Instead we change KTLS so that it is disabled by default.

We also swap to using a single "option" (i.e. SSL_OP_ENABLE_KTLS) rather
than two separate "modes", (i.e. SSL_MODE_NO_KTLS_RX and
SSL_MODE_NO_KTLS_TX).

Reviewed by: jkim
Obtained from: OpenSSL (a3a54179b6754fbed6d88e434baac710a83aaf80)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31440

(cherry picked from commit 62ca9fc1ad569eb3fafd281e03812a598b9856ee)

3 years agoOpenSSL: ktls: Initial support for ChaCha20-Poly1305
John Baldwin [Tue, 17 Aug 2021 21:38:47 +0000 (14:38 -0700)]
OpenSSL: ktls: Initial support for ChaCha20-Poly1305

Linux kernel is going to support ChaCha20-Poly1305 in TLS offload.
Add support for this cipher.

Reviewed by: jkim
Obtained from: OpenSSL (3aa7212e0a4fd1533c8a28b8587dd8b022f3a66f)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31439

(cherry picked from commit 63c6d3e283eb01d32f54e2a153e6719d19e4a80d)

3 years agoOpenSSL: Correct the return value of BIO_get_ktls_*().
John Baldwin [Tue, 17 Aug 2021 21:37:47 +0000 (14:37 -0700)]
OpenSSL: Correct the return value of BIO_get_ktls_*().

BIO_get_ktls_send() and BIO_get_ktls_recv() are documented as
returning either 0 or 1.  However, they were actually returning the
internal value of the associated BIO flag for the true case instead of
1.

Also trim redundant ternary operators.

Reviewed by: jkim
Obtained from: OpenSSL (f16e52b67c9261bdc7e1284a50502a802921ac6d)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31438

(cherry picked from commit 334d228a204c16d1384a978ab9b209e4e7e33275)

3 years agonfs tls: Update for SSL_OP_ENABLE_KTLS.
John Baldwin [Tue, 10 Aug 2021 21:18:43 +0000 (14:18 -0700)]
nfs tls: Update for SSL_OP_ENABLE_KTLS.

Upstream OpenSSL (and the KTLS backport) have switched to an opt-in
option (SSL_OP_ENABLE_KTLS) in place of opt-out modes
(SSL_MODE_NO_KTLS_TX and SSL_MODE_NO_KTLS_RX) for controlling kernel
TLS.

Reviewed by: rmacklem
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31445

(cherry picked from commit c7bb0f47f721a2095ed6100bca595ba68fa5645a)

3 years agoixgbe: Avoid sbuf_trim(9) in sysctl handler
Kevin Bowling [Mon, 23 Aug 2021 16:21:39 +0000 (09:21 -0700)]
ixgbe: Avoid sbuf_trim(9) in sysctl handler

This was an error, we cannot use sbuf_trim(9) in the
ixgbe_sbuf_fw_version function because it also gets called in
the context of sbuf_new_for_sysctl(9). sbuf(9) explains the interaction
with drain functions as used by sbuf_new_for_sysctl(9).

Reviewed by: imp
Fixes: 7660e4ea5cb7
MFC after: 1 day
Differential Revision: https://reviews.freebsd.org/D31633

(cherry picked from commit 5de5419b5e8685ab2261edaafe6fdb6fc36e8bbc)

3 years agoloader: fix multiboot loading on UEFI
Roger Pau Monné [Wed, 11 Aug 2021 14:55:10 +0000 (16:55 +0200)]
loader: fix multiboot loading on UEFI

(cherry picked from commit 5e4279a8f35aa4b46debf728d3f743d64f15aaf8)

3 years agoamd64 UEFI loader: stop copying staging area to 2M physical
Konstantin Belousov [Sat, 10 Jul 2021 19:55:56 +0000 (22:55 +0300)]
amd64 UEFI loader: stop copying staging area to 2M physical

(cherry picked from commit f75caed644a5c8c342a1ea5e7a6d5251f82ed0b1)

3 years agoamd64 pmap_vm_page_alloc_check(): loose the assert
Konstantin Belousov [Sun, 1 Aug 2021 21:58:21 +0000 (00:58 +0300)]
amd64 pmap_vm_page_alloc_check(): loose the assert

(cherry picked from commit 665895db262fa596b347e40f6857b37e0f43b184)

3 years agoamd64 pmap_vm_page_alloc_check(): print more data for failed assert
Konstantin Belousov [Sun, 1 Aug 2021 13:38:17 +0000 (16:38 +0300)]
amd64 pmap_vm_page_alloc_check(): print more data for failed assert

(cherry picked from commit 1a55a3a729cd4424e17308d3e86b54b9a6e68f7b)

3 years agoAdd pmap_vm_page_alloc_check()
Konstantin Belousov [Sat, 10 Jul 2021 19:53:41 +0000 (22:53 +0300)]
Add pmap_vm_page_alloc_check()

(cherry picked from commit 041b7317f75ecc5e1629e2dd6786c8bdbe1b19eb)

3 years agoamd64: do not assume that kernel is loaded at 2M physical
Konstantin Belousov [Sat, 10 Jul 2021 19:48:02 +0000 (22:48 +0300)]
amd64: do not assume that kernel is loaded at 2M physical

(cherry picked from commit e18380e341410ce70d97560a22827591f4b2d373)

3 years agoamd64: stop doing special allocation for the AP startup trampoline
Konstantin Belousov [Thu, 29 Jul 2021 00:22:35 +0000 (03:22 +0300)]
amd64: stop doing special allocation for the AP startup trampoline

(cherry picked from commit b27fe1c3ba2a1302c2866751e0c618b5a697bf30)

3 years agoamd64: rework AP startup
Konstantin Belousov [Sat, 10 Jul 2021 19:38:42 +0000 (22:38 +0300)]
amd64: rework AP startup

(cherry picked from commit d6717f877872e62d9df1e0ce2d8856620c993924)

3 years agoevdev: Use bit_foreach helper macro
Vladimir Kondratyev [Mon, 16 Aug 2021 21:28:37 +0000 (00:28 +0300)]
evdev: Use bit_foreach helper macro

for traversing all bits set in the bitstring(9).

While here move bit_change() definition to common header.

(cherry picked from commit 5f99ae56c9196753ae162ad464c2969ad1a131b6)

3 years agobitstring(3): Add bitstring traversal macros.
Vladimir Kondratyev [Mon, 16 Aug 2021 20:18:58 +0000 (23:18 +0300)]
bitstring(3): Add bitstring traversal macros.

The macro bit_foreach() traverses all set bits in the bitstring in the
forward direction, assigning each location in turn to variable.

The macro bit_foreach_at() traverses all set bits in the bitstring in
the forward direction at or after the zero-based bit index, assigning
each location in turn to variable.

The bit_foreach_unset() and bit_foreach_unset_at() macros which
traverses unset bits are implemented for completeness.

Reviewed by: asomers, dougm

(cherry picked from commit 14a4d6d01335dd233023834e05897377cb70d52a)

3 years agohms(4): Allow attachment to pointer top level collection.
Vladimir Kondratyev [Mon, 16 Aug 2021 20:18:43 +0000 (23:18 +0300)]
hms(4): Allow attachment to pointer top level collection.

to be in line with Microsoft mouse driver [1]

[1] https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/top-level-collections-opened-by-windows-for-system-use

(cherry picked from commit 9b78891df13d12abaf8d0f0b0ca3e7d5f0e857e3)

3 years agops4dshock(4): Fix touchpad width in HID report descriptor
Vladimir Kondratyev [Mon, 16 Aug 2021 20:18:27 +0000 (23:18 +0300)]
ps4dshock(4): Fix touchpad width in HID report descriptor

(cherry picked from commit 9b2b5f42b4fee7fdb6c7653829da71e9706f849b)

3 years agohid: move proper hat switch handling from ps4dshock to hgame
Greg V [Mon, 16 Aug 2021 20:18:09 +0000 (23:18 +0300)]
hid: move proper hat switch handling from ps4dshock to hgame

Generic "DirectInput" HID gamepads need this handling too.

Reviewed by: wulf

(cherry picked from commit 51b2216114546bb13b13002b29fb1263e600a0fc)

3 years agohmt(4): Do not ignore constant usages in HID report descriptor parser
Jack [Mon, 16 Aug 2021 20:17:41 +0000 (23:17 +0300)]
hmt(4): Do not ignore constant usages in HID report descriptor parser

This fixes hmt to work with MELF0411 1FD2:7012 touchscreen

Obtained from: sysutils/iichid

(cherry picked from commit cb910670ac59e11808a629c8375c60200f909217)

3 years agohid: Add extra constant to units of measurement
Vladimir Kondratyev [Mon, 16 Aug 2021 20:13:24 +0000 (23:13 +0300)]
hid: Add extra constant to units of measurement

Some devices like eGalax touchscreens use value of 0x33 instead of 0x13
for inches as unit of measure.

Reported by: Mark Kane <mark_AT_kane_DOT_mn>

(cherry picked from commit be75951af1ec2d69d34a8701700b9bfd2a50679e)

3 years agoevdev: Do not check maximal contact number for MT initialization
Vladimir Kondratyev [Mon, 16 Aug 2021 20:12:01 +0000 (23:12 +0300)]
evdev: Do not check maximal contact number for MT initialization

This allows singletouch devices which use multitouch protocols to work.

Reported by: Mark Kane <mark_AT_kane_DOT_mn>

(cherry picked from commit e40fec4ec9a7a6625b3e332d4f856eb1d05f0def)

3 years agohmt(4): Store Contact Count in separate variable.
Vladimir Kondratyev [Mon, 16 Aug 2021 20:11:36 +0000 (23:11 +0300)]
hmt(4): Store Contact Count in separate variable.

No functional changes.

(cherry picked from commit 95add157e341f2c1ce47eaa19b3c5771705ea20d)

3 years agoe1000: always enable PCSD when RSS hashing
Kevin Bowling [Mon, 16 Aug 2021 17:17:34 +0000 (10:17 -0700)]
e1000: always enable PCSD when RSS hashing

To enable RSS hashing in the NIC, the PCSD bit must be set.

By default, this is never set when RXCSUM is disabled - which
causes problems higher up in the stack.

While here improve the RXCSUM flag assignments when enabling or
disabling IFCAP_RXCSUM.

See also: https://lists.freebsd.org/pipermail/freebsd-current/2020-May/076148.html

Reviewed by: markj, Franco Fichtner <franco@opnsense.org>,
Stephan de Wit <stephan.dewt@yahoo.co.uk>
Obtained from: OPNsense
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31501
Co-authored-by: Stephan de Wit <stephan.dewt@yahoo.co.uk>
Co-authored-by: Franco Fichtner <franco@opnsense.org>
(cherry picked from commit 69e8e8ea3d4be9da6b5bc904a444b51958128ff5)

3 years agolibpfctl: Fix endianness issues
Kristof Provost [Fri, 20 Aug 2021 11:43:15 +0000 (13:43 +0200)]
libpfctl: Fix endianness issues

Several fields are supplied in big-endian format, so we need to convert
them before we display them.

MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 719b5397c2887bc0619bb6ffb38f67f37bbf13c6)

3 years agoarm: hide busdma statistics behind ifdef ARM_BUSDMA_MAPLOAD_STATS
Mateusz Guzik [Wed, 21 Jul 2021 03:34:32 +0000 (05:34 +0200)]
arm: hide busdma statistics behind ifdef ARM_BUSDMA_MAPLOAD_STATS

Stat collection using counter(9) is quite expensive on this platform and
these counters are normally not needed.

In particular we see about 1.5% bump in packet rate using Cortex-A9

Reviewed by: ian
Sponsored by: Rubicon Communications, LLC ("Netgate")
Different Revision: https://reviews.freebsd.org/D31592

(cherry picked from commit aec8ad8a9e6aba2d73c98bd41f2994744aae3d01)

3 years agopf: assert dir state on pf_test{,6}
Mateusz Guzik [Tue, 17 Aug 2021 18:16:09 +0000 (20:16 +0200)]
pf: assert dir state on pf_test{,6}

The intent is to line up various enums so that branching in the lines of:

idx = (dir == PF_IN ? PF_SK_WIRE : PF_SK_STACK);

is avoided.

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 3e875f952af05697807139b460e5124eb5f6137b)

3 years agopf: save on branching in the common case in pf_test
Mateusz Guzik [Tue, 17 Aug 2021 18:04:31 +0000 (20:04 +0200)]
pf: save on branching in the common case in pf_test

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 5091ca26507b83ebd5ce677dd26bd10e4bad4153)

3 years agouipc: avoid circular pr_{slow,fast}timos
Kyle Evans [Wed, 18 Aug 2021 17:31:45 +0000 (12:31 -0500)]
uipc: avoid circular pr_{slow,fast}timos

domain_init() gets reinvoked for each vnet on a system, so we must not
alter global state.  Practically speaking, we were creating circular
lists and tying up a softclock thread into an infinite loop.

The breakage here was most easily observed by simply creating a jail
in a new vnet and watching the system suddenly become erratic.

Reported by: markj
Fixes: e0a17c3f063f ("uipc: create dedicated lists for fast ...")
Pointy hat: kevans

(cherry picked from commit d7e1bdfebacc4de25dc51e14a91d66bb429677c9)

3 years agouipc: create dedicated lists for fast and slow timeout callbacks
Mateusz Guzik [Sun, 15 Aug 2021 21:41:47 +0000 (23:41 +0200)]
uipc: create dedicated lists for fast and slow timeout callbacks

This avoids having to walk all possible protocols only to check if they
have one (vast majority does not).

Original patch by kevans@.

Reviewed by: kevans
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit e0a17c3f063fd51430fb2b4f5bc667f79d2967c2)

3 years agocoretemp: use x86_msr_op for thermal MSR access
Konstantin Belousov [Mon, 2 Aug 2021 19:53:08 +0000 (22:53 +0300)]
coretemp: use x86_msr_op for thermal MSR access

(cherry picked from commit 4cc6fe1e5b73ce540882753d918bc8208849e9e9)

3 years agox86_msr_op: extend the KPI to allow MSR read and single-CPU operations
Konstantin Belousov [Mon, 2 Aug 2021 19:52:26 +0000 (22:52 +0300)]
x86_msr_op: extend the KPI to allow MSR read and single-CPU operations

(cherry picked from commit d0bc4b466683d17b84f9acafe4c3cc746f860dbf)

3 years agortld: constify most variables holding references to the environment values
Konstantin Belousov [Mon, 16 Aug 2021 16:55:06 +0000 (19:55 +0300)]
rtld: constify most variables holding references to the environment values

(cherry picked from commit aa68b3bb2e11392f4636b3656b0f0bcacec3385a)

3 years agortld: provide private getenv(3)
Konstantin Belousov [Mon, 16 Aug 2021 14:02:48 +0000 (17:02 +0300)]
rtld: provide private getenv(3)

(cherry picked from commit b4b274889145bbc559613b54e7520b95f43e51e6)

3 years agortld: avoid use of of getenv(3) for evaluating rtld env vars (LD_XXX)
Konstantin Belousov [Mon, 16 Aug 2021 12:59:05 +0000 (15:59 +0300)]
rtld: avoid use of of getenv(3) for evaluating rtld env vars (LD_XXX)

(cherry picked from commit bfd4c875a10560aaa2f41e82114df79fde008fdb)

3 years agortld: rework how environment variables are named
Konstantin Belousov [Sun, 15 Aug 2021 18:57:42 +0000 (21:57 +0300)]
rtld: rework how environment variables are named

(cherry picked from commit 451dc2b7cc0c845a3f76f9ee670f16699c49b491)

3 years agolibc tls: use TLS_DTV_OFFSET defined by rtld.h
Konstantin Belousov [Sun, 15 Aug 2021 02:14:26 +0000 (05:14 +0300)]
libc tls: use TLS_DTV_OFFSET defined by rtld.h

(cherry picked from commit 300e08933e80e9fce02d0d2f7a64e3ad27e4ce8e)

3 years agortld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK is set
Fangrui Song [Sun, 15 Aug 2021 04:13:33 +0000 (07:13 +0300)]
rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK is set

(cherry picked from commit 7da378f9de1a042ec0c81ba7ad39a392540d4721)

3 years agortld: Remove calculate_tls_end
Fangrui Song [Sat, 14 Aug 2021 17:02:09 +0000 (20:02 +0300)]
rtld: Remove calculate_tls_end

(cherry picked from commit 8f63fa78e84afd23fa68c82eabfe64763c92d4f5)

3 years agortld: Fix i386/amd64 TP offset when p_vaddr % p_align != 0
Fangrui Song [Sat, 14 Aug 2021 16:56:58 +0000 (19:56 +0300)]
rtld: Fix i386/amd64 TP offset when p_vaddr % p_align != 0

(cherry picked from commit e6c76962031625d51fe4225ecfa15c85155eb13a)

3 years agoufs_dirhash: Correct a typo in a comment
Gordon Bergling [Fri, 20 Aug 2021 07:59:18 +0000 (09:59 +0200)]
ufs_dirhash: Correct a typo in a comment

- s/memry/memory/

(cherry picked from commit 464a166c27bb8947d5de1f617170ef6813587cc3)

3 years agoOptimize res_find().
Alexander Motin [Mon, 9 Aug 2021 01:34:33 +0000 (21:34 -0400)]
Optimize res_find().

When the device name is provided, we can simply run strncmp() for each
line to quickly skip unrelated ones, that is much faster than sscanf()
and only then strcmp().

MFC after: 2 weeks

(cherry picked from commit 696fca3fd491972e615195f2ce94598b9c469cac)

3 years agosigtimedwait: Use a unique wait channel for sleeping
Mark Johnston [Mon, 16 Aug 2021 17:15:25 +0000 (13:15 -0400)]
sigtimedwait: Use a unique wait channel for sleeping

When a sigtimedwait(2) caller goes to sleep, it uses a wait channel of
p->p_sigacts with the proc lock as the interlock.  However, p_sigacts
can be shared between processes if a child is created with
rfork(RFSIGSHARE | RFPROC).  Thus we can end up with two threads
sleeping on the same wait channel using different locks, which is not
permitted.

Fix the problem simply by using a process-unique wait channel, following
the example of sigsuspend.  The actual wait channel value is irrelevant
here, sleeping threads are awoken using sleepq_abort().

Reported by: syzbot+8c417afabadb50bb8827@syzkaller.appspotmail.com
Reported by: syzbot+1d89fc2a9ef92ef64fa8@syzkaller.appspotmail.com
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit c4feb1ab0ae0c0e779af372e4c5f3b9e0d3e1388)

3 years agoftpd: delete dead code
Alan Somers [Tue, 27 Jul 2021 18:14:00 +0000 (12:14 -0600)]
ftpd: delete dead code

Delete code killed by SVN r13139 in 1996.  Little chance that it would
still compile today.

PR: 257317
Reported by: Alan Shearer <sakison@gmail.com>
Sponsored by: Axcient

(cherry picked from commit 674400eb20b65369a88b1cb778d729bc297832c9)

3 years agoiostat: fix rounding errors in iostat -x
Alan Somers [Thu, 8 Jul 2021 16:16:32 +0000 (10:16 -0600)]
iostat: fix rounding errors in iostat -x

Better to round numbers instead of flooring them.

Sponsored by: Axcient

(cherry picked from commit 61631b24a1347a23cafe0657fba894622b1606e2)

3 years agoEscape any '.' characters in sysctl node names
Alan Somers [Wed, 21 Jul 2021 21:11:00 +0000 (15:11 -0600)]
Escape any '.' characters in sysctl node names

ZFS creates some sysctl nodes that include a pool name, and '.' is an
allowed character in pool names.  But it's the separator in the sysctl
tree, so it can't be included in a sysctl name.  Replace it with "%25".
Handily, "%" is illegal in ZFS pool names, so there's no ambiguity
there.

PR: 257316
Sponsored by: Axcient
Reviewed by: freqlabs
Differential Revision: https://reviews.freebsd.org/D31265

(cherry picked from commit 6c9506559080da2914749bf611225d7c0a153609)

3 years agodiff: Use unprivileged_user with report_identical test
Olivier Cochard [Wed, 3 Feb 2021 16:18:59 +0000 (17:18 +0100)]
diff: Use unprivileged_user with report_identical test

Approved by: bapt
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D28466

(cherry picked from commit b67df8d7c203a139b5afbe72e1947fbb8c32dc73)

3 years agoAdd zfskeys rc.d script for auto-loading encryption keys
Eirik Øverby [Wed, 28 Jul 2021 16:11:35 +0000 (16:11 +0000)]
Add zfskeys rc.d script for auto-loading encryption keys

ZFS in 13 supports encryption, but for the use case where keys are
available in plaintext on disk there is no mechanism for automatically
loading keys on startup.

This script will, by default, look for any dataset with encryption and
keylocation prefixed with file://. It will attempt to unlock, timing
out after 10 seconds for each dataset found.
User can optionally specify explicitly which datasets to attempt to
unlock.

Also supports (optionally by force) unmounting filesystems and unloading
associated keys.

Sponsored by: Modirum
Differential Revision: https://reviews.freebsd.org/D30015

(cherry picked from commit 33ff39796ffe469a764e485ac49c31700a51fd6f)

3 years agoarm64: HWCAP/HWCAP2 aux args support for 32-bit ARM binaries.
Peter Grehan [Sun, 25 Jul 2021 09:34:14 +0000 (19:34 +1000)]
arm64: HWCAP/HWCAP2 aux args support for 32-bit ARM binaries.

This fixes build/run of golang under COMPAT32 emulation.

PR: 256897
Reviewed by: andrew, mmel, manu, jhb, cognet, Robert Clausecker
Tested by: brd, andrew, Robert Clausecker
Relnotes: yes
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31175

(cherry picked from commit bbe80bff7c3549128bd19862eea7899b3def1d7f)

3 years agokbdmux(4): Make callout handler mpsafe.
Alexander Motin [Sun, 8 Aug 2021 22:19:08 +0000 (18:19 -0400)]
kbdmux(4): Make callout handler mpsafe.

Both callout and taskqueue now have drain() routines not requiring
external locking.  It allows to remove TASK flag and manual drain,
so the only thing remaining for lock to protect inside the callout
handler is ks_inq_length zero comparison, that can be lockless.

MFC after: 2 weeks

(cherry picked from commit e5018628e76a27e0f61ca03e2aa2247b3c62a158)

3 years agotail: Add regression tests for -f and -F
Mark Johnston [Mon, 5 Jul 2021 15:01:41 +0000 (11:01 -0400)]
tail: Add regression tests for -f and -F

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 58b1a126b98f9d64f30246c90d6c049fd78dda6b)

3 years agotail: Fix -f with stdin
Mark Johnston [Thu, 8 Jul 2021 21:40:59 +0000 (17:40 -0400)]
tail: Fix -f with stdin

Based on a patch from swills@.

(cherry picked from commit 7e11889959a6c92f05e1c1949deb73295ce60bac)

3 years agorpc: Make function tables const
Mark Johnston [Fri, 9 Jul 2021 14:56:13 +0000 (10:56 -0400)]
rpc: Make function tables const

No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 20d728b559178577869e50c7e3c1bf0ad24a750c)

3 years agortsold: pass sending router address to other and managed script
Franco Fitchner [Sat, 14 Aug 2021 15:10:21 +0000 (11:10 -0400)]
rtsold: pass sending router address to other and managed script

Reviewed by: markj

(cherry picked from commit 02508a3d4e178b431fe5dda354a56d883f976c02)

3 years agortsold: auto-probe point to point interfaces
Franco Fitchner [Sat, 14 Aug 2021 15:08:07 +0000 (11:08 -0400)]
rtsold: auto-probe point to point interfaces

rtsold works fine for point to point interfaces in manual mode but will
not auto-probe them.

Reviewed by: markj

(cherry picked from commit bfa812f5407bddac2bcced290a09bd3e686e354a)

3 years agokevent: Prohibit negative change and event list lengths
Mark Johnston [Thu, 27 May 2021 19:49:32 +0000 (15:49 -0400)]
kevent: Prohibit negative change and event list lengths

Previously, a negative change list length would be treated the same as
an empty change list.  A negative event list length would result in
bogus copyouts.  Make kevent(2) return EINVAL for both cases so that
application bugs are more easily found, and to be more robust against
future changes to kevent internals.

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

(cherry picked from commit e00bae5c181ac8282caf41cd33a076da03cf8ac9)

3 years agokern: ether_gen_addr: randomize on default hostuuid, too
Kyle Evans [Fri, 16 Apr 2021 01:11:35 +0000 (20:11 -0500)]
kern: ether_gen_addr: randomize on default hostuuid, too

Currently, this will still hash the default (all zero) hostuuid and
potentially arrive at a MAC address that has a high chance of collision
if another interface of the same name appears in the same broadcast
domain on another host without a hostuuid, e.g., some virtual machine
setups.

Instead of using the default hostuuid, just treat it as a failure and
generate a random LA unicast MAC address.

Reviewed by: bz, gbe, imp, kbowling, kp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29788

(cherry picked from commit 2d741f33bd07bf94a59635db3c7b9e070a8a6e55)

3 years agoman: document ether_gen_addr(9)
Kyle Evans [Fri, 16 Apr 2021 01:08:27 +0000 (20:08 -0500)]
man: document ether_gen_addr(9)

This KPI is used to assign a MAC address to an interface that doesn't
already have one assigned.

Reviewed by: bcr, gnn, imp, kbowling, kp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D29787

(cherry picked from commit e58a65ccdac352712e19a60fffa57a86afabbde9)

3 years agoApply upstream lldb fix for unhandled Error causing abort
Dimitry Andric [Mon, 16 Aug 2021 16:56:41 +0000 (18:56 +0200)]
Apply upstream lldb fix for unhandled Error causing abort

Merge commit 5033f0793fe6 from llvm git (by Dimitry Andric):

  [lldb] Avoid unhandled Error in TypeSystemMap::GetTypeSystemForLanguage

  When assertions are turned off, the `llvm::Error` value created at the
  start of this function is overwritten using the move-assignment
  operator, but the success value is never checked. Whenever a TypeSystem
  cannot be found or created, this can lead to lldb core dumping with:

      Program aborted due to an unhandled Error:
      Error value was Success. (Note: Success values must still be checked prior to being destroyed).

  Fix this by not creating a `llvm::Error` value in advance, and directly
  returning the result of `llvm::make_error` instead, whenever an error is
  encountered.

  See also: <https://bugs.freebsd.org/253881> and
  <https://bugs.freebsd.org/257829>.

  Reviewed By: teemperor

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

Reported by: dmgk, ota@j.email.ne.jp
PR: 253881, 257829

(cherry picked from commit c1a540709a83f810aa47380b946552ab20020374)

3 years agowpa: Add wpa_cli action file event
Cy Schubert [Thu, 12 Aug 2021 13:38:21 +0000 (06:38 -0700)]
wpa: Add wpa_cli action file event

Yang Zhong at FreeBSD Foundation is working on a wireless network
configuratior for an experimental FreeBSD installer. The new installer
requires an event to detect when connecting to a network fails due to a
bad password. When this happens a WPA-EVENT-TEMP-DISABLED event is
triggered. This patch passes the event to an action file provided by
the new experimental installer.

Submitted by: Yang Zhong <yzhong () freebsdfoundation.org>
Reviewed by: assumed to be reviewed by emaste (and cy)

(cherry picked from commit ce92f5a91b161c85e0a7e37cc754e3c28074281a)

3 years agowpa: The ap library is not needed by wpa_supplicant or wpa_cli
Cy Schubert [Sat, 12 Jun 2021 23:51:51 +0000 (16:51 -0700)]
wpa: The ap library is not needed by wpa_supplicant or wpa_cli

The ap library is not needed by wpa_supplicant or wpa_cli. It is only
used by hostapd.

(cherry picked from commit dc9d54b5c1e058b4f1bb9ab9372b171ac87a0d72)

3 years agowpa: Fix GCC 6 build
Cy Schubert [Fri, 4 Jun 2021 01:40:55 +0000 (18:40 -0700)]
wpa: Fix GCC 6 build

GCC 6 searches serially to resolve external references.

(cherry picked from commit 681500889424423403ace51f118b3467e09acc00)

3 years agowpa: Fix a SIGBUS error in wpa_sm_set_rekey_offload
Cy Schubert [Wed, 2 Jun 2021 19:46:02 +0000 (12:46 -0700)]
wpa: Fix a SIGBUS error in wpa_sm_set_rekey_offload

Incorrectly linked built-in wpa functions resulted in overwriting
sm->ctx->set_rekey_offload with garbage. It was initialized correctly
however it changed after wpa_supplicant became a daemon.

No SIGBUS violations reported by dhw@ were experienced during testing
of the original commit by msyelf or philip@.

Reported by: dhw
Tested by: dhw
X-MFC with: 25ecdc7d52770caf1c9b44b5ec11f468f6b636f3

(cherry picked from commit 9a0f82285322a338548d13fcda07e1d574301190)

3 years agowpa: Restructure wpa build
Cy Schubert [Thu, 20 May 2021 21:28:17 +0000 (14:28 -0700)]
wpa: Restructure wpa build

The current WPA build assumes a flat namespace. However the latest sources
from w1.fi now have a duplicate config.c, in two separate subdirectories.
The flat namespace will overwrite config.o with the output from the most
recently modified config.c, of which there are two of them.

This commit resolves this problem by building each component in
wpa's src subdirectory tree into its own .a archive, just as the w1.fi
upstream build as used by the port does. The advantages of this approach
are:

1. Duplicate source file names, i.e. config.c in the wpa_supplicant
   direcory and another config.c in src/utils in the next wpa
   will result in both compiles writing to the same .o file.

2. This restructure simplifies maintanence. A develper needs only to add
   new files as identified by git status in the vendor branch to the
   appropriate Makefile within the usr.sbin/wpa tree. This also reduces
   time required to prepare a new import and should reduce error.

3. The new wpa build structure more closely represents the build as
   performed by the upstream tarball.

This is in preparation for the next wpa update from w1.fi.

Reviewed by: philip
Tested by: philip
Differential Revision: https://reviews.freebsd.org/D30372

(cherry picked from commit 25ecdc7d52770caf1c9b44b5ec11f468f6b636f3)

3 years agong_bridge: Use M_NOWAIT when allocating memory in the newhook routine
Mark Johnston [Fri, 13 Aug 2021 13:49:43 +0000 (09:49 -0400)]
ng_bridge: Use M_NOWAIT when allocating memory in the newhook routine

newhook can be invoked by ngthread, which runs in a network epoch
section and is thus not permitted to perform M_WAITOK allocations.

Reported by: Jenkins
Reviewed by: donner, afedorov
Sponsored by: The FreeBSD Foundation

(cherry picked from commit e0e3ded78a5d0859f3520c541726b815897ba7b0)

3 years agortld: Round down relro_size
Konstantin Belousov [Thu, 12 Aug 2021 02:45:15 +0000 (05:45 +0300)]
rtld: Round down relro_size

(cherry picked from commit c9f833abf1d76ea194b82caafa06a0627790ad97)

3 years agortld: fix the man page
Mariusz Zaborski [Wed, 24 Mar 2021 23:49:59 +0000 (00:49 +0100)]
rtld: fix the man page

(cherry picked from commit e086aff91c242a2decdf7dd1ceb5a0b3e723a53f)

3 years agortld: introduce PRELOAD_FDS
Mariusz Zaborski [Wed, 24 Mar 2021 21:10:33 +0000 (22:10 +0100)]
rtld: introduce PRELOAD_FDS

(cherry picked from commit f90218886fc82e7b1fdb9e241adc5d713dadabe3)

3 years agortld: style nits
Mariusz Zaborski [Wed, 24 Mar 2021 21:05:39 +0000 (22:05 +0100)]
rtld: style nits

(cherry picked from commit 852a88a1d92500028f1364a4afc58955190db7a5)

3 years agoloader: cstyle cleanup of userboot/devicename.c
Toomas Soome [Wed, 11 Aug 2021 07:07:28 +0000 (10:07 +0300)]
loader: cstyle cleanup of userboot/devicename.c

No functional changes intended.

(cherry picked from commit 5d5a6216645a6aefa8665c79bb761b754d74c067)

3 years agoFix a typo that was introduced while fixing a typo
Gordon Bergling [Sat, 14 Aug 2021 12:30:59 +0000 (14:30 +0200)]
Fix a typo that was introduced while fixing a typo

- s/enrtry/entry/

(cherry picked from commit 646f3a36c8df0e54e71332038ede594965daac6e)

3 years agoAdd test for fstatat(pipefd, AT_EMPTY_PATH)
Konstantin Belousov [Sat, 14 Aug 2021 10:33:18 +0000 (13:33 +0300)]
Add test for fstatat(pipefd, AT_EMPTY_PATH)

(cherry picked from commit b42df9dafb8038169e23f9225f3f1588ded8d27e)

3 years agofstatat(2): handle non-vnode file descriptors for AT_EMPTY_PATH
Konstantin Belousov [Fri, 13 Aug 2021 17:40:10 +0000 (20:40 +0300)]
fstatat(2): handle non-vnode file descriptors for AT_EMPTY_PATH

(cherry picked from commit 9446d9e88fd7b203fa50c015f29b636db5b1d52b)

3 years agoufs rename: ensure that the result of ufs_checkpath() is stable
Konstantin Belousov [Fri, 6 Aug 2021 01:03:19 +0000 (04:03 +0300)]
ufs rename: ensure that the result of ufs_checkpath() is stable

(cherry picked from commit 8df4bc48c89a1302078282f22139a8368dc06971)

3 years agoStyle: wrap the long line, definition of ufs_checkpath()
Konstantin Belousov [Sun, 1 Aug 2021 17:56:33 +0000 (20:56 +0300)]
Style: wrap the long line, definition of ufs_checkpath()

(cherry picked from commit 2e2212b4f55f307ed814cbe1ea633c32faea4a9c)

3 years agopipe_paircreate(): do not leak pipepair memory on error
Konstantin Belousov [Mon, 16 Aug 2021 09:24:49 +0000 (12:24 +0300)]
pipe_paircreate(): do not leak pipepair memory on error

(cherry picked from commit 81b895a95bdab28897bf948f5265fad1f51f8aa2)

3 years agoFix a few typos in source code comments
Gordon Bergling [Sat, 14 Aug 2021 07:06:09 +0000 (09:06 +0200)]
Fix a few typos in source code comments

- s/becase/because/

(cherry picked from commit fa7a635f7ee277960eb37b9102a3aef76b36b825)

3 years agoFix a few typos in source code comments
Gordon Bergling [Sat, 14 Aug 2021 07:39:17 +0000 (09:39 +0200)]
Fix a few typos in source code comments

- s/posbile/possible/

(cherry picked from commit 34f620f1d0cfa67f5987452ac3fdd8c113b6b099)

3 years agomd5(1): Fix a typo in the manual page
Gordon Bergling [Sat, 14 Aug 2021 12:48:39 +0000 (14:48 +0200)]
md5(1): Fix a typo in the manual page

- s/compatibilty/compatibility/

(cherry picked from commit 0d71cea832f4b6e1db9d28d3ca393682d577b43e)

3 years agoFix a common typo in source code comments
Gordon Bergling [Sat, 14 Aug 2021 12:08:46 +0000 (14:08 +0200)]
Fix a common typo in source code comments

- s/definitons/definitions/

(cherry picked from commit 1da11b8ac3474817f38330e272f50553f2ef21a4)

3 years agoFix some common typos in source code comments
Gordon Bergling [Sat, 14 Aug 2021 06:55:58 +0000 (08:55 +0200)]
Fix some common typos in source code comments

- s/struture/structure/
- s/structre/structure/

(cherry picked from commit 17db4b52fb41aeabeb945c68c1b5edd4db4eac31)

3 years agoFix a few typos in source code comments
Gordon Bergling [Sat, 14 Aug 2021 08:08:49 +0000 (10:08 +0200)]
Fix a few typos in source code comments

- s/procesing/processing/

(cherry picked from commit 288e553623d3f8ac33baaabc93a4f030689755d2)

3 years agoFix a common typo in a comment
Gordon Bergling [Sat, 14 Aug 2021 11:29:51 +0000 (13:29 +0200)]
Fix a common typo in a comment

- s/enrty/entry/

(cherry picked from commit 86b74b736818a0b025ef520f8a4f570f48741666)

3 years agoFix a common typo in source code comments
Gordon Bergling [Sat, 14 Aug 2021 12:17:48 +0000 (14:17 +0200)]
Fix a common typo in source code comments

- s/aligment/alignment/

(cherry picked from commit a1581cd73594bbbde638859c31226c2c21be1ab3)