]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agorc: Fix quoting in the zpoolreguid script
Mark Johnston [Tue, 31 May 2022 14:51:28 +0000 (10:51 -0400)]
rc: Fix quoting in the zpoolreguid script

Reported by: 0mp
Fixes: 227caacc918a ("rc: Add a zpoolreguid rc.d script")
Sponsored by: The FreeBSD Foundation

2 years agolinux(4): Return EINVAL when the clockid has invalid bits are set
Dmitry Chagin [Tue, 31 May 2022 08:46:15 +0000 (11:46 +0300)]
linux(4): Return EINVAL when the clockid has invalid bits are set

Linux forbids PERTHREAD bit set for CLOCKFD clock.

MFC after: 2 weeks

2 years agolinux(4): Return ENOTSUP for unsupported clockid
Dmitry Chagin [Tue, 31 May 2022 08:43:00 +0000 (11:43 +0300)]
linux(4): Return ENOTSUP for unsupported clockid

It's much better from the user perspective to get a sane error code.

MFC after: 2 weeks

2 years agolinprocfs: Add /proc/vm/max_map_count
Dmitry Chagin [Tue, 31 May 2022 08:42:06 +0000 (11:42 +0300)]
linprocfs: Add /proc/vm/max_map_count

On Linux this limits the number of maps per mm struct.
We don't limit mappings, return a suitable large value.

Reviewed by: emaste
Differential revision: https://reviews.freebsd.org/D35351
MFC after: 2 weeks

2 years agolibpmc: Fix INVERT flag mapping for both Intel and AMD.
Alexander Motin [Tue, 31 May 2022 04:02:06 +0000 (00:02 -0400)]
libpmc: Fix INVERT flag mapping for both Intel and AMD.

Looks like somebody's trivial copy/paste bug.

MFC after: 1 month

2 years agosoo_aio_*: use socket buffer mutexes in struct socket directly
Gleb Smirnoff [Tue, 31 May 2022 03:38:34 +0000 (20:38 -0700)]
soo_aio_*: use socket buffer mutexes in struct socket directly

A miss from commit 4328318445a.

2 years agohwpmc: Add basic Intel Alderlake CPUs support.
Alexander Motin [Tue, 31 May 2022 03:17:37 +0000 (23:17 -0400)]
hwpmc: Add basic Intel Alderlake CPUs support.

The PMC subsystem is not designed for non-uniform CPU capabilities
(P/E-cores are different), but at least several working architectural
events like cpu_clk_unhalted.thread_p should be better than nothing.

MFC after: 1 month

2 years agohwpmc: Update Intel's programmable counters restrictions.
Alexander Motin [Tue, 31 May 2022 02:51:00 +0000 (22:51 -0400)]
hwpmc: Update Intel's programmable counters restrictions.

Primarily remove unneeded restrictions from later CPUs.

MFC after: 1 month

2 years agozdiff: avoid non-conformant features
Kyle Evans [Fri, 20 May 2022 20:38:03 +0000 (15:38 -0500)]
zdiff: avoid non-conformant features

`setvar` is a non-conformant feature that looks slightly neater but is
not portable to other /bin/sh implementations.  Making the script
portable is straightforward, so let's do it.

Tests are added to make sure that I didn't break anything major in the
process.

Reviewed by: bapt (previous version), jilles
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D35275

2 years agolibpmc: Disable hardcoding of Intel fixed counters.
Alexander Motin [Mon, 30 May 2022 23:58:40 +0000 (19:58 -0400)]
libpmc: Disable hardcoding of Intel fixed counters.

Intel json's now have pretty reasonable fixed counters representation
via event=0 and umask.  Hardcoded values create more confusion than fix.

MFC after: 1 month

2 years agohwpmc: Correct selection of Intel fixed counters.
Alexander Motin [Mon, 30 May 2022 23:46:48 +0000 (19:46 -0400)]
hwpmc: Correct selection of Intel fixed counters.

Intel json's use event=0 to specify fixed counter number via umask.
Alternatively fixed counters have equivalent programmable event/umask.

MFC after: 1 month

2 years agoirdma: fix LINT-NOIP/NOINET/NOINET6 builds
Mitchell Horne [Mon, 30 May 2022 20:47:32 +0000 (17:47 -0300)]
irdma: fix LINT-NOIP/NOINET/NOINET6 builds

This module depends on the presence of both INET and INET6 options in
order to compile.

Reviewed by: erj
Fixes: cdcd52d41e24 ("irdma: Add RDMA driver for Intel(R) Ethernet...")
Differential Revision: https://reviews.freebsd.org/D35343

2 years agoibcore: Fix missing ib_cm_destroy_id() in ib_cm_insert_listen()
Hans Petter Selasky [Mon, 30 May 2022 18:19:33 +0000 (20:19 +0200)]
ibcore: Fix missing ib_cm_destroy_id() in ib_cm_insert_listen()

The algorithm pre-allocates a cm_id since allocation cannot be done while
holding the cm.lock spinlock, however it doesn't free it on one error
path, leading to a memory leak.

Linux commit:
c14dfddbd869bf0c2bafb7ef260c41d9cebbcfec

PR: 264248
MFC after: 1 week
Sponsored by: NVIDIA Networking

2 years agomlx4core: Fix a memory leak when deleting slave's resources
Hans Petter Selasky [Mon, 30 May 2022 18:11:50 +0000 (20:11 +0200)]
mlx4core: Fix a memory leak when deleting slave's resources

mlx4_delete_all_resources_for_slave() in the resource tracker should free
all memory allocated for a slave. While releasing memory of fs_rule,
it misses releasing memory of fs_rule->mirr_mbox.

