]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoFix gcc warning about shadowed global.
kib [Fri, 5 Apr 2019 20:12:19 +0000 (20:12 +0000)]
Fix gcc warning about shadowed global.

Sponsored by: Mellanox Technologies
MFC after: 2 weeks

5 years agoEmergency fix for NULL deref in xo_xml_leader_len
phil [Fri, 5 Apr 2019 19:42:54 +0000 (19:42 +0000)]
Emergency fix for NULL deref in xo_xml_leader_len

5 years agoImplement devctl(8) command 'reset', using DEV_RESET /dev/devctl2 ioctl.
kib [Fri, 5 Apr 2019 19:32:26 +0000 (19:32 +0000)]
Implement devctl(8) command 'reset', using DEV_RESET /dev/devctl2 ioctl.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agoAdd DEV_RESET /dev/devctl2 ioctl.
kib [Fri, 5 Apr 2019 19:31:26 +0000 (19:31 +0000)]
Add DEV_RESET /dev/devctl2 ioctl.

It performs BUS_RESET_CHILD() on the parental bus and the specified
device.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agoRemove single-use DEV_RESET() macro.
kib [Fri, 5 Apr 2019 19:27:51 +0000 (19:27 +0000)]
Remove single-use DEV_RESET() macro.

It conflicts with the sys/bus.h DEV_XXX namespace.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agoImplement resets for PCI buses and PCIe bridges.
kib [Fri, 5 Apr 2019 19:25:26 +0000 (19:25 +0000)]
Implement resets for PCI buses and PCIe bridges.

For PCI device (i.e. child of a PCI bus), reset tries FLR if
implemented and worked, and falls to power reset otherwise.

For PCIe bus (child of a PCIe bridge or root port), reset
disables PCIe link and then re-trains it, performing what is known as
link-level reset.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agoProvide newbus infrastructure for initiating device reset.
kib [Fri, 5 Apr 2019 18:09:22 +0000 (18:09 +0000)]
Provide newbus infrastructure for initiating device reset.

The methods BUS_RESET_PREPARE(), BUS_RESET(), and BUS_RESET_POST()
should be implemented by bus which can provide reset to a device.  The
methods are described in inline doxygen comments.

Code only provides BUS_RESET_PREPARE() and BUS_RESET_POST() helpers
instead of default implementation, because actual bus needs to handle
device state around reset, while helpers provide the other half of
typical prepare/post code.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agoAdd __BEGIN_DECLS/__END_DECLS braces to libdevctl header.
kib [Fri, 5 Apr 2019 17:54:31 +0000 (17:54 +0000)]
Add __BEGIN_DECLS/__END_DECLS braces to libdevctl header.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agobhyve: Fix NVMe data structure copy to guest
chuck [Fri, 5 Apr 2019 16:54:20 +0000 (16:54 +0000)]
bhyve: Fix NVMe data structure copy to guest

bhyve's NVMe emulation was transferring Identify data back to the guest
incorrectly causing memory corruptions. These corruptions resulted in
core dumps and other system level errors in the guest.

In their simplest form, NVMe Physical Region Page (PRP) values in
commands indicate which physical pages to use for data transfer. The
first PRP value is not required to be page aligned but does not cross a
page boundary. The second PRP value must be page aligned, does not cross
a page boundary, and need not be contiguous with PRP1.

The code was copying Identify data past the end of PRP1. This happens to
work if PRP1 and PRP2 are physically contiguous but will corrupt guest
memory in unpredictable ways if they are not.

Fix is to copy the Identify data back to the guest piecewise (i.e. for
each PRP entry). Also fix a similarly wrong problem when copying back
Log page data.

Reviewed by: imp (mentor), araujo, jhb, rgrimes, bhyve
Approved by: imp (mentor), bhyve (jhb)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19695

5 years agobhyve: Fix NVMe BAR size calculation
chuck [Fri, 5 Apr 2019 16:54:16 +0000 (16:54 +0000)]
bhyve: Fix NVMe BAR size calculation

The NVMe specification defines bits 13:4 of BAR0 as Reserved (i.e. 0x0).
Most drivers do not enforce this, but the Windows NVMe driver does and
will refuse to start the device (i.e. error 10) if any of these bits are
set.

The current BAR size calculation tries to minimize the amount of memory
the device reserves by scaling the BAR size by the maximum number of
queues supported by the device. But unless the device supports a large
number of queue pairs (over 1536), it will reserve too little memory.

The fix is to allocate a minimum of 16K bytes for BAR0.

Tested on Windows Server 2016 and 2019

Reviewed by: imp (mentor), araujo, jhb, bhyve
Approved by: imp (mentor), bhyve (jhb)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19676

5 years agovn_vmap_seekhole(): align running offset to the block boundary.
kib [Fri, 5 Apr 2019 16:14:16 +0000 (16:14 +0000)]
vn_vmap_seekhole(): align running offset to the block boundary.

Otherwise we might miss the last iteration where EOF appears below
unaligned noff.

Reported and reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D19811

5 years agoFix mis-merge.
kib [Fri, 5 Apr 2019 16:12:35 +0000 (16:12 +0000)]
Fix mis-merge.

Amusingly, it is nop.

Noted by: trasz
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
X-MFC-rev: r345702

5 years agotwsi: Use config_intrhook_oneshot instead of config_intrhook_establish
manu [Fri, 5 Apr 2019 15:53:27 +0000 (15:53 +0000)]
twsi: Use config_intrhook_oneshot instead of config_intrhook_establish

Suggested by: ian
MFC after: 1 month
X-MFC-With: 345948

5 years agotwsi: Add interrupt mode
manu [Fri, 5 Apr 2019 14:44:23 +0000 (14:44 +0000)]
twsi: Add interrupt mode

Add the ability to use interrupts for i2c message.
We still use polling for early boot i2c transfer (for PMIC
for example) but as soon as interrupts are available use them.
On Allwinner SoC >A20 is seems that polling mode is broken for some
reason, this is now fixed by using interrupt mode.
For Allwinner also fix the frequency calculation, the one in the code
was for when the APB frequency is at 48Mhz while it is at 24Mhz on most
(all?) Allwinner SoCs. We now support both cases.

While here add more debug info when it's compiled in.

Tested On: A20, H3, A64
MFC after: 1 month

5 years agoRemove another instance of All Rights Reserved.
imp [Fri, 5 Apr 2019 14:27:48 +0000 (14:27 +0000)]
Remove another instance of All Rights Reserved.

