]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoMFC r346120:
Edward Tomasz Napierala [Tue, 14 May 2019 20:41:24 +0000 (20:41 +0000)]
MFC r346120:

Use shared vnode locks for the ELF interpreter.

Sponsored by: DARPA, AFRL

5 years agoMFC r346076:
Edward Tomasz Napierala [Tue, 14 May 2019 20:31:06 +0000 (20:31 +0000)]
MFC r346076:

Improve vnode lock assertions.

Sponsored by: DARPA, AFRL

5 years agoMFC r346053:
Edward Tomasz Napierala [Tue, 14 May 2019 20:29:12 +0000 (20:29 +0000)]
MFC r346053:

Factor out section loading into a separate function.

Sponsored by: DARPA, AFRL

5 years agoMFC r346030:
Edward Tomasz Napierala [Tue, 14 May 2019 20:27:45 +0000 (20:27 +0000)]
MFC r346030:

Refactor ELF interpreter loading into a separate function.

Sponsored by: DARPA, AFRL

5 years agoMFC r345661:
Edward Tomasz Napierala [Tue, 14 May 2019 20:26:05 +0000 (20:26 +0000)]
MFC r345661:

Factor out retrieving the interpreter path from the main ELF
loader routine.

MFC r345734 by kib:

Fix branding after r345661.

In particular, elf32 FreeBSD binaries were not executed on LP64 hosts.
The interp_name_len value should account for the nul terminator.  This
is needed for strncmp()s in brand checking code to work.

Sponsored by: DARPA, AFRL

5 years agoMFC r345547:
Edward Tomasz Napierala [Tue, 14 May 2019 20:19:29 +0000 (20:19 +0000)]
MFC r345547:

Factor out resource limit enforcement code in the ELF loader.
It makes the code slightly easier to follow, and might make
it easier to fix the resouce accounting to also account for
the interpreter.

The PROC_UNLOCK() is moved earlier - I don't see anything
it should protect; the lim_max() is a wrapper around lim_rlimit(),
and that, differently from lim_rlimit_proc(), doesn't require
the proc lock to be held.

Sponsored by: DARPA, AFRL

5 years agoMFC r345448:
Edward Tomasz Napierala [Tue, 14 May 2019 20:03:19 +0000 (20:03 +0000)]
MFC r345448:

Remove trunc_page_ps() and round_page_ps() macros.  This completes
the undoing of r100384.

Sponsored by: DARPA, AFRL

5 years agoMFC r344705:
Edward Tomasz Napierala [Tue, 14 May 2019 19:52:18 +0000 (19:52 +0000)]
MFC r344705:

Remove sv_pagesize, originally introduced with r100384.

In all of the architectures we have today, we always use PAGE_SIZE.
While in theory one could define different things, none of the
current architectures do, even the ones that have transitioned from
32-bit to 64-bit like i386 and arm. Some ancient mips binaries on
other systems used 8k instead of 4k, but we don't support running
those and likely never will due to their age and obscurity.

Differently from the original commit, the merge leaves the struct
member in place to preserve the ABI.

Sponsored by: DARPA, AFRL

5 years agoMFC r347566:
Konstantin Belousov [Tue, 14 May 2019 17:04:00 +0000 (17:04 +0000)]
MFC r347566:
Mitigations for Microarchitectural Data Sampling.

Reference: https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00233.html
Security: CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
Security: FreeBSD-SA-19:07.mds
Reviewed by: jhb
Tested by: emaste, lwhsu
Approved by: so (gtetlow)

5 years agoMFC r346028:
Ganbold Tsagaankhuu [Tue, 14 May 2019 03:08:37 +0000 (03:08 +0000)]
MFC r346028:
Fix URE_WDT6_SET_MODE value in the register definition.
Both linux and u-boot sources for RTL8152 driver has this value.
RTL8152 USB ethernet is used in NanoPI R1 board as second ethernet.
This fixes RTL8152 USB ethernet not detected problem after
reboot.

5 years agoMFC r347241 (partial), r347392, r347429: ifconfig(8) ifname <-> kld mapping
Kyle Evans [Tue, 14 May 2019 02:00:12 +0000 (02:00 +0000)]
MFC r347241 (partial), r347392, r347429: ifconfig(8) ifname <-> kld mapping

MFC r347241 (partial): Initial mechanism for mapping ifname <-> kld

if_tun/if_tap mappings have been removed and the vmnet mapping has been
updated to the if_tap module.

MFC r347392: ifconfig(8): Partial revert of r347241

r347241 introduced an ifname <-> kld mapping table, mostly so tun/tap/vmnet
can autoload the correct module on use. It also inadvertently made bogus
some previously valid uses of sizeof().

Revert back to ifkind on the stack for simplicity sake. This reduces the
diff from the previous version of ifmaybeload for easiser auditing.

MFC r347429: ifconfig(8): Add kld mappings for ipsec/enc

Additionally, providing mappings makes the comparison for already loaded
modules a little more strict. This should have been done at initial
introduction, but there was no real reason- however, it proves necessary for
enc which has a standard enc -> if_enc mapping but there also exists an
'enc' module that's actually CAM. The mapping lets us unambiguously
determine the correct module.

5 years agoMFC r347227:
Mark Johnston [Tue, 14 May 2019 00:34:08 +0000 (00:34 +0000)]
MFC r347227:
Simplify the test against maxproc in fork1().