Linux commit:
461d5f1b59490ce0096dfda45e10038c122a7892

PR: 264249
MFC after: 1 week
Sponsored by: NVIDIA Networking

2 years agolibpmc: jevents: Sync with the latest Linux kernel.
Alexander Motin [Mon, 30 May 2022 18:07:31 +0000 (14:07 -0400)]
libpmc: jevents: Sync with the latest Linux kernel.

commit f4df0dbbe62ee8e4405a57b27ccd54393971c773
Date:   Wed May 25 22:04:10 2022 +0800

MFC after: 1 month

2 years agoRevert "libpmc: jevents: Partial style(9) pass"
Alexander Motin [Mon, 30 May 2022 14:07:31 +0000 (10:07 -0400)]
Revert "libpmc: jevents: Partial style(9) pass"

This file is shared with Linux.  Having local style patches does not
help with updating it.

This reverts commit 3ea691c2612952dc5e6963649ad64312bd6dff4f.

2 years agolinux(4): Properly restore the thread signal mask after signal delivery on i386
Dmitry Chagin [Mon, 30 May 2022 17:03:49 +0000 (20:03 +0300)]
linux(4): Properly restore the thread signal mask after signal delivery on i386

Replace sigframe sf_extramask by native sigset_t and use it to
store/restore the thread signal mask without conversion to/from
Linux signal mask.

Pointy hat to: dchagin
MFC after: 2 weeks

2 years agolinux(4): Prefer sizeof(object) vs sizeof(type)
Dmitry Chagin [Mon, 30 May 2022 17:03:14 +0000 (20:03 +0300)]
linux(4): Prefer sizeof(object) vs sizeof(type)

MFC after: 2 weeks

2 years agolinux(4): Error is not a bool, use proper comparison
Dmitry Chagin [Mon, 30 May 2022 17:00:30 +0000 (20:00 +0300)]
linux(4): Error is not a bool, use proper comparison

MFC afer: 2 weeks

2 years agolinux(4): Use the copyin_sigset() in the remaining places
Dmitry Chagin [Mon, 30 May 2022 16:59:45 +0000 (19:59 +0300)]
linux(4): Use the copyin_sigset() in the remaining places

MFC after: 2 weeks

2 years agolinux(4): Refactor SIGPWR mapping
Dmitry Chagin [Mon, 30 May 2022 16:55:49 +0000 (19:55 +0300)]
linux(4): Refactor SIGPWR mapping

Map Linux RT signals to the native RT signals starting from SIGRTMIN,
and Linux SIGPWR signal map to after the last RT signal.

MFC after: 2 weeks

2 years agolinux(4): Fix the type of a constant in the signal mask macro
Dmitry Chagin [Mon, 30 May 2022 16:53:52 +0000 (19:53 +0300)]
linux(4): Fix the type of a constant in the signal mask macro

Since l_sigset_t is 64-bit unsigned on all Linuxulators, fix the type
of a constant in the signal mask manipulation macro.
The suffix L indicates type long which is 32-bit on i386, therefore,
bitwise operations between a 32-bit constant and 64-bit signal mask
lead to the wrong result.

Pointy hat to: dchagin
MFC after: 2 weeks

2 years agolinux(4): Properly build argument list for the signal handler
Dmitry Chagin [Mon, 30 May 2022 16:53:12 +0000 (19:53 +0300)]
linux(4): Properly build argument list for the signal handler

Provide arguments 2 and 3 if signal handler installed with SA_SIGINFO.

MFC after: 2 weeks

2 years agolinux(4): Microoptimize rt_sendsig(), convert signal mask once
Dmitry Chagin [Mon, 30 May 2022 16:49:45 +0000 (19:49 +0300)]
linux(4): Microoptimize rt_sendsig(), convert signal mask once

On amd64 Linux saves the thread signal mask in both contexts, in the machine
dependent and in the machine independent. Both contexts are user accessible.
Convert the mask once, then copy it.

MFC after: 2 weeks

2 years agolinux(4): Avoid direct manipulation of td_sigmask
Dmitry Chagin [Mon, 30 May 2022 16:48:20 +0000 (19:48 +0300)]
linux(4): Avoid direct manipulation of td_sigmask

Use kern_sigprocmask() instead of direct manipulation of td_sigmask
to reschedule newly blocked signals.

MFC after: 2 weeks

2 years agolinux(4): Reduce duplication between MD parts of the Linuxulator
Dmitry Chagin [Mon, 30 May 2022 16:47:26 +0000 (19:47 +0300)]
linux(4): Reduce duplication between MD parts of the Linuxulator

Move sigprocmask actions defines under compat/linux,
they are identical across all Linux architectures.

MFC after: 2 weeks

2 years agosockbuf: retain backward compatibility with userland after d59bc188d652
Alexander V. Chernikov [Mon, 30 May 2022 14:56:25 +0000 (14:56 +0000)]
sockbuf: retain backward compatibility with userland after d59bc188d652

Add spare fields to xsockbuf in place of sb_mcnt / sb_ccnt to avoid
 rebuilding userland binaries like sockstat(1).

Reviewed by: glebius

2 years agosrc.conf.5: Regenerate
Mark Johnston [Mon, 30 May 2022 14:53:13 +0000 (10:53 -0400)]
src.conf.5: Regenerate

2 years agosrc.conf.5: Update the WITHOUT_ZFS description
Mark Johnston [Mon, 30 May 2022 14:45:57 +0000 (10:45 -0400)]
src.conf.5: Update the WITHOUT_ZFS description

... to take into account programs and libraries which might implement
some ZFS-specific features without being exclusive to ZFS.

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