Remove the phrase from boilerplate copyright we stick on vers.c when
we can't find the template file. In practice, this won't change a
thing, except for the case of compiling the kernel standalone w/o the
rest of a tree on a system that doesn't have
/usr/share/examples/etc/bsd-copyright installed.

5 years agoAdd mpr, mps, mpt to NOTES file
imp [Fri, 5 Apr 2019 02:54:02 +0000 (02:54 +0000)]
Add mpr, mps, mpt to NOTES file

Add these to all the architectures that these are in the GENERIC
kernel.

5 years agoFix build.
delphij [Fri, 5 Apr 2019 02:37:10 +0000 (02:37 +0000)]
Fix build.

MFC after: 2 weeks
X-MFC-With: r345900

5 years agoImplement checking of `.' and `..' entries of subdirectory.
delphij [Fri, 5 Apr 2019 02:21:16 +0000 (02:21 +0000)]
Implement checking of `.' and `..' entries of subdirectory.

Reviewed by: pfg
Obtained from: Android https://android.googlesource.com/platform/external/fsck_msdos/+/b6ee08aadb580341a4d80943741b80de16a88b5d%5E%21/
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19824

5 years agoAdd an entry to UPDATING for r345895, which affects the use of nfsuserd daemons
rmacklem [Thu, 4 Apr 2019 23:40:30 +0000 (23:40 +0000)]
Add an entry to UPDATING for r345895, which affects the use of nfsuserd daemons
built from head sources between July 6, 2017 and Aug. 22, 2018.

5 years agoRestore lfcl when LOSTDIR's chain was corrupted and overwritten
delphij [Thu, 4 Apr 2019 23:34:03 +0000 (23:34 +0000)]
Restore lfcl when LOSTDIR's chain was corrupted and overwritten
with invalid value.

Obtained from: Android https://android.googlesource.com/platform/external/fsck_msdos/+/4d6d6f8a3674ad67f970e2ae908d34f64e4854cf%5E%21/
MFC after: 2 weeks

5 years agosort(1): randomcoll: Skip the memory allocation entirely
cem [Thu, 4 Apr 2019 23:32:27 +0000 (23:32 +0000)]
sort(1): randomcoll: Skip the memory allocation entirely

There's no reason to order based on strcmp of ASCII digests instead of
memcmp of the raw digests.

While here, remove collision fallback.  If you collide two MD5s, they're
probably the same string anyway.  If robustness against MD5 collisions is
desired, maybe we shouldn't use MD5.

None of the behavior of sort -R is specified by POSIX, so we're free to
implement this however we like.  E.g., using a 128-bit counter and block cipher
to generate unique indices for each line of input.

PR: 230792 (2/many)
Relnotes: This will change the sort order for a given dataset with a
given seed.  Other similarly breaking changes are planned.
Sponsored by: Dell EMC Isilon

5 years agoRevert r320698, since the related userland changes were reverted by r338192.
rmacklem [Thu, 4 Apr 2019 23:30:27 +0000 (23:30 +0000)]
Revert r320698, since the related userland changes were reverted by r338192.

r338192 reverted the changes to nfsuserd so that it could use an AF_LOCAL
socket, since it resulted in a vnode locking panic().
Post r338192 nfsuserd daemons use the old AF_INET socket for upcalls and
do not use these kernel changes.
I left them in for a while, so that nfsuserd daemons built from head sources
between r320757 (Jul. 6, 2017) and r338192 (Aug. 22, 2018) would need them
by default.
This only affects head, since the changes were never MFC'd.
I will add an UPDATING entry, since an nfsuserd daemon built from head
sources between r320757 and r338192 will not run unless the "-use-udpsock"
option is specified. (This command line option is only in the affected
revisions of the nfsuserd daemon.)

I suspect few will be affected by this, since most who run systems built
from head sources (not stable or releases) will have rebuilt their nfsuserd
daemon from sources post r338192 (Aug. 22, 2018)

This is being reverted in preparation for an update to include AF_INET6
support to the code.

5 years agoRestore the ability of checking and fixing next free
delphij [Thu, 4 Apr 2019 23:16:36 +0000 (23:16 +0000)]
Restore the ability of checking and fixing next free
cluster in FSINFO that was lost in r203872.

Obtained from: NetBSD
MFC after: 2 weeks

5 years agoAdd requiered programs (cc and c++) for some lib/atf regression tests
olivier [Thu, 4 Apr 2019 20:34:17 +0000 (20:34 +0000)]
Add requiered programs (cc and c++) for some lib/atf regression tests

PR: 236889
Reviewed by: ngie
Approved by: emaste (on IRC)
MFC after: 1 month
Sponsored by: Netflix

5 years agosort(1): randomcoll: Don't sort on ENOMEM
cem [Thu, 4 Apr 2019 20:27:13 +0000 (20:27 +0000)]
sort(1): randomcoll: Don't sort on ENOMEM

PR: 230792 (1/many)
Sponsored by: Dell EMC Isilon

5 years agoif_muge: use NULL not 0 for DRIVER_MODULE pointer args
emaste [Thu, 4 Apr 2019 19:59:31 +0000 (19:59 +0000)]
if_muge: use NULL not 0 for DRIVER_MODULE pointer args

Sponsored by: The FreeBSD Foundation

5 years agoUse IN_foo() macros from sys/netinet/in.h inplace of handcrafted code
rgrimes [Thu, 4 Apr 2019 19:01:13 +0000 (19:01 +0000)]
Use IN_foo() macros from sys/netinet/in.h inplace of handcrafted code

There are a few places that use hand crafted versions of the macros
from sys/netinet/in.h making it difficult to actually alter the
values in use by these macros.  Correct that by replacing handcrafted
code with proper macro usage.

Reviewed by: karels, kristof
Approved by: bde (mentor)
MFC after: 3 weeks
Sponsored by: John Gilmore
Differential Revision: https://reviews.freebsd.org/D19317

5 years agoRewrite intro(4) man page.
ygy [Thu, 4 Apr 2019 18:52:03 +0000 (18:52 +0000)]
Rewrite intro(4) man page.

- Remove issues that no longer apply thanks to devfs
- Add language pointing out devfs's role and referencing its config
- Add a "historical notes" section and move discussion of block vs character devs to it, including pointing out the removal of block devs
- Modernize some examples

MFC after: 1 week
PR: 236970
Submitted by: andrew@tao173.riddles.org.uk
Reviewed by: 0mp
Differential Revision: https://reviews.freebsd.org/D19799