5 years agoMFC r346708:
Stephen Hurd [Mon, 13 May 2019 18:48:08 +0000 (18:48 +0000)]
MFC r346708:

iflib: Better control over queue core assignment

By default, cores are now assigned to queues in a sequential
manner rather than all NICs starting at the first core. On a four-core
system with two NICs each using two queue pairs, the nic:queue -> core
mapping has changed from this:

0:0 -> 0, 0:1 -> 1
1:0 -> 0, 1:1 -> 1

To this:

0:0 -> 0, 0:1 -> 1
1:0 -> 2, 1:1 -> 3

Additionally, a device can now be configured to use separate cores for TX
and RX queues.

Two new tunables have been added, dev.X.Y.iflib.separate_txrx and
dev.X.Y.iflib.core_offset. If core_offset is set, the NIC is not part
of the auto-assigned sequence.

Reviewed by: marius
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D20029

5 years agoMFC r347031: iflib: remove assertion that isc_capabilities is nonzero
Ed Maste [Mon, 13 May 2019 14:52:50 +0000 (14:52 +0000)]
MFC r347031: iflib: remove assertion that isc_capabilities is nonzero

It's atypical, but not invalid, for a driver to pass no capabilities.

Submitted by: Gerald Aryeetey <aryeeteygerald_rogers.com>
Sponsored by: The FreeBSD Foundation

5 years agoMFC r347186: Reformat arm64 linux syscalls.master per current style
Ed Maste [Mon, 13 May 2019 14:50:51 +0000 (14:50 +0000)]
MFC r347186: Reformat arm64 linux syscalls.master per current style

5 years agoMFC r347160: Decode some more ATA commands found in ACS-4.
Alexander Motin [Mon, 13 May 2019 13:29:51 +0000 (13:29 +0000)]
MFC r347160: Decode some more ATA commands found in ACS-4.

5 years agoMFC r347158: Decode Deallocate Logical Block Features.
Alexander Motin [Mon, 13 May 2019 13:28:42 +0000 (13:28 +0000)]
MFC r347158: Decode Deallocate Logical Block Features.

5 years agoMFC r346965:
Dmitry Chagin [Mon, 13 May 2019 10:43:18 +0000 (10:43 +0000)]
MFC r346965:

Follow the FreeBSD and implement PDEATH_SIG prctl ops in the Linuxulator.
It was first introduced in r163734 and missied by me in r283383.

5 years agoMFC r347178:
Andrey V. Elsukov [Mon, 13 May 2019 08:29:28 +0000 (08:29 +0000)]
MFC r347178:
  Add ipsec.ko to required_modules for rc.d/ipsec script.

  Thus it can be automatically loaded if ipsec_enable="YES" and option IPSEC
  is not in the kernel config.

5 years agoMFC r346885:
Andrey V. Elsukov [Mon, 13 May 2019 08:26:21 +0000 (08:26 +0000)]
MFC r346885:
  Handle HAVE_PROTO flag and print "proto" keyword for O_IP4 and O_IP6
  opcodes when it is needed.
  This should fix the problem, when printed by `ipfw show` rule can not
  be added due to missing "proto" keyword.

5 years agoMFC r346073:
Andriy Voskoboinyk [Sun, 12 May 2019 12:30:45 +0000 (12:30 +0000)]
MFC r346073:
urtw(4), otus(4), iwi(4): allow to set non-default MAC address via ifconfig(8)

Was tested with Netgear WG111 v3 (RTL8187B, urtw(4)), STA mode.

5 years agoMFC r347150, r347180:
Konstantin Belousov [Sun, 12 May 2019 07:53:24 +0000 (07:53 +0000)]
MFC r347150, r347180:
Do not collapse objects with OBJ_NOSPLIT backing swap or default object.

5 years agoMFC r345829, r345831
Justin Hibbits [Sat, 11 May 2019 18:31:05 +0000 (18:31 +0000)]
MFC r345829, r345831

r345829:
powerpc: Apply r178139 from sparc64 to powerpc's fpu_sqrt

This fix was committed less than 2 months after the code was forked into the
powerpc kernel.  Though powerpc doesn't use quad-precision floating point,
or need it for emulation, the changes do look like correctness fixes
overall.

This was found while trying to get fsqrt emulation working on e5500, which
does have a real FPU, but lacks the fsqrt instruction.  This is not the
complete fix, the rest is to be committed separately.

r345831:
powerpc: Allow emulating optional FPU instructions on CPUs with an FPU

The e5500 has an FPU, but lacks the optional fsqrt instruction.  This
instruction gets emulated in the kernel, but the emulation uses stale data,
from the last switch out, and does not return the result of the operation
immediately.  Fix both of these conditions by saving and restoring the FPRs
around the emulation point.

5 years agoMFC r345435:
Justin Hibbits [Sat, 11 May 2019 18:25:15 +0000 (18:25 +0000)]
MFC r345435:

powernv: Add Hypervisor Maintenance Interrupt handler

Attempting to build www/firefox on POWER9 resulted in a HMI exception being
thrown, a fatal trap currently.  This is typically caused by timer facility
errors, but examination of the Hypervisor Maintenance Exception Register
(HMER) yielded only that an exception had recovered, with no information of
the actual exception cause.

When an HMI occurs, OPAL_HANDLE_HMI or OPAL_HANDLE_HMI2 must be called to
handle the exception at the firmware level.  If the exception is handled, we
can continue.