2 years agorc: Add a zpoolreguid rc.d script
Mark Johnston [Mon, 30 May 2022 14:43:44 +0000 (10:43 -0400)]
rc: Add a zpoolreguid rc.d script

If one boots up multiple copies of a template VM image containing a
zpool, the pool GUIDs will be identical, making it impossible to, e.g.,
share datasets between them.

This diff introduces a simple workaround for the problem: one can use
the script to, upon first boot, assign a new GUID to one or more zpools.
This will be useful when building ZFS-based VM images from release(7).

Reviewed by: mav, allanjude, asomers
Reviewed by: Pau Amma (docs)
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35336

2 years agogitignore: Ignore compile_commands.events.json
Mark Johnston [Sun, 29 May 2022 17:32:24 +0000 (13:32 -0400)]
gitignore: Ignore compile_commands.events.json

This is a temporary file that appears when a build is wrapped using
devel/bear.

MFC after: 1 week

2 years agopkgbase: Move pw to the runtime package
Doug Rabson [Mon, 30 May 2022 13:22:08 +0000 (14:22 +0100)]
pkgbase: Move pw to the runtime package

This allows building a container image with enough functionality for
downloading and installing packages without having to include the
utilities package.

Reviewed by: manu
MFC after:   2 weeks

2 years agopf: make sure the rule tree is allocated in DIOCCHANGERULE
Mateusz Guzik [Fri, 27 May 2022 22:15:34 +0000 (00:15 +0200)]
pf: make sure the rule tree is allocated in DIOCCHANGERULE

Original patch by: peter
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agohwpmc: Use hardware PMCs freezing on PMI on Intel v2+.
Alexander Motin [Mon, 30 May 2022 13:07:30 +0000 (09:07 -0400)]
hwpmc: Use hardware PMCs freezing on PMI on Intel v2+.

Since version 2 Intel CPUs can freeze PMCs when intering PMI to reduce
PMI effects on collected statistics.  Since version 4 hardware supports
"streamlined" mechanism, not requiring IA_GLOBAL_CTRL MSR access.

MFC after: 1 month

2 years agolib/libgssapi: Trailing whitespace cleanup
Cy Schubert [Fri, 27 May 2022 20:48:23 +0000 (13:48 -0700)]
lib/libgssapi: Trailing whitespace cleanup

Clean up trailing whitespace (trailing spaces and trailing tabs).

MFC after: 1 week

2 years agosockstat: be more verbose when reporting kernel/userland size mismatch.
Alexander V. Chernikov [Mon, 30 May 2022 10:54:53 +0000 (10:54 +0000)]
sockstat: be more verbose when reporting kernel/userland size mismatch.

MFC after: 2 weeks

2 years agonetinet6: fix ndp proxying
KUROSAWA Takahiro [Mon, 30 May 2022 07:51:15 +0000 (07:51 +0000)]
netinet6: fix ndp proxying

We could insert proxy NDP entries by the ndp command, but the host
with proxy ndp entries had not responded to Neighbor Solicitations.
Change the following points for proxy NDP to work as expected:
* join solicited-node multicast addresses for proxy NDP entries
  in order to receive Neighbor Solicitations.
* look up proxy NDP entries not on the routing table but on the
  link-level address table when receiving Neighbor Solicitations.

Reviewed By: melifaro
Differential Revision: https://reviews.freebsd.org/D35307
MFC after: 2 weeks

2 years agolltable: introduce the llt_post_resolved callback
KUROSAWA Takahiro [Mon, 30 May 2022 07:38:54 +0000 (07:38 +0000)]
lltable: introduce the llt_post_resolved callback

In order to decrease ifdef INET/INET6s in the lltable implementation,
introduce the llt_post_resolved callback and implement protocol-dependent
code in the protocol-dependent part.

Reviewed By: melifaro
Differential Revision: https://reviews.freebsd.org/D35322
MFC after: 2 weeks

2 years agolltable: use sa_family_t instead of int for lltable.llt_af
KUROSAWA Takahiro [Mon, 30 May 2022 07:36:52 +0000 (07:36 +0000)]
lltable: use sa_family_t instead of int for lltable.llt_af

Reviewed By: melifaro, #network
Differential Revision: https://reviews.freebsd.org/D35323
MFC after: 2 weeks

2 years agox86/mp: don't create empty cpu groups
Corvin Köhne [Mon, 30 May 2022 09:19:14 +0000 (11:19 +0200)]
x86/mp: don't create empty cpu groups

When some APICs are disabled by tunables, some cpu groups could end up
empty. An empty cpu group causes the system to panic because not all
functions handle them correctly. Additionally, it's wasted time to
handle and inspect empty cpu groups. Therefore, just don't create them.

Reviewed by: kib, avg, cem
Sponsored by: Beckhoff Automation GmbH & Co. KG
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D24927

2 years agovmm: add tunable to trap WBINVD
Corvin Köhne [Mon, 30 May 2022 08:02:52 +0000 (10:02 +0200)]
vmm: add tunable to trap WBINVD

x86 is cache coherent. However, there are special cases where cache
coherency isn't ensured (e.g. when switching the caching mode). In these
cases, WBINVD can be used. WBINVD writes all cache lines back into main
memory and invalidates the whole cache.

Due to the invalidation of the whole cache, WBINVD is a very heavy
instruction and degrades the performance on all cores. So, we should
minimize the use of WBINVD as much as possible.

In a virtual environment, the WBINVD call is mostly useless. The guest
isn't able to break cache coherency because he can't switch the physical
cache mode. When using pci passthrough WBINVD might be useful.

