]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoCopy googletest 1.8.1 from ^/vendor/google/googletest/1.8.1 to .../contrib/googletest
ngie [Wed, 13 Feb 2019 02:46:46 +0000 (02:46 +0000)]
Copy googletest 1.8.1 from ^/vendor/google/googletest/1.8.1 to .../contrib/googletest

5 years agoCopy ^/vendor/google/googletest/dist to ^/vendor/google/googletest/1.8.1
ngie [Wed, 13 Feb 2019 02:21:45 +0000 (02:21 +0000)]
Copy ^/vendor/google/googletest/dist to ^/vendor/google/googletest/1.8.1

Approved by: emaste (mentor, implicit)

5 years agoImport GoogleTest 1.8.1 into the vendor tree under `^/google/googletest/dist`
ngie [Wed, 13 Feb 2019 02:16:52 +0000 (02:16 +0000)]
Import GoogleTest 1.8.1 into the vendor tree under `^/google/googletest/dist`

GoogleTest is a widely used opensource C++ test framework, licensed under a
BSD 3-clause license. It fits best in the realm of doing functional/whitebox
testing, similar to ATF's C++ library. However, it has additional functionality
such as per-testcase setup fixtures, class level setup and teardown fixtures,
and a lot more functional/syntactic goodness.

In addition to large corporations adopting GoogleTest as their defacto C++ test
library (Facebook, Google, etc), many opensource projects have adopted
GoogleTest, e.g., the Capsicum project, Chrome, etc.

The goal for importing this is to enable testing with zfsd and integrate
googletest into kyua.

This is the final version that will support a pre-C++-11 compiler. As such, this
test framework will not be available to gcc 4.2.1, similar to ATF's C++ library.

A subsequent set of commits will:

1. Tag ^/google/googletest/dist as ^/google/googletest/1.8.1 using `svn cp ^/google/googletest/dist ^/google/googletest/1.8.1`.
2. Import this code into ^/head and integrate it into the build for all applicable
   platforms and C++ compile toolchains.

The import was done via the following command pipeline on OSX:
```
curl -L https://github.com/google/googletest/archive/release-1.8.1.tar.gz | tar --strip-components=1 -xvzf - -C dist/
```

Approved by: emaste (mentor)
Discussed with: brooks, jtl
Differential Revision: https://reviews.freebsd.org/D18622

5 years agoFix panic message.
imp [Wed, 13 Feb 2019 00:10:12 +0000 (00:10 +0000)]
Fix panic message.

The panic message lead people to believe some userland CAM request had
caused a problem when in reallity it was for a kernel request (eg the
USER bit was cleared). Reword message. Also, improve a couple of
comments to reflect that the periph shouldn't be completely torn down
before we get here (so the path and sim pointers should be valid, but
aren't and the code is designed to be robust enough in the face of
that to give a specific panic message).

5 years agoWith r344062 in place, hwpmc_mod.c generally needs bus_if.h and
marius [Tue, 12 Feb 2019 23:39:18 +0000 (23:39 +0000)]
With r344062 in place, hwpmc_mod.c generally needs bus_if.h and
device_if.h.

5 years agoFix up concurrent test zpool setup and teardown
ngie [Tue, 12 Feb 2019 23:35:46 +0000 (23:35 +0000)]
Fix up concurrent test zpool setup and teardown

Set up zpools with a more unique name, stash the zpool name away in a file pointed
to by `$ZPOOL_NAME_FILE` (which is relative to a per-testcase generated temporary
directory), then remove the file based on `$ZPOOL_NAME_FILE` in the cleanup
routines.

This is a more concurrency-safe solution and will allow the testcases to be safely
executed in parallel.