This adds only the preliminary handler, enough to prevent package building
from panicking.  An enhancement in the future is to use the flags returned
by OPAL_HANDLE_HMI2 to print more useful error messages, and log maintenance
events.

5 years agoMFC r347243:
Dimitry Andric [Sat, 11 May 2019 09:56:59 +0000 (09:56 +0000)]
MFC r347243:

Pull in r360099 from upstream llvm trunk (by Eli Friedman):

  [ARM] Glue register copies to tail calls.

  This generally follows what other targets do. I don't completely
  understand why the special case for tail calls existed in the first
  place; even when the code was committed in r105413, call lowering
  didn't work in the way described in the comments.

  Stack protector lowering breaks if the register copies are not glued
  to a tail call: we have to insert the stack protector check before
  the tail call, and we choose the location based on the assumption
  that all physical register dependencies of a tail call are adjacent
  to the tail call. (See FindSplitPointForStackProtector.) This is sort
  of fragile, but I don't see any reason to break that assumption.

  I'm guessing nobody has seen this before just because it's hard to
  convince the scheduler to actually schedule the code in a way that
  breaks; even without the glue, the only computation that could
  actually be scheduled after the register copies is the computation of
  the call address, and the scheduler usually prefers to schedule that
  before the copies anyway.

  Fixes https://bugs.llvm.org/show_bug.cgi?id=41417

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

This should fix several instances of "Bad machine code: Using an
undefined physical register", when compiling ports such as
multimedia/vlc, audio/alsa-lib and devel/avro-c for armv6, with
-fstack-protector-strong.

Reported by: jbeich
PR: 237074, 237783, 237784

5 years agoMFC r347133:
Konstantin Belousov [Sat, 11 May 2019 09:12:13 +0000 (09:12 +0000)]
MFC r347133:
arm64: Properly restore PAN when done with userspace access in casueword.

5 years agoMFC of 347064, 347066, and 347130
Kirk McKusick [Fri, 10 May 2019 23:45:16 +0000 (23:45 +0000)]
MFC of 347064, 347066, and 347130

Avoid leaking kernel stack when creating directory names.

5 years agoMFC r347234:
Cy Schubert [Fri, 10 May 2019 01:02:07 +0000 (01:02 +0000)]
MFC r347234:

Improve the legibility of the login.access.5 man page by separating
each argument into its own paragraph.

5 years agoMFC r346578:
Enji Cooper [Thu, 9 May 2019 17:02:47 +0000 (17:02 +0000)]
MFC r346578:

Build libclang_rt/profile on all clang-supported architectures

There's no reason why a special case needs to be added specifically for amd64,
arm, and i386, as the code is written in machine architecture agnostic C/C++.

This will make it possible for all supporting clang architectures to produce
runtime coverage with `--coverage`.

5 years agoMFC r347019:
Konstantin Belousov [Thu, 9 May 2019 09:49:07 +0000 (09:49 +0000)]
MFC r347019:
Cleanup for rtld_malloc.c.

PR: 237577

5 years agoMFC r346594: Add ATA power mode support to camcontrol
Steven Hartland [Thu, 9 May 2019 08:35:50 +0000 (08:35 +0000)]
MFC r346594: Add ATA power mode support to camcontrol

Sponsored by: Multiplay

5 years agoMFC r347198: Drop periph lock around cam_periph_unmapmem().
Alexander Motin [Thu, 9 May 2019 04:16:06 +0000 (04:16 +0000)]
MFC r347198: Drop periph lock around cam_periph_unmapmem().

Since r345656 it may call copyout(), that may sleep.

5 years agoMFC r346602, r346670-r346671, r347183: tun/tap race fixes
Kyle Evans [Thu, 9 May 2019 03:51:34 +0000 (03:51 +0000)]
MFC r346602, r346670-r346671, r347183: tun/tap race fixes

r346602:
tun(4): Defer clearing TUN_OPEN until much later

tun destruction will not continue until TUN_OPEN is cleared. There are brief
moments in tunclose where the mutex is dropped and we've already cleared
TUN_OPEN, so tun_destroy would be able to proceed while we're in the middle
of cleaning up the tun still. tun_destroy should be blocked until these
parts (address/route purges, mostly) are complete.

r346670:
tun/tap: close race between destroy/ioctl handler

It seems that there should be a better way to handle this, but this seems to
be the more common approach and it should likely get replaced in all of the
places it happens... Basically, thread 1 is in the process of destroying the
tun/tap while thread 2 is executing one of the ioctls that requires the
tun/tap mutex and the mutex is destroyed before the ioctl handler can
acquire it.

This is only one of the races described/found in PR 233955.

r346671:
tun(4): Don't allow open of open or dying devices

Previously, a pid check was used to prevent open of the tun(4); this works,
but may not make the most sense as we don't prevent the owner process from
opening the tun device multiple times.

The potential race described near tun_pid should not be an issue: if a
tun(4) is to be handed off, its fd has to have been sent via control message
or some other mechanism that duplicates the fd to the receiving process so
that it may set the pid. Otherwise, the pid gets cleared when the original
process closes it and you have no effective handoff mechanism.

Close up another potential issue with handing a tun(4) off by not clobbering
state if the closer isn't the controller anymore. If we want some state to
be cleared, we should do that a little more surgically.

