]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoMFC r357234, r357365, r357375:
Kristof Provost [Tue, 4 Feb 2020 04:29:54 +0000 (04:29 +0000)]
MFC r357234, r357365, r357375:

tests: Test for an epair panic

if_epair abused the ifr_data field to insert its second interface in
IFC_IFLIST. If userspace provides a value for ifr_data it would get
dereferenced by the kernel leading to a panic.

Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com>

4 years agoMFC 356913
George V. Neville-Neil [Tue, 4 Feb 2020 03:31:28 +0000 (03:31 +0000)]
MFC 356913

Add support for latest Intel I219 device, supported in Lenovo Carbon X1 v7

4 years agoMFC r356947:
Mark Johnston [Tue, 4 Feb 2020 02:06:21 +0000 (02:06 +0000)]
MFC r356947:
Add relocation handling required for -zifunc-noplt to work on arm64.

4 years agoMFC r357298:
Hans Petter Selasky [Mon, 3 Feb 2020 11:04:18 +0000 (11:04 +0000)]
MFC r357298:
Add missing mutex unlock in failure case.

Differential Revision: https://reviews.freebsd.org/D23430
Submitted by: cem
Reported by: Coverity
Coverity CID: 1368773
Sponsored by: Mellanox Technologies

4 years agoMFC r357077:
Hans Petter Selasky [Mon, 3 Feb 2020 10:59:27 +0000 (10:59 +0000)]
MFC r357077:
Implement mmget_not_zero() in the LinuxKPI.

Submitted by: Austin Shafer <ashafer@badland.io>
Sponsored by: Mellanox Technologies

4 years agoMFC r357041:
Hans Petter Selasky [Mon, 3 Feb 2020 10:53:03 +0000 (10:53 +0000)]
MFC r357041:
Fix build of stand/usb .

Sponsored by: Mellanox Technologies

4 years agoMFC r356952:
Hans Petter Selasky [Mon, 3 Feb 2020 10:49:18 +0000 (10:49 +0000)]
MFC r356952:
Add new USB ID to uslcom(4).

Submitted by: Oleg Sharoyko <osharoiko@gmail.com>
PR: 243494
Sponsored by: Mellanox Technologies

4 years agoMFC r356633:
Hans Petter Selasky [Mon, 3 Feb 2020 10:45:09 +0000 (10:45 +0000)]
MFC r356633:
Make sure the VNET is properly set when reaping mbufs in ipoib.
Else the following panic may happen:

panic()
icmp_error()
ipoib_cm_mb_reap()
linux_work_fn()
taskqueue_run_locked()
taskqueue_thread_loop()
fork_exit()
fork_trampoline()

Submitted by: Andreas Kempe <kempe@lysator.liu.se>
Sponsored by: Mellanox Technologies

4 years agoMFC r357292:
Philip Paeps [Sun, 2 Feb 2020 08:46:29 +0000 (08:46 +0000)]
MFC r357292:

  acpi_ibm: add support for ThinkPad PrivacyGuard

  ThinkPad PrivacyGuard is a built-in toggleable privacy filter that
  restricts viewing angles when on. It is an available on some new
  ThinkPad models such as the X1 Carbon 7th gen (as an optional HW
  upgrade).

  The privacy filter can be enabled/disabled via an ACPI call. This commit
  adds a sysctl under dev.acpi_ibm that allows for getting and setting the
  PrivacyGuard state.

Submitted by:   Kamila Součková <kamila@ksp.sk>
Reviewed By:    cem, philip
Differential Revision: https://reviews.freebsd.org/D23370

4 years agoMFC r357232:
Dimitry Andric [Fri, 31 Jan 2020 21:20:22 +0000 (21:20 +0000)]
MFC r357232:

Merge r357231 from the clang1000-import branch:

Work around assembler error from clang 10.0.0 in gptboot:

stand/i386/gptboot/gptldr.S:141:3: error: value of 36878 is too large for field of 2 bytes.
  jmp MEM_JMP # Start BTX
  ^

Use the same construct as in stand/i386/boot2/boot1.S, which ensures the
jump distance does not become too large.

4 years agoMFC r357226:
Dimitry Andric [Fri, 31 Jan 2020 20:04:32 +0000 (20:04 +0000)]
MFC r357226:

Merge r357224 from the clang1000-import branch:

Fix the following -Werror warning from clang 10.0.0 in binutils:

contrib/binutils/bfd/peicode.h:1356:3: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                if (efi)
                ^
contrib/binutils/bfd/peicode.h:1353:8: note: previous statement is here
              if (pe_arch (bfd_target_efi_arch (*target_ptr)) != arch)
              ^
contrib/binutils/bfd/peicode.h:1370:3: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                if (!efi)
                ^
contrib/binutils/bfd/peicode.h:1367:8: note: previous statement is here
              if (pe_arch (bfd_target_pei_arch (*target_ptr)) != arch)
              ^

4 years agoMFC r354922
Warner Losh [Fri, 31 Jan 2020 13:18:25 +0000 (13:18 +0000)]
MFC r354922

