]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 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
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31563

2 years agoktls: Fix accounting for TLS 1.0 empty fragments.
John Baldwin [Mon, 16 Aug 2021 17:42:46 +0000 (10:42 -0700)]
ktls: Fix accounting for TLS 1.0 empty fragments.

TLS 1.0 empty fragment mbufs have no payload and thus m_epg_npgs is
zero.  However, these mbufs need to occupy a "unit" of space for the
purposes of M_NOTREADY tracking similar to regular mbufs.  Previously
this was done for the page count returned from ktls_frame() and passed
to ktls_enqueue() as well as the page count passed to pru_ready().

However, sbready() and mb_free_notready() only use m_epg_nrdy to
determine the number of "units" of space in an M_EXT mbuf, so when a
TLS 1.0 fragment was marked ready it would mark one unit of the next
mbuf in the socket buffer as ready as well.  To fix, set m_epg_nrdy to
1 for empty fragments.  This actually simplifies the code as now only
ktls_frame() has to handle TLS 1.0 fragments explicitly and the rest
of the KTLS functions can just use m_epg_nrdy.

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

2 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>
2 years agoipfilter: remove doubled semicolons
Ed Maste [Mon, 16 Aug 2021 17:16:23 +0000 (13:16 -0400)]
ipfilter: remove doubled semicolons

Local commit; ipfilter upstream is inactive.

Discussed with: cy
MFC after: 3 days

2 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
MFC after: 3 days

2 years agobxe: tag files to skip clang-format formatting
Ed Maste [Thu, 25 Jun 2020 00:42:10 +0000 (20:42 -0400)]
bxe: tag files to skip clang-format formatting

bxe contains three files which are sets of constants or other data, and
might be auto-generated or have an upstream.  They are rather large
files and clang-format takes quite some time when run against them, so
just skip formatting.

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27806

2 years agosys/cddl: remove extraneous semicolons
Ed Maste [Mon, 16 Aug 2021 14:29:44 +0000 (10:29 -0400)]
sys/cddl: remove extraneous semicolons

Fixes: 5a1b490d502e ("FreeBSD changes to vendor source.")
Fixes: 91eaf3e1831d ("Custom DTrace kernel module...")
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 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

Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 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

The current lookup prefers a strong definition to a STB_WEAK definition
(similar to glibc pre-2.2 behavior) which does not conform to the ELF
specification.

The non-compliant behavior provoked https://reviews.llvm.org/D4418
which was intended to fix -shared-libasan but introduced
new problems (and caused some sanitizer tests (e.g.
test/asan/TestCases/interception_failure_test.cpp) to fail): sanitizer
interceptors are STB_GLOBAL instead of STB_WEAK, so defining a second
STB_GLOBAL interceptor can lead to a multiple definition linker error.
For example, in a -fsanitize={address,memory,...} build, libc functions
like malloc/free/strtol/... cannot be provided by user object files.

See
https://docs.freebsd.org/cgi/getmsg.cgi?fetch=16483939+0+archive/2014/freebsd-current/20140716.freebsd-current
for discussions.

This patch implements the ELF-compliant behavior when LD_DYNAMIC_WEAK is
set. STB_WEAK wrestling in symbol lookups in `Search the dynamic linker
itself` are untouched.

Reviewed by: kib
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D26352

2 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

Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31541

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

Variant I architectures use off and Variant II ones use size + off.
Define TLS_VARIANT_I/TLS_VARIANT_II symbols similarly to how libc
handles it.

Reviewed by: kib
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31539
Differential revision: https://reviews.freebsd.org/D31541

2 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

For a Variant II architecture, the TP offset of a TLS symbol is st_value -
tlsoffset + r_addend. tlsoffset is computed by either calculate_tls_offset
or calculate_first_tls_offset.

The return value of calculate_first_tls_offset is the smallest integer
satisfying res >= size and (-res) % p_align = p_vaddr % p_align
(= p_offset % p_align).  (The formula is a bit contrived. The basic idea
is to subtract the minimum integer from size + align - 1 so that the result
ihas the expected remainder.)

Reviewed by: kib
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31538
Differential revision: https://reviews.freebsd.org/D31541

2 years agoAdd missing lex/yacc dependency for mkesdb/mkcsmapper bootstrap
Alex Richardson [Mon, 16 Aug 2021 08:56:17 +0000 (09:56 +0100)]
Add missing lex/yacc dependency for mkesdb/mkcsmapper bootstrap