Reviewed by: kevans, jtl
Approved by: jtl (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19024

5 years agoAdd rc.resume(8) alias for rc(8) to fix the manpage cross references
ngie [Tue, 12 Feb 2019 23:33:16 +0000 (23:33 +0000)]
Add rc.resume(8) alias for rc(8) to fix the manpage cross references

This issue was noticed when running `make manlint` as part of MFCing r342597 to
^/stable/11:
```
$ make -C share/man/man8 rc.8lint
mandoc -Tascii -Tlint rc.8
mandoc: rc.8:548:6: STYLE: referenced manual not found: Xr rc.resume 8
$
```

This is a followup commit to r339818.

Reviewed by: eugen
Approved by: jtl (mentor)
MFC after: 1 week
MFC to: ^/stable/12
Differential Revision: https://reviews.freebsd.org/D19158

5 years agoMFV r344063:
mm [Tue, 12 Feb 2019 23:24:45 +0000 (23:24 +0000)]
MFV r344063:
Sync libarchive with vendor.

Relevant vendor changes:
  PR #1085: Fix a null pointer dereference bug in zip writer
  PR #1110: ZIP reader added support for XZ, LZMA, PPMD8 and BZIP2
            decopmpression
  PR #1116: Add support for 64-bit ar format
  PR #1120: Fix a 7zip crash [1] and a ISO9660 infinite loop [2]
  PR #1125: RAR5 reader - fix an invalid read and a memory leak
  PR #1131: POSIX reader - do not fail when tree_current_lstat() fails
            due to ENOENT [3]
  PR #1134: Delete unnecessary null pointer checks before calls of free()
  OSS-Fuzz 10843: Force intermediate to uint64_t to make UBSAN happy.
  OSS-Fuzz 11011: Avoid buffer overflow in rar5 reader

PR: 233006 [3]
Security: CVE-2019-1000019 [1], CVE-2019-1000020 [2]
MFC after: 2 weeks

5 years agoFix the build with ALTQ after r344060.
marius [Tue, 12 Feb 2019 22:33:17 +0000 (22:33 +0000)]
Fix the build with ALTQ after r344060.

5 years agoUpdate vendor/libarchive/dist to git 31c0a517c91f44eeee717a04db8b075cadda83d8
mm [Tue, 12 Feb 2019 22:29:41 +0000 (22:29 +0000)]
Update vendor/libarchive/dist to git 31c0a517c91f44eeee717a04db8b075cadda83d8

Relevant vendor changes:
  PR #1085: Fix a null pointer dereference bug in zip writer
  PR #1110: ZIP reader added support for XZ, LZMA, PPMD8 and BZIP2
            decopmpression
  PR #1116: Add support for 64-bit ar format
  PR #1120: Fix a 7zip crash [1] and a ISO9660 infinite loop [2]
  PR #1125: RAR5 reader - fix an invalid read and a memory leak
  PR #1131: POSIX reader - do not fail when tree_current_lstat() fails
            due to ENOENT [3]
  PR #1134: Delete unnecessary null pointer checks before calls of free()
  OSS-Fuzz 10843: Force intermediate to uint64_t to make UBSAN happy.
  OSS-Fuzz 11011: Avoid buffer overflow in rar5 reader

PR: 233006 [3]
Security: CVE-2019-1000019 [1], CVE-2019-1000020 [2]

5 years agoMake taskqgroup_attach{,_cpu}(9) work across architectures
marius [Tue, 12 Feb 2019 21:23:59 +0000 (21:23 +0000)]
Make taskqgroup_attach{,_cpu}(9) work across architectures

So far, intr_{g,s}etaffinity(9) take a single int for identifying
a device interrupt. This approach doesn't work on all architectures
supported, as a single int isn't sufficient to globally specify a
device interrupt. In particular, with multiple interrupt controllers
in one system as found on e. g. arm and arm64 machines, an interrupt
number as returned by rman_get_start(9) may be only unique relative
to the bus and, thus, interrupt controller, a certain device hangs
off from.
In turn, this makes taskqgroup_attach{,_cpu}(9) and - internal to
the gtaskqueue implementation - taskqgroup_attach_deferred{,_cpu}()
not work across architectures. Yet in turn, iflib(4) as gtaskqueue
consumer so far doesn't fit architectures where interrupt numbers
aren't globally unique.
However, at least for intr_setaffinity(..., CPU_WHICH_IRQ, ...) as
employed by the gtaskqueue implementation to bind an interrupt to a
particular CPU, using bus_bind_intr(9) instead is equivalent from
a functional point of view, with bus_bind_intr(9) taking the device
and interrupt resource arguments required for uniquely specifying a
device interrupt.
Thus, change the gtaskqueue implementation to employ bus_bind_intr(9)
instead and intr_{g,s}etaffinity(9) to take the device and interrupt
resource arguments required respectively. This change also moves
struct grouptask from <sys/_task.h> to <sys/gtaskqueue.h> and wraps
struct gtask along with the gtask_fn_t typedef into #ifdef _KERNEL
as userland likes to include <sys/_task.h> or indirectly drags it
in - for better or worse also with _KERNEL defined -, which with
device_t and struct resource dependencies otherwise is no longer
as easily possible now.
The userland inclusion problem probably can be improved a bit by
introducing a _WANT_TASK (as well as a _WANT_MOUNT) akin to the
existing _WANT_PRISON etc., which is orthogonal to this change,
though, and likely needs an exp-run.

While at it:
- Change the gt_cpu member in the grouptask structure to be of type
  int as used elswhere for specifying CPUs (an int16_t may be too
  narrow sooner or later),
- move the gtaskqueue_enqueue_fn typedef from <sys/gtaskqueue.h> to
  the gtaskqueue implementation as it's only used and needed there,
- change the GTASK_INIT macro to use "gtask" rather than "task" as
  argument given that it actually operates on a struct gtask rather
  than a struct task, and
- let subr_gtaskqueue.c consistently use __func__ to print functions
  names.

Reported by: mmel
Reviewed by: mmel
Differential Revision: https://reviews.freebsd.org/D19139

5 years agogarp: Fix vnet related panic for gratuitous arp
kp [Tue, 12 Feb 2019 21:22:57 +0000 (21:22 +0000)]
garp: Fix vnet related panic for gratuitous arp

Gratuitous ARP packets are sent from a timer, which means we don't have a vnet
context set. As a result we panic trying to send the packet.

Set the vnet context based on the interface associated with the interface
address.

To reproduce:
  sysctl net.link.ether.inet.garp_rexmit_count=2
  ifconfig vtnet1 10.0.0.1/24 up

PR: 235699
Reviewed by: vangyzen@
MFC after: 1 week

5 years agoFurther correct and optimize the bus_dma(9) usage of iflib(4):
marius [Tue, 12 Feb 2019 21:08:44 +0000 (21:08 +0000)]
Further correct and optimize the bus_dma(9) usage of iflib(4):
o Correct the obvious bugs in the netmap(4) parts:
  - No longer check for the existence of DMA maps as bus_dma(9)
    is used unconditionally in iflib(4) since r341095.
  - Supply the correct DMA tag and map pairs to bus_dma(9)
    functions (see also the commit message of r343753).
  - In iflib_netmap_timer_adjust(), add synchronization of the
    TX descriptors before calling the ift_txd_credits_update
    method as the latter evaluates the TX descriptors possibly
    updated by the MAC.
  - In _task_fn_tx(), wrap the netmap(4)-specific bits in
    #ifdef DEV_NETMAP just as done in _task_fn_admin() and
    _task_fn_rx() respectively.
o In iflib_fast_intr_rxtx(), synchronize the TX rather than
  the RX descriptors before calling the ift_txd_credits_update
  method (see also above).
o There's no need to synchronize an RX buffer that is going to
  be recycled in iflib_rxd_pkt_get(), yet; it's sufficient to
  do that as late as passing RX buffers to the MAC via the
  ift_rxd_refill method. Hence, combine that synchronization
  with the synchronization of new buffers into a common spot
  in _iflib_fl_refill().
o There's no need to synchronize the RX descriptors of a free
  list in preparation of the MAC updating their statuses with
  every invocation of rxd_frag_to_sd(); it's enough to do this
  once before handing control over to the MAC, i. e. before
  calling ift_rxd_flush method in _iflib_fl_refill(), which
  already performs the necessary synchronization.
o Given that the ift_rxd_available method evaluates the RX
  descriptors which possibly have been altered by the MAC,
  synchronize as appropriate beforehand. Most notably this
  is now done in iflib_rxd_avail(), which in turn means that
  we don't need to issue the same synchronization yet again
  before calling the ift_rxd_pkt_get method in iflib_rxeof().
o In iflib_txd_db_check(), synchronize the TX descriptors
  before handing them over to the MAC for transmission via
  the ift_txd_flush method.
o In iflib_encap(), move the TX buffer synchronization after
  the invocation of the ift_txd_encap() method. If the MAC
  driver fails to encapsulate the packet and we retry with
  a defragmented mbuf chain or finally fail, the cycles for
  TX buffer synchronization have been wasted. Synchronizing
  afterwards matches what non-iflib(4) drivers typically do
  and is sufficient as the MAC will not actually start with
  the transmission before - in this case - the ift_txd_flush
  method is called.
  Moreover, for the latter reason the synchronization of the
  TX descriptors in iflib_encap() can go as it's enough to
  synchronize them before passing control over to the MAC by
  issuing the ift_txd_flush() method (see above).
o In iflib_txq_can_drain(), only synchronize TX descriptors
  if the ift_txd_credits_update method accessing these is
  actually called.

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

5 years agoPoint people to SMP(4) for CPU<->domain mapping.
phk [Tue, 12 Feb 2019 21:06:07 +0000 (21:06 +0000)]
Point people to SMP(4) for CPU<->domain mapping.

5 years agoRevert r343077 until the license issues surrounding it can be resolved.
imp [Tue, 12 Feb 2019 19:05:09 +0000 (19:05 +0000)]
Revert r343077 until the license issues surrounding it can be resolved.

Approved by: core@

5 years agoPull in r339734 from upstream llvm trunk (by Eli Friedman):
dim [Tue, 12 Feb 2019 18:32:14 +0000 (18:32 +0000)]
Pull in r339734 from upstream llvm trunk (by Eli Friedman):

  [ARM] Make PerformSHLSimplify add nodes to the DAG worklist correctly.

  Intentionally excluding nodes from the DAGCombine worklist is likely
  to lead to weird optimizations and infinite loops, so it's generally
  a bad idea.

  To avoid the infinite loops, fix DAGCombine to use the
  isDesirableToCommuteWithShift target hook before performing the
  transforms in question, and implement the target hook in the ARM
  backend disable the transforms in question.

  Fixes https://bugs.llvm.org/show_bug.cgi?id=38530 . (I don't have a
  reduced testcase for that bug. But we should have sufficient test
  coverage for PerformSHLSimplify given that we're not playing weird
  tricks with the worklist. I can try to bugpoint it if necessary,
  though.)

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