> Author: imp <imp@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
> Date:   Wed Nov 20 23:45:31 2019 +0000
>
>    Create /etc/os-release file.
>
>    Each boot, regenerate /var/run/os-release based on the currently running
>    system. Create a /etc/os-release symlink pointing to this file (so that this
>    doesn't create a new reason /etc can not be mounted read-only).
>
>    This is compatible with what other systems do and is what the sysutil/os-release
>    port attempted to do, but in an incomplete way. Linux, Solaris and DragonFly all
>    implement this natively as well. The complete standard can be found at
>    https://www.freedesktop.org/software/systemd/man/os-release.html
>
>    Moving this to the base solves both the non-standard location problem with the
>    port, as well as the lack of update of this file on system update.
>
>    Bump __FreeBSD_version to 1300060
>
>    PR: 238953
>    Differential Revision:  https://reviews.freebsd.org/D22271

Execpt bump __FreeBSD_version to 1201511

4 years agoMFC r357043: Fix kernel-tags target.
Yoshihiro Takahashi [Fri, 31 Jan 2020 12:38:53 +0000 (12:38 +0000)]
MFC r357043: Fix kernel-tags target.

>  - A depend-file is broken up into .depend.*.o files. [1]
>  - Fix an assembly file support.
>
>  PR:           241746
>  Submitted by: leres [1]

4 years agoMFC r357233:
Kristof Provost [Fri, 31 Jan 2020 10:34:36 +0000 (10:34 +0000)]
MFC r357233:

epair: Do not abuse params to register the second interface

if_epair used the 'params' argument to pass a pointer to the b interface
through if_clone_create().
This pointer can be controlled by userspace, which means it could be abused to
trigger a panic. While this requires PRIV_NET_IFCREATE
privileges those are assigned to vnet jails, which means that vnet jails
could panic the system.

Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com>

4 years agoMFC r356707: Map ECKSUM and EFRAGS from ZFS onto real errnos.
Alexander Motin [Thu, 30 Jan 2020 16:38:40 +0000 (16:38 +0000)]
MFC r356707: Map ECKSUM and EFRAGS from ZFS onto real errnos.

Make it less confusing when, for example, stat sets errno to 122 because a
checksum failed in ZFS:

Before: getfacl: /foo/bar: stat() failed: Unknown error: 122
After: getfacl: /foo/bar: stat() failed: Integrity check failed

Submitted by: Ryan Moeller <ryan@ixsystems.com>

4 years agoMFC r343111,343113-343115 (by mckusick):
Alexander Motin [Thu, 30 Jan 2020 16:11:19 +0000 (16:11 +0000)]
MFC r343111,343113-343115 (by mckusick):
Create new EINTEGRITY error with message "Integrity check failed".

An integrity check such as a check-hash or a cross-correlation failed.
The integrity error falls between EINVAL that identifies errors in
parameters to a system call and EIO that identifies errors with the
underlying storage media. EINTEGRITY is typically raised by intermediate
kernel layers such as a filesystem or an in-kernel GEOM subsystem when
they detect inconsistencies. Uses include allowing the mount(8) command
to return a different exit value to automate the running of fsck(8)
during a system boot.

These changes make no use of the new error, they just add it. Later
commits will be made for the use of the new error number and it will
be added to additional manual pages as appropriate.

Approved by: mckusick

4 years agoMFC r357048:
Mark Johnston [Thu, 30 Jan 2020 15:00:41 +0000 (15:00 +0000)]
MFC r357048:
arm64: Don't enable interrupts in init_secondary().

4 years agoMFC r356816:
Kristof Provost [Thu, 30 Jan 2020 09:56:56 +0000 (09:56 +0000)]
MFC r356816:

Fix pfdenied not returning any results

When _a is empty we end up with an invalid invocation of pfctl, and no output.
We must add quotes to make it clear to pfctl that we're passing an empty anchor
name.

PR: 224415
Submitted by: sigsys AT gmail.com

4 years agoMFC r357159
Vincenzo Maffione [Wed, 29 Jan 2020 22:55:59 +0000 (22:55 +0000)]
MFC r357159

netmap_mem_unmap: fix NULL pointer dereference

4 years agoMFC r354637:
Roger Pau Monné [Wed, 29 Jan 2020 09:33:40 +0000 (09:33 +0000)]
MFC r354637:

xen: fix dispatching of NMIs

4 years agoMFC 357212.
Gordon Tetlow [Tue, 28 Jan 2020 18:40:55 +0000 (18:40 +0000)]
MFC 357212.

Fix urldecode buffer overrun.

Reported by: Duncan Overbruck
Approved by: so
Security: FreeBSD-SA-20:01.libfetch
Security: CVE-2020-7450

4 years agoMFC r356527-356528:
Bjoern A. Zeeb [Tue, 28 Jan 2020 18:08:53 +0000 (18:08 +0000)]
MFC r356527-356528:

  vnet: virtualise more network stack sysctls.

  Virtualise tcp_always_keepalive, TCP and UDP log_in_vain.  All three are
  set in the netoptions startup script, which we would love to run for VNETs
  as well.

  While virtualising the log_in_vain sysctls seems pointles at first for as
  long as the kernel message buffer is not virtualised, it at least allows
  an administrator to debug the base system or an individual jail if needed
  without turning the logging on for all jails running on a system.

  Run netoptions startup script in vnet jails.

  People use rc.conf inside vnet jails to configure networking setups.
  Presumably because some sysctl were not virtualised up until r356527 the
  script was not run for vnet jails leaving the rc.conf options without
  effect for non-obvious reasons.  Run the netoptions startup script also
  for VNET jails now to make the rc.conf options work.

PR: 243193

4 years agoMFC r356662:
Bjoern A. Zeeb [Tue, 28 Jan 2020 17:48:14 +0000 (17:48 +0000)]
MFC r356662:

  nd6_rtr: constantly use __func__ for nd6log()

  Over time one or two hard coded function names did not match the
  actual function anymore.  Consistently use __func__ for nd6log() calls
  and re-wrap/re-format some messages for consitency.

4 years agoMFC r353026,353030,354244 (glebius), r356386:
Bjoern A. Zeeb [Tue, 28 Jan 2020 17:39:03 +0000 (17:39 +0000)]
MFC r353026,353030,354244 (glebius), r356386:

  Remove the compile time limit for number of links a ng_bridge node
  can handle.  Instead using an array on node private data, use per-hook
  private data.

  Reestablish old ABI.

PR: 240787
Submitted by: Lutz Donnerhacke (lutz donnerhacke.de)

4 years agoMFC r356940:
Konstantin Belousov [Tue, 28 Jan 2020 11:33:12 +0000 (11:33 +0000)]
MFC r356940:
Add support for Hygon Dhyana Family 18h processor.

4 years agoMFC r356629, r356636
Xin LI [Tue, 28 Jan 2020 07:49:52 +0000 (07:49 +0000)]
MFC r356629, r356636

r356629:
Apply typo fix from NetBSD, we have already applied all NetBSD changes so
update the NetBSD tag while I'm there.

r356636:
Correct off-by-two issue when determining FAT type.

In the code we used NumClusters as the upper (non-inclusive) boundary
of valid cluster number, so the actual value was 2 (CLUST_FIRST) more
than the real number of clusters. This causes a FAT16 media with
65524 clusters be treated as FAT32 and might affect FAT12 media with
4084 clusters as well.

To fix this, we increment NumClusters by CLUST_FIRST after the type
determination.

PR: 243179

4 years agoMFC r357084: caroot: use bsd.obj.mk, not bsd.prog.mk
Kyle Evans [Tue, 28 Jan 2020 02:58:39 +0000 (02:58 +0000)]
MFC r357084: caroot: use bsd.obj.mk, not bsd.prog.mk

This directory stages certdata into .OBJDIR and processes it, but does not
actually build a prog-shaped object; bsd.obj.mk provides the minimal support
that we actually need, an .OBJDIR and descent into subdirs. This is
admittedly the nittiest of nits.

4 years agoMFC r357103-r357104: unbreak local.lua, add a modules.loaded hook
Kyle Evans [Tue, 28 Jan 2020 02:42:33 +0000 (02:42 +0000)]
MFC r357103-r357104: unbreak local.lua, add a modules.loaded hook

r357103:
loader.lua: re-arrange to load local.lua *after* config loading

The major problem with the current ordering is that loader.conf may contain
all of the magic we need to actually setup the console, so loading local.lua
prior to that can make it excessively difficult and annoying to debug
(whoops, sorry Ravi & Warner).

The new ordering has some implications, but I suspect they are a non-issue.
The first is that it's no longer possible for the local module to inject any
logic prior to loading config -- I suspect no one has relied on this. The
second implication is that the config.loaded hook is now useless, as the
local module will always be included after that hook would have fired.

For config.loaded, I will opt to leave it in, just in case we add an early
point for local lua to get injected or in case one wants to schedule some
deferred logic in a custom loader.lua. The overhead of having it if no hooks
will be invoked is relatively minimal.

r357104:
lua: add modules.loaded hook

This may be used for the local module to hook in and load any additional
modules that it wants, since it can't modify the modules table internal to
config. We may consider adding API to do so at a later time, but I suspect
it will be more complicated to use with little return.

status is captured but ignored for the purpose of loading the hook. status
will be false if *any* module failed to load, but we typically don't let
that halt the boot so there's no reason to let it halt hooks. Some vendors
or setups may have expected fails that would be actively thwarted by
checking it.

We may, at a later date, consider adding an API for letting non-config
modules check which modules have successfully (or not) loaded in case an
unexpected failure *should* halt whatever they are doing.

4 years agoMFC r356994: Mark rfork(2) as __returns_twice
Kyle Evans [Mon, 27 Jan 2020 22:13:42 +0000 (22:13 +0000)]
MFC r356994: Mark rfork(2) as __returns_twice

rfork is not generally a built-in that would be recognized as behaving like
vfork/fork; provide the hint.

4 years agoMFC r356919,r357054:
Konstantin Belousov [Mon, 27 Jan 2020 13:12:40 +0000 (13:12 +0000)]
MFC r356919,r357054:
x86: Wait for curpcb to be set up as an indicator that the boot stack
is no longer used.

4 years agoMFC r356929:
Dimitry Andric [Mon, 27 Jan 2020 07:03:57 +0000 (07:03 +0000)]
MFC r356929:

Merge commit bc4bc5aa0 from llvm git (by Justin Hibbits):

  Add 8548 CPU definition and attributes

  8548 CPU is GCC's name for the e500v2, so accept this in clang.  The
  e500v2 doesn't support lwsync, so define __NO_LWSYNC__ for this as
  well, as GCC does.

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

Merge commit ff0311c4b from llvm git (by Justin Hibbits):

  [PowerPC]: Add powerpcspe target triple subarch component

  Summary:
  This allows the use of '-target powerpcspe-unknown-linux-gnu' or
  'powerpcspe-unknown-freebsd' to be used, instead of '-target
  powerpc-unknown-linux-gnu -mspe'.

  Reviewed By: dim
  Differential Revision: https://reviews.llvm.org/D72014

Merge commit ba91dffaf from llvm git (by Fangrui Song):

  [Driver][PowerPC] Move powerpcspe logic from cc1 to Driver

  Follow-up of D72014. It is more appropriate to use a target feature
  instead of a SubTypeArch to express the difference.

  Reviewed By: #powerpc, jhibbits

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

commit 36eedfcb3 from llvm git (by Justin Hibbits):

  [PowerPC] Fix powerpcspe subtarget enablement in llvm backend

  Summary:

  As currently written, -target powerpcspe will enable SPE regardless
  of disabling the feature later on in the command line.  Instead,
  change this to just set a default CPU to 'e500' instead of a generic
  CPU.

  As part of this, add FeatureSPE to the e500 definition.

  Reviewed By: MaskRay
  Differential Revision: https://reviews.llvm.org/D72673

These are needed to unbreak the build for powerpcspe.

Requested by: jhibbits

4 years agoMFC r356789 (by arichardson):
Dimitry Andric [Mon, 27 Jan 2020 07:02:52 +0000 (07:02 +0000)]
MFC r356789 (by arichardson):

Merge commit 894f742acb from llvm git (by me):

  [MIPS][ELF] Use PC-relative relocations in .eh_frame when possible

  When compiling position-independent executables, we now use
  DW_EH_PE_pcrel | DW_EH_PE_sdata4. However, the MIPS ABI does not define a
  64-bit PC-relative ELF relocation so we cannot use sdata8 for the large
  code model case. When using the large code model, we fall back to the
  previous behaviour of generating absolute relocations.

  With this change clang-generated .o files can be linked by LLD without
  having to pass -Wl,-z,notext (which creates text relocations).
  This is simpler than the approach used by ld.bfd, which rewrites the
  .eh_frame section to convert absolute relocations into relative references.

  I saw in D13104 that apparently ld.bfd did not accept pc-relative relocations
  for MIPS ouput at some point. However, I also checked that recent ld.bfd
  can process the clang-generated .o files so this no longer seems true.

  Reviewed By: atanasyan
  Differential Revision: https://reviews.llvm.org/D72228

Merge commit 8e8ccf47 from llvm git (by me)

  [MIPS] Don't emit R_(MICRO)MIPS_JALR relocations against data symbols

  The R_(MICRO)MIPS_JALR optimization only works when used against functions.
  Using the relocation against a data symbol (e.g. function pointer) will
  cause some linkers that don't ignore the hint in this case (e.g. LLD prior
  to commit 5bab291) to generate a relative branch to the data symbol
  which crashes at run time. Before this patch, LLVM was erroneously emitting
  these relocations against local-dynamic TLS function pointers and global
  function pointers with internal visibility.

  Reviewers: atanasyan, jrtc27, vstefanovic
  Reviewed By: atanasyan
  Differential Revision: https://reviews.llvm.org/D72571