This causes build failures on macOS where the build can end up invoking
an incompatible m4 binary.

Fxies: 2de949cf85d0 ("Remove mkcsmapper_static and mkesdb_static from build-tools")

2 years agodomain: make it safer to add domains post-domainfinalize
Kyle Evans [Fri, 26 Jun 2020 02:38:27 +0000 (21:38 -0500)]
domain: make it safer to add domains post-domainfinalize

I can see two concerns for adding domains after domainfinalize:

1.) The slow/fast callouts have already been setup.
2.) Userland could create a socket while we're in the middle of
  initialization.

We can address #1 fairly easily by tracking whether the domain's been
initialized for at least the default vnet. There are still some concerns
about the callbacks being invoked while a vnet is in the process of
being created/destroyed, but this is a pre-existing issue that the
callbacks must coordinate anyways.

We should also address #2, but technically this has been an issue
anyways because we don't assert on post-domainfinalize additions; we
don't seem to hit it in practice.

Future work can fix that up to make sure we don't find partially
constructed domains, but care must be taken to make sure that at least,
e.g., the usages of pffindproto in ip_input.c can still find them.

Differential Revision: https://reviews.freebsd.org/D25459

2 years agohvsock: fail the probe on non-HyperV machines
Kyle Evans [Wed, 4 Aug 2021 20:57:55 +0000 (15:57 -0500)]
hvsock: fail the probe on non-HyperV machines

Differential Revision: https://reviews.freebsd.org/D25459

2 years agodomain: give domains a chance to probe for availability
Kyle Evans [Fri, 26 Jun 2020 02:17:47 +0000 (21:17 -0500)]
domain: give domains a chance to probe for availability

This gives any given domain a chance to indicate that it's not actually
supported on the current system. If dom_probe isn't supplied, we assume
the domain is universally applicable as most of them are. Keeping
fully-initialized and registered domains around that physically can't
work on a large majority of FreeBSD deployments is sub-optimal and leads
to errors that aren't consistent with the reality of why the socket
can't be created (e.g. ESOCKTNOSUPPORT) because such scenario has to be
caught upon pru_attach, at which point kicking back the more-appropriate
EAFNOSUPPORT would seem weird.

The initial consumer of this will be hvsock, which is only available on
HyperV guests.

Reviewed by: cem (earlier version), bcr (manpages)
Differential Revision: https://reviews.freebsd.org/D25062

2 years agotpm_tis: Improve interrupt allocation
Kornel Duleba [Mon, 16 Aug 2021 04:26:50 +0000 (06:26 +0200)]
tpm_tis: Improve interrupt allocation

Validate the irq received from ACPI. Test if it works by sending a simple command and checking if the interrupt handler was executed.
Internal buffer allocation was moved away from common code to tis and crb parts - in order to test the interrupt we need to have it allocated early.

Obtained from: Semihalf
Differential revision: https://reviews.freebsd.org/D31395

2 years agorouting: Use process fib instead of fib 0 when conducting tests.
Alexander V. Chernikov [Sun, 15 Aug 2021 22:05:41 +0000 (22:05 +0000)]
routing: Use process fib instead of fib 0 when conducting tests.

* Allow to do validation/performance tests by using process
 fib instead of default fib 0.
* Print all validation errors instead of just the first one.

MFC after: 1 week

2 years agofrag6: do less work in frag6_slowtimo if possible
Mateusz Guzik [Fri, 13 Aug 2021 11:32:03 +0000 (13:32 +0200)]
frag6: do less work in frag6_slowtimo if possible

frag6_slowtimo avoidably uses CPU on otherwise idle boxes

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31528

2 years agofrag6: drop the volatile keyword from frag6_nfrags and mark with __exclusive_cache_line
Mateusz Guzik [Fri, 13 Aug 2021 11:28:39 +0000 (13:28 +0200)]
frag6: drop the volatile keyword from frag6_nfrags and mark with __exclusive_cache_line

The keyword adds nothing as all operations on the var are performed
through atomic_*

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31528

2 years agoip_reass: do less work in ipreass_slowtimo if possible
Mateusz Guzik [Fri, 13 Aug 2021 09:32:16 +0000 (11:32 +0200)]
ip_reass: do less work in ipreass_slowtimo if possible

ipreass_slowtimo avoidably uses CPU on otherwise idle boxes

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31526