This should fix a possible hang when compiling sys/dev/nxge/if_nxge.c
(which exists now only in the stable/11 branch) for arm.

5 years agoFix markup - use .Pa for the directory component, not .Fa.
trasz [Tue, 12 Feb 2019 13:01:55 +0000 (13:01 +0000)]
Fix markup - use .Pa for the directory component, not .Fa.

Reported by: 0mp
MFC after: 2 weeks
Sponsored by: DARPA, AFRL

5 years ago[ppc64] prevent infinite loop on icache sync
luporl [Tue, 12 Feb 2019 11:29:03 +0000 (11:29 +0000)]
[ppc64] prevent infinite loop on icache sync

At moea64_sync_icache(), when the 'va' argument has page size
alignment, round_page() will return the same value as 'va'.
This would cause 'len' to be 0 and thus an infinite loop.

With this change, 'lim' will always point to the next page boundary.

This issue occurred especially during debugging sessions, when a breakpoint
was placed on an exact page-aligned offset, for instance.

Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D19149

5 years agoImprove input validation for raw IPv4 socket using the IP_HDRINCL
tuexen [Tue, 12 Feb 2019 10:17:21 +0000 (10:17 +0000)]
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
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D18834

5 years agoRemove empty files
lwhsu [Tue, 12 Feb 2019 08:16:05 +0000 (08:16 +0000)]
Remove empty files

Approved by: markj (mentor)
Sponsored by: The FreeBSD Foundation

5 years agotermcap: Add an entry for kitty
bwidawsk [Tue, 12 Feb 2019 05:15:36 +0000 (05:15 +0000)]
termcap: Add an entry for kitty

The project is here:
https://github.com/kovidgoyal/kitty/

I created a port (which now needs updating):
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=233010