These two changes should allow using lld for MIPS64 (and maybe also MIPS32)
by default.
The second commit is not strictly necessary for clang+lld since LLD9 will
not perform the R_MIPS_JALR optimization (it was only added for 10) but it
is probably required in order to use recent ld.bfd.

Reviewed By: dim, emaste
Differential Revision: https://reviews.freebsd.org/D23203

4 years agoMFC r355553
Don Lewis [Sun, 26 Jan 2020 01:42:47 +0000 (01:42 +0000)]
MFC r355553

Fix a logic bug in error handling code.  It is an error if p == NULL.
The linelen tests are only meaningful when p != NULL.

Reported by: Coverity
Coverity CID: 1368655

4 years agoMFC r356863: ifa_maintain_loopback_route: adjust debugging output
Eugene Grosbein [Sat, 25 Jan 2020 09:12:20 +0000 (09:12 +0000)]
MFC r356863: ifa_maintain_loopback_route: adjust debugging output

Correction after r333476:

- write this as LOG_DEBUG again instead of LOG_INFO;
- get back function name into the message;
- error may be ESRCH if an address is removed in process (by carp f.e.),
  not only ENOENT;
- expression complexity grows, so try making it more readable.

4 years agoRegenerate ibcs2 sysent targets, NFC
Kyle Evans [Sat, 25 Jan 2020 05:52:31 +0000 (05:52 +0000)]
Regenerate ibcs2 sysent targets, NFC

Direct commit; these hadn't been regenerated in a wihle, and it's nice to
see no diff going forward in case these get tweaked a little bit more for
conventions. Unlikely.

4 years agoMFC r355473, r356540, r356604, r356868, r356937: sysent improvements
Kyle Evans [Sat, 25 Jan 2020 05:47:56 +0000 (05:47 +0000)]
MFC r355473, r356540, r356604, r356868, r356937: sysent improvements

The main motivation here being .ORDER to render -jN > 1 harmless; svr4/ibcs2
targets were also refactored a bit, but both are irregular and cannot use
sysent.mk as-is due to differences in files generated. I have no interest in
refactoring, since these are gone in head anyways.

r355473: sysent: Reduce duplication and improve readability.

Use the power of variable to avoid spelling out source and generated
files too many times.  The previous Makefiles were hard to read, hard to
edit, and badly formatted.

r356540:
kern/Makefile: systrace_args.c is also generated

r356604:
Set .ORDER for makesyscalls generated files

When either makesyscalls.lua or syscalls.master changes, all of the
${GENERATED} targets are now out-of-date. With make jobs > 1, this means we
will run the makesyscalls script in parallel for the same ABI, generating
the same set of output files.

Prior to r356603 , there is a large window for interlacing output for some
of the generated files that we were generating in-place rather than staging
in a temp dir. After that, we still should't need to run the script more
than once per-ABI as the first invocation should update all of them. Add
.ORDER to do so cleanly.

r356868:
sysent targets: further cleanup and deduplication

r355473 vastly improved the readability and cleanliness of these Makefiles.
Every single one of them follows the same pattern and duplicates the exact
same logic.

Now that we have GENERATED/SRCS, split SRCS up into the two parameters we'll
use for ${MAKESYSCALLS} rather than assuming a specific ordering of SRCS and
include a common sysent.mk to handle the rest. This makes it less tedious to
make sweeping changes.

Some default values are provided for GENERATED/SYSENT_*; almost all of these
just use a 'syscalls.master' and 'syscalls.conf' in cwd, and they all use
effectively the same filenames with an arbitrary prefix. Most ABIs will be
able to get away with just setting GENERATED_PREFIX and including
^/sys/conf/sysent.mk, while others only need light additions. kern/Makefile
is the notable exception, as it doesn't take a SYSENT_CONF and the generated
files are spread out between ^/sys/kern and ^/sys/sys, but it otherwise fits
the pattern enough to use the common version.

r356937:
sysent.mk: split interpreter out of target command

The main objective here is to make it easy to identify what needs to change
in order to use a different sysent generator than the current Lua-based one,
which may be used to MFC some of the changes that have happened so we can
avoid parallel accidents in stable branches, for instance.