Additionally, nothing prevents a dying tun(4) from being "reopened" in the
middle of tun_destroy as soon as the mutex is unlocked, quickly leading to a
bad time. Return EBUSY if we're marked for destruction, as well, and the
consumer will need to deal with it. The associated character device will be
destroyed in short order.

r347183:
geom: fix initialization order

There's a race between the initialization of devsoftc.mtx (by devinit)
and the creation of the geom worker thread g_run_events, which calls
devctl_queue_data_f. Both of those are initialized at SI_SUB_DRIVERS
and SI_ORDER_FIRST, which means the geom worked thread can be created
before the mutex has been initialized, leading to the panic below:

 wpanic: mtx_lock() of spin mutex (null) @ /usr/home/osstest/build.135317.build-amd64-freebsd/freebsd/sys/kern/subr_bus.c:620
 cpuid = 3
 time = 1
 KDB: stack backtrace:
 db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe003b968710
 vpanic() at vpanic+0x19d/frame 0xfffffe003b968760
 panic() at panic+0x43/frame 0xfffffe003b9687c0
 __mtx_lock_flags() at __mtx_lock_flags+0x145/frame 0xfffffe003b968810
 devctl_queue_data_f() at devctl_queue_data_f+0x6a/frame 0xfffffe003b968840
 g_dev_taste() at g_dev_taste+0x463/frame 0xfffffe003b968a00
 g_load_class() at g_load_class+0x1bc/frame 0xfffffe003b968a30
 g_run_events() at g_run_events+0x197/frame 0xfffffe003b968a70
 fork_exit() at fork_exit+0x84/frame 0xfffffe003b968ab0
 fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe003b968ab0
 --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
 KDB: enter: panic
 [ thread pid 13 tid 100029 ]
 Stopped at      kdb_enter+0x3b: movq    $0,kdb_why

Fix this by initializing geom at SI_ORDER_SECOND instead of
SI_ORDER_FIRST.

PR: 233955

5 years agoMFC r346960:
Mark Johnston [Wed, 8 May 2019 16:04:33 +0000 (16:04 +0000)]
MFC r346960:
Retry upon NET_RT_IFLIST sysctl failure.

PR: 195191

5 years agoMFC r346888:
Mark Johnston [Wed, 8 May 2019 16:01:59 +0000 (16:01 +0000)]
MFC r346888:
Stop checking TD_IDLETHREAD() in buffer cache routines.

5 years agoMFC r347139:
Cy Schubert [Wed, 8 May 2019 15:48:55 +0000 (15:48 +0000)]
MFC r347139:

MFV r347136: Update sqlite3-3.27.2 (3270200) --> sqlite3-3.28.0 (3280000)

Security: CVE-2019-9937, CVE-2019-9936

5 years agoMFC r346990:
Konstantin Belousov [Wed, 8 May 2019 15:44:53 +0000 (15:44 +0000)]
MFC r346990:
Fix another race between vm_map_protect() and vm_map_wire().

5 years agoMFC r346851:
Konstantin Belousov [Wed, 8 May 2019 15:43:22 +0000 (15:43 +0000)]
MFC r346851:
Remove witness warning, same as r346351 for busdma_dmar.

bounce_bus_dmamap_create() does not sleep either.

5 years agoMFC r346976: Respect quotes and escapes when splitting exports fields.
Alexander Motin [Wed, 8 May 2019 15:25:07 +0000 (15:25 +0000)]
MFC r346976: Respect quotes and escapes when splitting exports fields.

Without this r293305 was still unable to handle names with spaces.

5 years agoMFC r346898: ip multicast debug: fix strings vs defines
Alexander Motin [Wed, 8 May 2019 15:23:45 +0000 (15:23 +0000)]
MFC r346898: ip multicast debug: fix strings vs defines

Turning on multicast debug made multicast failure worse
because the strings and #define values no longer matched
up.  Fix them, and make sure they stay matched-up.

5 years agoMFC r346511: Report DIF protection type the disk is formatted with.
Alexander Motin [Wed, 8 May 2019 15:20:16 +0000 (15:20 +0000)]
MFC r346511: Report DIF protection type the disk is formatted with.

Some disks formatted with protection report errors if written without
protection used.  This should help to diagnose the problem.

5 years agoMFC r346491: Polish SCSI sense data validity checks.
Alexander Motin [Wed, 8 May 2019 15:17:04 +0000 (15:17 +0000)]
MFC r346491: Polish SCSI sense data validity checks.

According to specs and common sense, all sense data reported in descriptor
format should be valid.  But practice shows different, some devices return
descriptors with invalid data, resulting in error messages looking worse.

Decouple block/stream commands sense data and information field printing.
Looking on present specs, there are much more cases when those fields are
not related, and incomplete old code was not printing valid sense data and
leaving empty lines for invalid.

5 years agoMFC r347056:
Glen Barber [Wed, 8 May 2019 15:16:45 +0000 (15:16 +0000)]
MFC r347056:
 Increase the default size of the GCE disk image from 3GB to 20GB,
 as 3GB is too small as discovered in last week's snapshot builds.

Sponsored by: The FreeBSD Foundation

5 years agoMFC r346884:
Andrey V. Elsukov [Wed, 8 May 2019 15:13:59 +0000 (15:13 +0000)]
MFC r346884:
  Add IPv6 support for O_IPLEN opcode.

  Obtained from: Yandex LLC