If only we could use terminfo :(

MFC after:      5 days
Approved by:    bapt
Differential Revision: https://reviews.freebsd.org/D19060

5 years agoUMA: unsign some variables related to allocation in hash_alloc().
pfg [Tue, 12 Feb 2019 04:33:05 +0000 (04:33 +0000)]
UMA: unsign some variables related to allocation in hash_alloc().

As a followup to r343673, unsign some variables related to allocation
since the hashsize cannot be negative. This gives a bit more space to
handle bigger allocations and avoid some implicit casting.

While here also unsign uh_hashmask, it makes little sense to keep that
signed.

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

5 years agoBump `__FreeBSD_version__` for r343891
ngie [Tue, 12 Feb 2019 03:32:40 +0000 (03:32 +0000)]
Bump `__FreeBSD_version__` for r343891

This will allow upstream consumers, e.g., capsicum-test and third-party
packages (via ports(7)), to test for a specific `__FreeBSD_version__` and
expect `renameat(2)` to be functional.

PR: 222258
Approved by: emaste (mentor)
Reviewed by: emaste
MFC with: r343891
Differential Revision: https://reviews.freebsd.org/D19154

5 years agoRemove entry for Intenso product.
kevlo [Tue, 12 Feb 2019 02:55:25 +0000 (02:55 +0000)]
Remove entry for Intenso product.

5 years agoRemove duplicate vendor id in r334650. Intenso doesn't have a USB VID.
kevlo [Tue, 12 Feb 2019 02:48:16 +0000 (02:48 +0000)]
Remove duplicate vendor id in r334650.  Intenso doesn't have a USB VID.

5 years agolibbe(3): Belatedly note the BE_DESTROY_ORIGIN option added in r343977
kevans [Tue, 12 Feb 2019 02:16:21 +0000 (02:16 +0000)]
libbe(3): Belatedly note the BE_DESTROY_ORIGIN option added in r343977

X-MFC-With: r343977

5 years agoFix the fix added in r343287 for spurious HFSC bandwidth check errors
pkelsey [Mon, 11 Feb 2019 22:58:43 +0000 (22:58 +0000)]
Fix the fix added in r343287 for spurious HFSC bandwidth check errors

The logic added in r343287 to avoid false-positive
sum-of-child-bandwidth check errors for HFSC queues has a bug in it
that causes the upperlimit service curve of an HFSC queue to be pulled
down to its parent's linkshare service curve if it happens to be above
it.

Upon further inspection/reflection, this generic
sum-of-child-bandwidths check does not need to be fixed for HFSC - it
needs to be skipped.  For HFSC, the equivalent check is to ensure the
sum of child linkshare service curves are at or below the parent's
linkshare service curve, and this check is already being performed by
eval_pfqueue_hfsc().

This commit reverts the affected parts of r343287 and adds new logic
to skip the generic sum-of-child-bandwidths check for HFSC.

MFC after: 1 day
Sponsored by: RG Nets
Differential Revision: https://reviews.freebsd.org/D19124

5 years agoCID 1009492: Logically dead code in sys/cam/scsi/scsi_xpt.c
dab [Mon, 11 Feb 2019 22:09:26 +0000 (22:09 +0000)]
CID 1009492: Logically dead code in sys/cam/scsi/scsi_xpt.c

In `probedone()`, for the `PROBE_REPORT_LUNS` case, all paths that
fall to the bottom of the case set `lp` to `NULL`, so the test for a
non-NULL value of `lp` and call to `free()` if true is dead code as
the test can never be true. Fix by eliminating the whole if
statement. To guard against a possible future change that accidentally
violates this assumption, use a `KASSERT()` to catch if `lp` is
non-NULL.

Reviewed by: cem
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19109

5 years agomdmfs: Fix many bugs in automatic md(4) creation.
brooks [Mon, 11 Feb 2019 21:31:26 +0000 (21:31 +0000)]
mdmfs: Fix many bugs in automatic md(4) creation.

This code allocated a correctly sized buffer, read past the end of the
source buffer, writing off the end of the target buffer, and then writing
a '\0' terminator past the end of the target buffer (in the wrong place).
It then leaked the buffer.

Switch to a statically sized buffer on the stack and update the source
pointer and
length before use so the correct things are copied.

Fix a logic error in the checks that the format of the line is as
expected and move on out of an assert.

Remove an unneeded close(). fclose() closes the descriptor.

Found with: CheriABI
Obtained from: CheriBSD
Reviewed by: kib, jhb, markj
Differential Revision: https://reviews.freebsd.org/D19122

5 years agoEnable PCI BAR reallocation by default.
jhb [Mon, 11 Feb 2019 20:47:09 +0000 (20:47 +0000)]
Enable PCI BAR reallocation by default.

When pci_realloc_bars was first added, the intention was to eventually
enable it by default, but it was left disabled to preserve existing
behavior.  The setting is pretty conservative in that it does not
attempt to allocate resources for BARs that the BIOS/firmware leaves
disabled.  It only attempts to reallocate resources for a BAR that the
firmware programmed during boot but that conflicts with another
resource during the kernel's device scan.

PR 221350 is an example of a machine that this knob fixes.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D18965

5 years agoAdd explanation of branches to the ports(7) man page.
trasz [Mon, 11 Feb 2019 20:46:32 +0000 (20:46 +0000)]
Add explanation of branches to the ports(7) man page.

Reviewed by: matthew@, freebsd@mhka.no
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D19146

5 years agoRemove `set' field from state structure and use set from parent rule.
ae [Mon, 11 Feb 2019 18:10:55 +0000 (18:10 +0000)]
Remove `set' field from state structure and use set from parent rule.

Initially it was introduced because parent rule pointer could be freed,
and rule's information could become inaccessible. In r341471 this was
changed. And now we don't need this information, and also it can become
stale. E.g. rule can be moved from one set to another. This can lead
to parent's set and state's set will not match. In this case it is
possible that static rule will be freed, but dynamic state will not.
This can happen when `ipfw delete set N` command is used to delete
rules, that were moved to another set.
To fix the problem we will use the set number from parent rule.

Obtained from: Yandex LLC
MFC after: 1 week
Sponsored by: Yandex LLC

5 years agoBump .Dd for today's edit.
cracauer [Mon, 11 Feb 2019 16:31:15 +0000 (16:31 +0000)]
Bump .Dd for today's edit.

Thank you Enji Cooper

5 years agoClarify NFSv4 /etc/exports semantics, with working example.
cracauer [Mon, 11 Feb 2019 15:51:28 +0000 (15:51 +0000)]
Clarify NFSv4 /etc/exports semantics, with working example.
The existing wording has been confusing users for years.

5 years agoFix flags used when compiling kern_kcov.c and subr_coverage.c.
tuexen [Mon, 11 Feb 2019 15:38:05 +0000 (15:38 +0000)]
Fix flags used when compiling kern_kcov.c and subr_coverage.c.

Without this fix, the usage of kernel coverage would lockup the system.
Thanks to Andrew for suggesting the final form of the fix.

PR: 235611
Reviewed by: andrew@, emaste@
Differential Revision: https://reviews.freebsd.org/D19135

5 years agoAdd sensors support for AXP803/AXP813. Sensor values such as
ganbold [Mon, 11 Feb 2019 14:31:19 +0000 (14:31 +0000)]
Add sensors support for AXP803/AXP813. Sensor values such as
battery charging, charge state, voltage, charging current, discharging current,
battery capacity etc. can be obtained via sysctl.

Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D19145

5 years agoFix off-by-one error in BERI virtio driver
gonzo [Mon, 11 Feb 2019 07:42:32 +0000 (07:42 +0000)]
Fix off-by-one error in BERI virtio driver

The hardcoded ident is exactly 20 bytes long but sprintf adds terminating zero,
so there is one byte written out of array bounds.As a fix use strncpy it
appends \0 only if space allows and its behavior matches virtio spec:

When VIRTIO_BLK_T_GET_ID is issued, the device identifier, up to 20 bytes, is
written to the buffer. The identifier should be interpreted as an ascii string.
It is terminated with \0, unless it is exactly 20 bytes long.

PR: 202298
Reviewed by: br
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D18852

5 years agoPlace pf_altq_get_nth_active() under the ALTQ ifdef
pkelsey [Mon, 11 Feb 2019 05:39:38 +0000 (05:39 +0000)]
Place pf_altq_get_nth_active() under the ALTQ ifdef

MFC after: 1 week

5 years agoReduce the time it takes the kernel to install a new PF config containing a large...
pkelsey [Mon, 11 Feb 2019 05:17:31 +0000 (05:17 +0000)]
Reduce the time it takes the kernel to install a new PF config containing a large number of queues

In general, the time savings come from separating the active and
inactive queues lists into separate interface and non-interface queue
lists, and changing the rule and queue tag management from list-based
to hash-bashed.

In HFSC, a linear scan of the class table during each queue destroy
was also eliminated.

There are now two new tunables to control the hash size used for each
tag set (default for each is 128):

net.pf.queue_tag_hashsize
net.pf.rule_tag_hashsize

Reviewed by: kp
MFC after: 1 week
Sponsored by: RG Nets
Differential Revision: https://reviews.freebsd.org/D19131

5 years agobectl(8): commit missing test modifications from r343993
kevans [Mon, 11 Feb 2019 04:00:42 +0000 (04:00 +0000)]
bectl(8): commit missing test modifications from r343993

X-MFC-With: r343993

5 years agobectl(8): Add -o flag to destroy to clean up the origin snapshot of BE
kevans [Mon, 11 Feb 2019 04:00:01 +0000 (04:00 +0000)]
bectl(8): Add -o flag to destroy to clean up the origin snapshot of BE

We can't predict when destruction of origin is needed, and currently we have
a precedent for not prompting for things. Leave the decision up to the user
of bectl(8) if they want the origin snapshot to be destroyed or not.

Emits a warning when -o isn't used and an origin snapshot is left to be
cleaned up, for the time being. This is handy when one drops the -o flag but
really did want to clean up the origin.

A couple of -e ignore's have been sprinkled around the test suite for places
that we don't care that the origin's not been cleaned up. -o functionality
tests will be added in the future, but are omitted for now to reduce
conflicts with work in flight to fix bits of the tests.

Reported by: Shawn Webb
MFC after: 1 week

5 years agogbde(8) - simplify randomisation with arc4random_buf
cem [Mon, 11 Feb 2019 00:11:02 +0000 (00:11 +0000)]
gbde(8) - simplify randomisation with arc4random_buf

Submitted by: David CARLIER <devnexen AT gmail.com>
Differential Revision: https://reviews.freebsd.org/D18678

5 years agonet80211(4): hide casts for 'i_seq' field offset calculation inside
avos [Sun, 10 Feb 2019 23:58:56 +0000 (23:58 +0000)]
net80211(4): hide casts for 'i_seq' field offset calculation inside
ieee80211_getqos() and reuse it in various places.

Checked with RTL8188EE, HOSTAP mode + RTL8188CUS, STA mode.

MFC after: 2 weeks

5 years agolibnv: fix memory leaks
oshogbo [Sun, 10 Feb 2019 23:30:54 +0000 (23:30 +0000)]
libnv: fix memory leaks

Free the data array for NV_TYPE_DESCRIPTOR_ARRAY case.

MFC after: 2 weeks

5 years agolibnv: fix memory leaks
oshogbo [Sun, 10 Feb 2019 23:28:55 +0000 (23:28 +0000)]
libnv: fix memory leaks

nvpair_create_stringv: free the temporary string; this fix affects
nvlist_add_stringf() and nvlist_add_stringv().

nvpair_remove_nvlist_array (NV_TYPE_NVLIST_ARRAY case): free the chain
of nvpairs (as resetting it prevents nvlist_destroy() from freeing it).
Note: freeing the chain in nvlist_destroy() is not sufficient, because
it would still leak through nvlist_take_nvlist_array().  This affects
all nvlist_*_nvlist_array() use

Submitted by: Mindaugas Rasiukevicius <rmind@netbsd.org>
Reported by: clang/gcc ASAN
MFC after: 2 weeks

5 years agoPrevent overflow for usertime/systime in caclru1
cem [Sun, 10 Feb 2019 23:07:46 +0000 (23:07 +0000)]
Prevent overflow for usertime/systime in caclru1

PR: 76972 and duplicates
Reported by: Dr. Christopher Landauer <cal AT aero.org>,
Steinar Haug <sthaug AT nethelp.no>
Submitted by: Andrey Zonov <andrey AT zonov.org> (earlier version)
MFC after: 2 weeks

5 years agosh: Restore $((x)) error checking after fix for $((-9223372036854775808))
jilles [Sun, 10 Feb 2019 22:23:05 +0000 (22:23 +0000)]
sh: Restore $((x)) error checking after fix for $((-9223372036854775808))

SVN r342880 was designed to fix $((-9223372036854775808)) and things like
$((0x8000000000000000)) but also broke error detection for values of
variables without dollar sign ($((x))).

For compatibility, overflow in plain literals continues to be ignored and
the value is clamped to the boundary (except 9223372036854775808 which is
changed to -9223372036854775808).

Reviewed by: se (although he would like error checking to be removed)
MFC after: 2 weeks
X-MFC-with: r342880
Differential Revision: https://reviews.freebsd.org/D18926

5 years agoifconfig(8): display 802.11n rates correctly for 'roam:rate' parameter
avos [Sun, 10 Feb 2019 21:32:39 +0000 (21:32 +0000)]
ifconfig(8): display 802.11n rates correctly for 'roam:rate' parameter

MFC after: 5 days

5 years agoAs struct cryptop is wrapped in #ifdef _KERNEL, userland doesn't
marius [Sun, 10 Feb 2019 21:27:03 +0000 (21:27 +0000)]
As struct cryptop is wrapped in #ifdef _KERNEL, userland doesn't
need to drag in <sys/_task.h> either.

5 years agopfctl: Fix ifa_grouplookup()
kp [Sun, 10 Feb 2019 21:22:55 +0000 (21:22 +0000)]
pfctl: Fix ifa_grouplookup()

Setting the length of the request got lost in r343287, which means SIOCGIFGMEMB
gives us the required length, but does not copy the names of the group members.
As a result we don't get a correct list of group members, and 'set skip on
<ifgroup>' broke.

This produced all sorts of very unexpected results, because we would end up
applying 'set skip' to unexpected interfaces.

X-MFC-with: r343287

5 years agolibbe(3): Add a destroy option for removing the origin
kevans [Sun, 10 Feb 2019 21:19:09 +0000 (21:19 +0000)]
libbe(3): Add a destroy option for removing the origin

Currently origin snapshots are left behind when a BE is destroyed, whether
it was an auto-created snapshot or explicitly specified via, for example,
`bectl create -e be@mysnap ...`.

Removing it automatically could be argued as a POLA violation in some
circumstances, so provide a flag to be_destroy for it. An accompanying
option will be added to bectl(8) to utilize this.

Some minor style/consistency nits in the affected areas also addressed.

Reported by: Shawn Webb
MFC after: 1 week

5 years agopowerpc: Clamp MAXCPU for MPC85XXSPE kernel to 2
jhibbits [Sun, 10 Feb 2019 20:21:20 +0000 (20:21 +0000)]
powerpc: Clamp MAXCPU for MPC85XXSPE kernel to 2

SoCs with e500v2 chips only have at most 2 cores, and there are no plans to
release any more e500v2-based SoCs.  Clamping MAXCPU down to 2 saves 5MB of
data, and 1.5MB bss.

5 years agoPerformance improvements for octe(4):
nwhitehorn [Sun, 10 Feb 2019 20:13:59 +0000 (20:13 +0000)]
Performance improvements for octe(4):
- Distribute RX load across multiple cores, if present. This reverts
  r217212, which is no longer relevant (I think because of the newer
  SDK).
- Use newer APIs for pinning taskqueue entries to specific cores.
- Deepen RX buffers.

This more than doubles NAT forwarding throughput on my EdgeRouter Lite from,
with typical packet mixture, 90 Mbps to over 200 Mbps. The result matches
forwarding throughput in Linux without the UBNT hardware offload on the same
hardware, and thus likely reflects hardware limits.

Reviewed by: jhibbits

5 years agocxgbe(4): Ignore unused interrupts.
np [Sun, 10 Feb 2019 19:20:03 +0000 (19:20 +0000)]
cxgbe(4): Ignore unused interrupts.

Sponsored by: Chelsio Communications

5 years agoSync "struct addrinfo" declaration with netdb.h.
pluknet [Sun, 10 Feb 2019 19:07:47 +0000 (19:07 +0000)]
Sync "struct addrinfo" declaration with netdb.h.

Notably, unlike in OpenBSD, which the man page was copied from,
ai_canonname and ai_addr come in different order.

PR: 225880
MFC after: 1 week

5 years agostruct xswdev on amd64 requires compat32 shims after ino64.
kib [Sun, 10 Feb 2019 19:01:05 +0000 (19:01 +0000)]
struct xswdev on amd64 requires compat32 shims after ino64.

i386 is the only architecture where uint64_t does not specify 8-bytes
alignment, which makes struct xswdev layout not compatible between
64bit and i386.

Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoFix bug introduced by r343962.
mmel [Sun, 10 Feb 2019 18:28:37 +0000 (18:28 +0000)]
Fix bug introduced by r343962.
DMAMAP_DMAMEM_ALLOC is property of dmamap, not dmatag.

MFC after: 1 week
Reported by: ian
Pointy hat: mmel

5 years agoImplement Address Space Layout Randomization (ASLR)
kib [Sun, 10 Feb 2019 17:19:45 +0000 (17:19 +0000)]
Implement Address Space Layout Randomization (ASLR)

With this change, randomization can be enabled for all non-fixed
mappings.  It means that the base address for the mapping is selected
with a guaranteed amount of entropy (bits). If the mapping was
requested to be superpage aligned, the randomization honours the
superpage attributes.

Although the value of ASLR is diminshing over time as exploit authors
work out simple ASLR bypass techniques, it elimintates the trivial
exploitation of certain vulnerabilities, at least in theory.  This
implementation is relatively small and happens at the correct
architectural level.  Also, it is not expected to introduce
regressions in existing cases when turned off (default for now), or
cause any significant maintaince burden.

The randomization is done on a best-effort basis - that is, the
allocator falls back to a first fit strategy if fragmentation prevents
entropy injection.  It is trivial to implement a strong mode where
failure to guarantee the requested amount of entropy results in
mapping request failure, but I do not consider that to be usable.

I have not fine-tuned the amount of entropy injected right now. It is
only a quantitive change that will not change the implementation.  The
current amount is controlled by aslr_pages_rnd.

To not spoil coalescing optimizations, to reduce the page table
fragmentation inherent to ASLR, and to keep the transient superpage
promotion for the malloced memory, locality clustering is implemented
for anonymous private mappings, which are automatically grouped until
fragmentation kicks in.  The initial location for the anon group range
is, of course, randomized.  This is controlled by vm.cluster_anon,
enabled by default.

The default mode keeps the sbrk area unpopulated by other mappings,
but this can be turned off, which gives much more breathing bits on
architectures with small address space, such as i386.  This is tied
with the question of following an application's hint about the mmap(2)
base address. Testing shows that ignoring the hint does not affect the
function of common applications, but I would expect more demanding
code could break. By default sbrk is preserved and mmap hints are
satisfied, which can be changed by using the
kern.elf{32,64}.aslr.honor_sbrk sysctl.

ASLR is enabled on per-ABI basis, and currently it is only allowed on
FreeBSD native i386 and amd64 (including compat 32bit) ABIs.  Support
for additional architectures will be added after further testing.

Both per-process and per-image controls are implemented:
- procctl(2) adds PROC_ASLR_CTL/PROC_ASLR_STATUS;
- NT_FREEBSD_FCTL_ASLR_DISABLE feature control note bit makes it possible
  to force ASLR off for the given binary.  (A tool to edit the feature
  control note is in development.)
Global controls are:
- kern.elf{32,64}.aslr.enable - for non-fixed mappings done by mmap(2);
- kern.elf{32,64}.aslr.pie_enable - for PIE image activation mappings;
- kern.elf{32,64}.aslr.honor_sbrk - allow to use sbrk area for mmap(2);
- vm.cluster_anon - enables anon mapping clustering.

PR: 208580 (exp runs)
Exp-runs done by: antoine
Reviewed by: markj (previous version)
Discussed with: emaste
Tested by: pho
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D5603

5 years agoDon't allocate same clock twice..
mmel [Sun, 10 Feb 2019 14:30:15 +0000 (14:30 +0000)]
Don't allocate same clock twice..

MFC after: 1 week
Reported by: jah

5 years agoProperly handle alignment requests bigger that page size.
mmel [Sun, 10 Feb 2019 14:25:29 +0000 (14:25 +0000)]
Properly handle alignment requests bigger that page size.
 - for now, alignments bigger that page size is allowed only for buffers
   allocated by bus_dmamem_alloc(), cover this fact by KASSERT.
 - never bounce buffers allocated by bus_dmamem_alloc(), these always comply
   with the required rules (alignment, boundary, address range).

MFC after: 1 week
Reviewed by: jah
PR: 235542

5 years agoFix a locking issue when reporing outbount messages.
tuexen [Sun, 10 Feb 2019 14:02:14 +0000 (14:02 +0000)]
Fix a locking issue when reporing outbount messages.

MFC after: 3 days

5 years agoFix a locking issue in the IPPROTO_SCTP level SCTP_PEER_ADDR_THLDS socket
tuexen [Sun, 10 Feb 2019 13:55:32 +0000 (13:55 +0000)]
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.

MFC after: 3 days

5 years agoFix the first couple of AddressSanitizer violations in usr.bin/top.
dim [Sun, 10 Feb 2019 13:44:36 +0000 (13:44 +0000)]
Fix the first couple of AddressSanitizer violations in usr.bin/top.

Avoid setting zero bytes beyond the length of the 'thisline' parameters
in i_process() and u_process(), and don't attempt to memset a negative
number of bytes.

MFC after: 1 week

5 years agoFix multiple warnings in usr.bin/top about variables shadowing global
dim [Sun, 10 Feb 2019 13:34:21 +0000 (13:34 +0000)]
Fix multiple warnings in usr.bin/top about variables shadowing global
declarations from base gcc, by renaming those variables.

MFC after: 1 week

5 years agoFix multiple warnings in usr.bin/top about discarded qualifiers from
dim [Sun, 10 Feb 2019 13:31:08 +0000 (13:31 +0000)]
Fix multiple warnings in usr.bin/top about discarded qualifiers from
both clang and gcc, by either constifying variables, or when that is not
possible, using __DECONST.

MFC after: 1 week

5 years agoFix a locking bug in the IPPROTO_SCTP level SCTP_EVENT socket option.
tuexen [Sun, 10 Feb 2019 10:42:16 +0000 (10:42 +0000)]
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.

MFC after: 3 days

5 years agoReplace calls to sin(x) and cos(x) with a single call to sincos().
peterj [Sun, 10 Feb 2019 08:46:07 +0000 (08:46 +0000)]
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().

Submitted by: Steve Kargl <sgk@troutmask.apl.washington.edu>
Reviewed by: bde
Approved by: grog
MFC after: 3 days

5 years agoEnable necessary bits when activating interrupts. This allows
ganbold [Sun, 10 Feb 2019 08:41:52 +0000 (08:41 +0000)]
Enable necessary bits when activating interrupts. This allows
reading some events from the interrupt status registers. These events
are reported to devd via system "PMU" and subsystem "Battery", "AC"
and "USB" such as plugged/unplugged, absent, charged and charging.

Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D19116

5 years agoFix locking for IPPROTO_SCTP level SCTP_DEFAULT_PRINFO socket option.
tuexen [Sun, 10 Feb 2019 08:28:56 +0000 (08:28 +0000)]
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.

MFC after: 3 days

5 years agoarm64: Fix compile when removing SOC_ROCKCHIP_* options
manu [Sun, 10 Feb 2019 08:14:06 +0000 (08:14 +0000)]
arm64: Fix compile when removing SOC_ROCKCHIP_* options

Make every rockchip file depend on the multiple soc_rockchip options
While here make rk_i2c and rk_gpio depend on their device options.

Reported by: sbruno

5 years agoRevert r343713 temporarily
cem [Sun, 10 Feb 2019 07:54:46 +0000 (07:54 +0000)]
Revert r343713 temporarily

The COVERAGE option breaks xtoolchain-gcc GENERIC kernel early boot
extremely badly and hasn't been fixed for the ~week since it was committed.
Please enable for GENERIC only when it doesn't do that.

Related fallout reported by: lwhsu, tuexen (pr 235611)

5 years agopowerpc: Fix AIM build
jhibbits [Sat, 9 Feb 2019 23:19:33 +0000 (23:19 +0000)]
powerpc: Fix AIM build

cpu_idle_e500mc is only used in booke, so ignore it completely in AIM.

MFC after: 2 weeks
MFC with: r343944

5 years agoDocument the ENOBUFS errno in setsockopt(2).
pluknet [Sat, 9 Feb 2019 21:33:32 +0000 (21:33 +0000)]
Document the ENOBUFS errno in setsockopt(2).

In particular, it is the case if SO_SNDBUF/SO_RCVBUF would exceed sb_max_adj.

PR: 200649
MFC after: 1 week

5 years agopowerpc: Split out the e500mc idling from rest of Book-E
jhibbits [Sat, 9 Feb 2019 21:19:53 +0000 (21:19 +0000)]
powerpc: Split out the e500mc idling from rest of Book-E

The e500v2 and e500mc (and derivatives) have different idling procedures, so
make them different functions.

MFC after: 2 weeks

5 years agoddb: Print the thread's pcb in 'show thread'
jhibbits [Sat, 9 Feb 2019 21:08:19 +0000 (21:08 +0000)]
ddb: Print the thread's pcb in 'show thread'

This can aid with debugging when a thread is running and has no backtrace.
State can be estimated based on the pcb, and refined from there, for
example, to get a rough idea of the stack pointer.

5 years agoAdd myself to committers-src.dot and calendar.freebsd
johalun [Sat, 9 Feb 2019 16:53:39 +0000 (16:53 +0000)]
Add myself to committers-src.dot and calendar.freebsd

Reviewed by: imp (mentor)
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D19101

5 years ago- Remove the redundant device disabled hint handling; ever since
marius [Sat, 9 Feb 2019 11:58:40 +0000 (11:58 +0000)]
- Remove the redundant device disabled hint handling; ever since
  r241119 that's performed globally by device_attach(9).
- As for the EM-class of devices, em(4) supports multiple queues
  and MSI-X respectively only with 82574 devices. However, since
  the conversion to iflib(4), em(4) relies on the interrupt type
  fallback mechanism, i. e. MSI-X -> MSI -> INTx, of iflib(4) to
  figure out the interrupt type to use for the EM-class (as well
  as the IGB-class) of MACs. Moreover, despite the datasheet for
  82583V not mentioning any support of MSI-X, there actually are
  82583V devices out there that report a varying number of MSI-X
  messages as supported. The interrupt type fallback of iflib(4)
  is causing two failure modes depending on the actual number of
  MSI-X messages supported for such instances of 82583V:
  1) With only one MSI-X message supported, none is left for the
     RX/TX queues as that one message gets assigned to the admin
     interrupt. Worse, later on - which will be addressed with a
     separate fix - iflib(4) interprets that one messages as MSI
     or INTx to be set up, but fails to actually do so as it has
     previously called pci_alloc_msix(9). [1, 2]
  2) With more message supported, their distribution is okay but
     then em_if_msix_intr_assign() doesn't work for 82583V, with
     the interface being left in a non-working state, too. [3]
  Thus, let em_if_attach_pre() indicate to iflib(4) to try MSI-X
  with 82574 only, and at most MSI for the remainder of EM-class
  devices.
  While at it, remove "try_second_bar" as it's polarity inverted
  and not actually needed.