5 years agostrings: capsicumize it
oshogbo [Thu, 4 Apr 2019 16:32:27 +0000 (16:32 +0000)]
strings: capsicumize it

Reviewed by: cem
Discussed with: emaste
Differential Revision: https://reviews.freebsd.org/D18038

5 years agoAdd cap_fileargs.h to -legacy if needed.
oshogbo [Thu, 4 Apr 2019 04:14:20 +0000 (04:14 +0000)]
Add cap_fileargs.h to -legacy if needed.

Reviewed by: arichardson
Differential Revision: https://reviews.freebsd.org/D19685

5 years agoFix malloc stats for the RPCSEC_GSS server code when DEBUG is enabled.
rmacklem [Thu, 4 Apr 2019 01:23:06 +0000 (01:23 +0000)]
Fix malloc stats for the RPCSEC_GSS server code when DEBUG is enabled.

The code enabled when "DEBUG" is defined uses mem_alloc(), which is a
malloc(.., M_RPC, M_WAITOK | M_ZERO), but then calls gss_release_buffer()
which does a free(.., M_GSSAPI) to free the memory.
This patch fixes the problem by replacing mem_alloc() with a
malloc(.., M_GSSAPI, M_WAITOK | M_ZERO).
This bug affects almost no one, since the sources are not normally built
with "DEBUG" defined.

Submitted by: peter@ifm.liu.se
MFC after: 2 weeks

5 years agoReplace read_random(9) with more appropriate arc4rand(9) KPIs
cem [Thu, 4 Apr 2019 01:02:50 +0000 (01:02 +0000)]
Replace read_random(9) with more appropriate arc4rand(9) KPIs

Reviewed by: ae, delphij
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19760

5 years agoImplement tests for online expansion:
pjd [Thu, 4 Apr 2019 00:05:36 +0000 (00:05 +0000)]
Implement tests for online expansion:
- init, init -R
- onetime, onetime -R
- 512 and 4k sectors
- encryption only
- encryption and authentication
- configure -r/-R for detached providers
- configure -r/-R for attached providers
- all keys allocated (10, 20 and 30MB provider sizes)
- keys allocated on demand (10, 20 and 30PB provider sizes)
- reading and writing to provider after expansion (10-30MB only)
- checking if metadata in old location is cleared.

Obtained from: Fudo Security

5 years agoUpdate configure tests after addition of the online expansion.
pjd [Wed, 3 Apr 2019 23:58:58 +0000 (23:58 +0000)]
Update configure tests after addition of the online expansion.

Obtained from: Fudo Security

5 years agoImplement automatic online expansion of GELI providers - if the underlying
pjd [Wed, 3 Apr 2019 23:57:37 +0000 (23:57 +0000)]
Implement automatic online expansion of GELI providers - if the underlying
provider grows, GELI will expand automatically and will move the metadata
to the new location of the last sector.

This functionality is turned on by default. It can be turned off with the
-R flag, but it is not recommended - if the underlying provider grows and
automatic expansion is turned off, it won't be possible to attach this
provider again, as the metadata is no longer located in the last sector.

If the automatic expansion is turned off and the underlying provider grows,
GELI will only log a message with the previous size of the provider, so
recovery can be easier.

Obtained from: Fudo Security

5 years ago- Add missing -T (notrim) option to the label subcommand.
pjd [Wed, 3 Apr 2019 23:50:52 +0000 (23:50 +0000)]
- Add missing -T (notrim) option to the label subcommand.
- Add missing -T option in the onetime subcommand comment.

Obtained from: Fudo Security

5 years agoImport libxo-1.0.2
phil [Wed, 3 Apr 2019 21:55:39 +0000 (21:55 +0000)]
Import libxo-1.0.2