As a secondary objective, it's now feasible to override the generator on a
per-Makefile basis if needed, so that one could refactor their Makefile to
use this while pinning generation to the legacy makesyscalls.sh. I don't
anticipate any consistent need for such a thing, but it's low-effort to
achieve.

4 years agoMFC r354968, r354976: Introduce, but do not use, bsd.sysdir.mk
Kyle Evans [Sat, 25 Jan 2020 05:17:44 +0000 (05:17 +0000)]
MFC r354968, r354976: Introduce, but do not use, bsd.sysdir.mk

[Some sysent bits use bsd.sysdir.mk now, but I don't see a point in
converting existing stuff]

MFC r354968: Introduce bsd.sysdir.mk to consolidate looking for the kernel.

MFC r354976: Install bsd.sysdir.mk

4 years agoMFC 356951: posix_spawn: mark error as volatile
Kyle Evans [Fri, 24 Jan 2020 17:15:31 +0000 (17:15 +0000)]
MFC 356951: posix_spawn: mark error as volatile

In the case of an error, the RFSPAWN'd thread will write back to psa->error
with the correct exit code. Mark this as volatile as the return value is
being actively dorked up for erroneous exits on !x86.

This fixes the following tests, tested on aarch64 (only under qemu, at the
moment):

- posix_spawn/spawn_test:t_spawn_missing
- posix_spawn/spawn_test:t_spawn_nonexec
- posix_spawn/spawn_test:t_spawn_zero

4 years agoMFC r352948-r352951, r353002, r353066, r353070: caroot infrastructure
Kyle Evans [Fri, 24 Jan 2020 15:29:33 +0000 (15:29 +0000)]
MFC r352948-r352951, r353002, r353066, r353070: caroot infrastructure

Infrastructure only -- no plans in place currently to commit any certs to
these branches.

r352948:
[1/3] Initial infrastructure for SSL root bundle in base

This setup will add the trusted certificates from the Mozilla NSS bundle
to base.

This commit includes:
- CAROOT option to opt out of installation of certs
- mtree amendments for final destinations
- infrastructure to fetch/update certs, along with instructions

A follow-up commit will add a certctl(8) utility to give the user control
over trust specifics. Another follow-up commit will actually commit the
initial result of updatecerts.

This work was done primarily by allanjude@, with minor contributions by
myself.

r352949:
[2/3] Add certctl(8)

This is a simple utility to hash all trusted on the system into
/etc/ssl/certs. It also allows the user to blacklist certificates they do
not trust.

This work was done primarily by allanjude@, with minor contributions by
myself.

r352950:
[3/3] etcupdate and mergemaster support for certctl

This commit add support for certctl in mergemaster and etcupdate. Both will
either rehash or prompt for rehash as new certificates are
trusted/blacklisted.

This work was done primarily by allanjude@, with minor contributions by
myself.

r352951:
caroot: add @generated tags to extracted .pem

As is the current trend; while these files are manually curated, they are
still generated.  If they end up in a review, it would be helpful to also
take the hint and hide them.

r353002:
Unbreak etcupdate(8) and mergemaster(8) after r352950

r352950 introduced improper case fall-through for shell scripts. Fix it with
a pipe.

r353066:
certctl(8): realpath the file before creating the symlink

Otherwise we end up creating broken relative symlinks in
/etc/ssl/blacklisted.

r353070:
certctl(8): let one blacklist based on hashed filenames

It seems reasonable to allow, for instance:

$ certctl list
# reviews output -- ah, yeah, I don't trust that one
$ certctl blacklist ce5e74ef.0
$ certctl rehash

We can unambiguously determine what cert "ce5e74ef.0" refers to, and we've
described it to them in `certctl list` output -- I see little sense in
forcing another level of filesystem inspection to determien what cert file
this physically corresponds to.

Relnotes: yes

4 years agoMFC r355647:
Eitan Adler [Fri, 24 Jan 2020 14:22:09 +0000 (14:22 +0000)]
MFC r355647:
[showmount] implement long options

add long options support to showmount. Where mappings exist use the GNU
names for said options.

Relnotes: yes

4 years agoMFC r356836: src.opts.mk: force DMAGENT off under WITHOUT_OPENSSL
Ed Maste [Fri, 24 Jan 2020 01:00:28 +0000 (01:00 +0000)]
MFC r356836: src.opts.mk: force DMAGENT off under WITHOUT_OPENSSL

dma(8) depends on OpenSSL unconditionally.

4 years agoMFC r356563:
Mark Johnston [Thu, 23 Jan 2020 14:01:03 +0000 (14:01 +0000)]
MFC r356563:
UMA: Don't destroy zones after the system shutdown process starts.

PR: 242427

4 years agoMFC of 356714
Kirk McKusick [Thu, 23 Jan 2020 06:20:57 +0000 (06:20 +0000)]
MFC of 356714

Fix DIRCHG panic

4 years agoMFC of 356763
Kirk McKusick [Thu, 23 Jan 2020 06:11:25 +0000 (06:11 +0000)]
MFC of 356763

Remove call to VFS_SYNC() to avoid unmount livelock

4 years agoMFC of 356739
Kirk McKusick [Thu, 23 Jan 2020 06:02:52 +0000 (06:02 +0000)]
MFC of 356739

Optimize quota sync'ing

4 years agoMFC r356876-r356877: add zfs_mount_at
Kyle Evans [Wed, 22 Jan 2020 22:51:55 +0000 (22:51 +0000)]
MFC r356876-r356877: add zfs_mount_at

r356876:
libzfs: add zfs_mount_at

This will be used in libbe in place of the internal zmount(); libbe only
wants to be able to mount a dataset at an arbitrary mountpoint without
altering dataset/pool properties. The natural way to do this in a portable
way is by creating a zfs_mount_at() interface that's effectively zfs_mount()
+ a mountpoint parameter. zfs_mount() is now a light wrapper around the new
method.

The interface and implementation have already been accepted into ZFS On
Linux, and the next commit to switch libbe() over to this new interface will
solve the last compatibility issue with ZoL.  The next sysutils/openzfs
rebase against ZoL should be able to build libbe/bectl with only minor
adjustments to build glue.

r356877:
libbe: use the new zfs_mount_at()

More background is available in r356876, but this new interface is more
portable across ZFS implementations and cleaner for what libbe is attempting
to achieve anyways.

4 years agoMFC r356849: bcm2835_vcbus: unifdef all platform definitions
Kyle Evans [Wed, 22 Jan 2020 22:08:02 +0000 (22:08 +0000)]
MFC r356849:  bcm2835_vcbus: unifdef all platform definitions

Raspberry Pi are all over the board, and the reality is that there's no harm
in including all of the definitions by default but plenty of harm in the
current situation. This change is safe because we match a definition by root
/compatible in the FDT, so there will be no false-positives because of it.

The main array of definitions grows, but it's only walked exactly once to
determine which we need to use.

4 years agoMFC of 356627
Kirk McKusick [Wed, 22 Jan 2020 01:28:37 +0000 (01:28 +0000)]
MFC of 356627

Reset link counts after directory update failures

4 years agoMFC r342873:
Pawel Jakub Dawidek [Wed, 22 Jan 2020 01:10:23 +0000 (01:10 +0000)]
MFC r342873:

In r316006 the getstrfromtype_locked() function was modified to return
an empty string, instead of NULL, if an entry is missing in the audit_control
file. Because of that change the getachost() function started to return
success even if the host name was not defined in the audit_control.
This in turn led to auditd_hostlen always being set (for an empty host it was
set to 0). If auditd_hostlen was not equal to -1 we were trying to append
the host name to trail file name. All this led to situation where when host
name is not defined in audit_control, auditd will create trail files with
a leading '.', which breaks auditdistd as it doesn't work with longer audit
trail file names.