2 years agoip_reass: drop the volatile keyword from nfrags and mark with __exclusive_cache_line
Mateusz Guzik [Fri, 13 Aug 2021 09:29:57 +0000 (11:29 +0200)]
ip_reass: drop the volatile keyword from nfrags and mark with __exclusive_cache_line

The keyword adds nothing as all operations on the var are performed
through atomic_*

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31526

2 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.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 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

MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31055

2 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@.

MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D31113

2 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
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31518

2 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
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31517

2 years agobhyve: Use pci(4) to access I/O port BARs
Mark Johnston [Sat, 14 Aug 2021 14:42:34 +0000 (10:42 -0400)]
bhyve: Use pci(4) to access I/O port BARs

This removes the dependency on /dev/io.

PR: 251046
Reviewed by: jhb
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31308

2 years agopci: Add an ioctl to perform I/O to BARs
Mark Johnston [Sat, 14 Aug 2021 14:41:43 +0000 (10:41 -0400)]
pci: Add an ioctl to perform I/O to BARs

This is useful for bhyve, which otherwise has to use /dev/io to handle
accesses to I/O port BARs when PCI passthrough is in use.

Reviewed by: imp, kib
Discussed with: jhb
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31307

2 years agolibc: vDSO timekeeping: Add pvclock support
Adam Fenn [Sat, 7 Aug 2021 20:11:29 +0000 (13:11 -0700)]
libc: vDSO timekeeping: Add pvclock support

Add support for 'VDSO_TH_ALGO_X86_PVCLK'; add vDSO-based timekeeping for
devices that support the KVM/XEN paravirtual clock API.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision:  https://reviews.freebsd.org/D31418

2 years agopvclock: Add vDSO support
Adam Fenn [Sat, 7 Aug 2021 20:10:04 +0000 (13:10 -0700)]
pvclock: Add vDSO support

Add vDSO support for timekeeping devices that support the KVM/XEN
paravirtual clock API.

Also, expose, in the userspace-accessible '<machine/pvclock.h>',
definitions that will be needed by 'libc' to support
'VDSO_TH_ALGO_X86_PVCLK'.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31418

2 years agokvm_clock: KVM paravirtual clock support
Adam Fenn [Wed, 4 Aug 2021 15:42:48 +0000 (08:42 -0700)]
kvm_clock: KVM paravirtual clock support

Add support for the KVM paravirtual clock device.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D29733

2 years agopvclock: Add 'struct pvclock' API
Adam Fenn [Sat, 7 Aug 2021 20:01:46 +0000 (13:01 -0700)]
pvclock: Add 'struct pvclock' API

Consolidate more hypervisor-agnostic functionality behind a new 'struct
pvclock' API.

This should also make it easier to subsequently add hypervisor-agnostic
vDSO timekeeping support.

Also, perform some clean-up:
    - Remove 'pvclock_get_last_cycles()'; do not allow external access
      to 'pvclock_last_systime' since this is not necessary.
    - Consolidate/simplify wall and system time reading codepaths.
    - Ensure correct ordering within wall and system time reading
      codepaths via 'atomic(9)' and 'rdtsc_ordered()' rather than via
      'rmb()'.
    - Remove some extra newlines.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31418

2 years agox86: files: Make sys/x86/x86/pvclock.c optional
Adam Fenn [Wed, 4 Aug 2021 15:10:43 +0000 (08:10 -0700)]
x86: files: Make sys/x86/x86/pvclock.c optional

Make inclusion of `sys/x86/x86/pvclock.c` contingent on that of its
dependents.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D31417

2 years agox86: cpufunc: Add rdtsc_ordered()
Adam Fenn [Wed, 28 Jul 2021 17:12:00 +0000 (10:12 -0700)]
x86: cpufunc: Add rdtsc_ordered()

Add a variant of 'rdtsc()' that performs the ordered version of 'rdtsc'
appropriate for the invoking x86 variant.

Also, expose the 'lfence'-ed and 'mfence'-ed 'rdtsc()' variants needed
by 'rdtsc_ordered()' for general use.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31416

2 years agox86: cpufunc: Add rdtscp_aux()
Adam Fenn [Mon, 26 Jul 2021 19:59:55 +0000 (12:59 -0700)]
x86: cpufunc: Add rdtscp_aux()

Add a variant of 'rdtscp()' that retains and returns the 'IA32_TSC_AUX'
value read by 'rdtscp'.