Nevertheless, trapping and ignoring WBINVD is an unsafe operation. For
that reason, we implement it as tunable.

Reviewed by: jhb
Sponsored by: Beckhoff Automation GmbH & Co. KG
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D35253

2 years agobhyve: use bhyve_config for SMBIOS strings
Corvin Köhne [Mon, 30 May 2022 08:01:36 +0000 (10:01 +0200)]
bhyve: use bhyve_config for SMBIOS strings

Some software uses SMBIOS entries to identify the system on which it's
running. In order to make it possible to use such software inside a VM,
SMBIOS entries should be configurable. Therefore, bhyve_config can be
used. While only a few SMBIOS entries might be of interest, it makes
sense that all SMBIOS entries are configurable. This way all SMBIOS
tables are build the same way and there's no special handling for some
tables.

Reviewed by: jhb
Sponsored by: Beckhoff Automation GmbH & Co. KG
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D34465

2 years agosctp: improve handling of listen() call
Michael Tuexen [Sun, 29 May 2022 18:40:30 +0000 (20:40 +0200)]
sctp: improve handling of listen() call

Fail the listen() call for 1-to-1 style sockets when the SCTP
association has been shutdown or aborted.

Reported by: syzbot+6c484f116b9dc88f7db1@syzkaller.appspotmail.com
MFC after: 3 days

2 years agohwpmc: Add Intel Core register defines up to version 5.
Alexander Motin [Sun, 29 May 2022 02:11:59 +0000 (22:11 -0400)]
hwpmc: Add Intel Core register defines up to version 5.

MFC after: 1 month

2 years agonfsstat: Add an entry to output NFSPROC_APPENDWRITE count
Rick Macklem [Sat, 28 May 2022 23:27:02 +0000 (16:27 -0700)]
nfsstat: Add an entry to output NFSPROC_APPENDWRITE count

Commit 5218d82c81f9 added a new NFSv4.1/4.2 procedure called
AppendWrite that uses a Verify to avoid a separate Getattr RPC
for the common case where the client knows the correct file
size for O_APPEND writes.

This patch modifies nfsstat so that it displays a count of
these new RPCs for the "-E -c" option.

2 years agomount_nfs: Only create a mounttab file entry is nmount(2) succeeds
Rick Macklem [Sat, 28 May 2022 22:48:40 +0000 (15:48 -0700)]
mount_nfs: Only create a mounttab file entry is nmount(2) succeeds

mount_nfs creates entries in the mounttab file and umount removes
them.  Entries in the mounttab file ae used by rpc.umntall to
notify the NFS server that NFSv3 entries need to be removed when
they have not been removed by umount.

Without this patch, an enty will be created in the mounttab file,
even if the nmount(2) syscall fails for the mount.  This patch
modifies the code so that the mounttab entry is only created
after nmount(2) succeeds.

This change only affects NFSv3 and only affects how showmount
displays NFSv3 mounts.

MFC after: 2 weeks

2 years agoApply clang fix for assertion failure building putty 0.77 on i386
Dimitry Andric [Sat, 28 May 2022 21:26:37 +0000 (23:26 +0200)]
Apply clang fix for assertion failure building putty 0.77 on i386