Fix this by appending host name to the trail file name only if the host name
is not empty.

Sponsored by: Fudo Security

4 years agoMFC r356474, r356480, r356482, r356506:
Alexander Motin [Wed, 22 Jan 2020 01:08:27 +0000 (01:08 +0000)]
MFC r356474, r356480, r356482, r356506:
Add Host Memory Buffer support to nvme(4).

This allows cheapest DRAM-less NVMe SSDs to use some of host RAM (about
1MB per 1GB on the devices I have) for its metadata cache, significantly
improving random I/O performance.  Device reports minimal and preferable
size of the buffer.  The code limits it to 5% of physical RAM by default.
If the buffer can not be allocated or below minimal size, the device will
just have to work without it.

4 years agoMFC r351357 (by imp): Document RST support in nvme(4) and ahci(4).
Alexander Motin [Wed, 22 Jan 2020 01:04:26 +0000 (01:04 +0000)]
MFC r351357 (by imp): Document RST support in nvme(4) and ahci(4).

4 years agoMFC r347967 (by cem): nvd.4: Reference nda(4)
Alexander Motin [Wed, 22 Jan 2020 01:03:24 +0000 (01:03 +0000)]
MFC r347967 (by cem): nvd.4: Reference nda(4)

Fix a totally minor typo in nvme.4 while here.

4 years agoMFC r341709 (by imp): Add nda(4) cross reference to nvme(4)
Alexander Motin [Wed, 22 Jan 2020 00:52:42 +0000 (00:52 +0000)]
MFC r341709 (by imp): Add nda(4) cross reference to nvme(4)

4 years agoMFC r355774 (by mmel): Properly synchronize completion DMA buffers.
Alexander Motin [Wed, 22 Jan 2020 00:48:54 +0000 (00:48 +0000)]
MFC r355774 (by mmel): Properly synchronize completion DMA buffers.

Within command completion processing the callback function may access
DMAed data buffer. Synchronize it before use, not after.
This allows to use NVMe disk on non-DMA coherent arm64 system.

4 years agoMFC r355721 (by imp): Move to using bool instead of boolean_t
Alexander Motin [Wed, 22 Jan 2020 00:46:09 +0000 (00:46 +0000)]
MFC r355721 (by imp): Move to using bool instead of boolean_t

While there are subtle semantic differences between bool and boolean_t, none of
them matter in these cases. Prefer true/false when dealing with bool
type. Preserve a couple of TRUEs since they are passed into int args into CAM.
Preserve a couple of FALSEs when used for status.done, an int.

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

4 years agoMFC r355631 (by imp): Move reset to the interrutp processing stage
Alexander Motin [Wed, 22 Jan 2020 00:43:51 +0000 (00:43 +0000)]
MFC r355631 (by imp): Move reset to the interrutp processing stage

This trims the boot time a bit more for AWS and other platforms that have nvme
drives. There's no reason too do this inline. This has been in my tree a while,
but IIRC I talked to Jim Harris about this at one of our face to face meetings.

4 years agoMFC r355465 (by imp): trackers always know what qpair they are on
Alexander Motin [Wed, 22 Jan 2020 00:41:18 +0000 (00:41 +0000)]
MFC r355465 (by imp): trackers always know what qpair they are on

Don't needlessly pass around qpair pointers when the tracker knows what
qpair it's on.  This will simplify code and make it easier to split
submission and completion queues in the future.

Signed-off-by: John Meneghini <johnm@netapp.com>
4 years agoMFC r356760:
Mark Johnston [Wed, 22 Jan 2020 00:30:27 +0000 (00:30 +0000)]
MFC r356760:
Handle a NULL thread pointer in linux_close_file().

PR: 242913

4 years agoMFC r356477:
Mark Johnston [Tue, 21 Jan 2020 15:07:23 +0000 (15:07 +0000)]
MFC r356477:
Use a deterministic hash for USDT symbol names.

4 years agoMFC r356703
Vincenzo Maffione [Mon, 20 Jan 2020 22:15:33 +0000 (22:15 +0000)]
MFC r356703

vmx: fix initialization of TSO related descriptor fields

Fix a mistake introduced by r343291, which ported the vmx(4)
driver to iflib.
In case of TSO, the hlen field of the (first) tx descriptor must
be initialized to the cumulative length of Ethernet, IP and TCP
headers. The length of the TCP header was missing.

PR:             236999
Reported by:    pkelsey
Reviewed by:    avg
Differential Revision:  https://reviews.freebsd.org/D22967

4 years agoMFC r356792:
Glen Barber [Mon, 20 Jan 2020 15:38:05 +0000 (15:38 +0000)]
MFC r356792:
 Update release(7) to note OSRELEASE is only relevant when the
 'install' target is invoked.

 While here, bump the sample output version name, and explicitly
 add the 'obj' target to avoid polluting the src checkout.

PR: 243287 (related)
Sponsored by: Rubicon Communications, LLC (netgate.com)

4 years agoMFC r356676:
Cy Schubert [Mon, 20 Jan 2020 13:46:09 +0000 (13:46 +0000)]
MFC r356676:

Unbound's config.h is manually maintained, using a ./configure produced
config.h as a guide. In practice contributed software maintains a copy
of config.h within its build directory tree containing its Makefile.
usr.sbin/unbound is the home for its config.h.

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

4 years agoMFC 356561: Add stricter checking on mac key lengths.
John Baldwin [Mon, 20 Jan 2020 11:54:00 +0000 (11:54 +0000)]
MFC 356561: Add stricter checking on mac key lengths.

Negative lengths are always invalid.  The key length should also
be zero for hash algorithms that do not accept a key.

admbugs: 949

4 years agoMFC 356507,356520: Add a reference count to cryptodev sessions.
John Baldwin [Mon, 20 Jan 2020 11:19:55 +0000 (11:19 +0000)]
MFC 356507,356520: Add a reference count to cryptodev sessions.

356507:
Add a reference count to cryptodev sessions.

This prevents use-after-free races with crypto requests (which may
sleep) and CIOCFSESSION as well as races from current CIOCFSESSION
requests.

356520:
Remove no-longer-used function prototype.

admbugs: 949
Sponsored by: Chelsio Communications

4 years agoMFC r356682:
Konstantin Belousov [Mon, 20 Jan 2020 08:55:27 +0000 (08:55 +0000)]
MFC r356682:
Code must not unlock a mutex while owning the thread lock.

4 years agoMFC r356695, r356731:
Mark Johnston [Mon, 20 Jan 2020 01:38:03 +0000 (01:38 +0000)]
MFC r356695, r356731:
Optimize diff -q.

PR: 242828

4 years agoMFC 356274: Some minor tweaks to arch(7).
John Baldwin [Sat, 18 Jan 2020 23:46:30 +0000 (23:46 +0000)]
MFC 356274: Some minor tweaks to arch(7).

- Drop mention of _LP64.  FreeBSD's source generally uses __LP64__
  instead of _LP64, and the relevant macros are better covered in the
  "Predefined Macros" section.
- Fix a noun/verb disagreement.

4 years agoMFC 356209: Formatting fixes for tables, no content changes.
John Baldwin [Sat, 18 Jan 2020 23:42:57 +0000 (23:42 +0000)]
MFC 356209: Formatting fixes for tables, no content changes.

- Add missing .Pp after the end of some lists so that there is a blank
  line before the subsequent paragraph.
- Use a more typical '-tag' bullet list of the make variable descriptions
  at the end.  This adds separation between bullets and is the formatting
  typically used in manpages for this sort of list.

4 years agoMFC 355866,355871: Update the crypto(4) and crypto(9) manpages.
John Baldwin [Sat, 18 Jan 2020 23:30:42 +0000 (23:30 +0000)]
MFC 355866,355871: Update the crypto(4) and crypto(9) manpages.