Sponsored By: Juniper Networks, Inc.
Sponsored By: Klara, Inc.
Reviewed by: markj, kib
Differential Revision: https://reviews.freebsd.org/D31415

2 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/

MFC after: 5 days

2 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/

MFC after: 5 days

2 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/

MFC after: 5 days

2 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/

MFC after: 5 days

2 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)

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

2 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/

MFC after: 5 days

2 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/

MFC after: 5 days

2 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/

MFC after: 5 days

2 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/

MFC after: 5 days

2 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/

MFC after: 5 days

2 years agoaio: revert the workaround for bug 251828 in the tests
Alan Somers [Fri, 13 Aug 2021 22:59:10 +0000 (16:59 -0600)]
aio: revert the workaround for bug 251828 in the tests

This bug is no longer reproducible in 14.0-CURRENT and 13.0-RELEASE

Do not MFC to stable/12 !

PR: 251828
Reported by: markj
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D31535

2 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

Set NIRES_EMPTYPATH earlies, to have use of EMPTYPATH recorded even if
we are going to return error.  When namei_setup() refused to accept dirfd,
which is not of the vnode type, and indicated by ENOTDIR error return,
fall back to kern_fstat(dirfd).

Reported by: dchagin
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31530

2 years agomgb: update Microchip URLs
Ed Maste [Fri, 13 Aug 2021 20:57:04 +0000 (16:57 -0400)]
mgb: update Microchip URLs

Sponsored by: The FreeBSD Foundation

2 years agoar: remove duplicate function declaration in header
Ed Maste [Fri, 13 Aug 2021 19:36:13 +0000 (15:36 -0400)]
ar: remove duplicate function declaration in header

Sponsored by: The FreeBSD Foundation

2 years agoar: diff reduction against ELF Tool Chain
Ed Maste [Fri, 13 Aug 2021 15:17:24 +0000 (11:17 -0400)]
ar: diff reduction against ELF Tool Chain

Remove ar_mode_* wrappers and call ar_read_archive / ar_write_archive
directly.

(This was originally committed in d20e9e02db3d but reverted due to a
regression, now fixed with an update from cy@.)

Obtained from: ELF Tool Chain
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31496

2 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

ufs_rename() calls ufs_checkpath() to ensure that the target directory
is not a child of the source.  If not, rename would create a loop.
For instance:
source->X1->X2->target
and if source moved under target, we get corrupted filesystem.
Suppose that we initially have
source->X1 .... and X2->target
where X1 is not on path from root to X2.  Then ufs_checkpath() accepts
the inodes, but there is nothing preventing parallel rename of X2 to become
under X1, after checkpath finished.

Ensure stability of ufs_checkpath() result by taking a per-mount sx in
ufs_rename right before ufs_checkpath() and till the end.

Reviewed by: chs, mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

2 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()

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agoar: diff reduction against ELF Tool Chain
Ed Maste [Thu, 12 Aug 2021 19:37:25 +0000 (15:37 -0400)]
ar: diff reduction against ELF Tool Chain

Drop exit status from bsdar_errc.  ELF Tool Chain always returns
EXIT_FAILURE in bsdar_errc.

Recommit of one part of d20e9e02db3d / review D31496.

Obtained from: ELF Tool Chain
Sponsored by: The FreeBSD Foundation

2 years agoarc4random: Avoid KMSAN false positives from pre-seeding results
Mark Johnston [Fri, 13 Aug 2021 13:52:05 +0000 (09:52 -0400)]
arc4random: Avoid KMSAN false positives from pre-seeding results

If code calls arc4random(), and our RNG is not yet seeded and
random_bypass_before_seeding is true, we'll compute a key using the
SHA256 hash of some hopefully hard-to-predict data, including the
contents of an uninitialized stack buffer (which is also the output
buffer).

When KMSAN is enabled, this use of uninitialized state propagtes through
to the arc4random() output, resulting in false positives.  To address
this, lie to KMSAN and explicitly mark the buffer as initialized.