Merge commit 45084eab5e63 from llvm git (by Arthur Eubanks):

  [clang] Fix some clang->llvm type cache invalidation issues

  Take the following as an example

    struct z {
      z (*p)();
    };

    z f();

  When we attempt to get the LLVM type of f, we recurse into z. z itself
  has a function pointer with the same type as f. Given the recursion,
  Clang simply treats z::p as a pointer to an empty struct `{}*`. The
  LLVM type of f is as expected. So we have two different potential
  LLVM types for a given Clang type. If we store one of those into the
  cache, when we access the cache with a different context (e.g. we
  are/aren't recursing on z) we may get an incorrect result. There is some
  attempt to clear the cache in these cases, but it doesn't seem to handle
  all cases.

  This change makes it so we only use the cache when we are not in any
  sort of function context, i.e. `noRecordsBeingLaidOut() &&
  FunctionsBeingProcessed.empty()`, which are the cases where we may
  decide to choose a different LLVM type for a given Clang type. LLVM
  types for builtin types are never recursive so they're always ok.

  This allows us to clear the type cache less often (as seen with the
  removal of one of the calls to `TypeCache.clear()`). We
  still need to clear it when we use a placeholder type then replace it
  later with the final type and other dependent types need to be
  recalculated.

  I've added a check that the cached type matches what we compute. It
  triggered in this test case without the fix. It's currently not
  check-clang clean so it's not on by default for something like expensive
  checks builds.

  This change uncovered another issue where the LLVM types for an argument
  and its local temporary don't match. For example in type-cache-3, when
  expanding z::dc's argument into a temporary alloca, we ConvertType() the
  type of z::p which is `void ({}*)*`, which doesn't match the alloca GEP
  type of `{}*`.

  No noticeable compile time changes:
  https://llvm-compile-time-tracker.com/compare.php?from=3918dd6b8acf8c5886b9921138312d1c638b2937&to=50bdec9836ed40e38ece0657f3058e730adffc4c&stat=instructions

  Fixes #53465.

  Reviewed By: rnk

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

PR: 264318
Reported by: mandree
MFC after: 3 days

2 years agolinux(4): Handle multiple mbufs in a control message chain in recvmsg
Dmitry Chagin [Sat, 28 May 2022 20:48:45 +0000 (23:48 +0300)]
linux(4): Handle multiple mbufs in a control message chain in recvmsg

PR: 230274
MFC after: 2 weeks

2 years agolinux(4): Ratelimit message about unupported cmsg
Dmitry Chagin [Sat, 28 May 2022 20:48:16 +0000 (23:48 +0300)]
linux(4): Ratelimit message about unupported cmsg

MFC after: 2 weeks

2 years agolinux(4): Handle IP_ORIGDSTADDR socket option for IPPROTO_IP protocol level
Dmitry Chagin [Sat, 28 May 2022 20:47:40 +0000 (23:47 +0300)]
linux(4): Handle IP_ORIGDSTADDR socket option for IPPROTO_IP protocol level

MFC after: 2 weeks

2 years agolinux(4): Add LINUX_RATELIMIT_MSG_OPT2 for future use
Dmitry Chagin [Sat, 28 May 2022 20:47:23 +0000 (23:47 +0300)]
linux(4): Add LINUX_RATELIMIT_MSG_OPT2 for future use

MFC after: 2 weeks

2 years agolinux(4): Overwrite SO_TIMESTAMP counterpart
Dmitry Chagin [Sat, 28 May 2022 20:46:38 +0000 (23:46 +0300)]
linux(4): Overwrite SO_TIMESTAMP counterpart

A socket cannot mix SO_TIMESTAMP and SO_TIMESTAMPNS: the two modes
are mutually exclusive.

MFC after: 2 weeks

2 years agolinux(4): Refactor linux_common_recvmsg()
Dmitry Chagin [Sat, 28 May 2022 20:46:22 +0000 (23:46 +0300)]
linux(4): Refactor linux_common_recvmsg()

To improve readability lower nesting level, better naming for variables.
No functional changes.

MFC after: 2 weeks

2 years agolinux(4): Handle SO_TIMESTAMPNS socket option
Dmitry Chagin [Sat, 28 May 2022 20:46:05 +0000 (23:46 +0300)]
linux(4): Handle SO_TIMESTAMPNS socket option

The SO_TIMESTAMPNS enables or disables the receiving of the SCM_TIMESTAMPNS
control message. The cmsg_data field is a struct timespec.
To distinguish between SO_TIMESTAMP and SO_TIMESTAMPNS in the recvmsg()
map the last one to the SO_BINTIME and convert bintime to the timespec.
In the rest, implementation is identical to the SO_TIMESTAMP.

MFC after: 2 weeks

2 years agolinux(4): Handle 64-bit SO_TIMESTAMP for 32-bit binaries
Dmitry Chagin [Sat, 28 May 2022 20:45:39 +0000 (23:45 +0300)]
linux(4): Handle 64-bit SO_TIMESTAMP for 32-bit binaries

To solve y2k38 problem in the recvmsg syscall the new SO_TIMESTAMP
constant were added on v5.1 Linux kernel. So, old 32-bit binaries
that knows only 32-bit time_t uses the old value of the constant,
and binaries that knows 64-bit time_t uses the new constant.

To determine what size of time_t type is expected by the user-space,
store requested value (SO_TIMESTAMP) in the process emuldata structure.

MFC after: 2 weeks

2 years agolinux(4): For future use replace malloc type for l_sockaddr by M_LINUX
Dmitry Chagin [Sat, 28 May 2022 20:44:48 +0000 (23:44 +0300)]
linux(4): For future use replace malloc type for l_sockaddr by M_LINUX

MFC after: 2 weeks

2 years agolinux(4): Improve recvmsg() readability
Dmitry Chagin [Sat, 28 May 2022 20:44:02 +0000 (23:44 +0300)]
linux(4): Improve recvmsg() readability

To improve recvmsg() readability SCM_ handlers moved to a separate
functions.

MFC after: 2 weeks

2 years agolinux(4): For future use move SCM definitions below socket options
Dmitry Chagin [Sat, 28 May 2022 20:42:23 +0000 (23:42 +0300)]
linux(4): For future use move SCM definitions below socket options

MFC after: 2 weeks

2 years agolinux(4): Avoid EISCONN if addr is specified for sendto()
Dmitry Chagin [Sat, 28 May 2022 20:42:09 +0000 (23:42 +0300)]
linux(4): Avoid EISCONN if addr is specified for sendto()

If the socket is in a connected state, the target address should be
ignored.

MFC after: 2 weeks

2 years agolinux(4): Fix SO_LINGER l_onoff value
Dmitry Chagin [Sat, 28 May 2022 20:31:06 +0000 (23:31 +0300)]
linux(4): Fix SO_LINGER l_onoff value

On Linux l_onoff should be 1 when linger is used.

MFC after: 2 weeks

2 years agolinux(4): Add a helper to copyout getsockopt value
Dmitry Chagin [Sat, 28 May 2022 20:30:22 +0000 (23:30 +0300)]
linux(4): Add a helper to copyout getsockopt value

For getsockopt(), optlen is a value-result argument, which is modified
on return to indicate the actual size of the value returned.
For some cases this was missed, fixed.

MFC after: 2 weeks

2 years agolinux(4): Check the socket before any others sanity checks
Dmitry Chagin [Sat, 28 May 2022 20:29:12 +0000 (23:29 +0300)]
linux(4): Check the socket before any others sanity checks

Strictly speaking, this check is performed by the kern_recvit(), but in
the Linux emulation layer before calling the kernel we do other sanity
checks and conversions from Linux types to the native types. This changes
an order of the error returning that is critical for some buggy Linux
applications.

For recvmmsg() syscall this fixes a panic in case when the user-supplied
vlen value is 0, then error is not initialized and garbage passed to the
bsd_to_linux_errno().

MFC after: 2 weeks

2 years agoFix a memory leak from caf73e58579
Alan Somers [Sat, 28 May 2022 19:17:37 +0000 (13:17 -0600)]
Fix a memory leak from caf73e58579

Don't shadow an already-local variable with another local declaration.

Reported by: dteske
MFC after: 13 days
MFC with: caf73e58579343fc1661f43554b30115bb940535
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D35331

2 years agoFinish cpuset_getaffinity() after f35093f8
Dmitry Chagin [Sat, 28 May 2022 17:53:08 +0000 (20:53 +0300)]
Finish cpuset_getaffinity() after f35093f8

Split cpuset_getaffinity() into a two counterparts, where the
user_cpuset_getaffinity() is intended to operate on the cpuset_t from
user va, while kern_cpuset_getaffinity() expects the cpuset from kernel
va.
Accordingly, the code that clears the high bits is moved to the
user_cpuset_getaffinity(). Linux sched_getaffinity() syscall returns
the size of set copied to the user-space and then glibc wrapper clears
the high bits.

MFC after: 2 weeks

2 years agosysent: Get rid of bogus sys/sysent.h include.
Dmitry Chagin [Sat, 28 May 2022 17:52:17 +0000 (20:52 +0300)]
sysent: Get rid of bogus sys/sysent.h include.

Where appropriate hide sysent.h under proper condition.

MFC after: 2 weeks

2 years agosctp: use a consistent view of the send parameters
Michael Tuexen [Sat, 28 May 2022 17:35:58 +0000 (19:35 +0200)]
sctp: use a consistent view of the send parameters

Reported by: syzbot+e26628a755f78bacff16@syzkaller.appspotmail.com
MFC after: 3 days

2 years agosctp: ignore SCTP_SENDALL flag on 1-to-1 style sockets
Michael Tuexen [Sat, 28 May 2022 17:07:10 +0000 (19:07 +0200)]
sctp: ignore SCTP_SENDALL flag on 1-to-1 style sockets

MFC after: 3 days

2 years agosctp: improve handling of send() when association is shutdown
Michael Tuexen [Sat, 28 May 2022 15:40:17 +0000 (17:40 +0200)]
sctp: improve handling of send() when association is shutdown

Accept send() calls only when the association is not being
shut down or the expicit message EOR mode is used and the
application provides follow-up data.

Reported by: syzbot+341e9ebd9d24ca7dc62a@syzkaller.appspotmail.com
MFC after: 3 days

2 years agosctp: cleanup of error paths
Michael Tuexen [Sat, 28 May 2022 15:15:14 +0000 (17:15 +0200)]
sctp: cleanup of error paths

MFC after: 3 days

2 years agoAdd several sanitizer ignore lists under /usr/lib/clang
Dimitry Andric [Fri, 27 May 2022 18:23:37 +0000 (20:23 +0200)]
Add several sanitizer ignore lists under /usr/lib/clang

Some of the sanitizers from compiler-rt can use ignore lists, which are
loosely modeled on valgrind's example. Upstream provides default lists
for AddressSanitizer, CFI, and MemorySanitizer, so install these in the
expected location, /usr/lib/clang/14.0.3/share.

Reviewed by: emaste
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35338

2 years agosctp: cleanup, no functional change except on error paths
Michael Tuexen [Sat, 28 May 2022 09:34:20 +0000 (11:34 +0200)]
sctp: cleanup, no functional change except on error paths

MFC after: 3 days

2 years agounix: unp_externalize() can M_WAITOK
Gleb Smirnoff [Sat, 28 May 2022 03:48:38 +0000 (20:48 -0700)]
unix: unp_externalize() can M_WAITOK

Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D35318

2 years agonfscl: Add a diagnostic printf() for a "should never happen" case
Rick Macklem [Fri, 27 May 2022 21:32:46 +0000 (14:32 -0700)]
nfscl: Add a diagnostic printf() for a "should never happen" case

When a NFSv4.1/4.2 session to the NFS server (not a pNFS DS) is
replaced, the old session should always be marked defunct by
nfsess_defunct being set non-zero.

However, the hang reported by the PR suggests that this might
be the case.

This patch adds a printf() to indicate this has somehow happened.

PR: 260011
MFC after:  2 weeks

2 years agonfscl: Do not handle NFSERR_BADSESSION in operation code
Rick Macklem [Fri, 27 May 2022 21:20:31 +0000 (14:20 -0700)]
nfscl: Do not handle NFSERR_BADSESSION in operation code

The NFSERR_BADSESSION reply from a NFSv4.1/4.2 server
is handled by newnfs_request().  It should not be handled
separately after newnfs_request() has returned.

These two cases were spotted during code inspection.
One of them should only redo what newnfs_request() already
did by the same "nfscl" thread.  The other might have
resulted in recovery being done twice, but the code is
only used for "pnfs" mounts, so that would be rare.
Also, since NFSERR_BADSESSION should only be replied by
a server after the server reboots, this would be extremely
rare.

MFC after:  2 weeks

2 years agotests: Fix i386 and powerpc build
Cy Schubert [Fri, 27 May 2022 14:19:53 +0000 (07:19 -0700)]
tests: Fix i386 and powerpc build

Fix:

tests/sys/kern/unix_passfd_test.c:414:24: error: comparison of integers
of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]
        ATF_REQUIRE(getnfds() == nfds + MAXFDS);
        ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