355866:
Update the crypto(4) and crypto(9) manpages.

There are probably bits that are still wrong, but this fixes some
things at least:
- Add named arguments to the functions in crypto(9).
- Add missing algorithms.
- Don't mention arguments that don't exist in crypto_register.
- Add CIOGSESSION2.
- Remove CIOCNFSESSION.
- Clarify some stale language that assumed an fd had only one sesson.
- Note that you have to use CRIOGET and add a note in BUGS lamenting
  that one has to use CRIOGET.
- Various other cleanups.

355871:
Bump Dd for changes in r355866.

Sponsored by: Chelsio Communications

4 years agoMFC 355634: Emulate reads of the PCI command register for passthrough devices.
John Baldwin [Sat, 18 Jan 2020 23:26:15 +0000 (23:26 +0000)]
MFC 355634: Emulate reads of the PCI command register for passthrough devices.

VFs return zero for the memory enable bit even if it has been set by a
prior write.  After r348779 this caused the annoying behavior that a
guest OS would unintentionally disable memory decoding on a future
read-modify-write operation on the command register.  Instead, return
the shadow value of the command register for reads.  This ensures that
the guest will only toggle the state of the memory enable bit when it
specifically intends to do so.

Sponsored by: Chelsio Communications

4 years agoMFC r349265: No need for each bsnmpd(1) module to open connection to syslog
Shteryana Shopova [Sat, 18 Jan 2020 10:55:38 +0000 (10:55 +0000)]
MFC r349265: No need for each bsnmpd(1) module to open connection to syslog

bsnmpd(1) main does that early on init and the connection is available
to all loaded modules

PR: 233431 , 221487
Event: Vienna Hackathon 2019

4 years agoMFC r349264: Unbreak snmp_pf(3) after the changes introduced in r338209
Shteryana Shopova [Sat, 18 Jan 2020 10:44:32 +0000 (10:44 +0000)]
MFC r349264: Unbreak snmp_pf(3) after the changes introduced in r338209

PR: 237011
Event: Vienna Hackathon 2019

4 years agoMFC r356574:
Ian Lepore [Fri, 17 Jan 2020 22:24:56 +0000 (22:24 +0000)]
MFC r356574:

Remove scary-looking printf output that happens when you kldload dtrace on
arm.  Replace it with a comment block explaining why the function is empty
on 32-bit arm.

4 years agoMFC r356295:
Ian Lepore [Fri, 17 Jan 2020 22:21:38 +0000 (22:21 +0000)]
MFC r356295:

Add the xdma framework and pl330 dma drivers to arm lint build.

4 years agoMFC 353932: Strip "sf" suffix when generating a target triple.
John Baldwin [Fri, 17 Jan 2020 22:02:35 +0000 (22:02 +0000)]
MFC 353932: Strip "sf" suffix when generating a target triple.

This fixes the target triple used when compiling riscv64sf with clang.

Sponsored by: DARPA

4 years agoMFC 353931: Fix atomic_*cmpset32 on riscv64 with clang.
John Baldwin [Fri, 17 Jan 2020 21:57:05 +0000 (21:57 +0000)]
MFC 353931: Fix atomic_*cmpset32 on riscv64 with clang.

The lr.w instruction used to read the value from memory sign-extends
the value read from memory.  GCC sign-extends the 32-bit comparison
value passed in whereas clang currently does not.  As a result, if the
value being compared has the MSB set, the comparison fails for
matching 32-bit values when compiled with clang.

Use a cast to explicitly sign-extend the unsigned comparison value.
This works with both GCC and clang.

There is commentary in the RISC-V spec that suggests that GCC's
approach is more correct, but it is not clear if the commentary in the
RISC-V spec is binding.

Sponsored by: DARPA

4 years agoMFC r356086, r356278, r356294, r356519, r356521-r356522, r356525-r356526
Ian Lepore [Fri, 17 Jan 2020 17:57:34 +0000 (17:57 +0000)]
MFC r356086, r356278, r356294, r356519, r356521-r356522, r356525-r356526

r356086:
Add comments to a couple i2c device lines in NOTES.

r356278:
Add support for i2c bus mux hardware.

An i2c bus can be divided into segments which can be selectively connected
and disconnected from the main bus. This is usually done to enable using
multiple slave devices having the same address, by isolating the devices
onto separate bus segments, only one of which is connected to the main bus
at once.

There are several types of i2c bus muxes, which break down into two general
categories...

 - Muxes which are themselves i2c slaves. These devices respond to i2c
   commands on their upstream bus, and based on those commands, connect
   various downstream buses to the upstream. In newbus terms, they are both
   a child of an iicbus and the parent of one or more iicbus instances.
 - Muxes which are not i2c devices themselves. Such devices are part of the
   i2c bus electrically, but in newbus terms their parent is some other
   bus. The association with the upstream bus must be established by
   separate metadata (such as FDT data).

In both cases, the mux driver has one or more iicbus child instances
representing the downstream buses. The mux driver implements the iicbus_if
interface, as if it were an iichb host bridge/i2c controller driver. It
services the IO requests sent to it by forwarding them to the iicbus
instance representing the upstream bus, after electrically connecting the
upstream bus to the downstream bus that hosts the i2c slave device which
made the IO request.

The net effect is automatic mux switching which is transparent to slaves on
the downstream buses. They just do i2c IO they way they normally do, and the
bus is electrically connected for the duration of the IO and then idled when
it is complete.

The existing iicbus_if callback() method is enhanced so that the parameter
passed to it can be a struct which contains a device_t for the requesting
bus and slave devices. This change is done by adding a flag that indicates
the extra values are present, and making the flags field the first field of
a new args struct. If the flag is set, the iichb or mux driver can recast
the pointer-to-flags into a pointer-to-struct and access the extra
fields. Thus abi compatibility with older drivers is retained (but a mux
cannot exist on the bus with the older iicbus driver in use.)

A new set of core support routines exists in iicbus.c. This code will help
implement mux drivers for any type of mux hardware by supplying all the
boilerplate code that forwards IO requests upstream. It also has code for
parsing metadata and instantiating the child iicbus instances based on it.

Two new hardware mux drivers are added. The ltc430x driver supports the
LTC4305/4306 mux chips which are controlled via i2c commands. The
iic_gpiomux driver supports any mux hardware which is controlled by
manipulating the state of one or more gpio pins.  Test Plan

Tested locally using a variety of mux'd bus configurations involving both
ltc4305 and a homebrew gpio-controlled mux. Tested configurations included
cascaded muxes (unlikely in the real world, but useful to prove that 'it all
just works' in terms of the automatic switching and upstream forwarding of
IO requests).

r356294:
Explicitly include sys/rman.h instead of relying on getting it via some
other header.

r356519:
Ensure any reserved gpio pins get released if an early exit is taken
from the attach function.

r356521:
Init sc->maxbus to -1, not 0.  It represents the highest array index that
has a non-NULL child bus stored in it, so the "none" value can't be zero
since that's a valid array index.  Also, when adding all possible buses
because there is no specific per-bus config, there's no need to reset
sc->maxbus on each loop iteration, it can be set once after the loop.

r356522:
Change some KASSERT to device_printf + return EINVAL.  There's no need to
bring the whole kernel down due to a configuration error detected when a
module is loaded, it suffices to just not attach the device.

r356525:
Split the code to find and add iicbus children out to its own function.
Move the decision to take an early exit from that function after adding
children based on FDT data into the #ifdef FDT block, so that it doesn't
offend coverity's notion of how the code should be written.  (What's the
point of compilers optimizing away dead code if static analyzers won't
let you use the feature in conjuction with an #ifdef block?)

Reported by: coverity via vangyzen@