- Remove code from em_if_timer() that effectively is a NOP since
  the conversion to iflib(4) ("trigger" is no longer read).
  While at it, let the comment for em_if_timer() reflect reality
  after said conversion.
- Implement an ifdi_watchdog_reset method which only updates the
  em(4) "watchdog_events" counter but doesn't perform any reset,
  so that the em(4) "watchdog_timeouts" SYSCTL (iflib(4) doesn't
  provide a counterpart) reflects reality and these timeouts add
  to IFCOUNTER_OERRORS again after the iflib(4) conversion.
- Remove the "mbuf_defrag_fail" and "tx_dma_fail" SYSCTLS; since
  the iflib(4) conversion, associated counters are disconnected,
  but iflib(4) provides "mbuf_defrag_failed" and "tx_map_failed"
  respectively as equivalents.
- Move the description preceding lem_smartspeed() to the correct
  spot before em_reset() and bring back appropriate comments for
  {igb,em}_initialize_rss_mapping() and lem_smartspeed() lost in
  the iflib(4) conversion.
- Adapt some other function descriptions and INIT_DEBUGOUT() use
  to match reality after the iflib(4) conversion.
- Put the debugging message of em_enable_vectors_82574() (missed
  in r343578) under bootverbose, too.

PR: 219428 [1], 235246 [2], 235147 [3]
Reviewed by: erj (previous version)
Differential Revision: https://reviews.freebsd.org/D19108

