]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoMFC r331707: MFV r331706:
mav [Mon, 16 Apr 2018 04:14:03 +0000 (04:14 +0000)]
MFC r331707: MFV r331706:
9235 rename zpool_rewind_policy_t to zpool_load_policy_t

illumos/illumos-gate@5dafeea3ebd2dd77affc802bcb90f63faf01589f

We want to be able to pass various settings during import/open of a pool,
which are not only related to rewind. Instead of adding a new policy and
duplicate a bunch of code, we should just rename rewind_policy to a more
generic term like load_policy.

For instance, we'd like to set spa->spa_import_flags from the nvlist,
rather from a flags parameter passed to spa_import as in some cases we want
those flags not only for the import case, but also for the open case. One
such flag could be ZFS_IMPORT_MISSING_LOG (as used in zdb) which would
allow zfs to open a pool when logs are missing.

Reviewed by: Matt Ahrens <matt@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years agoMFC r331705: MFV 331704:
mav [Mon, 16 Apr 2018 04:13:19 +0000 (04:13 +0000)]
MFC r331705: MFV 331704:
9191 dump vdev tree to zfs_dbgmsg when spa load fails due to missing log devices

illumos/illumos-gate@ccef24b493bcbd146fcd6d8946666cae081470b6

Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Matt Ahrens <matt@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years agoMFC r331703: MFV 331702:
mav [Mon, 16 Apr 2018 04:11:48 +0000 (04:11 +0000)]
MFC r331703: MFV 331702:
9187 racing condition between vdev label and spa_last_synced_txg in vdev_validate

illumos/illumos-gate@d1de72cfa29ab77ff80e2bb0e668a6afa5bccaf0

ztest failed with uncorrectable IO error despite having the fix for #7163.
Both sides of the mirror have CANT_OPEN_BAD_LABEL, which also distinguishes
it from that issue.

Definitely seems like a racing condition between the vdev_validate and spa_sync:
1. Thread A (spa_sync): vdev label is updated to latest txg
2. Thread B (vdev_validate): vdev label's txg is compared to spa_last_synced_txg and is ahead.
3. Thread A (spa_sync): spa_last_synced_txg is updated to latest txg.

Solution: do not check txg in vdev_validate unless config lock is held.

Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matt Ahrens <matthew.ahrens@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years agoMFC r331701: MFV r331695, 331700: 9166 zfs storage pool checkpoint
mav [Mon, 16 Apr 2018 04:10:56 +0000 (04:10 +0000)]
MFC r331701: MFV r331695, 331700: 9166 zfs storage pool checkpoint

illumos/illumos-gate@8671400134a11c848244896ca51a7db4d0f69da4

The idea of Storage Pool Checkpoint (aka zpool checkpoint) deals with
exactly that.  It can be thought of as a “pool-wide snapshot” (or a
variation of extreme rewind that doesn’t corrupt your data).  It remembers
the entire state of the pool at the point that it was taken and the user
can revert back to it later or discard it.  Its generic use case is an
administrator that is about to perform a set of destructive actions to ZFS
as part of a critical procedure.  She takes a checkpoint of the pool before
performing the actions, then rewinds back to it if one of them fails or puts
the pool into an unexpected state.  Otherwise, she discards it.  With the
assumption that no one else is making modifications to ZFS, she basically
wraps all these actions into a “high-level transaction”.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: John Kennedy <john.kennedy@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: Serapheim Dimitropoulos <serapheim.dimitro@delphix.com>

6 years agoMFC r331699: Partial MFV r329753:
mav [Mon, 16 Apr 2018 03:58:08 +0000 (03:58 +0000)]
MFC r331699: Partial MFV r329753:
8809 libzpool should leverage work done in libfakekernel

illumos/illumos-gate@f06dce2c1f0f3af78581e7574f65bfba843ddb6e

Reviewed by: Sebastien Roy <sebastien.roy@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: Andrew Stormont <astormont@racktopsystems.com>

We do not have libfakekernel, but need to reduce code divergence.

6 years agoMFC r331420 (by avg): zfs: fix mismatch between format specifier and type
mav [Mon, 16 Apr 2018 03:56:10 +0000 (03:56 +0000)]
MFC r331420 (by avg): zfs: fix mismatch between format specifier and type

vdev_dbgmsg_print_tree printed vdev_id of uint64_t type with %u format
specifier.  That caused subsequent parameters to be incorrectly read
from the stack and lead to a crash when a wrong value was interpreted as
a string pointer.

This should be upstreamed.

6 years agoMFC r331414: Reduce struct aggsum_bucket padding to fit into one cache line.
mav [Mon, 16 Apr 2018 03:55:14 +0000 (03:55 +0000)]
MFC r331414: Reduce struct aggsum_bucket padding to fit into one cache line.

6 years agoMFC r331408: MFV r331407: 9213 zfs: sytem typo
mav [Mon, 16 Apr 2018 03:54:35 +0000 (03:54 +0000)]
MFC r331408: MFV r331407: 9213 zfs: sytem typo

illumos/illumos-gate@edc8ef7d921c96b23969898aeb766cb24960bda7

Reviewed by: C Fraire <cfraire@me.com>
Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk>
Approved by: Joshua M. Clulow <josh@sysmgr.org>
Author: Toomas Soome <tsoome@me.com>

6 years agoMFC r331406: MFV r331405: 9084 spa_*_ashift must ignore spare devices
mav [Mon, 16 Apr 2018 03:53:34 +0000 (03:53 +0000)]
MFC r331406: MFV r331405: 9084 spa_*_ashift must ignore spare devices

illumos/illumos-gate@b037f3dbd69cef4a7ffd576ad33e07bfaf0b1e84

Reviewed by: Prashanth Sreenivasa <pks@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Prakash Surya <prakash.surya@delphix.com>

6 years agoMFC r331404: MFV r331400:
mav [Mon, 16 Apr 2018 03:52:54 +0000 (03:52 +0000)]
MFC r331404: MFV r331400:
8484 Implement aggregate sum and use for arc counters

In pursuit of improving performance on multi-core systems, we should
implements fanned out counters and use them to improve the performance of
some of the arc statistics. These stats are updated extremely frequently,
and can consume a significant amount of CPU time.

Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Paul Dagnelie <pcd@delphix.com>

6 years agoMFC r329808: MFV r329807:
mav [Mon, 16 Apr 2018 03:49:27 +0000 (03:49 +0000)]
MFC r329808: MFV r329807:
8940 Sending an intra-pool resumable send stream may result in EXDEV

illumos/illumos-gate@544132fce3fa6583f01318f9559adc46614343a7

"zfs send -t <token>" for an incremental send should be able to resume
successfully when sending to the same pool: a subtle issue in
zfs_iter_children() doesn't currently allow this.

Because resuming from a token requires "guid" -> "dataset" mapping
(guid_to_name()), we have to walk the whole hierarchy to find the right
snapshots to send.
When resuming an incremental send both source and destination live in the
same pool and have the same guid: this is where zfs_iter_children() gets
confused and picks up the wrong snapshot, so we end up trying to send an
incremental "destination@snap1 -> source@snap2" stream instead of
"source@snap1 -> source@snap2": this fails with an "Invalid cross-device
link" (EXDEV) error.

Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Author: loli10K <ezomori.nozomu@gmail.com>

6 years agoMFC r329805: MFV r329803:
mav [Mon, 16 Apr 2018 03:48:37 +0000 (03:48 +0000)]
MFC r329805: MFV r329803:
9080 recursive enter of vdev_indirect_rwlock from vdev_indirect_remap()