5 years agoMFC r345576: Merge r345574 from vendor-crypto:
Ed Maste [Tue, 7 May 2019 19:48:39 +0000 (19:48 +0000)]
MFC r345576: Merge r345574 from vendor-crypto:

upstream: when checking that filenames sent by the server side

match what the client requested, be prepared to handle shell-style brace
alternations, e.g. "{foo,bar}".

"looks good to me" millert@ + in snaps for the last week courtesy
deraadt@

OpenBSD-Commit-ID: 3b1ce7639b0b25b2248e3a30f561a548f6815f3e

PR: 234965
Discussed with: des
Obtained from: OpenSSH-portable 3d896c157c722bc47adca51a58dca859225b5874

5 years agoMFC of 345758
Kirk McKusick [Mon, 6 May 2019 19:13:04 +0000 (19:13 +0000)]
MFC of 345758

Properly flush outstanding I/Os when forcibly deleteing a memory disk device.

Sponsored by: Netflix

5 years agoMFC r347142:
Toomas Soome [Mon, 6 May 2019 08:32:49 +0000 (08:32 +0000)]
MFC r347142:

loader: validate sectorsize argument in disk_open()

The bug and patch is reported against 11.2, but it is good idea to have
the check in place for all versions.

PR: 236585
Submitted by: john@feith.com
Reported by: john@feith.com

5 years agoMFC r344871:
Justin Hibbits [Mon, 6 May 2019 03:39:25 +0000 (03:39 +0000)]
MFC r344871:

powerpc: Save stack pointer in savectx

This allows 'show acttrace' to show backtrace on processes currently running
on CPUs.

Reported by: Brandon Bergren

5 years agoMFC r344613:
Justin Hibbits [Mon, 6 May 2019 03:35:44 +0000 (03:35 +0000)]
MFC r344613:

powerpc/mpc85xx: Synchronize timebase the platform correct way

Summary:
To safely synchronize timebase we need to disable the timebase on all
cores, set timebase, and resynchronize.  This adds two new devices, mutually
exclusive, which attach on the SoC simplebus, to freeze and unfreeze the
timebase.  The devices are singletons, and platform-specific, so no reason
to make them optional and in separate files.

This was found to be necessary for top(1) to work correctly on an AmigaOne
X5000 (P5020 SoC).  It also fixes bufdaemon and bufspacedaemon hangs at
shutdown.

5 years agoMFC r340262,344730
Justin Hibbits [Mon, 6 May 2019 03:31:27 +0000 (03:31 +0000)]
MFC r340262,344730

r340262: powerpc64: Fix "show spr" command on ELFv2 kernels
r344730: powerpc: fix 'show spr' for ELFv1 powerpc64

5 years agoMFC r339559,344083,344202,344203,344204
Justin Hibbits [Mon, 6 May 2019 03:15:07 +0000 (03:15 +0000)]
MFC r339559,344083,344202,344203,344204

Bulk merge of Book-E pmap changes

r339559: powerpc/booke: Turn tlb*_print_tlbentries() into 'show tlb*' DDB
commands
r344083: powerpc/booke: Use the 'tlbilx' instruction on newer cores
r344202,344204: powerpc/booke: Use DMAP where possible for page copy and zeroing
r344203: powerpc/booke: depessimize MAS register updates

5 years agoMFC: r346856
Rick Macklem [Mon, 6 May 2019 03:06:22 +0000 (03:06 +0000)]
MFC: r346856
Add #ifdef INET6 around declaration of nbuf.

It was reported that without #ifdef INET6 around the declaration of "nbuf",
a build would report an unused variable. For some reason, I didn't see that
warning when I did a build, but it seems reasonable to add these #ifdef INET6's.

5 years agoMFC r347027-r347028: libbe(3) mountpoint handling fixes
Kyle Evans [Mon, 6 May 2019 02:10:04 +0000 (02:10 +0000)]
MFC r347027-r347028: libbe(3) mountpoint handling fixes

r347027:
libbe(3): Properly mount BEs with mountpoint=none

Instead of pretending to successfully mount them while not actually
mounting anything, we'll now actually mount them *and* claim we mounted them
successfully.

Reported by: ler

r347028:
libbe: set mountpoint=none in be_import

If we're going to set a mountpoint at all, mountpoint=none makes more sense
than mountpoint=/.

5 years agoMFC r347021: fdt: Fix installation of aarch64 dtb
Kyle Evans [Mon, 6 May 2019 02:08:52 +0000 (02:08 +0000)]
MFC r347021: fdt: Fix installation of aarch64 dtb

r345519 rewrote parts of how we build .dtb, but mistakenly dropped the
vendor dir for aarch64.  Simply drop the :T for building ${DTB} in the
aarch64 case- it'll get applied at install-time as-needed, with :H:T for
determining the vendor dir.

5 years agoMFC r346854:
Michael Tuexen [Sat, 4 May 2019 13:58:45 +0000 (13:58 +0000)]
MFC r346854:
Some test scripts use ncat --sctp --listen port to run an SCTP discard
server in the background. However, when running in the background,
stdin is closed and ncat initiates a graceful shutdown of the SCTP
association. This is not expected by the client. Therefore, the
ncat-based discard server is replaced by a perl-based one.

In addition, to remove the dependency from ncat, which needs to be
installed via the nmap port, also the code testing for a free SCTP port
is changed to use the perl-based client.

Finally, remove some debug output from the report generated.