Reviewed by: cem (previous version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31510

2 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
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31486

2 years agoipsec: fix race condition in key.c
Wojciech Macek [Fri, 13 Aug 2021 10:52:38 +0000 (12:52 +0200)]
ipsec: fix race condition in key.c

Small patch that fixes a race condition in sys/netipsec/key.c

Obtained from: Stormshield
Differential revision: https://reviews.freebsd.org/D31271

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

lld rounds up p_memsz(PT_GNU_RELRO) to satisfy common-page-size. If the
page size is smaller than common-page-size, rounding up relro_size may
incorrectly make some RW pages read-only.

GNU ld, gold, and ld.lld ensures p_vaddr+p_memsz is a multiple of
common-page-size. While max-page-size >= system the page size,
common-page-size can be smaller than the system page size.

Submitted by: MaskRay
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31498

2 years agousr.bin/ghä-bc, contrib/bc: update to version 5.0.0
Stefan Eßer [Tue, 10 Aug 2021 08:42:54 +0000 (10:42 +0200)]
usr.bin/ghä-bc, contrib/bc: update to version 5.0.0

Merge commit 2f57ecae4b98e76e5d675563785a7e6c59c868c4

This is a new major release with a number of changes and extensions:

- Limited the number of temporary numbers and made the space for them
  static so that allocating more space for them cannot fail.
- Allowed integers with non-zero scale to be used with power, places,
  and shift operators.
- Added greatest common divisor and least common multiple to lib2.bc.
- Made bc and dc UTF-8 capable.
- Added the ability for users to have bc and dc quit on SIGINT.
- Added the ability for users to disable prompt and TTY mode by
  environment variables.
- Added the ability for users to redefine keywords.
- Added dc's modular exponentiation and divmod to bc.
- Added the ability to assign strings to variables and array elements
  and pass them to functions in bc.
- Added dc's asciify command and stream printing to bc.
- Added bitwise and, or, xor, left shift, right shift, reverse,
  left rotate, right rotate, and mod functions to lib2.bc.
- Added the functions s2u(x) and s2un(x,n), to lib2.bc.

MFC after: 1 week

2 years agomroute: fix locking issues
Wojciech Macek [Wed, 11 Aug 2021 07:04:20 +0000 (09:04 +0200)]
mroute: fix locking issues

In some cases the code may fall into deadlock.
Avoid calling epoch_wait when W-lock is taken.

Sponsored by: Stormshield
Obtained from: Semihalf

2 years agolinux(4): Improve comment.
Dmitry Chagin [Fri, 13 Aug 2021 08:36:42 +0000 (11:36 +0300)]
linux(4): Improve comment.

Reported by: pfg
MFC after: 2 weeks

2 years agoipsec: Return error code if no matching SA was found
Kornel Duleba [Fri, 13 Aug 2021 07:35:08 +0000 (09:35 +0200)]
ipsec: Return error code if no matching SA was found

If we matched SP to a packet, but no associated SA was found
ipsec4_allocsa will return NULL while setting error=0.
This resulted in use after free and potential kernel panic.
Return EINPROGRESS if the case described above instead.

Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D30994

2 years agoipsec: Check PMTU before sending a frame.
Kornel Duleba [Fri, 13 Aug 2021 07:20:46 +0000 (09:20 +0200)]
ipsec: Check PMTU before sending a frame.

If an encapsulated frame is going to have DF bit set check its desitnitions'
PMTU and if it won't fit drop it and:

Generate ICMP 3/4 message if the packet was to be forwarded.
Return EMSGSIZE error otherwise.

Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D30993

2 years agonfsd: Fix sanity check for NFSv4.2 Allocate operations
Rick Macklem [Thu, 12 Aug 2021 23:48:28 +0000 (16:48 -0700)]
nfsd: Fix sanity check for NFSv4.2 Allocate operations

The NFSv4.2 Allocate operation sanity checks the aa_offset
and aa_length arguments.  Since they are assigned to variables
of type off_t (signed) it was possible for them to be negative.
It was also possible for aa_offset+aa_length to exceed OFF_MAX
when stored in lo_end, which is uint64_t.

This patch adds checks for these cases to the sanity check.

Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D31511

2 years agoclang: Fix inverted condition in llvm.build.mk
Jessica Clarke [Thu, 12 Aug 2021 22:53:30 +0000 (23:53 +0100)]
clang: Fix inverted condition in llvm.build.mk

Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux")
MFC after: 1 week

2 years agotools/build/cross-build: Fix building libllvmminimal on Linux
Jessica Clarke [Thu, 12 Aug 2021 22:50:48 +0000 (23:50 +0100)]
tools/build/cross-build: Fix building libllvmminimal on Linux

There is a __used member in glibc's posix_spawn_file_actions_t in
spawn.h, so we must temporarily undefine __used when including it,
otherwise Support/Unix/Program.inc fails to build. This is based on
similar handling for __unused in other headers.

Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux")
MFC after: 1 week

2 years agobsd.compiler.mk: Fix cross-building from non-FreeBSD
Jessica Clarke [Thu, 12 Aug 2021 22:45:09 +0000 (23:45 +0100)]
bsd.compiler.mk: Fix cross-building from non-FreeBSD

On non-FreeBSD, the various MACHINE variables for the host when
bootstrapping can be missing or not match FreeBSD's naming, causing
bsd.endian.mk to be unable to infer the endianness. Work around this by
assuming it's unsupported.

Note that we can't check BOOTSTRAPPING here as Makefile.inc1 includes
bsd.compiler.mk before that is set, and so we are unable to catch errors
during buildworld itself when cross-building and bsd.endian.mk failed,
but such errors should also show up when building on FreeBSD.

Fixes: 47363e99d3d3 ("Enable compressed debug on little-endian targets")

2 years agoRevert "ar: diff reduction against ELF Tool Chain"
Ed Maste [Thu, 12 Aug 2021 18:26:37 +0000 (14:26 -0400)]
Revert "ar: diff reduction against ELF Tool Chain"

This reverts commit d20e9e02db3dde383c3de1ce8cec3a8c35b3eee6.
It caused port build failures.

Reported by: cy

2 years agocxgbei: Wait for the final CPL to be received in icl_cxgbei_conn_close.
John Baldwin [Thu, 12 Aug 2021 15:48:14 +0000 (08:48 -0700)]
cxgbei: Wait for the final CPL to be received in icl_cxgbei_conn_close.

A socket in the FIN_WAIT_1 state is marked disconnected by
do_close_con_rpl() even though there might still receive data pending.
This is because the socket at that point has set SBS_CANTRCVMORE which
causes the protocol layer to discard any data received before the FIN.
However, icl_cxgbei_conn_close needs to wait until all the data has
been discarded.  Replace the wait for SS_ISDISCONNECTED with instead
waiting for final_cpl_received() to be called.

Reported by: Jithesh Arakkan @ Chelsio
Sponsored by: Chelsio Communications

2 years agoparam.h: Bump __FreeBSD_version to 1400030
Ka Ho Ng [Thu, 12 Aug 2021 14:59:41 +0000 (22:59 +0800)]
param.h: Bump __FreeBSD_version to 1400030

Commit a638dc4ebc8e expands VOP_DEALLOCATE(9)'s parameters list. File
system modules and modules calling VOP_DEALLOCATE(9) need to be rebuilt.

Commit 454bc887f250 introduces fspacectl(2) SPACECTL_DEALLOC support for
POSIX shared memory.

Sponsored by: The FreeBSD Foundation

2 years agouipc_shm: Implements fspacectl(2) support
Ka Ho Ng [Thu, 12 Aug 2021 15:01:02 +0000 (23:01 +0800)]
uipc_shm: Implements fspacectl(2) support

This implements fspacectl(2) support on shared memory objects. The
semantic of SPACECTL_DEALLOC is equivalent to clearing the backing
store and free the pages within the affected range. If the call
succeeds, subsequent reads on the affected range return all zero.

tests/sys/posixshm/posixshm_tests.c is expanded to include a
fspacectl(2) functional test.

Sponsored by: The FreeBSD Foundation
Reviewed by: kevans, kib
Differential Revision: https://reviews.freebsd.org/D31490

2 years agovfs: Add ioflag to VOP_DEALLOCATE(9)
Ka Ho Ng [Thu, 12 Aug 2021 14:58:52 +0000 (22:58 +0800)]
vfs: Add ioflag to VOP_DEALLOCATE(9)

The addition of ioflag allows callers passing
IO_SYNC/IO_DATASYNC/IO_DIRECT down to the file system implementation.
The vop_stddeallocate fallback implementation is updated to pass the
ioflag to the file system implementation. vn_deallocate(9) internally is
also changed to pass ioflag to the VOP_DEALLOCATE call.

Sponsored by: The FreeBSD Foundation
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D31500

2 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

Yan 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)
MFC after: 1 week