illumos/illumos-gate@bdfded42e66b9fc1395ff2401aa2952f7c44ae34

A scenario came up where a callback executed by vdev_indirect_remap() on a vdev, calls
vdev_indirect_remap() on the same vdev and tries to reacquire vdev_indirect_rwlock that
was already acquired from the first call to vdev_indirect_remap(). The specific scenario,
is that we want to remap a block pointer that is snapshoted but its dataset's remap_deadlist
is not cached. So in order to add it we issue a read through a vdev_indirect_remap() on the
same vdev, which brings up the aforementioned issue.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Author: Serapheim Dimitropoulos <serapheim.dimitro@delphix.com>

6 years agoMFC r329802: MFV r329799, r329800:
mav [Mon, 16 Apr 2018 03:47:53 +0000 (03:47 +0000)]
MFC r329802: MFV r329799, r329800:
9079 race condition in starting and ending condesing thread for indirect vdevs

illumos/illumos-gate@667ec66f1b4f491d5e839644e0912cad1c9e7122

The timeline of the race condition is the following:
[1] Thread A is about to finish condesing the first vdev in spa_condense_indirect_thread(),
so it calls the spa_condense_indirect_complete_sync() sync task which sets the
spa_condensing_indirect field to NULL. Waiting for the sync task to finish, thread A
sleeps until the txg is done. When this happens, thread A will acquire spa_async_lock
and set spa_condense_thread to NULL.
[2] While thread A waits for the txg to finish, thread B which is running spa_sync() checks
whether it should condense the second vdev in vdev_indirect_should_condense() by checking
the spa_condensing_indirect field which was set to NULL by spa_condense_indirect_thread()
from thread A. So it goes on and tries to spawn a new condensing thread in
spa_condense_indirect_start_sync() and the aforementioned assertions fails because thread A
has not set spa_condense_thread to NULL (which is basically the last thing it does before
returning).

The main issue here is that we rely on both spa_condensing_indirect and spa_condense_thread to
signify whether a condensing thread is running. Ideally we would only use one throughout the
codebase. In addition, for managing spa_condense_thread we currently use spa_async_lock which
basically tights condensing to scrubing when it comes to pausing and resuming those actions
during spa export.

Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Author: Serapheim Dimitropoulos <serapheim@delphix.com>

6 years agoMFC r329798: MFV r329793, r329795:
mav [Mon, 16 Apr 2018 03:45:39 +0000 (03:45 +0000)]
MFC r329798: MFV r329793, r329795:
9075 Improve ZFS pool import/load process and corrupted pool recovery

illumos/illumos-gate@6f7938128a2c5e23f4b970ea101137eadd1470a1

Some work has been done lately to improve the debugability of the ZFS pool
load (and import) process. This includes:

https://www.illumos.org/issues/7638: Refactor spa_load_impl into several functions
https://www.illumos.org/issues/8961: SPA load/import should tell us why it failed
https://www.illumos.org/issues/7277: zdb should be able to print zfs_dbgmsg's

To iterate on top of that, there's a few changes that were made to make the
import process more resilient and crash free. One of the first tasks during the
pool load process is to parse a config provided from userland that describes
what devices the pool is composed of. A vdev tree is generated from that config,
and then all the vdevs are opened.

The Meta Object Set (MOS) of the pool is accessed, and several metadata objects
that are necessary to load the pool are read. The exact configuration of the
pool is also stored inside the MOS. Since the configuration provided from
userland is external and might not accurately describe the vdev tree
of the pool at the txg that is being loaded, it cannot be relied upon to safely
operate the pool. For that reason, the configuration in the MOS is read early
on. In the past, the two configurations were compared together and if there was
a mismatch then the load process was aborted and an error was returned.

The latter was a good way to ensure a pool does not get corrupted, however it
made the pool load process needlessly fragile in cases where the vdev
configuration changed or the userland configuration was outdated. Since the MOS
is stored in 3 copies, the configuration provided by userland doesn't have to be
perfect in order to read its contents. Hence, a new approach has been adopted:
The pool is first opened with the untrusted userland configuration just so that
the real configuration can be read from the MOS. The trusted MOS configuration
is then used to generate a new vdev tree and the pool is re-opened.

When the pool is opened with an untrusted configuration, writes are disabled
to avoid accidentally damaging it. During reads, some sanity checks are
performed on block pointers to see if each DVA points to a known vdev;
when the configuration is untrusted, instead of panicking the system if those
checks fail we simply avoid issuing reads to the invalid DVAs.

This new two-step pool load process now allows rewinding pools accross
vdev tree changes such as device replacement, addition, etc. Loading a pool
from an external config file in a clustering environment also becomes much
safer now since the pool will import even if the config is outdated and didn't,
for instance, register a recent device addition.

With this code in place, it became relatively easy to implement a
long-sought-after feature: the ability to import a pool with missing top level
(i.e. non-redundant) devices. Note that since this almost guarantees some loss
Of data, this feature is for now restricted to a read-only import.

Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years agoMFC r329783: 8942 zfs promote .../%recv should be an error
mav [Mon, 16 Apr 2018 03:44:13 +0000 (03:44 +0000)]
MFC r329783: 8942 zfs promote .../%recv should be an error

illumos/illumos-gate@add927f8c8d101e16c23eb9cd270be4fd7edf7d5

Reported on the ZFSonLinux https://github.com/zfsonlinux/zfs/issues/4843,
fixed by https://github.com/zfsonlinux/zfs/pull/6339:

If we are in the middle of an incremental zfs receive, the child .../%recv
will exist. If you concurrently run zfs promote .../%recv, it will "work",
but then zfs gets confused. For example, there's no obvious way to destroy
the containing filesystem (because it is now a clone of its invisible child).

Attempting to do this promote should be an error. We could fix this by
having zfs_ioc_promote() check if zc_name contains a %, similar to
zfs_ioc_rename().

Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: loli10K <ezomori.nozomu@gmail.com>

6 years agoMFC r329777: MFV r329776:
mav [Mon, 16 Apr 2018 03:43:29 +0000 (03:43 +0000)]
MFC r329777: MFV r329776:
8477 Assertion failed in vdev_state_dirty(): spa_writeable(spa)

illumos/illumos-gate@f4c1745bd6c9829a05ecec15759ede7757100ab5

Illumos 4080 allows "zpool clear" to work on readonly pools: i don't think
this is the intended behaviour, we shouldn't be allowed to clear readonly
pools. Probably.

A fix is already in the ZFS on Linux repository to addess this issue:
https://github.com/zfsonlinux/zfs/commit/92e43c17188d47f47b69318e4884096dec380e36

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: loli10K <ezomori.nozomu@gmail.com>

6 years agoMFC r329775: MFV r329774:
mav [Mon, 16 Apr 2018 03:42:47 +0000 (03:42 +0000)]
MFC r329775: MFV r329774:
8408 dsl_props_set_sync_impl() does not handle nested nvlists correctly

illumos/illumos-gate@85723e5eec42f46dbfdb4c09b9e1ed66501d1ccf

When iterating over the input nvlist in dsl_props_set_sync_impl() when we
don't preserve the nvpair name before looking up ZPROP_VALUE, so when we
later go to process it nvpair_name() is always "value" instead of the actual
property name.