Reviewed by: lwhsu@
Differential Revision: https://reviews.freebsd.org/D20086

5 years agoMFC r346400:
Michael Tuexen [Sat, 4 May 2019 13:55:51 +0000 (13:55 +0000)]
MFC r346400:
Improve input validation for the socket option IPV6_CHECKSUM.

When using the IPPROTO_IPV6 level socket option IPV6_CHECKSUM on a raw
IPv6 socket, ensure that the value is either -1 or a non-negative even
number.

MFC r346401:
Avoid a buffer overwrite in rip6_output() when computing the checksum
as requested by the user via the IPPROTO_IPV6 level socket option
IPV6_CHECKSUM. The check if there are enough bytes in the packet to
store the checksum at the requested offset was wrong by 1.

MFC r346402:
When a checksum has to be computed for a received IPv6 packet because it
is requested by the application using the IPPROTO_IPV6 level socket option
IPV6_CHECKSUM on a raw socket, ensure that the packet contains enough
bytes to contain the checksum at the specified offset.

MFC r346406:
When an IPv6 packet is received for a raw socket which has the
IPPROTO_IPV6 level socket option IPV6_CHECKSUM enabled and the
checksum check fails, drop the message. Without this fix, an
ICMP6 message was sent indicating a parameter problem.

Thanks to bz@ for suggesting a way to simplify this fix.

Reviewed by: bz@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D19966
Differential Revision:  https://reviews.freebsd.org/D19967
Differential Revision:  https://reviews.freebsd.org/D19968
Differential Revision:  https://reviews.freebsd.org/D19969

5 years agoMFC: r346715: Acpi MADT table correction for VM_MAXCPU > 21
Rodney W. Grimes [Sat, 4 May 2019 13:43:48 +0000 (13:43 +0000)]
MFC: r346715: Acpi MADT table correction for VM_MAXCPU > 21

The bhyve acpi MADT table was given a static space of 256 (0x100) bytes,
this is enough space to allow VM_MAXCPU to be 21, this patch changes that
so VM_MAXCPU can be of arbitrary value and not overflow the space by
actually calculating the space needed for the table.

PR: 212782
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Approved by: bde (mentor, implicit), jhb (maintainer)
Differential Revision: https://reviews.freebsd.org/D18815

5 years agoMFC r346197:
Michael Tuexen [Sat, 4 May 2019 13:05:21 +0000 (13:05 +0000)]
MFC r346197:
When sending a routing message, don't allow the user to set the
RTF_RNH_LOCKED flag in rtm_flags, since this flag is used only
internally.

Reviewed by: ae@
Differential Revision: https://reviews.freebsd.org/D19898

5 years agoMFC r346182:
Michael Tuexen [Sat, 4 May 2019 13:02:46 +0000 (13:02 +0000)]
MFC r346182:
When sending IPv4 packets on a SOCK_RAW socket using the IP_HDRINCL option,
ensure that the ip_hl field is valid. Furthermore, ensure that the complete
IPv4 header is contained in the first mbuf. Finally, move the length checks
before relying on them when accessing fields of the IPv4 header.

Reported by: jtl@
Reviewed by: jtl@
Differential Revision: https://reviews.freebsd.org/D19181

5 years agoMFC r346134:
Michael Tuexen [Sat, 4 May 2019 13:00:39 +0000 (13:00 +0000)]
MFC r346134:
Fix an SCTP related locking issue. Don't report that the TCB_SEND_LOCK
is owned, when it is not.

This issue was found by running syzkaller.

5 years agoMFC r345525:
Michael Tuexen [Sat, 4 May 2019 12:57:55 +0000 (12:57 +0000)]
MFC r345525:
Fix a double free of an SCTP association in an error path.
This is joint work with rrs@. The issue was found by running
syzkaller.

5 years agoMFC r345505:
Michael Tuexen [Sat, 4 May 2019 12:56:09 +0000 (12:56 +0000)]
MFC r345505:
Initialize scheduler specific data for the FCFS scheduler.
This is joint work with rrs@. The issue was reported by using
syzkaller.

5 years agoMFC r345504:
Michael Tuexen [Sat, 4 May 2019 12:54:24 +0000 (12:54 +0000)]
MFC r345504:
Improve locking when tearing down an SCTP association.
This is joint work with rrs@ and the issue was found by
syzkaller.

5 years agoMFC r345494:
Michael Tuexen [Sat, 4 May 2019 12:52:24 +0000 (12:52 +0000)]
MFC r345494:
Fix the handling of fragmented unordered messages when using DATA chunks
and FORWARD-TSN.

This bug was reported in https://github.com/sctplab/usrsctp/issues/286
for the userland stack.

This is joint work with rrs@.

5 years agoMFC r345465:
Michael Tuexen [Sat, 4 May 2019 12:49:55 +0000 (12:49 +0000)]
MFC r345465:
Fix a signed/unsigned bug when receiving SCTP messages.
This is joint work with rrs@.

MFC r345466:
Fox more signed unsigned issues. This time on the send path.
This is joint work with rrs@ and was found by running syzkaller.

MFC r345467:
Fix build issue for the userland stack.
Joint work with rrs@.

5 years agoMerge r346846 from head to stable/12:
Robert Watson [Sat, 4 May 2019 12:35:12 +0000 (12:35 +0000)]
Merge r346846 from head to stable/12:

  Update the audit(4) man page to talk about dtaudit(4), and also add a
  dtaudit(4) cross reference to auditpipe(4).

  Sponsored by: DARPA, AFRL