2 years agohms(4): Fix a typo in sysctl description
Gordon Bergling [Thu, 12 Aug 2021 13:37:47 +0000 (15:37 +0200)]
hms(4): Fix a typo in sysctl description

- s/threshhold/threshold/

MFC after: 3 days

2 years agolinux(4): Remove clone3 and faccessat2 from dummy.
Dmitry Chagin [Thu, 12 Aug 2021 13:07:21 +0000 (16:07 +0300)]
linux(4): Remove clone3 and faccessat2 from dummy.

MFC after: 2 weeks

2 years agoMerge common parts of i386 and amd64's ieeefp.h into x86/x86_ieeefp.h
NagaChaitanya Vellanki [Thu, 12 Aug 2021 10:45:22 +0000 (18:45 +0800)]
Merge common parts of i386 and amd64's ieeefp.h into x86/x86_ieeefp.h

MFC after: 1 week
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D26292

2 years agovfs: Add get_write_ioflag helper to calculate ioflag
Ka Ho Ng [Thu, 12 Aug 2021 09:35:34 +0000 (17:35 +0800)]
vfs: Add get_write_ioflag helper to calculate ioflag

Converted vn_write to use this helper.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31513

2 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.

MFC after: 1 week

2 years agolinux(4): Remove the unnecessary spaces.
Dmitry Chagin [Thu, 12 Aug 2021 08:58:33 +0000 (11:58 +0300)]
linux(4): Remove the unnecessary spaces.