powerpc.powerpc/tmp/usr/include/atf-c/macros.h:144:15: note: expanded
from macro 'ATF_REQUIRE'
        if (!(expression)) \
              ^~~~~~~~~~
1 error generated.
--- unix_passfd_test.o ---

2 years agoDo comprehensive UFS/FFS superblock integrity checks when reading a superblock.
Kirk McKusick [Fri, 27 May 2022 19:21:11 +0000 (12:21 -0700)]
Do comprehensive UFS/FFS superblock integrity checks when reading a superblock.

Historically only minimal checks were made of a superblock when it
was read in as it was assumed that fsck would have been run to
correct any errors before attempting to use the filesystem. Recently
several bug reports have been submitted reporting kernel panics
that can be triggered by deliberately corrupting filesystem superblocks,
see Bug 263979 - [meta] UFS / FFS / GEOM crash (panic) tracking
which is tracking the reported corruption bugs.

This change upgrades the checks that are performed. These additional
checks should prevent panics from a corrupted superblock. Although
it appears in only one place, the new code will apply to the kernel
modules and (through libufs) user applications that read in superblocks.

Reported by:  Robert Morris and Neeraj
Reviewed by:  kib
Tested by:    Peter Holm
PR:           263979
MFC after:    1 month
Differential Revision: https://reviews.freebsd.org/D35219