5 years agoMerge r346814 from head to stable/12:
Robert Watson [Sat, 4 May 2019 12:34:11 +0000 (12:34 +0000)]
Merge r346814 from head to stable/12:

  Add a man page for the DTrace Audit Provider, since we are now growing a
  set of provider man pages.

  Sponsored by: DARPA, AFRL

5 years agoMFC r345461:
Michael Tuexen [Sat, 4 May 2019 12:07:00 +0000 (12:07 +0000)]
MFC r345461:
Limit the size of messages sent on 1-to-many style SCTP sockets with the
SCTP_SENDALL flag. Allow also only one operation per SCTP endpoint.

This fixes an issue found by running syzkaller and is joint work with rrs@.

5 years agoMFC r345460:
Michael Tuexen [Sat, 4 May 2019 12:02:41 +0000 (12:02 +0000)]
MFC r345460:
Limit the number of bytes which can be queued for SCTP sockets.
This is joint work with rrs@.

5 years agoMFC r345458:
Michael Tuexen [Sat, 4 May 2019 11:24:19 +0000 (11:24 +0000)]
MFC r345458:
Add sysctl variable net.inet.tcp.rexmit_initial for setting RTO.Initial
used by TCP.

Reviewed by: rrs@, 0mp@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D19355

5 years agoMFC r345441:
Michael Tuexen [Sat, 4 May 2019 11:21:41 +0000 (11:21 +0000)]
MFC r345441:
Fix a KASSERT() in tcp_output().

When checking the length of the headers at this point, the IP level
options have not been added to the mbuf chain.
So don't take them into account.

Reviewed by: rrs@
Sponsored by: Netflix, Inc.

5 years agoMFC r344925:
Michael Tuexen [Sat, 4 May 2019 11:18:39 +0000 (11:18 +0000)]
MFC r344925:
Fix locking bug.

5 years agoMFC r344924:
Michael Tuexen [Sat, 4 May 2019 11:17:20 +0000 (11:17 +0000)]
MFC r344924:
Some cleanup and consistency improvements.

5 years agoMFC r344872:
Michael Tuexen [Sat, 4 May 2019 11:15:01 +0000 (11:15 +0000)]
MFC r344872:
After removing an entry from the stream scheduler list, set the pointers
to NULL, since we are checking for it in case the element gets inserted
again.

This issue was found by running syzkaller.

5 years agoMFC r344742:
Michael Tuexen [Sat, 4 May 2019 11:13:03 +0000 (11:13 +0000)]
MFC r344742:
Allocate an assocition id and register the stcb with holding the lock.
This avoids a race where stcbs can be found, which are not completely
initialized.

This was found by running syzkaller.

5 years agoMFC r344726:
Michael Tuexen [Sat, 4 May 2019 11:11:03 +0000 (11:11 +0000)]
MFC r344726:
Remove debug output.

5 years agoMFC r344724:
Michael Tuexen [Sat, 4 May 2019 11:07:35 +0000 (11:07 +0000)]
MFC r344724:
Allow SCTP stream reconfiguration operations only in ESTABLISHED
state.

This issue was found by running syzkaller.

5 years agoMFC r344723:
Michael Tuexen [Sat, 4 May 2019 11:05:57 +0000 (11:05 +0000)]
MFC r344723:
Handle the case when calling the IPPROTO_SCTP level socket option
SCTP_STATUS on an association with no primary path (early state).

This issue was found by running syzkaller.

5 years agoMFC r344722:
Michael Tuexen [Sat, 4 May 2019 11:03:10 +0000 (11:03 +0000)]
MFC r344722:
Use correct buffer sizes in sctp_get[lp]addrs().

5 years agoMFC r344721:
Michael Tuexen [Sat, 4 May 2019 11:01:31 +0000 (11:01 +0000)]
MFC r344721:
Report the correct length when using the IPPROTO_SCTP level
socket options SCTP_GET_PEER_ADDRESSES and SCTP_GET_LOCAL_ADDRESSES.

5 years agoMFC r344708:
Michael Tuexen [Sat, 4 May 2019 10:59:13 +0000 (10:59 +0000)]
MFC r344708:
Honor the memory limits provided when processing the IPPROTO_SCTP
level socket option SCTP_GET_LOCAL_ADDRESSES in a getsockopt() call.

Thanks to Thomas Barabosch for reporting the issue which was found by
running syzkaller.

5 years agoMFC r344704:
Michael Tuexen [Sat, 4 May 2019 10:56:57 +0000 (10:56 +0000)]
MFC r344704:
Improve consistency, no functional change.

5 years agoMFC r344368:
Michael Tuexen [Sat, 4 May 2019 10:38:54 +0000 (10:38 +0000)]
MFC r344368:
Reduce the TCP initial retransmission timeout from 3 seconds to
1 second as allowed by RFC 6298.

Reviewed by: kbowling@, Richard Scheffenegger
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D18941

5 years agoMFC r344367:
Michael Tuexen [Sat, 4 May 2019 10:36:16 +0000 (10:36 +0000)]
MFC r344367:
Use exponential backoff for retransmitting SYN segments as specified
in the TCP RFCs.

Reviewed by: rrs@, Richard Scheffenegger
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D18974