r356526:
Remove some trailing whitespace; no functional changes.

4 years agoMFC r354709-r354710, r355069, r355439, r355780, r356273, r356472
Ian Lepore [Fri, 17 Jan 2020 15:55:14 +0000 (15:55 +0000)]
MFC r354709-r354710, r355069, r355439, r355780, r356273, r356472

r354709:
Rewrite arm/stack_machdep.c for EABI; add stack(9) support to arm kernels.

The old stack_machdep.c code was written for the APCS ABI (aka "oldabi").
When we switched to ARM EABI (back in freebsd 10) this file never got
updated, and apparently nobody noticed that until now.

The new implementation uses the same stack unwinder code used by the
arm implemenation of the db_trace stuff.

r354710:
Compile in arm/unwind.c if options STACK is in effect; the new arm stack(9)
code now uses unwind.c.

r355069:
When doing ARM stack unwinding as part of stack_save(9), do not search
loaded modules (pass 0/false for the can_lock arg).  Searching the unwind
info in modules acquires an exclusive sxlock, and the stack(9) functions can
be called in a context where unbounded sleeps are forbidden (such as from
the witness checkorder code).

Just ignoring the existence of modules in stack_save() is not ideal, so I'm
looking for a better solution, but this commit will make it possible to boot
an ARM kernel with WITNESS enabled again, until I get something better.

PR: 242200

r355439:
Declare the global kernel symbols created by ldscript.arm in arm's machdep.h,
and remove a couple scattered local declarations.

Most of these aren't referenced in C code (there are some references in
asm code), and they also aren't documented anywhere.  This helps a bit
with the latter.

r355780:
Rewrite arm kernel stack unwind code to work when unwinding through modules.

The arm kernel stack unwinder has apparently never been able to unwind when
the path of execution leads through a kernel module. There was code that
tried to handle modules by looking for the unwind data in them, but it did
so by trying to find symbols which have never existed in arm kernel
modules. That caused the unwind code to panic, and because part of panic
handling calls into the unwind code, that just created a recursion loop.

Locating the unwind data in a loaded module requires accessing the Elf
section headers to find the SHT_ARM_EXIDX section. For preloaded modules
those headers are present in a metadata blob. For dynamically loaded
modules, the headers are present only while the loading is in progress; the
memory is freed once the module is ready to use. For that reason, there is
new code in kern/link_elf.c, wrapped in #ifdef __arm__, to extract the
unwind info while the headers are loaded. The values are saved into new
fields in the linker_file structure which are also conditional on __arm__.

In arm/unwind.c there is new code to locally cache the per-module info
needed to find the unwind tables. The local cache is crafted for lockless
read access, because the unwind code often needs to run in context where
sleeping is not allowed.  A large comment block describes the local cache
list, so I won't repeat it all here.

r356273:
Since arm/unwind.c s conditionally compiled, only call functions in it
when one of those conditions is true.  Fixes build failure on kernel
configs with no debugging options active.

r356472:
Add #ifdef option-test wrappers around another call to an arm/unwind.c
function which is only compiled-in with certain options.

Why is it always the most trivial part of a big commit that takes 3 tries
to get right?

4 years agoMFC r355884: Add missing "ereport." prefixes of ZFS events.
Alexander Motin [Fri, 17 Jan 2020 04:13:16 +0000 (04:13 +0000)]
MFC r355884: Add missing "ereport." prefixes of ZFS events.

I was unable to find time when those were working.  I think they have been
Broken for at least 5 years or even longer.

4 years agoMFC r356315: Avoid duplicate I/O statistics accounting.
Alexander Motin [Fri, 17 Jan 2020 04:11:17 +0000 (04:11 +0000)]
MFC r356315: Avoid duplicate I/O statistics accounting.

Alike to geom_disk free the provider statistics structure and point GEOM
toward local statistics.  It allows to save some CPU time.

4 years agoMFC r339557:
Kristof Provost [Thu, 16 Jan 2020 21:53:36 +0000 (21:53 +0000)]
MFC r339557:

tcpdump: Log uid on pflog interfaces

If pf logs the user id ('pass out log (user)') have tcpdump also print
this.

Example output:
 00:00:00.000000 rule 0/0(match) [uid 1001]: pass out on vtnet0: (tos 0x0, ttl 64, id 57539, offset 0, flags [none], proto UDP (17), length 55)
    172.16.2.2.18337 > 172.16.2.1.53: [bad udp cksum 0x5c58 -> 0x16e4!] 40222+ A? google.be. (27)

PR: 122773

4 years agoMFC r356704
Vincenzo Maffione [Thu, 16 Jan 2020 20:55:15 +0000 (20:55 +0000)]
MFC r356704

netmap: disable passthrough with no hypervisor support

The netmap passthrough subsystem requires proper support in the
hypervisor. In particular, two PCI device ids (from the Red Hat
PCI vendor id 0x1b36) need to be assigned to the two netmap
virtual devices. We then disable these devices until the ids have
not been assigned, in order to avoid conflicts with other
virtual devices emulated by upstream QEMU.

PR:     241774

4 years agoMFC r356554:
Mark Johnston [Thu, 16 Jan 2020 16:01:03 +0000 (16:01 +0000)]
MFC r356554:
lagg: Further cleanup of the rr_limit option.

4 years agoMFC r356494:
Mark Johnston [Thu, 16 Jan 2020 16:00:28 +0000 (16:00 +0000)]
MFC r356494:

PR: 240992

4 years agoMFC r356281:
Mark Johnston [Thu, 16 Jan 2020 15:33:54 +0000 (15:33 +0000)]
MFC r356281:
Remove set_page_dirty_lock().

4 years agoMFC r356548, r356630:
Konstantin Belousov [Thu, 16 Jan 2020 10:51:32 +0000 (10:51 +0000)]
MFC r356548, r356630:
Resolve relative argv0 for direct exec mode to absolute path for AT_EXECPATH.

4 years agoMFC r356549:
Konstantin Belousov [Thu, 16 Jan 2020 10:25:47 +0000 (10:25 +0000)]
MFC r356549:
rtld: Return error if $ORIGIN for a dlopen-ed library cannot be resolved.

4 years agoMFC r356545:
Hans Petter Selasky [Thu, 16 Jan 2020 08:51:58 +0000 (08:51 +0000)]
MFC r356545:
Fix a XHCI driver issue with Intel's Gemini Lake SOC.

Do not configure any endpoint twice, but instead keep track of which
endpoints are configured on a per device basis, and use an evaluate
endpoint context command instead. When changing the configuration make
sure all endpoints get deconfigured and the configured endpoint mask
is reset.

This fixes an issue where an endpoint might stop working if there is
an error and the endpoint needs to be reconfigured as a part of the
error recovery mechanism in the FreeBSD USB stack.

Tested by: Shichun.Ma@dell.com
Sponsored by: Mellanox Technologies

4 years agoMFC r356551: arp(8): avoid segfaulting due to out-of-bounds memory access
Eugene Grosbein [Thu, 16 Jan 2020 08:11:45 +0000 (08:11 +0000)]
MFC r356551: arp(8): avoid segfaulting due to out-of-bounds memory access

Fix obvious mistake that sometimes results in reading memory
past end of an array.

PR: 242784

4 years agoMFC r356701:
Dimitry Andric [Thu, 16 Jan 2020 07:02:09 +0000 (07:02 +0000)]
MFC r356701:

Merge commit f46ba4f07 from llvm git (by Simon Atanasyan):

  [mips] Use less registers to load address of TargetExternalSymbol

  There is no pattern matched `add hi, (MipsLo texternalsym)`. As a
  result, loading an address of 32-bit symbol requires two registers
  and one more additional instruction:
  ```
  addiu $1, $zero, %lo(foo)
  lui   $2, %hi(foo)
  addu  $25, $2, $1
  ```

  This patch adds the missed pattern and enables generation more
  effective set of instructions:
  ```
  lui   $1, %hi(foo)
  addiu $25, $1, %lo(foo)
  ```

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

  llvm-svn: 370196