from 1.0.0:
    Add "continuation" flag, to allow multiple "xo" invocations in a single line of output (#58)
    Add --top-wrap to make top-level JSON wrappers
    Add --{open,close}-{list,instace} options
    Add xo_xml_leader(), to detect use of some bogus XML tags. It's still bad form, but it's a little safer now
    Avoid call to xo_write before xo_flush, since the latter calls the former
    Check return code from xo_flush_h properly (<0) (FreeBSD Bug 236935)
    For JSON output, avoid newline before a container's close brace (#62)
    Merge branch 'text_only' of https://github.com/zvr/libxo into zvr-text_only
    Use XO_USE_INT_RETURN_CODES, not USE_INT_RETURN_CODES
    add docs for --continuation
    add docs for --not-first
    call xo_state_set_flags before values and close containers; add XOIF_MADE_OUTPUT flag to track state; make proper empty JSON objects in xo_finish
    color_map code has to be #ifdef'd out, since the struct definition
    correct xo_flush_func_t (doesn't use xo_ssize_t)
    make depth change for --top-wrap only for JSON
    fix to handle --top-wrap in "xo" by being more consistent with handling trailing newlines
    fix to handle text-only version #64 (from zvr)
    fix xo_buf_has_room for round up to the next XO_BUFSIZ, not just add XO_BUFSIZ to the size (FreeBSD Bug 236937)
    update docs for new "xo" options
    update functions to use xo_ssize_t
    update test cases
from 1.0.1:
    Add EINTEGRITY to .pot files under test/gettext/ (fix from FreeBSD)
from 1.0.2:
    handle failure from xo_vnsprintf; don't add -1 to "rc"

PR: 236937, 236935
Submitted by: phil
Reported by: Alfonso S. Siciliano <alfix86@gmail.com>
MFC after: 2 weeks

5 years agoAdd support for cross-building cloudware images.
cperciva [Wed, 3 Apr 2019 21:54:47 +0000 (21:54 +0000)]
Add support for cross-building cloudware images.

If MACHINE_ARCH doesn't match TARGET_ARCH, and we're not in the special
case of building i386 images on an amd64 host, we need to pull in the
qemu-user-static package; this allows us to run some commands inside
the VM disk image chroot, most notably to install packages.

Reviewed by: gjb
MFC after: 2 weeks
Sponsored by: FreeBSD/EC2 patreon (https://www.patreon.com/cperciva)

5 years agoTag libxo 1.0.2
phil [Wed, 3 Apr 2019 21:48:09 +0000 (21:48 +0000)]
Tag libxo 1.0.2

5 years agoImport libxo 1.0.2
phil [Wed, 3 Apr 2019 21:47:19 +0000 (21:47 +0000)]
Import libxo 1.0.2

5 years agocpsw: use `phy-handle` in FDT to find PHY address
emaste [Wed, 3 Apr 2019 21:01:53 +0000 (21:01 +0000)]
cpsw: use `phy-handle` in FDT to find PHY address

In r337703 DTS files were updated to Linux 4.18, including Linux commit
4d8b032d3c03f4e9788a18bbb51b10e6c9e8a56b which removed the `phy_id`
property from am335x-bone-common (as the property was deprecated).

Use `phy-handle` via fdt_get_phyaddr, keeping the existing code as a
fallback for old DTBs.

PR: 236624
Submitted by: manu, Gerald Aryeetey <aryeeteygerald_rogers.com>
Reported by: Gerald Aryeetey
Reviewed by: manu
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19814

5 years agorctl: fix sysctl kern.racct.enable use after r341182
mjg [Wed, 3 Apr 2019 20:37:14 +0000 (20:37 +0000)]
rctl: fix sysctl kern.racct.enable use after r341182

The value was changed from int to bool. Since the new type
is smaller, the rest of the variable in the caller was left
unitialized.

PR: 236714
Reported by: trasz
Diagnosed by: markj
Sponsored by: The FreeBSD Foundation

5 years agoUndo my previous erroneous commit changing the tcp_output kassert.
rrs [Wed, 3 Apr 2019 19:35:07 +0000 (19:35 +0000)]
Undo my previous erroneous commit changing the tcp_output kassert.
Hmm now the question is where did the tcp_log_id change go :o

5 years agoFix typos in r345849.
mav [Wed, 3 Apr 2019 18:35:13 +0000 (18:35 +0000)]
Fix typos in r345849.

MFC after: 1 week

5 years agoList few more ATA commands.
mav [Wed, 3 Apr 2019 18:27:54 +0000 (18:27 +0000)]
List few more ATA commands.

MFC after: 1 week

5 years agolibbe(3): Add a serial to the generated snapshot names
kevans [Wed, 3 Apr 2019 17:04:38 +0000 (17:04 +0000)]
libbe(3): Add a serial to the generated snapshot names

To use bectl in an example, when one creates a new boot environment with
either `bectl create <be>` or `bectl create -e <otherbe> <be>`, libbe will
take a snapshot of the original boot environment to clone. Previously, this
used %F-%T date format as the snapshot name, but this has some limitations-
attempting to create multiple boot environments in quick succession may
collide if done within the same second.

Tack a serial onto it to reduce the chances of a collision... we could still
collide if multiple processes/threads are creating boot environments at the
same time, but this is likely not a big concern as this has only been
reported as occurring in freebsd-ci setup.

MFC after: 3 days

5 years agomsdosfs: zero tail of the last block on truncation for VREG vnodes as well.
kib [Wed, 3 Apr 2019 17:02:18 +0000 (17:02 +0000)]
msdosfs: zero tail of the last block on truncation for VREG vnodes as well.

Despite the call to vtruncbuf() from detrunc(), which results in
zeroing part of the partial page after EOF, there still is a
possibility to retain the stale data which is revived on file
enlargement.  If the filesystem block size is greater than the page
size, partial block might keep other after-EOF pages wired and they
get reused then.  Fix it by zeroing whole part of the partial buffer
after EOF, not relying on vnode_pager_setsize().

PR: 236977
Reported by: asomers
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agobectl.8: Bump date after r345845
0mp [Wed, 3 Apr 2019 13:59:35 +0000 (13:59 +0000)]
bectl.8: Bump date after r345845

Approved by: kevans

5 years agobectl.8: Clean up & clarify the create subcommand
0mp [Wed, 3 Apr 2019 13:46:43 +0000 (13:46 +0000)]
bectl.8: Clean up & clarify the create subcommand

- Improve formatting
- Use consistent variable names
- Improve the description of the create subcommand (1)

PR: 235850 (1)
Submitted by: kevans (1)
Reported by: ler (1)
Reviewed by: kevans
Approved by: src (kevans)
Differential Revision: https://reviews.freebsd.org/D19666

5 years agoFollow the declared behaviour that specifies server string format in
ae [Wed, 3 Apr 2019 12:47:49 +0000 (12:47 +0000)]
Follow the declared behaviour that specifies server string format in
bsnmpclient(3).

snmp_parse_server() function accepts string where some fields can be
omitted: [trans::][community@][server][:port]

"trans" field can be "udp", "udp6", "dgram" and "stream".
"community" can be empty string, if it is omitted, the default value
will be used. For read_community it is "public", for write_comminity
it is "private". "server" field can be hostname, IPv4 address or IPv6
address. IPv6 address should be specified in brackets "[]".
If port is omitted, the default value "snmp" will be used for "udp"
and "udp6" transports. So, now for bsnmpget(1) and bsnmwalk(1) it is
not required to specify all fields in argument of '-s' option. E.g.

  # bsnmpget -s 127.1 sysName.0
  # bsnmpget -s "udp::127.1" sysName.0
  # bsnmpget -s "udp::public@127.1" sysName.0
  # bsnmpget -s "udp::public@127.1:161" sysName.0
  # bsnmpget -s "udp::[::1]" sysName.0
  # bsnmpget -s "udp6::[::1]" sysName.0
  # bsnmpget -s "[fe80::1%lo0]" sysName.0

PR: 236664
Reported by: olivier
MFC after: 1 month

5 years agoAdd a cv_wait to the TPM2.0 harvesting function
mw [Wed, 3 Apr 2019 08:22:58 +0000 (08:22 +0000)]
Add a cv_wait to the TPM2.0 harvesting function

Harvesting has to compete for the TPM chip with userspace.
Before this change the callout could hijack an unread buffer
causing a userspace call to the TPM to fail.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: delphij
Obtained from: Semihalf
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D19712

5 years agoAssert that q can't be NULL. 'empty' is always non-NULL when DIREMPTY
delphij [Wed, 3 Apr 2019 07:09:28 +0000 (07:09 +0000)]
Assert that q can't be NULL.  'empty' is always non-NULL when DIREMPTY
is set earlier.

MFC after: 1 month

5 years agopowerpc: Allow emulating optional FPU instructions on CPUs with an FPU
jhibbits [Wed, 3 Apr 2019 04:01:08 +0000 (04:01 +0000)]
powerpc: Allow emulating optional FPU instructions on CPUs with an FPU

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

MFC after: 1 week
MFC with: r345829

5 years agoCreate kernel module to parse Veriexec manifest based on envs
mw [Wed, 3 Apr 2019 03:57:37 +0000 (03:57 +0000)]
Create kernel module to parse Veriexec manifest based on envs

The current approach of injecting manifest into mac_veriexec is to
verify the integrity of it in userspace (veriexec (8)) and pass its
entries into kernel using a char device (/dev/veriexec).
This requires verifying root partition integrity in loader,
for example by using memory disk and checking its hash.
Otherwise if rootfs is compromised an attacker could inject their own data.

This patch introduces an option to parse manifest in kernel based on envs.
The loader sets manifest path and digest.
EVENTHANDLER is used to launch the module right after the rootfs is mounted.
It has to be done this way, since one might want to verify integrity of the init file.
This means that manifest is required to be present on the root partition.
Note that the envs have to be set right before boot to make sure that no one can spoof them.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: sjg
Obtained from: Semihalf
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D19281

5 years agopowerpc: Apply r178139 from sparc64 to powerpc's fpu_sqrt
jhibbits [Wed, 3 Apr 2019 03:54:30 +0000 (03:54 +0000)]
powerpc: Apply r178139 from sparc64 to powerpc's fpu_sqrt

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

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

MFC after: 1 week

5 years agoAdd a comment to the r345818 patch to explain why cl_refs is initialized to 2.
rmacklem [Wed, 3 Apr 2019 03:50:16 +0000 (03:50 +0000)]
Add a comment to the r345818 patch to explain why cl_refs is initialized to 2.

PR: 235582
MFC after: 2 weeks

5 years agoFix a race in the RPCSEC_GSS server code that caused crashes.
rmacklem [Tue, 2 Apr 2019 23:51:08 +0000 (23:51 +0000)]
Fix a race in the RPCSEC_GSS server code that caused crashes.

When a new client structure was allocated, it was added to the list
so that it was visible to other threads before the expiry time was
initialized, with only a single reference count.
The caller would increment the reference count, but it was possible
for another thread to decrement the reference count to zero and free
the structure before the caller incremented the reference count.
This could occur because the expiry time was still set to zero when
the new client structure was inserted in the list and the list was
unlocked.

This patch fixes the race by initializing the reference count to two
and initializing all fields, including the expiry time, before inserting
it in the list.

Tested by: peter@ifm.liu.se
PR: 235582
MFC after: 2 weeks

5 years agoBuild NVMe CAM transport unrelated to NVMe SIM.
mav [Tue, 2 Apr 2019 20:27:56 +0000 (20:27 +0000)]
Build NVMe CAM transport unrelated to NVMe SIM.

Before this I suppose it was impossible load CAM-based NVMe as module.
Plus this appeared to be needed to build r345815 without NVMe driver.

MFC after: 2 weeks

5 years agoCorrect SMC definition in asmc(4) man page.
ygy [Tue, 2 Apr 2019 20:03:03 +0000 (20:03 +0000)]
Correct SMC definition in asmc(4) man page.

MFC after: 3 days
PR: 236954
Submitted by: fbsdbugs4@sentry.org

5 years agoMake cam_error_print() decode NVMe commands.
mav [Tue, 2 Apr 2019 19:37:52 +0000 (19:37 +0000)]
Make cam_error_print() decode NVMe commands.

MFC after: 2 weeks

5 years agoioat(4) should use bus_dma(9) for the operation source and destination
tychon [Tue, 2 Apr 2019 19:08:06 +0000 (19:08 +0000)]
ioat(4) should use bus_dma(9) for the operation source and destination
addresses

Reviewed by: cem
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19725

5 years agoioatcontrol(8) could exercise 8k-aligned copy with page-break, crc and
tychon [Tue, 2 Apr 2019 19:06:25 +0000 (19:06 +0000)]
ioatcontrol(8) could exercise 8k-aligned copy with page-break, crc and
crc-copy modes.

Reviewed by: cem
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19780

5 years agoDMAR driver assumes all physical addresses are backed by a fully
tychon [Tue, 2 Apr 2019 18:50:49 +0000 (18:50 +0000)]
DMAR driver assumes all physical addresses are backed by a fully
initialized struct vm_page.

Reviewed by: kib
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19753

5 years agocxgbe(4): Add a flag to indicate that bits in interrupt cause but not in
np [Tue, 2 Apr 2019 18:50:33 +0000 (18:50 +0000)]
cxgbe(4): Add a flag to indicate that bits in interrupt cause but not in
interrupt enable are not fatal.

The firmware sets up all the interrupt enables based on run time
configuration, which means the information in the enables is more
accurate than what's compiled into the driver.  This change also allows
the fatal bits to be updated without any changes in the driver in some
cases.

MFC after: 1 week
Sponsored by: Chelsio Communications

5 years agoFix regression in top(1) after r344381, causing informational messages
dim [Tue, 2 Apr 2019 18:01:54 +0000 (18:01 +0000)]
Fix regression in top(1) after r344381, causing informational messages
to no longer be displayed.  This was because the reimplementation of
setup_buffer() did not copy the previous contents into any reallocated
buffer.

Reported by: James Wright <james.wright@jigsawdezign.com>
PR: 236947
MFC after: 3 days

5 years agoPull in r357362 from upstream clang trunk (by David Chisnall):
dim [Tue, 2 Apr 2019 17:51:28 +0000 (17:51 +0000)]
Pull in r357362 from upstream clang trunk (by David Chisnall):

  [objc-gnustep] Use .init_array not .ctors when requested.

  This doesn't make a difference most of the time but FreeBSD/ARM
  doesn't run anything in the .ctors array.

This should help with updating the libobjc2 port for armv7.

Requested by: theraven
Upstream PR: https://github.com/gnustep/libobjc2/issues/83
MFC after: 3 days

5 years agoUnify SCSI_STATUS_BUSY retry handling with other cases.
mav [Tue, 2 Apr 2019 14:46:10 +0000 (14:46 +0000)]
Unify SCSI_STATUS_BUSY retry handling with other cases.

 - Do not retry if periph was invalidated.
 - Do not decrement retry_count if already zero.
 - Report action_string when applicable.

MFC after: 2 weeks

5 years agosystat -zarc to display disk activities like -vm
mr [Tue, 2 Apr 2019 14:01:03 +0000 (14:01 +0000)]
systat -zarc to display disk activities like -vm

PR: 213310
Submitted by: ota
MFH: 4 weeks
Differential Revision: https://reviews.freebsd.org/D18726

5 years agotmpfs: plug holes on rw->ro mount update.
kib [Tue, 2 Apr 2019 13:59:04 +0000 (13:59 +0000)]
tmpfs: plug holes on rw->ro mount update.

In particular:
- suspend the mount around vflush() to avoid new writes come after the
  vnode is processed;
- flush pending metadata updates (mostly node times);
- remap all rw mappings of files from the mount into ro.

It is not clear to me how to handle writeable mappings on rw->ro for
tmpfs best.  Other filesystems, which use vnode vm object, call
vgone() on vnodes with writers, which sets the vm object type to
OBJT_DEAD, and keep the resident pages and installed ptes as is.  In
particular, the existing mappings continue to work as far as
application only accesses resident pages, but changes are not flushed
to file.

For tmpfs the vm object of VREG vnodes also serves as the data pages
container, giving single copy of the mapped pages, so it cannot be set
to OBJT_DEAD.  Alternatives for making rw mappings ro could be either
invalidating them at all, or marking as CoW.

Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19737

5 years agotmpfs: ignore tmpfs_set_status() if mount point is read-only.
kib [Tue, 2 Apr 2019 13:49:32 +0000 (13:49 +0000)]
tmpfs: ignore tmpfs_set_status() if mount point is read-only.

In particular, this fixes atimes still changing for ro tmpfs.
tmpfs_set_status() gains tmpfs_mount * argument.

Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19737

5 years agoBlock creation of the new nodes for read-only tmpfs mounts.
kib [Tue, 2 Apr 2019 13:41:26 +0000 (13:41 +0000)]
Block creation of the new nodes for read-only tmpfs mounts.

Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19737

5 years agoCreate 64bit mibII counters for all interfaces.
ae [Tue, 2 Apr 2019 13:38:00 +0000 (13:38 +0000)]
Create 64bit mibII counters for all interfaces.

PR: 157015
Obtained from: Yandex LLC
MFC after: 1 month

5 years agoAdd IPv6 transport for bsnmp.
ae [Tue, 2 Apr 2019 12:50:01 +0000 (12:50 +0000)]
Add IPv6 transport for bsnmp.

This patch adds a new table begemotSnmpdTransInetTable that uses the
InetAddressType textual convention and can be used to create listening
ports for IPv4, IPv6, zoned IPv6 and based on DNS names. It also supports
future extension beyond UDP by adding a protocol identifier to the table
index. In order to support this gensnmptree had to be modified.

Submitted by:   harti
MFC after:      1 month
Relnotes:       yes
Differential Revision:  https://reviews.freebsd.org/D16654

5 years agoo Grab the number of devices supported by PLIC from FDT.
br [Tue, 2 Apr 2019 12:02:35 +0000 (12:02 +0000)]
o Grab the number of devices supported by PLIC from FDT.
o Fix bug in PLIC_ENABLE macro when irq >= 32.

Tested on the real hardware, which is HiFive Unleashed board.

Thanks to SiFive, Inc. for the board provided.

Reviewed by: markj
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D19775

5 years agoipmi: Fixes for ipmi_opal(powernv)
jhibbits [Tue, 2 Apr 2019 04:12:06 +0000 (04:12 +0000)]
ipmi: Fixes for ipmi_opal(powernv)

* Crank the OPAL state machine during the receive loop, to make sure the
  pollers are executed
* Add a proper detach function, so the module can be unloaded and reloaded
  at runtime.

It still doesn't reliably work 100% of the time on POWER9, and it appears
timing and/or cache related.  It may work on POWER8 now.

MFC after: 2 weeks

5 years agopowernv: Port OPAL asynchronous framework to use the new message framework
jhibbits [Tue, 2 Apr 2019 04:02:57 +0000 (04:02 +0000)]
powernv: Port OPAL asynchronous framework to use the new message framework

Since OPAL_GET_MSG does not discriminate between message types, asynchronous
completion events may be received in the OPAL_GET_MSG call, which dequeues
them from the list, thus preventing OPAL_CHECK_ASYNC_COMPLETION from
succeeding.  Handle this case by integrating with the messaging framework.

5 years agopowerpc/powernv: Add OPAL heartbeat thread
jhibbits [Tue, 2 Apr 2019 04:00:01 +0000 (04:00 +0000)]
powerpc/powernv: Add OPAL heartbeat thread

Summary:
OPAL needs to be kicked periodically in order for the firmware to make
progress on its tasks.  To do so, create a heartbeat thread to perform this task
every N milliseconds, defined by the device tree.  This task is also a central
location to handle all messages received from OPAL.

Reviewed By: luporl
Differential Revision: https://reviews.freebsd.org/D19743

5 years agoIntegrate capsicum-test into the FreeBSD test suite
ngie [Mon, 1 Apr 2019 21:24:50 +0000 (21:24 +0000)]
Integrate capsicum-test into the FreeBSD test suite

This change takes capsicum-test from upstream and applies some local changes to make the
tests work on FreeBSD when executed via Kyua.

The local modifications are as follows:
1. Make `OpenatTest.WithFlag` pass with the new dot-dot lookup behavior in FreeBSD 12.x+.
2. capsicum-test references a set of helper binaries: `mini-me`, `mini-me.noexec`, and
   `mini-me.setuid`, as part of the execve/fexecve tests, via execve, fexecve, and open.
   It achieves this upstream by assuming `mini-me*` is in the current directory, however,
   in order for Kyua to execute `capsicum-test`, it needs to provide a full path to
   `mini-me*`. In order to achieve this, I made `capsicum-test` cache the executable's
   path from argv[0] in main(..) and use the cached value to compute the path to
   `mini-me*` as part of the execve/fexecve testcases.
3. The capsicum-test test suite assumes that it's always being run on CAPABILITIES enabled
   kernels. However, there's a chance that the test will be run on a host without a
   CAPABILITIES enabled kernel, so we must check for the support before running the tests.
   The way to achieve this is to add the relevant `feature_present("security_capabilities")`
   check to SetupEnvironment::SetUp() and skip the tests when the support is not available.
   While here, add a check for `kern.trap_enotcap` being enabled. As noted by markj@ in
   https://github.com/google/capsicum-test/issues/23, this sysctl being enabled can trigger
   non-deterministic failures. Therefore, the tests should be skipped if this sysctl is
   enabled.

All local changes have been submitted to the capsicum-test project
(https://github.com/google/capsicum-test) and are in various stages of review.
Please see the following pull requests for more details:
1. https://github.com/google/capsicum-test/pull/35
2. https://github.com/google/capsicum-test/pull/41
3. https://github.com/google/capsicum-test/pull/42

Reviewed by: asomers
Discussed with: emaste, markj
Approved by: emaste (mentor)
MFC after: 2 months
Differential Revision: https://reviews.freebsd.org/D19758

5 years agoFix gdb/kgdb build under WITH_PIE
emaste [Mon, 1 Apr 2019 19:19:51 +0000 (19:19 +0000)]
Fix gdb/kgdb build under WITH_PIE

Explicitly specified bare .a libraries need ${PIE_SUFFIX}.

Reported by: David E. Cross, on twitter
Sponsored by: The FreeBSD Foundation

5 years agoDevices behind downstream bridges should still get DMAR protection.
tychon [Mon, 1 Apr 2019 19:08:05 +0000 (19:08 +0000)]
Devices behind downstream bridges should still get DMAR protection.

Reviewed by: kib
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19717

5 years agoRefactor error handling
kibab [Mon, 1 Apr 2019 18:54:15 +0000 (18:54 +0000)]
Refactor error handling

There is some code duplication in error handling paths in a few functions.
Create a function for printing such errors in human-readable way and get rid
of duplicates.

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

5 years agoUse information about max data size that the controller is able to operate
kibab [Mon, 1 Apr 2019 18:49:39 +0000 (18:49 +0000)]
Use information about max data size that the controller is able to operate

Using DFLTPHYS/MAXPHYS is not always OK, instead make it possible for the
controller driver to provide maximum data size to MMCCAM, and use it there.

The old stack already does this.

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

5 years agoImport proof-of-concept for handling `GTEST_SKIP()` in `Environment::SetUp`
ngie [Mon, 1 Apr 2019 18:07:48 +0000 (18:07 +0000)]
Import proof-of-concept for handling `GTEST_SKIP()` in `Environment::SetUp`

Per the upstream pull-request [1]:

```
  gtest prior to this change would completely ignore `GTEST_SKIP()` if
  called in `Environment::SetUp()`, instead of bailing out early, unlike
  `Test::SetUp()`, which would cause the tests themselves to be skipped.
  The only way (prior to this change) to skip the tests would be to
  trigger a fatal error via `GTEST_FAIL()`.

  Desirable behavior, in this case, when dealing with
  `Environment::SetUp()` is to check for prerequisites on a system
  (example, kernel supports a particular featureset, e.g., capsicum), and
  skip the tests. The alternatives prior to this change would be
  undesirable:

  - Failing sends the wrong message to the test user, as the result of the
    tests is indeterminate, not failed.
  - Having to add per-test class abstractions that override `SetUp()` to
    test for the capsicum feature set, then skip all of the tests in their
    respective SetUp fixtures, would be a lot of human and computational
    work; checking for the feature would need to be done for all of the
    tests, instead of once for all of the tests.

  For those reasons, making `Environment::SetUp()` handle `GTEST_SKIP()`,
  by not executing the testcases, is the most desirable solution.

  In order to properly diagnose what happened when running the tests if
  they are skipped, print out the diagnostics in an ad hoc manner.

  Update the documentation to note this change and integrate a new test,
  gtest_skip_in_environment_setup_test, into the test suite.

  This change addresses #2189.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
```

The goal with my merging in this change is to avoid requiring extensive
refactoring/retesting of test suites when ensuring prerequisites are met,
e.g., checking for a CAPABILITIES-enabled kernel before running capsicum-test
(see D19758 for more details).

The proof-of-concept is being imported before accepted by the upstream
project due to the fact that the upstream project is undergoing a potential
development freeze and the maintainers aren't responding to my PR.

1. https://github.com/google/googletest/pull/2203

Reported by: asomers (https://github.com/google/googletest/issues/2189)
Reviewed by: asomers
Approved by: emaste (mentor)
MFC after: 2 months
Differential Revision: https://reviews.freebsd.org/D19765

5 years agolibbe: Fix zfs_is_mounted check w/ snapshots
kevans [Mon, 1 Apr 2019 17:44:20 +0000 (17:44 +0000)]
libbe: Fix zfs_is_mounted check w/ snapshots

'be_destroy' can destroy a boot environment (by name) or a given snapshot.
If the target to be destroyed is a dataset, check if it's mounted. We don't
want to check if the origin dataset is mounted when destroying a snapshot.

PR: 236043
Submitted by: Rob Fairbanks <rob.fx907 gmail com>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19650

5 years agoFix and simplify code by using ATF_REQUIRE_FEATURE macro
olivier [Mon, 1 Apr 2019 14:21:32 +0000 (14:21 +0000)]
Fix and simplify code by using ATF_REQUIRE_FEATURE macro

PR: 236857
Reviewed by: asomers, ngie
Approved by: emaste
MFC after:  1 month
Sponsored by: Netflix

5 years agoCorrect a port number assignment.
ae [Mon, 1 Apr 2019 12:14:45 +0000 (12:14 +0000)]
Correct a port number assignment.

PR: 236930
MFC after: 1 week

5 years agoWhen using the force option to shut down a memory-disk device,
mckusick [Sun, 31 Mar 2019 21:34:58 +0000 (21:34 +0000)]
When using the force option to shut down a memory-disk device,
I/O operations already in its queue were not being properly drained.
The GEOM framework does the queue draining, but the device driver
needs to wait for the draining to happen. The waiting is done by
adding a g_md_providergone() function to wait for the I/O operations
to finish up.

It is likely that every GEOM provider that implements orphaning
attached GEOM consumers needs to use the "providergone" mechanism
for this same reason, but some of them do not do so. Apparently
Kenneth Merry (ken@) added the drain for just such races, but he
missed adding it to some of the device drivers that needed it.

Submitted by: Chuck Silvers
Reviewed by:  imp
Tested by:    Chuck Silvers
MFC after:    1 week
Sponsored by: Netflix

5 years agoImprove debugging options in bcm2835_sdhci.c
bz [Sun, 31 Mar 2019 19:27:44 +0000 (19:27 +0000)]
Improve debugging options in bcm2835_sdhci.c

Similar to bcm2835_sdhost.c add a TUNABLE and SYSCTL to selectively
turn on debugging printfs if debugging is turned on at compile time.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Reviewed by: gonzo, andrew
Differential Revision: https://reviews.freebsd.org/D19745

5 years agorun(4): properly set F_DATAPAD radiotap flag if frame has padding between
avos [Sun, 31 Mar 2019 14:18:02 +0000 (14:18 +0000)]
run(4): properly set F_DATAPAD radiotap flag if frame has padding between
frame header and data.

This will fix 'Mysterious OLPC stuff' for received frames and wrong
CCMP / TKIP / data decoding for transmitted frames in net/wireshark
dissector.

While here, drop unneeded comment - net80211 handles padding requirements
for Tx & Rx without driver adjustment.

Tested with D-Link DWA-140 rev B3, STA mode.

MFC after: 1 week

5 years agorun(4): do not clear PROTECTED bit if frame was not decrypted by NIC.
avos [Sun, 31 Mar 2019 13:41:20 +0000 (13:41 +0000)]
run(4): do not clear PROTECTED bit if frame was not decrypted by NIC.

Tested with D-Link DWA-140 rev B3, STA / MONITOR modes.

MFC after: 1 week

5 years agouath(4), urtw(4): restart driver if device does not respond after Tx request
avos [Sun, 31 Mar 2019 09:52:36 +0000 (09:52 +0000)]
uath(4), urtw(4): restart driver if device does not respond after Tx request

MFC after: 1 week

5 years agorandom(4): Attempt to persist entropy promptly
cem [Sun, 31 Mar 2019 04:57:50 +0000 (04:57 +0000)]
random(4): Attempt to persist entropy promptly

The goal of saving entropy in Fortuna is two-fold: (1) to provide early
availability of the random device (unblocking) on next boot; and (2), to
have known, high-quality entropy available for that initial seed.  We know
it is high quality because it's output taken from Fortuna.

The FS&K paper makes it clear that Fortuna unblocks when enough bits have
been input that the output //may// be safely seeded.  But they emphasize
that the quality of various entropy sources is unknown, and a saved entropy
file is essential for both availability and ensuring initial
unpredictability.

In FreeBSD we persist entropy using two mechanisms:

1. The /etc/rc.d/random shutdown() function, which is used for ordinary
   shutdowns and reboots; and,

2. A cron job that runs every dozen minutes or so to persist new entropy, in
   case the system suffers from power loss or a crash (bypassing the
   ordinary shutdown path).

Filesystems are free to cache dirty data indefinitely, with arbitrary flush
policy.  Fsync must be used to ensure the data is persisted, especially for
the cron job save-entropy, whose entire goal is power loss and crash safe
entropy persistence.

Ordinary shutdown may not need the fsync because unmount should flush out
the dirty entropy file shortly afterwards.  But it is always possible power
loss or crash occurs during the short window after rc.d/random shutdown runs
and before the filesystem is unmounted, so the additional fsync there seems
harmless.

PR: 230876
Reviewed by: delphij, markj, markm
Approved by: secteam (delphij)
Differential Revision: https://reviews.freebsd.org/D19742

5 years agofreebsd32: fix padding of computed control message length for recvmsg()
jah [Sat, 30 Mar 2019 23:43:58 +0000 (23:43 +0000)]
freebsd32: fix padding of computed control message length for recvmsg()

Each control message region must be aligned on a 4-byte boundary on 32-bit
architectures. The 32-bit compat shim for recvmsg() gets the actual layout
right, but doesn't pad the payload length when computing msg_controllen for
the output message header. If a control message contains an unaligned
payload, such as the 1-byte TTL field in the example attached to PR 236737,
this can produce control message payload boundaries that extend beyond
the boundary reported by msg_controllen.

PR: 236737
Reported by: Yuval Pavel Zholkover <paulzhol@gmail.com>
Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19768

5 years agoDo not perform DAD on stf(4) interfaces.
markj [Sat, 30 Mar 2019 18:00:44 +0000 (18:00 +0000)]
Do not perform DAD on stf(4) interfaces.

stf(4) interfaces are not multicast-capable so they can't perform DAD.
They also did not set IFF_DRV_RUNNING when an address was assigned, so
the logic in nd6_timer() would periodically flag such an address as
tentative, resulting in interface flapping.

Fix the problem by setting IFF_DRV_RUNNING when an address is assigned,
and do some related cleanup:
- In in6if_do_dad(), remove a redundant check for !UP || !RUNNING.
  There is only one caller in the tree, and it only looks at whether
  the return value is non-zero.
- Have in6if_do_dad() return false if the interface is not
  multicast-capable.
- Set ND6_IFF_NO_DAD when an address is assigned to an stf(4) interface
  and the interface goes UP as a result. Note that this is not
  sufficient to fix the problem because the new address is marked as
  tentative and DAD is started before in6_ifattach() is called.
  However, setting no_dad is formally correct.
- Change nd6_timer() to not flag addresses as tentative if no_dad is
  set.

This is based on a patch from Viktor Dukhovni.

Reported by: Viktor Dukhovni <ietf-dane@dukhovni.org>
Reviewed by: ae
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19751

5 years agoAllow programs to set `NO_SHARED` on a per-PROG basis
ngie [Sat, 30 Mar 2019 17:23:15 +0000 (17:23 +0000)]
Allow programs to set `NO_SHARED` on a per-PROG basis

This is particularly useful when installing programs for tests that need to be
linked statically, e.g., mini-me from capsicum-test, which is linked statically
to avoid the dynamic library lookup in the upstream project.

Reviewed by: emaste
Approved by: emaste (mentor)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D19756

5 years agoFix branding after r345661.
kib [Sat, 30 Mar 2019 16:58:51 +0000 (16:58 +0000)]
Fix branding after r345661.

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

Reported by: andreast
Sponsored by: The FreeBSD Foundation
MFC after: 12 days (together with r345661)

5 years agourtw(4): export TSF timestamp for received frames via radiotap
avos [Sat, 30 Mar 2019 09:24:06 +0000 (09:24 +0000)]
urtw(4): export TSF timestamp for received frames via radiotap

Tested with Netgear WG111 v3 (RTL8187B), STA mode.

MFC after: 1 week

5 years agoIf the autoexpand pool property is turned on and vdev is healthy try to
pjd [Sat, 30 Mar 2019 07:29:20 +0000 (07:29 +0000)]
If the autoexpand pool property is turned on and vdev is healthy try to
expand the pool automatically when we detect underlying GEOM provider
size change.

Obtained from: Fudo Security
Tested in: AWS

5 years agoIntroduce new event SIZECHANGE within GEOM system to inform about GEOM
pjd [Sat, 30 Mar 2019 07:24:34 +0000 (07:24 +0000)]
Introduce new event SIZECHANGE within GEOM system to inform about GEOM
providers mediasize changes.

While here, use GEOM nomenclature to describe providers instead of calling
them device nodes.

Obtained from: Fudo Security
Tested in: AWS

5 years agoImplement support for online disk capacity changes.
pjd [Sat, 30 Mar 2019 07:20:28 +0000 (07:20 +0000)]
Implement support for online disk capacity changes.

Obtained from: Fudo Security
Tested in: AWS