5 years agoRemove -R option which was added to sysctl(8) man page per r244106, but it is not...
ygy [Sat, 9 Feb 2019 04:36:02 +0000 (04:36 +0000)]
Remove -R option which was added to sysctl(8) man page per r244106, but it is not implemented.

MFC after: 3 days
Submitted by: Alfonso Siciliano <alfix86@gmail.com>
Reviewed by: 0mp, imp
Differential Revision:  https://reviews.freebsd.org/D19012

5 years agoi386: honor kern.elf32.read_exec for ommap(2) and break(2), as already
kib [Sat, 9 Feb 2019 03:56:48 +0000 (03:56 +0000)]
i386: honor kern.elf32.read_exec for ommap(2) and break(2), as already
done on amd64.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoNormalize the declaration of i386_read_exec variable.
kib [Sat, 9 Feb 2019 03:51:51 +0000 (03:51 +0000)]
Normalize the declaration of i386_read_exec variable.

It is currently re-declared in sys/sysent.h which is a wrong place for
MD variable.  Which causes redeclaration error with gcc when
sys/sysent.h and machine/md_var.h are included both.

Remove it from sys/sysent.h and instead include machine/md_var.h when
needed, under #ifdef for both i386 and amd64.

Reported and tested by: bde
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoRemove remnants of byte order manipulation, back when FreeBSD stack
glebius [Sat, 9 Feb 2019 03:00:00 +0000 (03:00 +0000)]
Remove remnants of byte order manipulation, back when FreeBSD stack
stored packets in host byte order.