5 years agoMFC r344148:
Michael Tuexen [Sat, 4 May 2019 10:33:31 +0000 (10:33 +0000)]
MFC r344148:
Fix a byte ordering issue for the advertised receiver window in ACK
segments sent in TIMEWAIT state, which I introduced in r336937.

Sponsored by: Netflix, Inc.

5 years agoMFC r344048:
Michael Tuexen [Sat, 4 May 2019 10:13:37 +0000 (10:13 +0000)]
MFC r344048:
Improve input validation for raw IPv4 socket using the IP_HDRINCL
option.

This issue was found by running syzkaller on OpenBSD.
Greg Steuck made me aware that the problem might also exist on FreeBSD.

Reported by: Greg Steuck
Differential Revision: https://reviews.freebsd.org/D18834

5 years agoMFC r343961:
Michael Tuexen [Sat, 4 May 2019 10:09:25 +0000 (10:09 +0000)]
MFC r343961:
Fix a locking issue when reporing outbound messages.

5 years agoMFC r343960:
Michael Tuexen [Sat, 4 May 2019 10:06:17 +0000 (10:06 +0000)]
MFC r343960:
Fix a locking issue in the IPPROTO_SCTP level SCTP_PEER_ADDR_THLDS socket
option. The problem affects only setsockopt with invalid parameters.

This issue was found by syzkaller.

5 years agoMFC r340179:
Michael Tuexen [Sat, 4 May 2019 10:04:00 +0000 (10:04 +0000)]
MFC r340179:
Don't use a function when neither INET nor INET6 are defined.
This is a valid case for the userland stack, where this fixes
two set-but-not-used warnings in this case.

Thanks to Christian Wright for reporting the issue.

5 years agoMFC r343954:
Michael Tuexen [Sat, 4 May 2019 09:28:11 +0000 (09:28 +0000)]
MFC r343954:
Fix a locking bug in the IPPROTO_SCTP level SCTP_EVENT socket option.
This occurs when call setsockopt() with invalid parameters.

This issue was found by syzkaller.

5 years agoMFC r343951:
Michael Tuexen [Sat, 4 May 2019 09:25:32 +0000 (09:25 +0000)]
MFC r343951:
Fix locking for IPPROTO_SCTP level SCTP_DEFAULT_PRINFO socket option.
This problem occurred when calling setsockopt() will invalid parameters.

This issue was found by running syzkaller.

5 years agoMFC r343770:
Michael Tuexen [Sat, 4 May 2019 09:18:19 +0000 (09:18 +0000)]
MFC r343770:
Only reduce the PMTU after the send call. The only way to increase it, is
via PMTUD.

This fixes an MTU issue reported by Timo Voelker.

5 years agoMFC r343769:
Michael Tuexen [Sat, 4 May 2019 09:15:57 +0000 (09:15 +0000)]
MFC r343769:
Fix an off-by-one error in the input validation of the SCTP_RESET_STREAMS
socketoption.

This was found by running syzkaller.

5 years agoMFC r343742:
Michael Tuexen [Sat, 4 May 2019 09:13:52 +0000 (09:13 +0000)]
MFC r343742:
Add missing SCTP_EOR entry.

5 years agoMFC r343661:
Michael Tuexen [Sat, 4 May 2019 09:11:17 +0000 (09:11 +0000)]
MFC r343661:
When handling SYN-ACK segments in the SYN-RCVD state, set tp->snd_wnd
consistently.

This inconsistency was observed when working on the bug reported in
PR 235256, although it does not fix the reported issue. The fix for
the PR will be a separate commit.

PR: 235256
Reviewed by: rrs@, Richard Scheffenegger
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D19033

5 years agoMFC r343525:
Michael Tuexen [Sat, 4 May 2019 09:07:53 +0000 (09:07 +0000)]
MFC r343525:
Fix the detection of ECN-setup SYN-ACK packets.

RFC 3168 defines an ECN-setup SYN-ACK packet as on with the ECE flags
set and the CWR flags not set. The code was only checking if ECE flag
is set. This patch adds the check to verify that the CWR flags is not
set.

Submitted by: Richard Scheffenegger
Reviewed by: tuexen@
Differential Revision: https://reviews.freebsd.org/D18996

5 years agoMFC r343401:
Michael Tuexen [Sat, 4 May 2019 09:01:56 +0000 (09:01 +0000)]
MFC r343401:
Update a comment to reflect the current reality.
SYN-cache entries live for abaut 12 seconds, not 45, when default
setting are used.

MFC r343402:
Kill a trailing whitespace character...

MFC r343403:
Get the arithmetic right...

Sponsored by: Netflix, Inc.

5 years agoMFC: r346266
Peter Jeremy [Fri, 3 May 2019 23:06:35 +0000 (23:06 +0000)]
MFC: r346266
Specify correct Ethernet phy for RPI-B

Approved by: grog, jhb (mentors)

5 years agoMFC: r346265
Peter Jeremy [Fri, 3 May 2019 23:02:15 +0000 (23:02 +0000)]
MFC: r346265
Fix cpufreq(4) on RPI-B

Approved by: grog, jhb (mentors)

5 years agoMFC r343953:
Peter Jeremy [Fri, 3 May 2019 22:54:56 +0000 (22:54 +0000)]
MFC r343953:
Replace calls to sin(x) and cos(x) with a single call to sincos().
Replace calls to sinf(x) and cosf(x) with a single call to sincosf().

Approved by: grog, jhb (mentors)