This results in a couple of bugs in the recv code:

 - received properties are not restored correctly when failing to receive
   an incremental send stream
 - received properties are not completely replaced by the new ones when
   successfully receiving an incremental send stream

This was discovered on ZFS on Linux (fixed in
https://github.com/zfsonlinux/zfs/commit/5f1346c29997dd4e02acf4c19c875d5484f33b1e)

Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: loli10K <ezomori.nozomu@gmail.com>

6 years agoMFC r329771: MFV r329770: 9035 zfs: this statement may fall through
mav [Mon, 16 Apr 2018 03:42:06 +0000 (03:42 +0000)]
MFC r329771: MFV r329770: 9035 zfs: this statement may fall through

illumos/illumos-gate@46ac8fdfc5a1f9d8240c79a6ae5b2889cbe83553

Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Toomas Soome <tsoome@me.com>

6 years agoMFC r329769: MFV r329766: 8962 zdb should work on non-idle pools
mav [Mon, 16 Apr 2018 03:41:21 +0000 (03:41 +0000)]
MFC r329769: MFV r329766: 8962 zdb should work on non-idle pools

illumos/illumos-gate@e144c4e6c90e7d4dccaad6db660ee42b6e7ba04f

Currently `zdb` consistently fails to examine non-idle pools as it fails
during the `spa_load()` process. The main problem seems to be that
`spa_load_verify()` fails as can be seen below:

$ sudo zdb -d -G dcenter
    zdb: can't open 'dcenter': I/O error

ZFS_DBGMSG(zdb):
    spa_open_common: opening dcenter
    spa_load(dcenter): LOADING
    disk vdev '/dev/dsk/c4t11d0s0': best uberblock found for spa dcenter. txg 40824950
    spa_load(dcenter): using uberblock with txg=40824950
    spa_load(dcenter): UNLOADING
    spa_load(dcenter): RELOADING
    spa_load(dcenter): LOADING
    disk vdev '/dev/dsk/c3t10d0s0': best uberblock found for spa dcenter. txg 40824952
    spa_load(dcenter): using uberblock with txg=40824952
    spa_load(dcenter): FAILED: spa_load_verify failed [error=5]
    spa_load(dcenter): UNLOADING

This change makes `spa_load_verify()` a dryrun when ran from `zdb`. This is
done by creating a global flag in zfs and then setting it in `zdb`.

Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Andy Stormont <astormont@racktopsystems.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years agoMFC r329765: MFV r329762: 8961 SPA load/import should tell us why it failed
mav [Mon, 16 Apr 2018 03:40:12 +0000 (03:40 +0000)]
MFC r329765: MFV r329762: 8961 SPA load/import should tell us why it failed

illumos/illumos-gate@3ee8c80c747c4aa3f83351a6920f30c411236e1b

When we fail to open or import a storage pool, we typically don't get any
additional diagnostic information, just "no pool found" or "can not import".

While there may be no additional user-consumable information, we should at
least make this situation easier to debug/diagnose for developers and support.
For example, we could start by using `zfs_dbgmsg()` to log each thing that we
try when importing, and which things failed. E.g. "tried uberblock of txg X
from label Y of device Z". Also, we could log each of the stages that we go
through in `spa_load_impl()`.

Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years agoMFC r329761: MFV r329760: 7638 Refactor spa_load_impl into several functions
mav [Mon, 16 Apr 2018 03:39:24 +0000 (03:39 +0000)]
MFC r329761: MFV r329760: 7638 Refactor spa_load_impl into several functions

illumos/illumos-gate@1fd3785ff6601d3e391378c2dcbf4c5f27e1fe32

spa_load_impl has grown out of proportions.  It is currently over 700
lines long and makes it very hard to follow or debug the import process
even for experienced ZFS developers.  The objective is to split it up
in a series of well commented functions.

Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Pavel Zakharov <pavel.zakharov@delphix.com>

6 years agoMFC r329759:
mav [Mon, 16 Apr 2018 03:38:37 +0000 (03:38 +0000)]
MFC r329759:
9018 Replace kmem_cache_reap_now() with kmem_cache_reap_soon()

illumos/illumos-gate@36a64e62848b51ac5a9a5216e894ec723cfef14e

To prevent kmem_cache reaping from blocking other system resources, turn
kmem_cache_reap_now() (which blocks) into kmem_cache_reap_soon(). Callers
to kmem_cache_reap_soon() should use kmem_cache_reap_active(), which
exploits #9017's new taskq_empty().

Reviewed by: Bryan Cantrill <bryan@joyent.com>
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Author: Tim Kordas <tim.kordas@joyent.com>

FreeBSD does not use taskqueue for kmem caches reaping, so this change
is less dramatic then it is on Illumos, just limiting reaping to 1 time
per second.  It may possibly be improved later, if needed.

6 years agoMFC r329755: MFV r329753:
mav [Mon, 16 Apr 2018 03:35:18 +0000 (03:35 +0000)]
MFC r329755: MFV r329753:
8809 libzpool should leverage work done in libfakekernel

illumos/illumos-gate@f06dce2c1f0f3af78581e7574f65bfba843ddb6e

Reviewed by: Sebastien Roy <sebastien.roy@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: Andrew Stormont <astormont@racktopsystems.com>

6 years agoMFC r329732: MFV r329502: 7614 zfs device evacuation/removal
mav [Mon, 16 Apr 2018 03:32:41 +0000 (03:32 +0000)]
MFC r329732: MFV r329502: 7614 zfs device evacuation/removal

illumos/illumos-gate@5cabbc6b49070407fb9610cfe73d4c0e0dea3e77

https://www.illumos.org/issues/7614:
This project allows top-level vdevs to be removed from the storage pool with
“zpool remove”, reducing the total amount of storage in the pool. This
operation copies all allocated regions of the device to be removed onto other
devices, recording the mapping from old to new location. After the removal is
complete, read and free operations to the removed (now “indirect”) vdev must
be remapped and performed at the new location on disk. The indirect mapping
table is kept in memory whenever the pool is loaded, so there is minimal
performance overhead when doing operations on the indirect vdev.

The size of the in-memory mapping table will be reduced when its entries
become “obsolete” because they are no longer used by any block pointers in
the pool. An entry becomes obsolete when all the blocks that use it are
freed. An entry can also become obsolete when all the snapshots that
reference it are deleted, and the block pointers that reference it have been
“remapped” in all filesystems/zvols (and clones). Whenever an indirect block
is written, all the block pointers in it will be “remapped” to their new
(concrete) locations if possible. This process can be accelerated by using
the “zfs remap” command to proactively rewrite all indirect blocks that
reference indirect (removed) vdevs.

Note that when a device is removed, we do not verify the checksum of the data
that is copied. This makes the process much faster, but if it were used on
redundant vdevs (i.e. mirror or raidz vdevs), it would be possible to copy
the wrong data, when we have the correct data on e.g. the other side of the
mirror. Therefore, mirror and raidz devices can not be removed.

Reviewed by: Alex Reece <alex@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: John Kennedy <john.kennedy@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Richard Laager <rlaager@wiktel.com>
Reviewed by: Tim Chase <tim@chase2k.com>
Approved by: Garrett D'Amore <garrett@damore.org>
Author: Prashanth Sreenivasa <pks@delphix.com>

6 years agoMFC r307317: MFV r307313:
mav [Mon, 16 Apr 2018 03:14:54 +0000 (03:14 +0000)]
MFC r307317: MFV r307313:
5120 zfs should allow large block/gzip/raidz boot pool (loader project)

Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Toomas Soome <tsoome@me.com>

openzfs/openzfs@c8811bd3e2427dddbac6c05a59cfe117d8fea370

FreeBSD still does not support booting from gzip-compressed datasets,
so keep one chunk of this commit out.

6 years agoMFC r308137, r316312, r332361
kevans [Mon, 16 Apr 2018 00:42:45 +0000 (00:42 +0000)]
MFC r308137, r316312, r332361

r308137:
Fix alignment issues on MIPS: align the pointers properly.

All the 5520 GEOM_ELI tests passed successfully on MIPS64EB.

r316312:
sys/geom/eli: Switch bzero() to explicit_bzero() for sensitive data

In GELI, anywhere we are zeroing out possibly sensitive data, like
the metadata struct, the metadata sector (both contain the encrypted
master key), the user key, or the master key, use explicit_bzero.

Didn't touch the bzero() used to initialize structs.

r332361:
Introduce dry run option for attaching the device.
This will allow us to verify if passphrase and key is valid without
decrypting whole device.

6 years agoMFC r323108, r323125, r326047-r326049
kevans [Mon, 16 Apr 2018 00:29:07 +0000 (00:29 +0000)]
MFC r323108, r323125, r326047-r326049

r323108:
Add efimedia attribute for all GPT partitions.

r323125:
The hard drive media device path contains the size of the partition,
not its end. This makes the GEOM efimedia attribute match the
FreeBSD:Boot1Device environment variable now.

r326047:
Implement efi media tagging for MBR partitioning types.

r326048:
Remove trailing whitespace (one I just introduced and a bunch of
others in the same directory).

r326049:
While the EFI spec allows numbers to be in many forms, libefivar
produces hex numbers for the dsn. Since that come is from EDK2, change
this for symmetry, by generating the dsn as a hex number.

[Missed as part of the efivar/efibootmgr MFCs]

Reported by: Oliver Pinter <oliver.pinter@hardenedbsd.org>

6 years agogeom_aes: Provide some deprecation notices
kevans [Mon, 16 Apr 2018 00:18:57 +0000 (00:18 +0000)]
geom_aes: Provide some deprecation notices

This is a direct commit to stable/11, due to having already been removed in
head.

6 years agoMFC r322318-r322319
kevans [Mon, 16 Apr 2018 00:12:03 +0000 (00:12 +0000)]
MFC r322318-r322319

r322318:
Mark geom classes as deprecated.

geom_bsd, geom_mbr and geom_sunlabel have been obsolete since Marcel
Moolenaar's geom_part was in FreeBSD 7. They haven't been in GENERIC
since FreeBSD 8. Add warning when used.

geom_vol_ffs has been obsolete since ufs support to geom_label was
committed in FreeBSD 5. It hasn't been in GENERIC since FreeBSD 5.
Add warning when used.

geom_fox has been obsolete since gmultipath was committed in FreeBSD 7.
(no warning added, since this is a very obscure class).

These will all be removed in FreeBSD 12.

r322319:
Also provide a warning for geom_fox.

6 years agoMFC r330764
grehan [Sun, 15 Apr 2018 20:29:37 +0000 (20:29 +0000)]
MFC r330764
  Add CR2 get/set support.

6 years agoMFC r325261
grehan [Sun, 15 Apr 2018 20:20:08 +0000 (20:20 +0000)]
MFC r325261
  Emulate the "OR reg, r/m" instruction (opcode 0BH).

  This is needed for the HDA emulation with FreeBSD guests.

6 years agoMFC r331436:
kp [Sun, 15 Apr 2018 15:22:28 +0000 (15:22 +0000)]
MFC r331436:

netpfil: Introduce PFIL_FWD flag

Forwarded packets passed through PFIL_OUT, which made it difficult for
firewalls to figure out if they were forwarding or producing packets. This in
turn is an issue for pf for IPv6 fragment handling: it needs to call
ip6_output() or ip6_forward() to handle the fragments. Figuring out which was
difficult (and until now, incorrect).
Having pfil distinguish the two removes an ugly piece of code from pf.

Introduce a new variant of the netpfil callbacks with a flags variable, which
has PFIL_FWD set for forwarded packets. This allows pf to reliably work out if
a packet is forwarded.

6 years agoFix mis-merge of r329507 in r331501
gonzo [Sat, 14 Apr 2018 20:49:38 +0000 (20:49 +0000)]
Fix mis-merge of r329507 in r331501

sus/modules/Makefile part of r329507 just removed ffec
while r331501 also added conditional clause for bcm283x_clkman
and bcm283x_pwm. Since they're part of another revision,
remove mi-merged chunk

6 years agoMFC r332182:
kib [Sat, 14 Apr 2018 17:41:54 +0000 (17:41 +0000)]
MFC r332182:
Handle Skylake-X errata SKZ63.

6 years agoMFC r331077 (brooks): Add _IOC_NEWLEN() and _IOC_NEWTYPE() macros.
emaste [Sat, 14 Apr 2018 12:52:34 +0000 (12:52 +0000)]
MFC r331077 (brooks): Add _IOC_NEWLEN() and _IOC_NEWTYPE() macros.

These macros take an existing ioctl(2) command and replace the length
with the specified length or length of the specified type respectively.
These can be used to define commands for 32-bit compatibility with fewer
opportunities for cut-and-paste errors then a whole new definition.

Obtained from: CheriBSD
Sponsored by: DARPA, AFRL

6 years agoMFC r332142:
kp [Sat, 14 Apr 2018 00:12:16 +0000 (00:12 +0000)]
MFC r332142:

pf: Improve ioctl validation

Ensure that multiplications for memory allocations cannot overflow, and
that we'll not try to allocate M_WAITOK for potentially overly large
allocations.

6 years agoMFC r332107:
kp [Fri, 13 Apr 2018 22:33:50 +0000 (22:33 +0000)]
MFC r332107:

pf: Improve ioctl validation for DIOCRGETTABLES, DIOCRGETTSTATS, DIOCRCLRTSTATS and DIOCRSETTFLAGS

These ioctls can process a number of items at a time, which puts us at
risk of overflow in mallocarray() and of impossibly large allocations
even if we don't overflow.

Limit the allocation to required size (or the user allocation, if that's
smaller). That does mean we need to do the allocation with the rules
lock held (so the number doesn't change while we're doing this), so it
can't M_WAITOK.

6 years agoMFC r332088:
brooks [Fri, 13 Apr 2018 22:32:28 +0000 (22:32 +0000)]
MFC r332088:

Add 32-bit compat for ioctls that take struct ifgroupreq.

Use an accessor to access ifgr_group and ifgr_groups.

Use an macro CASE_IOC_IFGROUPREQ(cmd) in place of case statements such
as "case SIOCAIFGROUP:". This avoids poluting the switch statements
with large numbers of #ifdefs.

Reviewed by: kib
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14960

6 years agoMFC r332136:
kp [Fri, 13 Apr 2018 21:19:03 +0000 (21:19 +0000)]
MFC r332136:

pf: Improve ioctl validation for DIOCIGETIFACES and DIOCXCOMMIT

These ioctls can process a number of items at a time, which puts us at
risk of overflow in mallocarray() and of impossibly large allocations
even if we don't overflow.

There's no obvious limit to the request size for these, so we limit the
requests to something which won't overflow. Change the memory allocation
to M_NOWAIT so excessive requests will fail rather than stall forever.

6 years agoMFC r332101:
kp [Fri, 13 Apr 2018 19:23:01 +0000 (19:23 +0000)]
MFC r332101:

pf: Improve ioctl validation for DIOCRADDTABLES and DIOCRDELTABLES

The DIOCRADDTABLES and DIOCRDELTABLES ioctls can process a number of
tables at a time, and as such try to allocate <number of tables> *
sizeof(struct pfr_table). This multiplication can overflow. Thanks to
mallocarray() this is not exploitable, but an overflow does panic the
system.

Arbitrarily limit this to 65535 tables. pfctl only ever processes one
table at a time, so it presents no issues there.

6 years agoRemove .info debugging output that accidentally got left in for MFC commit.
ian [Fri, 13 Apr 2018 19:15:31 +0000 (19:15 +0000)]
Remove .info debugging output that accidentally got left in for MFC commit.

This was just an artifact of my testing to ensure the option had the
desired effect on freebsd 11, both when enabled and when disabled.

Reported by: Thomas Mueller <tmueller@sysgo>
Point hat: ian@

6 years agoMFC r332372-r332374: tail(1)/head(1) compatibility long options
kevans [Fri, 13 Apr 2018 17:57:00 +0000 (17:57 +0000)]
MFC r332372-r332374: tail(1)/head(1) compatibility long options

r332372:
tail(1): Add some long options

Add --blocks, --bytes, and --lines long options for -b, -c, and -n
respectively. This improves tail(1)'s compatibility with its GNU counterpart
in a straightforward way.

r332373:
tail(1): Address mandoc concern (space before punctuation after macro)

r332374:
head(1): Provide long options

Provide long options --bytes and --lines to match -c and -n respectively.
This improves head(1)'s compatibility with its GNU counterpart in a sensible
way.

6 years agoMove 1-second spin into ixgbe_netmap_reg()
shurd [Fri, 13 Apr 2018 17:45:54 +0000 (17:45 +0000)]
Move 1-second spin into ixgbe_netmap_reg()

This should still work around the netmap issue, but should not impact other
calls to ixgbe_stop().

PR: 221317
Sponsored by: Limelight Networks

6 years agoMFC: r332075
rgrimes [Fri, 13 Apr 2018 03:47:41 +0000 (03:47 +0000)]
MFC: r332075

Exit with usage when extra arguments are on command line
preventing mistakes such as "halt 0p" for "halt -p".
Approved by: bde (mentor, implicit), phk (mentor,implicit)
MFC after: 1 week

6 years agoMFC r319897-r319898, r319904: Improve yes' throughput
kevans [Fri, 13 Apr 2018 03:32:18 +0000 (03:32 +0000)]
MFC r319897-r319898, r319904: Improve yes' throughput

r319897: Improve yes' throughput

On my system, this brings up the throughput from ~20 to ~600 MiB/s.

Inspired by:
  https://www.reddit.com/r/unix/comments/6gxduc/how_is_gnu_yes_so_fast/

r319898: Handle partial writes

r319904: style(9) fixes.

6 years agoMFC r308432, r308657: Capsicumize some trivial stdio programs
kevans [Fri, 13 Apr 2018 03:30:10 +0000 (03:30 +0000)]
MFC r308432, r308657: Capsicumize some trivial stdio programs

r308432: Capsicumize some trivial stdio programs

Trivially capsicumize some simple programs that just interact with
stdio.  This list of programs uses 'pledge("stdio")' in OpenBSD.

r308657: fold(1): Revert incorrect r308432

As Jean-Sébastien notes, fold(1) requires handling argv-supplied files. That
will require a slightly more sophisticated approach.

6 years agoMFC r306758 (emaste): locate: ANSIfy
kevans [Fri, 13 Apr 2018 02:40:10 +0000 (02:40 +0000)]
MFC r306758 (emaste): locate: ANSIfy

6 years agoMFC r332145: Do not fail devices just for errors in descriptor format.
mav [Fri, 13 Apr 2018 00:29:42 +0000 (00:29 +0000)]
MFC r332145: Do not fail devices just for errors in descriptor format.

Sponsored by: iXsystems, Inc.

6 years agoMFC r331758: makefs: sync fragment and block size with newfs
emaste [Fri, 13 Apr 2018 00:25:53 +0000 (00:25 +0000)]
MFC r331758: makefs: sync fragment and block size with newfs

r222319 in newfs raised the default blocksize for UFS/FFS filesystems
from 16K to 32K and the default fragment size from 2K to 4K, with a
rationale that most disks were now running with 4K sectors.

Relnotes: Yes
Sponsored by: The FreeBSD Foundation

6 years agoWork around netmap issue with ixgbe
shurd [Thu, 12 Apr 2018 19:06:15 +0000 (19:06 +0000)]
Work around netmap issue with ixgbe

After multiple start/stop of netmap, ixgbe will get into a bad state
requiring a reboot to recover.  Adding a delay before stopping the interface
appears to work around the issue.

The -CURRENT driver has diverged too far from -STABLE for an MFC.

PR: 221317
Submitted by: Sylvain Galliano <sg@efficientip.com>
Reported by: Cassiano Peixoto <peixoto.cassiano@gmail.com>
Sponsored by: Limelight Networks

6 years agoMFC r332061:
kib [Thu, 12 Apr 2018 13:40:02 +0000 (13:40 +0000)]
MFC r332061:
Fix ERESTART for lcall $7,$0 syscalls.

6 years agoMFC r332060:
kib [Thu, 12 Apr 2018 13:39:01 +0000 (13:39 +0000)]
MFC r332060:
Make the INTO instruction operational in 32bit mode.

6 years agoMFC 328101,328911: Require SHF_ALLOC for kernel object module sections.
jhb [Wed, 11 Apr 2018 22:23:22 +0000 (22:23 +0000)]
MFC 328101,328911: Require SHF_ALLOC for kernel object module sections.

328101:
Require the SHF_ALLOC flag for program sections from kernel object modules.

ELF object files can contain program sections which are not supposed
to be loaded into memory (e.g. .comment).  Normally the static linker
uses these flags to decide which sections are allocated to loadable
program segments in ELF binaries and shared objects (including kernels
on all architectures and kernel modules on architectures other than
amd64).

Mapping ELF object files (such as amd64 kernel modules) into memory
directly is a bit of a grey area.  ELF object files are intended to be
used as inputs to the static linker.  As a result, there is not a
standardized definition for what the memory layout of an ELF object
should be (none of the section headers have valid virtual memory
addresses for example).

The kernel and loader were not checking the SHF_ALLOC flag but loading
any program sections with certain types such as SHT_PROGBITS.  As a
result, the kernel and loader would load into RAM some sections that
weren't marked with SHF_ALLOC such as .comment that are not loaded
into RAM for kernel modules on other architectures (which are
implemented as ELF shared objects).  Aside from possibly requiring
slightly more RAM to hold a kernel module this does not affect runtime
correctness as the kernel relocates symbols based on the layout it
uses.

Debuggers such as gdb and lldb do not extract symbol tables from a
running process or kernel.  Instead, they replicate the memory layout
of ELF executables and shared objects and use that to construct their
own symbol tables.  For executables and shared objects this works
fine.  For ELF objects the current logic in kgdb (and probably lldb
based on a simple reading) assumes that only sections with SHF_ALLOC
are memory resident when constructing a memory layout.  If the
debugger constructs a different memory layout than the kernel, then it
will compute different addresses for symbols causing symbols in the
debugger to appear to have the wrong values (though the kernel itself
is working fine).  The current port of mdb does not check SHF_ALLOC as
it replicates the kernel's logic in its existing kernel support.

The bfd linker sorts the sections in ELF object files such that all of
the allocated sections (sections with SHF_ALLOCATED) are placed first
followed by unallocated sections.  As a result, when kgdb composed a
memory layout using only the allocated sections, this layout happened
to match the layout used by the kernel and loader.  The lld linker
does not sort the sections in ELF object files and mixed allocated and
unallocated sections.  This resulted in kgdb composing a different
memory layout than the kernel and loader.

We could either patch kgdb (and possibly in the future lldb) to use
custom handling when generating memory layouts for kernel modules that
are ELF objects, or we could change the kernel and loader to check
SHF_ALLOCATED.  I chose the latter as I feel we shouldn't be loading
things into RAM that the module won't use.  This should mostly be a
NOP when linking with bfd but will allow the existing kgdb to work
with amd64 kernel modules linked with lld.

Note that we only require SHF_ALLOC for "program" sections for types
like SHT_PROGBITS and SHT_NOBITS.  Other section types such as symbol
tables, string tables, and relocations must also be loaded and are not
marked with SHF_ALLOC.

328911:
Ignore relocation tables for non-memory-resident sections.

As a followup to r328101, ignore relocation tables for ELF object
sections that are not memory resident.  For modules loaded by the
loader, ignore relocation tables whose associated section was not
loaded by the loader (sh_addr is zero).  For modules loaded at runtime
via kldload(2), ignore relocation tables whose associated section is
not marked with SHF_ALLOC.

6 years agoMFC r328988,r328989:
ae [Wed, 11 Apr 2018 10:36:20 +0000 (10:36 +0000)]
MFC r328988,r328989:
  Rework ipfw dynamic states implementation to be lockless on fast path.

  o added struct ipfw_dyn_info that keeps all needed for ipfw_chk and
    for dynamic states implementation information;
  o added DYN_LOOKUP_NEEDED() macro that can be used to determine the
    need of new lookup of dynamic states;
  o ipfw_dyn_rule now becomes obsolete. Currently it used to pass
    information from kernel to userland only.
  o IPv4 and IPv6 states now described by different structures
    dyn_ipv4_state and dyn_ipv6_state;
  o IPv6 scope zones support is added;
  o ipfw(4) now depends from Concurrency Kit;
  o states are linked with "entry" field using CK_SLIST. This allows
    lockless lookup and protected by mutex modifications.
  o the "expired" SLIST field is used for states expiring.
  o struct dyn_data is used to keep generic information for both IPv4
    and IPv6;
  o struct dyn_parent is used to keep O_LIMIT_PARENT information;
  o IPv4 and IPv6 states are stored in different hash tables;
  o O_LIMIT_PARENT states now are kept separately from O_LIMIT and
    O_KEEP_STATE states;
  o per-cpu dyn_hp pointers are used to implement hazard pointers and they
    prevent freeing states that are locklessly used by lookup threads;
  o mutexes to protect modification of lists in hash tables now kept in
    separate arrays. 65535 limit to maximum number of hash buckets now
    removed.
  o Separate lookup and install functions added for IPv4 and IPv6 states
    and for parent states.
  o By default now is used Jenkinks hash function.

  Obtained from: Yandex LLC
  Sponsored by: Yandex LLC
  Differential Revision: https://reviews.freebsd.org/D12685

6 years agoMFC r331668:
ae [Wed, 11 Apr 2018 10:24:47 +0000 (10:24 +0000)]
MFC r331668:
  Rework ipfw rules parsing and printing code.

  Introduce show_state structure to keep information about printed opcodes.
  Split show_static_rule() function into several smaller functions. Make
  parsing and printing opcodes into several passes. Each printed opcode
  is marked in show_state structure and will be skipped in next passes.
  Now show_static_rule() function is simple, it just prints each part
  of rule separately: action, modifiers, proto, src and dst addresses,
  options. The main goal of this change is avoiding occurrence of wrong
  result of `ifpw show` command, that can not be parsed by ipfw(8).
  Also now it is possible to make some simple static optimizations
  by reordering of opcodes in the rule.

  PR: 222705

6 years agoMFC r308490 by syrinx:
emaste [Tue, 10 Apr 2018 23:38:31 +0000 (23:38 +0000)]
MFC r308490 by syrinx:

Reply to a snmpEngineID discovery PDU with a Report PDU as per the
requirements of RFC 3414 section 4.

PR: 174974
Submitted by: pguyot@kallisys.net

6 years agoMFC r329388, r331441 and r331898, to bring the -CURRENT ck version.
cognet [Tue, 10 Apr 2018 20:22:36 +0000 (20:22 +0000)]
MFC r329388, r331441 and r331898, to bring the -CURRENT ck version.
r329388:
Define CK_MD_TSO for the relevant arches (i386, amd64 and sparc64).
Defaulting to CK_MD_RMO has the unfortunate side effect of generating
memory barriers that are useless on those arches, and the even more
unfortunate side effect of generating lfence/sfence/mfence on i386, even
if older CPUs don't support it.
This should fix the panic reported when using IPFW on a Pentium 3.
Note that mfence and sfence might still be used in a few case, but that
shouldn't happen in FreeBSD right now, and should be fixed upstream first.

r331441:
In __sync_bool_compare_and_swap(), return true if the returned value is the
same as the expected one, not the desired one.

r331898:
Import CK as of commit b19ed4c6a56ec93215ab567ba18ba61bf1cfbac8
It should fix ck_pr_[load|store]_ptr on mips and riscv, make sure no
*fence instructions are used on i386, as older cpus don't support it, and
make sure we don't rely on gcc builtins that can lead to calls to
libatomic when linked with -O0.

6 years agoMFC r318412: fix sparc64 build by restoring 'register' in pcpu.h
emaste [Tue, 10 Apr 2018 16:44:40 +0000 (16:44 +0000)]
MFC r318412: fix sparc64 build by restoring 'register' in pcpu.h

6 years agoMFC r328037: Rename 'recv' to 'receive' to appease shadow warnings from GCC.
kevans [Tue, 10 Apr 2018 15:38:16 +0000 (15:38 +0000)]
MFC r328037: Rename 'recv' to 'receive' to appease shadow warnings from GCC.

6 years agoMFC r319828, r324625
kevans [Tue, 10 Apr 2018 14:13:35 +0000 (14:13 +0000)]
MFC r319828, r324625

r319828:
rc.subr: Optimize repeated sourcing.

When /etc/rc runs all /etc/rc.d scripts, it has already loaded /etc/rc.subr
but each /etc/rc.d script sources it again (since /etc/rc.d scripts must
also work when started stand-alone).

Therefore, if rc.subr is already loaded, return so sh need not parse the
rest of the file.

A second effect is that there is no longer a compound command around most of
rc.subr. This reduces memory usage while sh is loading rc.subr for the first
time (but this memory is free()d once rc.subr is loaded).

For purposes of porting this to other systems, I do not recommend porting
this to systems with shells that do not have the change to the return
special builtin like in r255215 (before FreeBSD 10.0-RELEASE). This change
ensures that return in the top level of a dot script returns from the dot
script, even if the dot script was sourced from a function.

A comparison of CPU time on an amd64 bhyve virtual machine from a times
command added near the end of /etc/rc, all four values summed:

x orig1
+ quickreturn
+--------------------------------------------------------------------------+
|  +    +              +                             x    x               x|
||______M__A_________|                             |______M___A__________| |
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   3         1.704         1.802         1.726         1.744   0.051419841
+   3         1.467         1.559         1.487     1.5043333   0.048387326
Difference at 95.0% confidence
-0.239667 +/- 0.113163
-13.7424% +/- 6.48873%
(Student's t, pooled s = 0.0499266)

r324625:
rc.subr: Remove test that is always true.

The code above always sets _pidcmd to a non-empty value.

6 years agoDocument EN-18:03, EN-18:04, SA-18:04, SA-18:05.
gjb [Tue, 10 Apr 2018 14:07:29 +0000 (14:07 +0000)]
Document EN-18:03, EN-18:04, SA-18:04, SA-18:05.

Sponsored by: The FreeBSD Foundation

6 years agoMFC r309350, r309352
kevans [Tue, 10 Apr 2018 14:04:11 +0000 (14:04 +0000)]
MFC r309350, r309352

r309350:
If the kenv variable rc_debug is set, turn on rc_debug.

r309352:
Finish incomplete comments in prior revision. I was going to fix this
after I tested it, but didn't.

6 years agoMFC r308896
kevans [Tue, 10 Apr 2018 14:00:45 +0000 (14:00 +0000)]
MFC r308896

r308896: rc.subr: $(ps -p $$ -o jid=) is always 0, so do not fork ps for it.

The JID keyword writes 0 for a process also in the host system or in the
same jail.

6 years agoRevert r331880, MFC of r328331 and bump FreeBSD_version
kevans [Tue, 10 Apr 2018 13:35:07 +0000 (13:35 +0000)]
Revert r331880, MFC of r328331 and bump FreeBSD_version

There are logistics issues that weren't considered when this was originally
MFC'd. All rc scripts in ports need audited (this is in progress) for usage
of ${name}_limits that doesn't line up with the new interpretation, and
individual rc.conf(5)'s need to be scrubbed of usage that doesn't line up.

It's since been decided that it should be left for a feature in 12.

1101514 introduced interpretation of ${name}_limits for rc scripts; this
feature no longer exists as of 1101515.

6 years agoMFC r331180: Plug a possible memory leak.
delphij [Tue, 10 Apr 2018 03:12:22 +0000 (03:12 +0000)]
MFC r331180: Plug a possible memory leak.

6 years agodmagent: add -D_WITH_GETLINE to fix stable/11 build
emaste [Mon, 9 Apr 2018 21:16:28 +0000 (21:16 +0000)]
dmagent: add -D_WITH_GETLINE to fix stable/11 build

The need for _WITH_GETLINE and _WITH_DPRINTF was removed in HEAD in
r303524 but is still needed in stable/11 to enable prototypes for these
functions.

6 years agoMFC r326641 by bapt: Split body of mails not respecting RFC2822
emaste [Mon, 9 Apr 2018 20:00:07 +0000 (20:00 +0000)]
MFC r326641 by bapt: Split body of mails not respecting RFC2822

For mails which has a body not respecting RFC2822 (which often happen with
crontabs) try to split by words finding the last space before 1000's
character

If no spaces are found then consider the mail to be malformed anyway

PR: 208261

6 years agoFix wl(4) after r332288.
brooks [Mon, 9 Apr 2018 16:18:02 +0000 (16:18 +0000)]
Fix wl(4) after r332288.

I missed that this was an assignment (a bad pattern, use another
member) on i386.  As wl(4) is i386 only and gone in head, just
expand the ifr_ifru member rather than adding an accessor.

Reported by: gjb

6 years agoMFC r332151:
brooks [Mon, 9 Apr 2018 15:21:40 +0000 (15:21 +0000)]
MFC r332151:

ifconf(): correct handling of sockaddrs smaller than struct sockaddr.

Portable programs that use SIOCGIFCONF (e.g. traceroute) assume
that each pseudo ifreq is of length MAX(sizeof(struct ifreq),
sizeof(ifr_name) + ifr_addr.sa_len).  For short sockaddrs we copied
too much from the source sockaddr resulting in a heap leak.

I believe only one such sockaddr exists (struct sockaddr_sco which
is 8 bytes) and it is unclear if such sockaddrs end up on interfaces
in practice.  If it did, the result would be an 8 byte heap leak on
current architectures.

admbugs: 869
Reviewed by: kib
Obtained from: CheriBSD
Security: kernel heap leak
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14981

6 years agoMFC r331225:
kp [Mon, 9 Apr 2018 15:11:17 +0000 (15:11 +0000)]
MFC r331225:

pf: Fix memory leak in DIOCRADDTABLES

If a user attempts to add two tables with the same name the duplicate table
will not be added, but we forgot to free the duplicate table, leaking memory.
Ensure we free the duplicate table in the error path.

Reported by: Coverity
CID: 1382111

6 years agoMFC r327559:
smh [Mon, 9 Apr 2018 08:25:29 +0000 (08:25 +0000)]
MFC r327559:

Disabled the use of flowid for lagg by default

Sponsored by: Multiplay

6 years agoMFC r328434 by maxim:
gonzo [Mon, 9 Apr 2018 05:43:30 +0000 (05:43 +0000)]
MFC r328434 by maxim:

o A command line flag for the syslog_facility fixed in the SYNOPSIS.

PR: 225441

6 years agoMFC r331439: Sort headers in MD Linuxulator files
emaste [Mon, 9 Apr 2018 01:07:47 +0000 (01:07 +0000)]
MFC r331439: Sort headers in MD Linuxulator files

Bring #includes closer to style(9) and reduce differences between the
(three) MD versions of linux_machdep.c and linux_sysvec.c.

6 years agoMFC r331053: ANSIfy i386/vm86.c
emaste [Mon, 9 Apr 2018 01:06:09 +0000 (01:06 +0000)]
MFC r331053: ANSIfy i386/vm86.c

6 years agoMFC r332146: Re-sort LOADER options
kevans [Mon, 9 Apr 2018 01:02:32 +0000 (01:02 +0000)]
MFC r332146: Re-sort LOADER options

6 years agoMFC r331969, r332035:
pfg [Sun, 8 Apr 2018 21:56:35 +0000 (21:56 +0000)]
MFC r331969, r332035:
pthread.h: drop nullability attributes.

These have been found to be practically useless. We were actually
following the Android bionic library and had some interest in replicating
the same warnings and behaviour but Android has since removed them.

We are still keeping some uses of nullability attributes in other headers,
somewhat in line with Apple's libc.

Hinted by: bionic (git 3f66e74b903905e763e104396aff52a81718cfde)

6 years agoRegen src.conf.5 after r332306 (WITH_KERNEL_RETPOLINE MFC)
emaste [Sun, 8 Apr 2018 20:58:13 +0000 (20:58 +0000)]
Regen src.conf.5 after r332306 (WITH_KERNEL_RETPOLINE MFC)

6 years agoMFC r330110: Add kernel retpoline option for amd64
emaste [Sun, 8 Apr 2018 20:54:13 +0000 (20:54 +0000)]
MFC r330110: Add kernel retpoline option for amd64

Retpoline is a compiler-based mitigation for CVE-2017-5715, also known
as Spectre V2, that protects against speculative execution branch target
injection attacks.

In this commit it is disabled by default, but will be changed in a
followup commit.

MFC r330962: Remove KERNEL_RETPOLINE from BROKEN_OPTIONS on i386

Clang will compile both amd64 and i386 with retpoline.

Sponsored by: The FreeBSD Foundation

6 years agoMFC r331082: ANSIfy sys/x86
emaste [Sun, 8 Apr 2018 20:52:09 +0000 (20:52 +0000)]
MFC r331082: ANSIfy sys/x86

6 years agoMFC ath(4) potential memory disclosure fixes
emaste [Sun, 8 Apr 2018 20:50:16 +0000 (20:50 +0000)]
MFC ath(4) potential memory disclosure fixes

[1] r327499: ath: fix memory disclosure from ath_btcoex_ioctl

The ath_btcoex_ioctl handler allocated a buffer without M_ZERO and
returned it to userland without writing to it.

The device has permissions only for root so this is not urgent, and the
fix can be MFCd and considered for a future EN.

[2] r327500: ath: fix possible memory disclosures in ioctl handlers

Apply the fix from r327499 to additional ioctl handlers.

[3] r327529: ath: fix possible memory disclosure in ioctl handler

Submitted by: Domagoj Stolfa <domagoj.stolfa@gmail.com> [1,3]
Reported by: Ilja van Sprundel <ivansprundel@ioactive.com> [1,2]
Reviewed by: adrian [1]
Sponsored by: The FreeBSD Foundation

6 years agoMFC r331935: vtfontcvt: allow .bdf characters less than full height
emaste [Sun, 8 Apr 2018 20:30:52 +0000 (20:30 +0000)]
MFC r331935: vtfontcvt: allow .bdf characters less than full height

Sponsored by: The FreeBSD Foundation

6 years agoMFC r328972: add retpoline compiler and linker feature flags
emaste [Sun, 8 Apr 2018 20:28:37 +0000 (20:28 +0000)]
MFC r328972: add retpoline compiler and linker feature flags

These features indicate that the compiler and linker support the
retpoline speculative execution vulnerability (CVE-2017-5715)
mitigation.

6 years agoMFC r320243 (bdrewery): Fix spelling error.
emaste [Sun, 8 Apr 2018 20:26:50 +0000 (20:26 +0000)]
MFC r320243 (bdrewery): Fix spelling error.

6 years agoMFC r332087:
brooks [Sun, 8 Apr 2018 17:18:51 +0000 (17:18 +0000)]
MFC r332087:

ifconf(): Always zero the whole struct ifreq.

The previous split of zeroing ifr_name and ifr_addr seperately is safe
on current architectures, but would be unsafe if pointers were larger
than 8 bytes. Combining the zeroing adds no real cost (a few
instructions) and makes the security property easier to verify.

Reviewed by: kib, emaste
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14912

6 years agoGC never enabled support for SIOCGADDRROM and SIOCGCHIPID.
brooks [Sun, 8 Apr 2018 16:59:39 +0000 (16:59 +0000)]
GC never enabled support for SIOCGADDRROM and SIOCGCHIPID.

When de(4) was imported in 1997 the world was not ready for these ioctls.
In over 20 years that hasn't changed so it seems safe to assume their
time will never come.

Reviewed by: imp, jhb
Approved by: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14889

6 years agoMFC r331797:
brooks [Sun, 8 Apr 2018 16:54:07 +0000 (16:54 +0000)]
MFC r331797:

Use an accessor function to access ifr_data.

This fixes 32-bit compat (no ioctl command defintions are required
as struct ifreq is the same size).

Reviewed by: kib
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14900

6 years agoMFC r331641, r331644, r332158
brooks [Sun, 8 Apr 2018 15:52:32 +0000 (15:52 +0000)]
MFC r331641, r331644, r332158

r331641:
Fix access to ifru_buffer on freebsd32.

Make all kernel accesses to ifru_buffer go via access functions
which take the process ABI into account and use an appropriate union
to access members in the correct place in struct ifreq.

Reviewed by: kib
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14846

r331644:
Fix a whitespace bug missed in refactoring prior to r331641.

MFC with: r331641

r332158:
Remove the thread argument from ifr_buffer_*() accessors.

They are always used in a context where curthread is the correct thread.
This makes them more similar to the ifr_data_get_ptr() accessor.

6 years agoMFC r331654, r331869
brooks [Sun, 8 Apr 2018 15:30:58 +0000 (15:30 +0000)]
MFC r331654, r331869

r331654:
Don't access userspace directly from the kernel in nxge(4).

Update to what the previous code seemed to be doing via the correct
interfaces.  Further issues exist in xge_ioctl_registers(), but this is
debugging code in a driver that has few users and they don't appear to
be crashes or leaks.

Reviewed by: jhb (prior version)
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14848

r331869:
Fix the build on arches with default unsigned char.  Capture the fubyte()
return value in an int as well as the char, and test the full int value
for fubyte() failure.

6 years agoMFC r327203:
tuexen [Sun, 8 Apr 2018 14:09:27 +0000 (14:09 +0000)]
MFC r327203:

Allow the first (and second) argument of sn_calloc() be a sum.
This fixes a bug reported in
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224103

PR: 224103

6 years agoMFC r327214:
tuexen [Sat, 7 Apr 2018 21:25:29 +0000 (21:25 +0000)]
MFC r327214:

Whitespace changes.

6 years agoMFC r327209:
tuexen [Sat, 7 Apr 2018 21:24:17 +0000 (21:24 +0000)]
MFC r327209:

Clarify that there is no break missing. While there, cleanup whitespaces.

6 years agoClarify that the break is not missing.
tuexen [Sat, 7 Apr 2018 21:22:29 +0000 (21:22 +0000)]
Clarify that the break is not missing.

CID: 1008198

6 years agoMFC r327205:
tuexen [Sat, 7 Apr 2018 21:12:16 +0000 (21:12 +0000)]
MFC r327205:

Fix an assignment. While there, do some whitespace cleanups.

CID: 1008936

6 years agoMFC r328081:
tuexen [Sat, 7 Apr 2018 21:09:51 +0000 (21:09 +0000)]
MFC r328081:

Add missing assignment to make sure non-first cmsgs are handled as such.

6 years agoMFC r328059:
tuexen [Sat, 7 Apr 2018 21:08:44 +0000 (21:08 +0000)]
MFC r328059:

Improve the printing of cmgs when the length is 0. Fix error handling.

6 years agoMFC r328058:
tuexen [Sat, 7 Apr 2018 21:07:47 +0000 (21:07 +0000)]
MFC r328058:

Using %p already prints "0x", so don't do it explicitly.

6 years agoMFC r328033:
tuexen [Sat, 7 Apr 2018 21:06:39 +0000 (21:06 +0000)]
MFC r328033:

Bump date, which I missed in r328014. Thanks to jhb@ for reporting.

6 years agoMFC r328015:
tuexen [Sat, 7 Apr 2018 21:05:39 +0000 (21:05 +0000)]
MFC r328015:

Decode msghdr argument of sendmsg() and recvmsg().

6 years agoMFC r328014:
tuexen [Sat, 7 Apr 2018 21:04:43 +0000 (21:04 +0000)]
MFC r328014:

Add support for decoding the nxt_flags, rcv_flags, and snd_flags of
SCTP level cmsgs.

6 years agoMFC r327995:
tuexen [Sat, 7 Apr 2018 21:03:46 +0000 (21:03 +0000)]
MFC r327995:

Add support for decoding the type of a cmsg.