5 years agoCorrect the CPU target for powerpcspe
jhibbits [Sat, 9 Feb 2019 02:04:27 +0000 (02:04 +0000)]
Correct the CPU target for powerpcspe

The MPC8540 is actually e500v1, which doesn't have double-precision floating
point support.  The 8548 does, so use that as the CPU target.

MFC after: 2 weeks

5 years agocxgbe(4): Delay the panic due to a fatal error by 30s.
np [Sat, 9 Feb 2019 01:49:53 +0000 (01:49 +0000)]
cxgbe(4): Delay the panic due to a fatal error by 30s.

This lets information logged by the interrupt handler reach the system
log before the system goes down.

5 years agodhclient: Return non-zero status when script exits due to a signal
jilles [Fri, 8 Feb 2019 23:03:28 +0000 (23:03 +0000)]
dhclient: Return non-zero status when script exits due to a signal

r343896 made it such that a non-zero exit status was passed through, but was
still wrong if the script exits on a signal. POSIX does not say what the
WEXITSTATUS macro returns in this case and in practice 0 is a common value.

Instead, translate the wait status into 8 bits the same way as the shell
calculates $?.

Reviewed by: kib, Nash Kaminski
MFC after: 1 week

5 years agoAdd an example to pw.8 about how to add an existing user to a group.
bcr [Fri, 8 Feb 2019 22:10:40 +0000 (22:10 +0000)]
Add an example to pw.8 about how to add an existing user to a group.

Instead of using pw to modify group membership, users often edit
/etc/group by hand, which is discouraged.  Provide an example of
adding a user to the wheel group, which is a common use case.
I'm using a different user here as in the previous example as that
deleted the user (although the examples don't necessarily have to
be followed in order).

Reviewed by: rgrimes,0mp
Approved by: 0mp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D19123

5 years agoEnsure that when using the TCP CDG congestion control and setting the
tuexen [Fri, 8 Feb 2019 20:42:49 +0000 (20:42 +0000)]
Ensure that when using the TCP CDG congestion control and setting the
sysctl variable net.inet.tcp.cc.cdg.smoothing_factor to 0, the smoothing
is disabled. Without this patch, a division by zero orrurs.

PR: 193762
Reviewed by: lstewart@, rrs@
MFC after: 3 days
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D19071

5 years agoFix em(4) interrupt routing
pkelsey [Fri, 8 Feb 2019 20:34:47 +0000 (20:34 +0000)]
Fix em(4) interrupt routing

When configured with more tx queues than rx queues,
em_if_msix_intr_assign() was incorrectly routing the tx event
interrupts.

Reviewed by: erj, marius
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19070

5 years agoTeach /etc/rc.d/growfs how to handle systems running ZFS.
cperciva [Fri, 8 Feb 2019 19:19:31 +0000 (19:19 +0000)]
Teach /etc/rc.d/growfs how to handle systems running ZFS.

There are many cases which this code does not handle (e.g. ZFS mirrors)
but the code can handle the single-disk case -- so it's enough to take
care of the "disk image which gets booted into a VM with a larger than
expected disk" case for which this firstboot script was created.

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

5 years agoAmend r343442, by only expecting the lib.msun.cbrt_test.cbrtl_powl and
dim [Fri, 8 Feb 2019 18:31:54 +0000 (18:31 +0000)]
Amend r343442, by only expecting the lib.msun.cbrt_test.cbrtl_powl and
trig_test.reduction test cases to fail, if the fixes from r343916 have
not yet been applied to the base compiler.