2 years agoApply clang fix for assertion failure building webkit2-gtk
Dimitry Andric [Fri, 27 May 2022 17:43:39 +0000 (19:43 +0200)]
Apply clang fix for assertion failure building webkit2-gtk

Merge commit 30baa5d2a450 from llvm git (by Richard Smith):

  PR45879: Fix assert when constant evaluating union assignment.

  Consider the form of the first operand of a class assignment not the
  second operand when implicitly starting the lifetimes of union members.
  Also add a missing check that the assignment call actually came from a
  syntactic assignment, not from a direct call to `operator=`.

PR: 264280
Reported by: bapt
MFC after: 3 days

2 years agosockbuf: remove unused mbuf counter and cluster counter
Gleb Smirnoff [Fri, 27 May 2022 15:19:28 +0000 (08:19 -0700)]
sockbuf: remove unused mbuf counter and cluster counter

With M_EXTPG mbufs these two counters already do not represent the
reality.  As we are moving towards protocol independent socket buffers,
which may not even use mbufs at all, the counters become less and less
relevant.  The only userland seeing them was 'netstat -x'.

PR: 264181 (exp-run)
Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D35334

2 years agoReplace subversion with git in the installation DVD
Alan Somers [Thu, 26 May 2022 19:08:34 +0000 (13:08 -0600)]
Replace subversion with git in the installation DVD

I assume the original reason for Subversion's inclusion was to checkout
the base system.  But now we use git for that.

Reviewed by: gjb
Sponsored by: Axcient
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35329

2 years agobsdinstall: fix prepopulating the ZFS disk menu with ZFSBOOT_DISKS
Alan Somers [Thu, 26 May 2022 22:20:03 +0000 (16:20 -0600)]
bsdinstall: fix prepopulating the ZFS disk menu with ZFSBOOT_DISKS

If the ZFSBOOT_DISKS variable is set to one or more disk names, then
those disks should be preselected in the disk menu.  However, the code
wasn't correctly setting the variable, leaving all disks unselected.

MFC after: 2 weeks
Sponsored by: Axcient
Reviewed by: dteske
Differential Revision: https://reviews.freebsd.org/D35331

2 years agostress2: Added a syzkaler reproducer
Peter Holm [Fri, 27 May 2022 13:05:33 +0000 (15:05 +0200)]
stress2: Added a syzkaler reproducer

2 years agoarp: Implement sticky ARP mode for interfaces.
Konrad Sewiłło-Jopek [Fri, 27 May 2022 11:02:57 +0000 (11:02 +0000)]
arp: Implement sticky ARP mode for interfaces.

Provide sticky ARP flag for network interface which marks it as the
"sticky" one similarly to what we have for bridges. Once interface is
marked sticky, any address resolved using the ARP will be saved as a
static one in the ARP table. Such functionality may be used to prevent
ARP spoofing or to decrease latencies in Ethernet networks.

The drawbacks include potential limitations in usage of ARP-based
load-balancers and high-availability solutions such as carp(4).

The implemented option is disabled by default, therefore should not
impact the default behaviour of the networking stack.

Sponsored by: Conclusive Engineering sp. z o.o.
Reviewed By: melifaro, pauamma_gundo.com
Differential Revision: https://reviews.freebsd.org/D35314
MFC after: 2 weeks

2 years agolibpmc: Another update of x86 event definitions.
Alexander Motin [Fri, 27 May 2022 02:07:42 +0000 (22:07 -0400)]
libpmc: Another update of x86 event definitions.

MFC after: 1 month

2 years agocxgbei: Adjust the calculation for the maximum ISO payload.
John Baldwin [Thu, 26 May 2022 20:38:20 +0000 (13:38 -0700)]
cxgbei: Adjust the calculation for the maximum ISO payload.

Round down the maximim ISO payload by the current MSS.  Otherwise the
round up by MSS when calculating the 16-bit maximum payload len passed
along in the FLOWC work request can overflow.

Discussed with: np
Sponsored by: Chelsio Communications

2 years agounix: fix incorrect assertion in 4682ac697ce
Gleb Smirnoff [Thu, 26 May 2022 18:35:05 +0000 (11:35 -0700)]
unix: fix incorrect assertion in 4682ac697ce

Pointy hat to: glebius
Fixes: 4682ac697ce9b306d11e03a628d1ac07f4b540c8

2 years agoAdd newline after 20220524 entry in ObsoleteFiles.inc
Dimitry Andric [Thu, 26 May 2022 14:31:51 +0000 (16:31 +0200)]
Add newline after 20220524 entry in ObsoleteFiles.inc