MFC after: 2 weeks

2 years agofork: Remove the unnecessary spaces.
Dmitry Chagin [Thu, 12 Aug 2021 08:58:17 +0000 (11:58 +0300)]
fork: Remove the unnecessary spaces.

MFC after: 2 weeks

2 years agolinux(4): Move ff variable initialization from declaration.
Dmitry Chagin [Thu, 12 Aug 2021 08:57:16 +0000 (11:57 +0300)]
linux(4): Move ff variable initialization from declaration.

Modern style(9) allows variables initialization where they are declared,
but in this case initialization obfuscate the code.

MFC after: 2 weeks

2 years agolinux(4): Verify that higher 32bits of exit_signal in clone3 are unset.
Dmitry Chagin [Thu, 12 Aug 2021 08:56:51 +0000 (11:56 +0300)]
linux(4): Verify that higher 32bits of exit_signal in clone3 are unset.

MFC after: 2 weeks

2 years agolinux(4): Return ENOSYS for unsupported clone3 option bits.
Dmitry Chagin [Thu, 12 Aug 2021 08:56:36 +0000 (11:56 +0300)]
linux(4): Return ENOSYS for unsupported clone3 option bits.

Differential Revision: https://reviews.freebsd.org/D31483
MFC after: 2 weeks

2 years agolinux(4): Add LINUX_RATELIMIT_MSG macro for future use.
Dmitry Chagin [Thu, 12 Aug 2021 08:55:55 +0000 (11:55 +0300)]
linux(4): Add LINUX_RATELIMIT_MSG macro for future use.

Differential Revision: https://reviews.freebsd.org/D31488
MFC after: 2 weeks

2 years agolinux(4): Implement CLONE_CLEAR_SIGHAND option bit.
Dmitry Chagin [Thu, 12 Aug 2021 08:55:35 +0000 (11:55 +0300)]
linux(4): Implement CLONE_CLEAR_SIGHAND option bit.

CLONE_CLEAR_SIGHAND is designed to reset all signal handlers of the child
not set to SIG_IGN to SIG_DFL.

Reviewed by: kib
Differential revision: https://reviews.freebsd.org/D31481
MFC after: 2 weeks

2 years agolinux(4): Add CLONE_PIDFD option bit.
Dmitry Chagin [Thu, 12 Aug 2021 08:55:24 +0000 (11:55 +0300)]
linux(4): Add CLONE_PIDFD option bit.

Differential revision: https://reviews.freebsd.org/D31478
MFC after: 2 weeks

2 years agoEnable arm64 SError exceptions in the kernel
Andrew Turner [Mon, 9 Aug 2021 16:30:44 +0000 (16:30 +0000)]
Enable arm64 SError exceptions in the kernel

These are needed to signal to the kernel when a Reliability,
Availability, and Serviceability (RAS) exception has triggered.

Reviewed by: mhorne
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31477

2 years agoAdd the Apple arm64 implementer ID
Andrew Turner [Wed, 11 Aug 2021 15:30:44 +0000 (16:30 +0100)]
Add the Apple arm64 implementer ID

Sponsored by: The FreeBSD Foundation