Merge commit 59bb3609f from llvm git (by Simon Atanasyan):

  [mips] Fix 64-bit address loading in case of applying 32-bit mask to
  the result

  If result of 64-bit address loading combines with 32-bit mask, LLVM
  tries to optimize the code and remove "redundant" loading of upper
  32-bits of the address. It leads to incorrect code on MIPS64 targets.

  MIPS backend creates the following chain of commands to load 64-bit
  address in the `MipsTargetLowering::getAddrNonPICSym64` method:
  ```
  (add (shl (add (shl (add %highest(sym), %higher(sym)),
      16),
 %hi(sym)),
    16),
       %lo(%sym))
  ```

  If the mask presents, LLVM decides to optimize the chain of commands.
  It really does not make sense to load upper 32-bits because the
  0x0fffffff mask anyway clears them. After removing redundant commands
  we get this chain:
  ```
  (add (shl (%hi(sym), 16), %lo(%sym))
  ```

  There is no patterns matched `(MipsHi (i64 symbol))`. Due a bug in
  `SYM_32` predicate definition, backend incorrectly selects a pattern
  for a 32-bit symbols and uses the `lui` instruction for loading
  `%hi(sym)`.

  As a result we get incorrect set of instructions with unnecessary
  16-bit left shifting:
  ```
  lui     at,0x0
      R_MIPS_HI16     foo
  dsll    at,at,0x10
  daddiu  at,at,0
      R_MIPS_LO16     foo
  ```

  This patch resolves two problems:
  - Fix `SYM_32/SYM_64` predicates to prevent selection of patterns
    dedicated to 32-bit symbols in case of using N64 ABI.
  - Add missed patterns for 64-bit symbols for `%hi/%lo`.

  Fix PR42736.

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

  llvm-svn: 370268

These two commits fix a miscompilation of the kernel for mips64, and
should allow clang to be used as the default compiler for mips64.

Requested by: arichards

4 years agoMFC r356356, r356358, r356422: replace gcclibs' libssp
Kyle Evans [Thu, 16 Jan 2020 03:38:06 +0000 (03:38 +0000)]
MFC r356356, r356358, r356422: replace gcclibs' libssp

r356356:
Provide libssp based on libc

For libssp.so, rebuild stack_protector.c with FORTIFY_SOURCE stubs that just
abort built into it.

For libssp_nonshared.a, steal stack_protector_compat.c from
^/lib/libc/secure and massage it to maintain that __stack_chk_fail_local
is a hidden symbol.

libssp is now built unconditionally regardless of {WITH,WITHOUT}_SSP in the
build environment, and the gcclibs version has been disconnected from the
build in favor of this one.

r356358:
libssp: fix FORTIFY_SOURCE stub declarations

The LSB 4.1 that I referenced omitted the varargs, and I failed to catch it.
The __vsnprintf_chk error was from just downright misreading the page. GCC6
caught all of these, but I had only tested GCC4.2.

r356422:
Update libssp paths in various Makefile.depend* files

I've been advised that the model that uses these are fairly resilient, but
we do know the proper path to use (or remove, in the case of ^/targets/...),
so go ahead and update them to reflect that.

4 years agoMFC r356688, r356694: tap(4) manpage improvements
Kyle Evans [Thu, 16 Jan 2020 03:16:08 +0000 (03:16 +0000)]
MFC r356688, r356694: tap(4) manpage improvements

r356688:
Install tap(4) manpage as vmnet(4) as well

If one comes across a vmnet interface, this is a useful pointer to have
towards what it actually is if they're otherwise unfamiliar.

r356694:
tap(4): also note that we drop configured addresses

This provides a specific pointer for users of tap(4) to understand why their
interfaces are losing their addresses, and specifically how to workaround
this if they need different behavior.

This manpage received a .Dd bump earlier today in r35688, so no bump occurs
this time.

4 years agoMFC r356649: regulator: small enhancements to regulator_shutdown
Kyle Evans [Thu, 16 Jan 2020 03:14:01 +0000 (03:14 +0000)]
MFC r356649: regulator: small enhancements to regulator_shutdown

Highlights:

- Exit early if we're not disabling unused regulators; there's no need to
  take the regulator topology lock and re-evaluate this every iteration, as
  it's not going to change.
- Don't emit a notice that we're shutting down a regulator if it's not
  enabled, to reduce noise.
- Mention the outcome of the shutdown, to aide debugging and easily let
  developer/user collect list of regulators we actually shutdown to
  determine problematic one.

4 years agoMFC r356538: stand/fdt: Scale blob size better as overlays apply
Kyle Evans [Thu, 16 Jan 2020 03:11:25 +0000 (03:11 +0000)]
MFC r356538: stand/fdt: Scale blob size better as overlays apply

Currently, our overlay blob will grow to include the size of the complete
overlay blob we're applying. This doesn't scale very well with a lot of
overlays- they tend to include a lot of overhead, and they will generally
only add a fraction of their total size to the blob they're being applied
to.

To combat this, pack the blob as we apply new overlays and keep track of how
many overlays we've applied. Only ubldr has any fixups to be applied after
overlays, so we only need to re-pad the blob in ubldr. Presumably the
allocation won't fail since we just did a lot worse in trying to apply
overlays and succeeded.

I have no intention of removing the padding in make_dtb.sh. There might be
an argument to be had over whether it should be configurable, since ubldr
*is* the only loader that actually has fixups to be applied and we can do
this at runtime, but I'm not too concerned about this.

This diff has been sitting in Phabricator for a year and a half, but I've
decided to flush it as it does make sure that we're scaling the blob
appropriately and leave room at the end for fixups in case of some freak
circumstance where applying overlays leaves us with a blob of insufficient
size.

4 years agoMFC r356685, r356686:
Glen Barber [Thu, 16 Jan 2020 01:13:32 +0000 (01:13 +0000)]
MFC r356685, r356686:
 r356685:
  Ensure the TYPE, BRANCH, and REVISION variables are set in
  cloudware targets when OSRELEASE is overridden. [1]

 r356686:
  Fix a typo.

PR: 243287 [1]
Sponsored by: Rubicon Communications, LLC (netgate.com)

4 years agoMFC r356569:
Mark Johnston [Thu, 16 Jan 2020 00:26:53 +0000 (00:26 +0000)]
MFC r356569:
libc: Fix a few bugs in the xlocale collation code.

PR: 243195

4 years agoMFC r345681: Skip test if feature security_capabilities is not available
Ed Maste [Wed, 15 Jan 2020 21:05:43 +0000 (21:05 +0000)]
MFC r345681: Skip test if feature security_capabilities is not available

PR: 236863
Sponsored by: The FreeBSD Foundation

4 years agoMFC r355258: Bhyve AMD IOMMU log the last timeout command.
Anish Gupta [Wed, 15 Jan 2020 02:31:03 +0000 (02:31 +0000)]
MFC r355258: Bhyve AMD IOMMU log the last timeout command.
Differential Revision: https://reviews.freebsd.org/D22566

4 years agoMFC r356628: Require FAT to occupy at least one sector.
Xin LI [Tue, 14 Jan 2020 06:28:07 +0000 (06:28 +0000)]
MFC r356628: Require FAT to occupy at least one sector.

4 years agoMFC r356445:
Mark Johnston [Tue, 14 Jan 2020 02:44:24 +0000 (02:44 +0000)]
MFC r356445:
Decrease logging severity when adding a device or reading config table.

PR: 243056