2 years agosyscons: note incompatibility with UEFI
Ed Maste [Thu, 26 May 2022 00:19:24 +0000 (20:19 -0400)]
syscons: note incompatibility with UEFI

PR: 264226
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agodhclient: test against a real (ISC) dhcp server
John-Mark Gurney [Thu, 12 May 2022 00:04:14 +0000 (17:04 -0700)]
dhclient: test against a real (ISC) dhcp server

This tests both both normal (untagged), and pcp tagged (VLAN 0)
networks which are now common for fiber ISPs.

Reviewed by: markj, kp
Differential Revision: https://reviews.freebsd.org/D35178

2 years agoetcupdate: Preserve permissions when installing a resolved file.
John Baldwin [Wed, 25 May 2022 21:20:40 +0000 (14:20 -0700)]
etcupdate: Preserve permissions when installing a resolved file.

Similar to the change in 1a04446f088c79cc2cf85fd86e60ebcc228d3075, use
cat to overwrite the contents of the existing file rather than cp so
that metadata of the existing file such as permissions and ownership
is preserved.

PR: 255514
Reported by: uqs
MFC after: 1 week

2 years agoetcupdate: Don't rotate trees for a dry run.
John Baldwin [Wed, 25 May 2022 21:02:51 +0000 (14:02 -0700)]
etcupdate: Don't rotate trees for a dry run.

When performing a dry run, remove the temporary tree created rather
than rotating the trees.  Rotating the trees meant that etcupdate
thought the latest changes were already merged and would not merge
them on the next real run.

PR: 260281
Reported by: Tomoaki AOKI <junchoon@dec.sakura.ne.jp>
Fixes: 0611aec3cf3a etcupdate: Always extract to a temporary tree.
MFC after: 1 week

2 years agounix: turn check in unp_externalize() into assertion
Gleb Smirnoff [Wed, 25 May 2022 20:29:20 +0000 (13:29 -0700)]
unix: turn check in unp_externalize() into assertion

In this function we always work with mbufs that we previously
created ourselves in unp_internalize().  They must be valid.

Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D35319

2 years agounix/*: check new control size in unp_internalize()
Gleb Smirnoff [Wed, 25 May 2022 20:29:13 +0000 (13:29 -0700)]
unix/*: check new control size in unp_internalize()

Now that we call sbcreatecontrol() with M_WAITOK, we are expected to
pass a valid size.  Return same error code, we are returning for an
oversized control from sockargs().

Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D35317

2 years agosockets: return EMSGSIZE if control part of message is too large
Gleb Smirnoff [Wed, 25 May 2022 20:29:04 +0000 (13:29 -0700)]
sockets: return EMSGSIZE if control part of message is too large

Specification doesn't list an explicit error code for the control
size specified by msg_control being too large.  But it does list
EMSGSIZE as error code for "message is too large to be sent all at
once (as the socket requires)".  It also lists EINVAL as code for
the "The sum of the iov_len values overflows an ssize_t."  Given
how generic and uninformative EINVAL is, the EMSGSIZE is more
appropriate.

https://pubs.opengroup.org/onlinepubs/9699919799/functions/sendmsg.html

Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D35316

2 years agotests/unix_passfd: sending many and too many SCM_RIGHTS
Gleb Smirnoff [Wed, 25 May 2022 20:28:40 +0000 (13:28 -0700)]
tests/unix_passfd: sending many and too many SCM_RIGHTS

o Exercise bounds checking when sending large set of file descriptors,
  that can't fit into single control mbuf.
o Exercise resource limits checks when receiving a large sets.
o Check that socket isn't left in a completely stuck state when we can't
  receive SCM_RIGHTS due to limits.  Current SOCK_STREAM socket would
  free the control, but leave the data in.  This seems to be a legit
  behavior for a stream socket, as we don't want holes in the data.

PR: 239250
Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D35315

2 years agobacklight: Update cached value when getting the brightness
Emmanuel Vadot [Wed, 25 May 2022 14:48:10 +0000 (16:48 +0200)]
backlight: Update cached value when getting the brightness

External events can cause the backlight level to change (AC adapter
plug/unplug for example) so cache the value there too.

PR: 257796
Sponsored by: Beckhoff Automation GmbH & Co. KG
MFC after: 1 week

2 years agodiff3: Add help and version options
Tom Jones [Wed, 25 May 2022 13:53:06 +0000 (14:53 +0100)]
diff3: Add help and version options

Add help and version flags. Exit values in these paths are set to match
the behaviour of gnu diff3.

2 years agodiff3: Copy line into debug information
Tom Jones [Wed, 25 May 2022 13:45:45 +0000 (14:45 +0100)]
diff3: Copy line into debug information

Sponsored by: Klara Inc.

2 years agodiff3: Don't perform a bitwise OR when comparing diffs
Tom Jones [Wed, 25 May 2022 13:41:43 +0000 (14:41 +0100)]
diff3: Don't perform a bitwise OR when comparing diffs

This fixes the build now that it uses -Wbitwise-instead-of-logical

Sponsored by: Klara Inc.

2 years agoSave only callee-saved registers in pcb
Dapeng Gao [Wed, 25 May 2022 10:25:06 +0000 (11:25 +0100)]
Save only callee-saved registers in pcb

On AArch64, registers x9-x18 are not callee-saved, yet they are
preserved at many placed in swtch.S. This patch removes code that
preserves these registers.

2 years agoAdd arm64 CnP support
Andrew Turner [Wed, 25 May 2022 09:55:40 +0000 (10:55 +0100)]
Add arm64 CnP support

Set the Common not Private bit in the ttbr registers when supported on
arm64. This tells the hardware it can share the translation table
entries on multiple CPUs.

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