2 years agoSort the arm64 cpu_implementers list by name
Andrew Turner [Wed, 11 Aug 2021 15:29:09 +0000 (16:29 +0100)]
Sort the arm64 cpu_implementers list by name

We perform a linear search, so make it easier to add new entries in the
correct place.

Sponsored by: The FreeBSD Foundation

2 years agolinux(4): Regen for clone3 system call.
Dmitry Chagin [Thu, 12 Aug 2021 08:50:22 +0000 (11:50 +0300)]
linux(4): Regen for clone3 system call.

MFC after: 2 weeks

2 years agolinux(4): Implement clone3 system call.
Dmitry Chagin [Thu, 12 Aug 2021 08:49:36 +0000 (11:49 +0300)]
linux(4): Implement clone3 system call.

clone3 system call is used by glibc-2.34.

Differential revision: https://reviews.freebsd.org/D31475
MFC after: 2 weeks

2 years agolinux(4): Add struct clone_args for future clone3 system call.
Dmitry Chagin [Thu, 12 Aug 2021 08:49:01 +0000 (11:49 +0300)]
linux(4): Add struct clone_args for future clone3 system call.

In preparation for clone3 system call add struct clone_args and use it in
clone implementation.
Move all of clone related bits to the newly created linux_fork.h header.

Differential revision: https://reviews.freebsd.org/D31474
MFC after: 2 weeks

2 years agolinux(4): Regen for clone syscall.
Dmitry Chagin [Thu, 12 Aug 2021 08:47:31 +0000 (11:47 +0300)]
linux(4): Regen for clone syscall.

MFC after: 2 weeks

2 years agolinux(4): Change clone syscall definition to match Linux actual one.
Dmitry Chagin [Thu, 12 Aug 2021 08:46:36 +0000 (11:46 +0300)]
linux(4): Change clone syscall definition to match Linux actual one.

Differential revision: https://reviews.freebsd.org/D31473
MFC after: 2 weeks

2 years agofork: Allow ABI to specify fork return values for child.
Dmitry Chagin [Thu, 12 Aug 2021 08:45:25 +0000 (11:45 +0300)]
fork: Allow ABI to specify fork return values for child.

At least Linux x86 ABI's does not use carry bit and expects that the dx register
is preserved. For this add a new sv_set_fork_retval hook and call it from cpu_fork().

Add a short comment about touching dx in x86_set_fork_retval(), for more details
see phab comments from kib@ and imp@.

Reviewed by: kib
Differential revision: https://reviews.freebsd.org/D31472
MFC after: 2 weeks

2 years agolinux(4): Plug in aarch64 fcntl flags.
Dmitry Chagin [Thu, 12 Aug 2021 08:42:50 +0000 (11:42 +0300)]
linux(4): Plug in aarch64 fcntl flags.

Fixes opendir() libc function.

Differential Revision: https://reviews.freebsd.org/D31357
MFC after: 2 weeks

2 years agolinux(4): Regen for faccessat2 system call.
Dmitry Chagin [Thu, 12 Aug 2021 08:41:35 +0000 (11:41 +0300)]
linux(4): Regen for faccessat2 system call.

MFC after: 2 weeks

2 years agolinux(4): Implement faccessat2 system call.
Dmitry Chagin [Thu, 12 Aug 2021 08:40:42 +0000 (11:40 +0300)]
linux(4): Implement faccessat2 system call.

It's used by bash on arm64 with glibc-2.32.

Reviewed by: trasz
Differential Revision: https://reviews.freebsd.org/D31345
MFC after: 2 weeks

2 years agolinux(4): Fix futex copyrights.
Dmitry Chagin [Thu, 12 Aug 2021 08:36:24 +0000 (11:36 +0300)]
linux(4): Fix futex copyrights.

As no more NetBSD code in futexes exists replace NetBSD copyrights by
standard FreeBSD 2 clause license.
Add Roman Divacky's copyrights as an author of the robust futexes.

Differential revision: https://reviews.freebsd.org/D31347
MFC after: 2 weeks

2 years agovmm: Fix wrong assert in ivhd_dev_add_entry
Ka Ho Ng [Thu, 12 Aug 2021 07:54:40 +0000 (15:54 +0800)]
vmm: Fix wrong assert in ivhd_dev_add_entry

The correct condition is to check the number of ivhd entries fit into
the array.

Reported by: bz
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D31514