Reported by:    lwhsu
PR: 234040
Upstream PR: https://bugs.llvm.org/show_bug.cgi?id=40206
MFC after: 1 week

5 years agoPull in r352607 from upstream llvm trunk (by Craig Topper):
dim [Fri, 8 Feb 2019 18:24:53 +0000 (18:24 +0000)]
Pull in r352607 from upstream llvm trunk (by Craig Topper):

  [X86] Add FPSW as a Def on some FP instructions that were missing it.

Pull in r353141 from upstream llvm trunk (by Craig Topper):

  [X86] Connect the default fpsr and dirflag clobbers in inline
  assembly to the registers we have defined for them.

  Summary:
  We don't currently map these constraints to physical register numbers
  so they don't make it to the MachineIR representation of inline
  assembly.

  This could have problems for proper dependency tracking in the
  machine schedulers though I don't have a test case that shows that.

  Reviewers: rnk

  Reviewed By: rnk

  Subscribers: eraman, llvm-commits

  Tags: #llvm

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

Pull in r353489 from upstream llvm trunk (by Craig Topper):

  [X86] Add FPCW as a register and start using it as an implicit use on
  floating point instructions.

  Summary:
  FPCW contains the rounding mode control which we manipulate to
  implement fp to integer conversion by changing the roudning mode,
  storing the value to the stack, and then changing the rounding mode
  back. Because we didn't model FPCW and its dependency chain, other
  instructions could be scheduled into the middle of the sequence.

  This patch introduces the register and adds it as an implciit def of
  FLDCW and implicit use of the FP binary arithmetic instructions and
  store instructions. There are more instructions that need to be
  updated, but this is a good start. I believe this fixes at least the
  reduced test case from PR40529.

  Reviewers: RKSimon, spatel, rnk, efriedma, andrew.w.kaylor

  Subscribers: dim, llvm-commits

  Tags: #llvm

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

These should fix a problem in clang 7.0 where it would sometimes emit
long double floating point instructions in a slightly wrong order,
leading to failures in our libm tests.  In particular, the cbrt_test
test case 'cbrtl_powl' and the trig_test test case 'reduction'.

Also bump __FreeBSD_cc_version, to be able to detect this in our test
suite.

Reported by:    lwhsu
PR: 234040
Upstream PR: https://bugs.llvm.org/show_bug.cgi?id=40206
MFC after: 1 week

5 years agoAdd myself to committers-ports.dot and calendar.freebsd
kai [Fri, 8 Feb 2019 17:57:39 +0000 (17:57 +0000)]
Add myself to committers-ports.dot and calendar.freebsd

Reviewed by: miwi (mentor)
Approved by: miwi (mentor)
Differential Revision: https://reviews.freebsd.org/D19119

5 years agoFix the spelling of cov_unregister_pc.
andrew [Fri, 8 Feb 2019 16:18:17 +0000 (16:18 +0000)]
Fix the spelling of cov_unregister_pc.

When unregistering kcov from the coverage interface we should use the
unregister function, not the register function.

Sponsored by: DARPA, AFRL

5 years agopms(4) should use bus_get_dma_tag() to get parent tag.
tychon [Fri, 8 Feb 2019 16:05:38 +0000 (16:05 +0000)]
pms(4) should use bus_get_dma_tag() to get parent tag.

Reviewed by: imp
Sponsored by: Dell EMC Isilon

5 years agoAllow reading the UEFI variable size
mw [Fri, 8 Feb 2019 14:56:28 +0000 (14:56 +0000)]
Allow reading the UEFI variable size

When loading bigger variables form UEFI it is necessary to know their
size beforehand, so that an appropriate amount of memory can be
allocated. The easiest way to do this is to try to read the variable
with buffer size equal 0, expecting EFI_BUFFER_TOO_SMALL error to be
returned. Allow such possible approach in efi_getenv routine.

Extracted from a bigger patch as suggested by imp.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield

5 years agonewkey(8): fix 'tmpname' memory leak (always) and input file descriptor leak
avos [Fri, 8 Feb 2019 14:31:44 +0000 (14:31 +0000)]
newkey(8): fix 'tmpname' memory leak (always) and input file descriptor leak
when output file cannot be opened

PR: 201732
Reported by: David Binderman <dcb314@hotmail.com>
MFC after: 1 week

5 years agoFix several Coverity-detected issues in newsyslog.
dab [Fri, 8 Feb 2019 13:54:16 +0000 (13:54 +0000)]
Fix several Coverity-detected issues in newsyslog.

- CID 1394815, CID 1305673: Dereference before null check - memory was
  allocated and the allocation checked for NULL with a call to errx()
  if it failed. Code below that was guaranteed that the pointer was
  non-NULL, but there was another check for NULL at the exit of the
  function (after the memory had already been referenced). Eliminate
  the useless NULL check.

- CID 1007454, CID 1007453: Resource leak - The result of a strdup()
  was stored in a global variable and not freed before program exit.

- CID 1007452: Resource leak - Storage intended to be allocated and
  returned to the caller was never freed. This was the result of a
  regression in the function signature introduced in r208648 (2010)
  (thanks for that find, @cem!). Fixed by altering the function
  signature and passing the allocated memory to the caller as
  intended. This also fixes PR158794.

- CID 1008620: Logically dead code in newsyslog.c - This was a direct
  result of CID 1007452. Since the memory allocated as described there
  was not returned to the caller, a subsequent check for the memory
  having been allocated was dead code. Returning the memory
  re-animates the code that is the subject of this CID.

- CID 1006131: Unused value - in parsing a configuration file, a
  pointer to the end of the last field was saved, but not used after
  that. Rewrite to use the pointer value. This could have been fixed
  by avoiding the assignment altogether, but this solutions more
  closely follows the pattern used in the preceding code.

PR: 158794
Reported by: Coverity, Ken-ichi EZURA <k.ezura@gmail.com> (PR158794)
Reviewed by: cem, markj
MFC after: 1 week
Sponsored by: Dell EMC Isilon

5 years agoImprove Bluetooth device discovery support for Android and Microsoft devices.
hselasky [Fri, 8 Feb 2019 13:10:45 +0000 (13:10 +0000)]
Improve Bluetooth device discovery support for Android and Microsoft devices.

Tested using the virtual_bt_speaker(8) tool from the virtual_oss(8)
project at github.com.

PR: 210089
MFC after: 1 week
Sponsored by: Mellanox Technologies

5 years agoAdd macOS 10.14.
pluknet [Fri, 8 Feb 2019 11:49:59 +0000 (11:49 +0000)]
Add macOS 10.14.

5 years agoUn null_vptocnp(), cache vp->v_mount and use it for null_nodeget() call.
kib [Fri, 8 Feb 2019 08:20:18 +0000 (08:20 +0000)]
Un null_vptocnp(), cache vp->v_mount and use it for null_nodeget() call.

The vp vnode is unlocked during the execution of the VOP method and
can be reclaimed, zeroing vp->v_data.  Caching allows to use the
correct mount point.

Reported and tested by: pho
PR: 235549
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoBefore using VTONULL(), check that the covered vnode belongs to nullfs.
kib [Fri, 8 Feb 2019 08:17:31 +0000 (08:17 +0000)]
Before using VTONULL(), check that the covered vnode belongs to nullfs.

Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week