]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoRemove google_accounts_manager from VM_RC_LIST in the GCE configuration
gjb [Thu, 22 Mar 2018 17:49:27 +0000 (17:49 +0000)]
Remove google_accounts_manager from VM_RC_LIST in the GCE configuration
file, no longer needed.

PR: 221714
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

6 years agoDrop any recursed taking of Giant once and for all at the top of
imp [Thu, 22 Mar 2018 15:34:37 +0000 (15:34 +0000)]
Drop any recursed taking of Giant once and for all at the top of
kern_reboot(). The shutdown path is now safe to run without Giant.

Discussed with: kib@
Sponsored by: Netflix

6 years agoEnter into the EFI environment before dereferencing the runtime services
andrew [Thu, 22 Mar 2018 15:32:57 +0000 (15:32 +0000)]
Enter into the EFI environment before dereferencing the runtime services
pointer. This may be within the EFI address space and not the FreeBSD
kernel address space.

X-MFC-With: r330868
Sponsored by: DARPA, AFRL

6 years agoIncrease the size of the endpoint buffers. They are double buffered so
andrew [Thu, 22 Mar 2018 15:24:26 +0000 (15:24 +0000)]
Increase the size of the endpoint buffers. They are double buffered so
need to be twice the size.

Sponsored by: DARPA, AFRL

6 years agoRevert r331298
imp [Thu, 22 Mar 2018 15:11:53 +0000 (15:11 +0000)]
Revert r331298

Normally, shutdown_nice() just signals init. However, sometimes it
calls kern_reboot directly. For that case, r331298 dropped the Giant
lock before calling it. This turns out to be incorrect for the more
common case where init exists and we just signal it. Restore the old
behavior. The direct call to kern_reboot() doesn't sync buffers to the
disk, so should work with Giant held, so we don't need to drop locks
here for that.

Noticed by: bde@
Sponsored by: Netflix

6 years agotftpd: misc Coverity cleanup in the tests
asomers [Thu, 22 Mar 2018 14:51:05 +0000 (14:51 +0000)]
tftpd: misc Coverity cleanup in the tests

A bunch of unchecked return values from open(2) and read(2)

Reported by: Coverity
CID: 138690013869111386926138692813869321386942
CID: 13869611386979
MFC after: 8 days
X-MFC-With: 330696

6 years agoThe pci_disable_device() function is also expected to clear the PCI
hselasky [Thu, 22 Mar 2018 13:30:35 +0000 (13:30 +0000)]
The pci_disable_device() function is also expected to clear the PCI
busmaster. This fixes LinuxKPI compliancy with Linux.

MFC after: 1 week
Sponsored by: Mellanox Technologies

6 years agoShare Linux errno table with libsysdecode
emaste [Thu, 22 Mar 2018 12:58:49 +0000 (12:58 +0000)]
Share Linux errno table with libsysdecode

Requested by: jhb
Reviewed by: jhb
Sponsored by: Turing Robotic Industries Inc.

6 years agoClear old MSIX IRQ numbers in the LinuxKPI.
hselasky [Thu, 22 Mar 2018 12:26:27 +0000 (12:26 +0000)]
Clear old MSIX IRQ numbers in the LinuxKPI.

When disabling the MSIX IRQ vectors for a PCI device through the
LinuxKPI, make sure any old MSIX IRQ numbers are no longer visible to
the linux_pci_find_irq_dev() function else IRQs can be requested from
the wrong PCI device.

MFC after: 1 week
Sponsored by: Mellanox Technologies

6 years agoPartially revert r328780
kevans [Thu, 22 Mar 2018 11:57:59 +0000 (11:57 +0000)]
Partially revert r328780

efi.4th was added to ObsoleteFiles and disconnected from the build, but not
removed from hte repo. We've since found a mild use for it that makes some
amount of sense, so partially revert r328780 and bring it back to life.

Reported by: many
X-MFC-With: r331326

6 years agoBump netstat.1's .Dd after r331347.
jtl [Thu, 22 Mar 2018 09:43:15 +0000 (09:43 +0000)]
Bump netstat.1's .Dd after r331347.

6 years agoAdd the "TCP Blackbox Recorder" which we discussed at the developer
jtl [Thu, 22 Mar 2018 09:40:08 +0000 (09:40 +0000)]
Add the "TCP Blackbox Recorder" which we discussed at the developer
summits at BSDCan and BSDCam in 2017.

The TCP Blackbox Recorder allows you to capture events on a TCP connection
in a ring buffer. It stores metadata with the event. It optionally stores
the TCP header associated with an event (if the event is associated with a
packet) and also optionally stores information on the sockets.

It supports setting a log ID on a TCP connection and using this to correlate
multiple connections that share a common log ID.

You can log connections in different modes. If you are doing a coordinated
test with a particular connection, you may tell the system to put it in
mode 4 (continuous dump). Or, if you just want to monitor for errors, you
can put it in mode 1 (ring buffer) and dump all the ring buffers associated
with the connection ID when we receive an error signal for that connection
ID. You can set a default mode that will be applied to a particular ratio
of incoming connections. You can also manually set a mode using a socket
option.

This commit includes only basic probes. rrs@ has added quite an abundance
of probes in his TCP development work. He plans to commit those soon.

There are user-space programs which we plan to commit as ports. These read
the data from the log device and output pcapng files, and then let you
analyze the data (and metadata) in the pcapng files.

Reviewed by: gnn (previous version)
Obtained from: Netflix, Inc.
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D11085

6 years agoFix build.
lwhsu [Thu, 22 Mar 2018 08:32:39 +0000 (08:32 +0000)]
Fix build.

Reviewed by: cem
Differential Revision: https://reviews.freebsd.org/D14793

6 years agojedec_dimm: Use correct string length when populating sc->slotid_str
rpokala [Thu, 22 Mar 2018 06:31:05 +0000 (06:31 +0000)]
jedec_dimm: Use correct string length when populating sc->slotid_str

Don't limit the copy to the size of the target string *pointer* (always
4 on 32-bit / 8 on 64-bit). Instead, just use strdup().

Reported by: Coverity
CID: 1386912
Reviewed by: cem, imp
MFC after: 1 week

6 years agoRedo r331328. We need to fix not only type but also format. While
glebius [Thu, 22 Mar 2018 05:26:27 +0000 (05:26 +0000)]
Redo r331328. We need to fix not only type but also format. While
here again notice that we are fixing regression from r331106.

6 years agoFix LINT-NOINET build initializing local to false. This is
glebius [Thu, 22 Mar 2018 05:07:57 +0000 (05:07 +0000)]
Fix LINT-NOINET build initializing local to false. This is
a dead code, since for NOINET build isipv6 is always true,
but this dead code makes it compilable.

Reported by: rpokala

6 years agocxgbe(4): Do not read MFG diags information from custom boards.
np [Thu, 22 Mar 2018 04:42:29 +0000 (04:42 +0000)]
cxgbe(4): Do not read MFG diags information from custom boards.

MFC after: 1 week
Sponsored by: Chelsio Communications

6 years agoforthloader: Don't break BIOS boots...
kevans [Thu, 22 Mar 2018 04:16:14 +0000 (04:16 +0000)]
forthloader: Don't break BIOS boots...

I thought I tested this scenario, but clearly I failed to. =(

BIOS boots won't have efi-autoresizecons, so trying to use it as a forth
word fails during include. Use evaluate on "efi-autoresizecons" as a string
instead to move any potential errors to runtime- safely after we've already
checked that we're booting UEFI.

Pointy hat to: me
Reported by: cy

6 years agocxgbe(4): Tunnel congestion drops on a port should be cleared when the
np [Thu, 22 Mar 2018 02:04:57 +0000 (02:04 +0000)]
cxgbe(4): Tunnel congestion drops on a port should be cleared when the
stats for that port are cleared.

MFC after: 1 week
Sponsored by: Chelsio Communications

6 years agoCorrect signedness bug in drm_modeset_ctl
emaste [Thu, 22 Mar 2018 01:00:55 +0000 (01:00 +0000)]
Correct signedness bug in drm_modeset_ctl

drm_modeset_ctl() takes a signed in from userland, does a boundscheck,
and then uses it to index into a structure and write to it.  The
boundscheck only checks upper bound, and never checks for nagative
values.  If the int coming from userland is negative [after conversion]
it will bypass the boundscheck, perform a negative index into an array
and write to it, causing memory corruption.

Note that this is in the "old" drm driver; this issue does not exist
in drm2.

Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Reviewed by: cem
MFC after: 1 day
Sponsored by: The FreeBSD Foundation

6 years agogetentropy(3): Fallback to kern.arandom sysctl on older kernels
cem [Wed, 21 Mar 2018 23:52:37 +0000 (23:52 +0000)]
getentropy(3): Fallback to kern.arandom sysctl on older kernels

On older kernels, when userspace program disables SIGSYS, catch ENOSYS and
emulate getrandom(2) syscall with the kern.arandom sysctl (via existing
arc4_sysctl wrapper).

Special care is taken to faithfully emulate EFAULT on NULL pointers, because
sysctl(3) as used by kern.arandom ignores NULL oldp.  (This was caught by
getentropy(3) ATF tests.)

Reported by: kib
Reviewed by: kib
Discussed with: delphij
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D14785

6 years agoFix kernel memory disclosure in drm_infobufs
emaste [Wed, 21 Mar 2018 23:51:14 +0000 (23:51 +0000)]
Fix kernel memory disclosure in drm_infobufs

drm_infobufs() has a structure on the stack, fills it out and copies it
to userland.  There are 2 elements in the struct that are not filled out
and left uninitialized.  This will leak uninitialized kernel stack data
to userland.

Submitted by: Domagoj Stolfa <ds815@cam.ac.uk>
Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com>
MFC after: 1 day
Security: Kernel memory disclosure (798)

6 years agoIf a jail parameter isn't found, try loading a related kernel module.
jamie [Wed, 21 Mar 2018 23:50:46 +0000 (23:50 +0000)]
If a jail parameter isn't found, try loading a related kernel module.

6 years agoApply r228478 (CTASSERT => _Static_assert()) to stand bootstrap.h
cem [Wed, 21 Mar 2018 23:46:26 +0000 (23:46 +0000)]
Apply r228478 (CTASSERT => _Static_assert()) to stand bootstrap.h

Reported by: GCC (it doesn't like the unused array)
Sponsored by: Dell EMC Isilon

6 years agoFix kernel memory disclosure in ibcs2_getdents
emaste [Wed, 21 Mar 2018 23:26:42 +0000 (23:26 +0000)]
Fix kernel memory disclosure in ibcs2_getdents

ibcs2_getdents() copies a dirent structure to userland.  The ibcs2
dirent structure contains a 2 byte pad element.  This element is never
initialized, but copied to userland none-the-less.

Note that ibcs2 has not built on HEAD since r302095.

Submitted by: Domagoj Stolfa <ds815@cam.ac.uk>
Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com>
MFC after: 3 days
Security: Kernel memory disclosure (803)

6 years agoFix sysctl types broken in r329612.
glebius [Wed, 21 Mar 2018 23:21:32 +0000 (23:21 +0000)]
Fix sysctl types broken in r329612.

6 years agoAdd ) missing from r330297
emaste [Wed, 21 Mar 2018 23:17:26 +0000 (23:17 +0000)]
Add ) missing from r330297

Sponsored by: The FreeBSD Foundation

6 years agoForth version of EFI autoresizing
kevans [Wed, 21 Mar 2018 22:01:51 +0000 (22:01 +0000)]
Forth version of EFI autoresizing

r331321 delegated autoresizing to an efi-autoresizecons command that
currently is expected to be done in forth/lua prior to drawing anything
useful.

Add the Forth version of the lua addition in r331321, hook efi.4th up to be
installed.

efiboot? was written by dteske@; anything outside of that may be blamed on
me.

6 years agoElide the object lock in the common case in vfs_vmio_unwire().
markj [Wed, 21 Mar 2018 21:15:43 +0000 (21:15 +0000)]
Elide the object lock in the common case in vfs_vmio_unwire().

The object lock was only needed when attempting to free B_DIRECT
buffer pages, and for testing for invalid pages (and freeing them
if so). Handle the latter by instead moving invalid pages near the head
of the inactive queue, where they will be reclaimed quickly.

Reviewed by: alc, kib, jeff
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D14778

6 years agoEnsure thread library is initialized in pthread_testcancel().
jhb [Wed, 21 Mar 2018 21:13:26 +0000 (21:13 +0000)]
Ensure thread library is initialized in pthread_testcancel().

Call _thr_check_init() before reading curthread in pthread_testcancel().

If a constructor in a library creates a semaphore via sem_init() and
then waits for it via sem_wait(), the program can core dump in
_pthread_testcancel() called from sem_wait().  This is because the
semaphore implementation lives in libc, so the library's constructors
can be run before libthr's constructors.

Reported by: arichardson
Reviewed by: kib
Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D14786

6 years agoThe net.inet.tcp.nolocaltimewait=1 optimization prevents local TCP connections
glebius [Wed, 21 Mar 2018 20:59:30 +0000 (20:59 +0000)]
The net.inet.tcp.nolocaltimewait=1 optimization prevents local TCP connections
from entering the TIME_WAIT state. However, it omits sending the ACK for the
FIN, which results in RST. This becomes a bigger deal if the sysctl
net.inet.tcp.blackhole is 2. In this case RST isn't send, so the other side of
the connection (also local) keeps retransmitting FINs.

To fix that in tcp_twstart() we will not call tcp_close() immediately. Instead
we will allocate a tcptw on stack and proceed to the end of the function all
the way to tcp_twrespond(), to generate the correct ACK, then we will drop the
last PCB reference.

While here, make a few tiny improvements:
- use bools for boolean variable
- staticize nolocaltimewait
- remove pointless acquisiton of socket lock

Reported by: jtl
Reviewed by: jtl
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D14697

6 years agoUEFI: Ditch console mode setting, choose optimal GOP mode later in boot
kevans [Wed, 21 Mar 2018 20:36:57 +0000 (20:36 +0000)]
UEFI: Ditch console mode setting, choose optimal GOP mode later in boot

boot1 is too early to be deciding a good resolution. Console modes don't map
cleanly/predictably to actual screen resolutions, and GOP does not reflect
the actual screen resolution after a console mode change. Rip it out.

Add an efi-autoresizecons command to loader to choose an optimal screen
resolution based on the current environment. We'll explicitly execute this
later, preferably before we draw anything of value but after we load config
and pick up any tunables we may need to decide where we're going.

This method also allows us to actually pass the correct framebuffer
information on to the kernel.

UGA autoresizing is not implemented because it doesn't have the kind of mode
enumeration that GOP does. If an interested person with relevant hardware
could get in contact, we can take a look at implementing UGA autoresize.

This effectively "fixes" the breakage caused by r327058, but doesn't
actually set the resolution correctly until the interpreter calls
efi-autoresizcons. The lualoader version of this has been included for
reference; the forth equivalent will follow.

Reviewed by: imp (with some hestitation), manu
Differential Revision: https://reviews.freebsd.org/D14788

6 years agolualoader: Use printc when we expect ANSI escape sequences
kevans [Wed, 21 Mar 2018 18:02:56 +0000 (18:02 +0000)]
lualoader: Use printc when we expect ANSI escape sequences

6 years agoDocument the limitations associated with using the audit syscalls
csjp [Wed, 21 Mar 2018 17:22:42 +0000 (17:22 +0000)]
Document the limitations associated with using the audit syscalls
from jailed process.  These might get implemented in jails in the
future, but for now they are not supported.

Discussed on:   freebsd-security@
Reviewed by:    brueffer@
MFC after:      2 weeks

6 years agoImport Blake2 algorithms (blake2b, blake2s) from libb2
cem [Wed, 21 Mar 2018 16:18:14 +0000 (16:18 +0000)]
Import Blake2 algorithms (blake2b, blake2s) from libb2

The upstream repository is on github BLAKE2/libb2.  Files landed in
sys/contrib/libb2 are the unmodified upstream files, except for one
difference:  secure_zero_memory's contents have been replaced with
explicit_bzero() only because the previous implementation broke powerpc
link.  Preferential use of explicit_bzero() is in progress upstream, so
it is anticipated we will be able to drop this diff in the future.

sys/crypto/blake2 contains the source files needed to port libb2 to our
build system, a wrapped (limited) variant of the algorithm to match the API
of our auth_transform softcrypto abstraction, incorporation into the Open
Crypto Framework (OCF) cryptosoft(4) driver, as well as an x86 SSE/AVX
accelerated OCF driver, blake2(4).

Optimized variants of blake2 are compiled for a number of x86 machines
(anything from SSE2 to AVX + XOP).  On those machines, FPU context will need
to be explicitly saved before using blake2(4)-provided algorithms directly.
Use via cryptodev / OCF saves FPU state automatically, and use via the
auth_transform softcrypto abstraction does not use FPU.

The intent of the OCF driver is mostly to enable testing in userspace via
/dev/crypto.  ATF tests are added with published KAT test vectors to
validate correctness.

Reviewed by: jhb, markj
Obtained from: github BLAKE2/libb2
Differential Revision: https://reviews.freebsd.org/D14662

6 years agocryptosoft(4): Zero plain hash contexts, too
cem [Wed, 21 Mar 2018 16:12:07 +0000 (16:12 +0000)]
cryptosoft(4): Zero plain hash contexts, too

An OCF-naive user program could use these primitives to implement HMAC, for
example.  This would make the freed context sensitive data.

Probably other bzeros in this file should be explicit_bzeros as well.
Future work.

Reviewed by: jhb, markj
Differential Revision: https://reviews.freebsd.org/D14662 (minor part of a larger work)

6 years agoUpdate copyright per Matthew Macy
shurd [Wed, 21 Mar 2018 15:57:36 +0000 (15:57 +0000)]
Update copyright per Matthew Macy

"Under my tutelage Nicole did 85% of the work. At the time it seemed
simplest for a number of reasons to put my copyright on it. I now consider
that to have been a mistake."

Submitted by: Matthew Macy <mmacy@mattmacy.io>
Reviewed by: shurd
Approved by: shurd
Differential Revision: https://reviews.freebsd.org/D14766

6 years agoIf the INP lock is uncontested, avoid taking a reference and jumping
jtl [Wed, 21 Mar 2018 15:54:46 +0000 (15:54 +0000)]
If the INP lock is uncontested, avoid taking a reference and jumping
through the lock-switching hoops.

A few of the INP lookup operations that lock INPs after the lookup do
so using this mechanism (to maintain lock ordering):

1. Lock lookup structure.
2. Find INP.
3. Acquire reference on INP.
4. Drop lock on lookup structure.
5. Acquire INP lock.
6. Drop reference on INP.

This change provides a slightly shorter path for cases where the INP
lock is uncontested:

1. Lock lookup structure.
2. Find INP.
3. Try to acquire the INP lock.
4. If successful, drop lock on lookup structure.

Of course, if the INP lock is contested, the functions will need to
revert to the previous way of switching locks safely.

This saves a few atomic operations when the INP lock is uncontested.

Discussed with: gallatin, rrs, rwatson
MFC after: 2 weeks
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D12911

6 years agoUse a table to find the endpoint configuration
andrew [Wed, 21 Mar 2018 15:17:54 +0000 (15:17 +0000)]
Use a table to find the endpoint configuration

On the Allwinner SoCs we need to set a custom endpoint configuration. To
allow for this use a table to store the configuration so the attachment
can override it.

Reviewed by: hselasky
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14783

6 years agolualoader: Clear up some possible naming confusion
kevans [Wed, 21 Mar 2018 15:09:47 +0000 (15:09 +0000)]
lualoader: Clear up some possible naming confusion

In the original lualoader project, 'escapef' and 'escapeb' were chosen for
'escape fg' and 'escape bg'. We've carried on this naming convention, and as
our use of attributes grow the likeliness of 'escapeb'/'resetb' being
confused upon glance for 'escape bold'/'reset bold' increases.

Fix this by renaming these four functions to {escape,reset}{fg,bg} rather
than {escape,reset}{f,b} for clarity.

Reported by: dteske

6 years agoMark psycho interrupts as MPSAFE. It's safe to do so now that we don't
imp [Wed, 21 Mar 2018 14:47:17 +0000 (14:47 +0000)]
Mark psycho interrupts as MPSAFE. It's safe to do so now that we don't
need Giant to call shutdown_nice().

6 years agoUnlock giant when calling shutdown_nice()
imp [Wed, 21 Mar 2018 14:47:12 +0000 (14:47 +0000)]
Unlock giant when calling shutdown_nice()

6 years agoThis is MPSAFE on this platform, so don't take Giant out while running
imp [Wed, 21 Mar 2018 14:47:08 +0000 (14:47 +0000)]
This is MPSAFE on this platform, so don't take Giant out while running
the callback.

6 years agoThese interrupts call shutdown_nice() which should be called Giant
imp [Wed, 21 Mar 2018 14:47:03 +0000 (14:47 +0000)]
These interrupts call shutdown_nice() which should be called Giant
unlocked. Rather than dropping it in the interrupt handler, mark these
handlers as MPSAFE.

6 years agobufshutdown is no longer called with Giant held, so there's no need to
imp [Wed, 21 Mar 2018 14:46:59 +0000 (14:46 +0000)]
bufshutdown is no longer called with Giant held, so there's no need to
drop or pickup Giant anymore. Remove that code and adjust comments.

6 years agoRemove Giant from init creation and vfs_mountroot.
imp [Wed, 21 Mar 2018 14:46:54 +0000 (14:46 +0000)]
Remove Giant from init creation and vfs_mountroot.

Sponsored by: Netflix
Discussed with: kib@, mckusick@
Differential Review: https://reviews.freebsd.org/D14712

6 years agoAdd new shared library -- libipt.
br [Wed, 21 Mar 2018 14:37:04 +0000 (14:37 +0000)]
Add new shared library -- libipt.

libipt is the Intel Processor Trace (Intel PT) packets decoder.

- Include libipt to amd64 build.
- Install libipt headers to /usr/include/libipt/

Sponsored by: DARPA, AFRL

6 years agoFollowing ports commit r465175, avoid fetch(1) to obtain
gjb [Wed, 21 Mar 2018 14:36:16 +0000 (14:36 +0000)]
Following ports commit r465175, avoid fetch(1) to obtain
overlays and DTB files for the RPI3.

Submitted by: manu
Sponsored by: The FreeBSD Foundation

6 years agoRevert r331273: "Release the "TUR" reference when clearing the TUR work flag. We...
imp [Wed, 21 Mar 2018 12:55:59 +0000 (12:55 +0000)]
Revert r331273: "Release the "TUR" reference when clearing the TUR work flag. We mostly"

It exposes other issues, so revert to the pervious state of known issues.

6 years agoMove sysinit and sysuninit linker sets in the data (writeable) section.
kib [Wed, 21 Mar 2018 10:26:39 +0000 (10:26 +0000)]
Move sysinit and sysuninit linker sets in the data (writeable) section.

Both sets are sorted in place, and with the introduction of read-only
permissions on the amd64 kernel text, the sorting override depended on
CR0.WP turned off.  Make it correct by moving the sets into writeable
part of the KVA, also fixing boot on machines where hand-off from BIOS
to OS occurs with CR0.WP set.

Based on submission by: Peter Lei <peter.lei@ieee.org>
MFC after: 1 week

6 years ago[bsd-family-tree] Announce NetBSD 7.1.2
eadler [Wed, 21 Mar 2018 09:07:01 +0000 (09:07 +0000)]
[bsd-family-tree] Announce NetBSD 7.1.2

MFC After: 3 days

6 years agoAppease GCC 4.2
cem [Wed, 21 Mar 2018 04:44:19 +0000 (04:44 +0000)]
Appease GCC 4.2

It mistakenly believes the 'static' keyword must come first.  Fix PPC,
Sparc64, and maybe MIPS world.  Fallout from r331279.

Reported by: tinderbox (results come slowly)

6 years agoAdd missed sys/limits.h include
cem [Wed, 21 Mar 2018 03:43:40 +0000 (03:43 +0000)]
Add missed sys/limits.h include

Apparently header pollution on x86 hid its absense.  Sorry, other arch
users.

Fix the missed header introduced in r331279.

Reported by: tinderbox

6 years agocore.lua(8): Update to reflect recently added function clearCachedKernels
kevans [Wed, 21 Mar 2018 03:16:14 +0000 (03:16 +0000)]
core.lua(8): Update to reflect recently added function clearCachedKernels

6 years agolualoader: Add primitive hook module, use it to untangle bogus reference
kevans [Wed, 21 Mar 2018 03:07:16 +0000 (03:07 +0000)]
lualoader: Add primitive hook module, use it to untangle bogus reference

See: comments in the hook module about intended usage, as well as the
introduced use for config.reloaded.

Use the newly introduced hook module to define a "config.reloaded" hook.
This is currently used to register core's clearKernelCache as a reload hook
to avoid a circular dependency and fix this functionality- it didn't
actually work out, and it isn't immediately obvious how it slipped into src.

Other hook types will be introduced into the core lualoader as useful hook
points are identified.

6 years agoRegenerate sysent files after r331279.
cem [Wed, 21 Mar 2018 01:17:01 +0000 (01:17 +0000)]
Regenerate sysent files after r331279.

6 years agoImplement getrandom(2) and getentropy(3)
cem [Wed, 21 Mar 2018 01:15:45 +0000 (01:15 +0000)]
Implement getrandom(2) and getentropy(3)

The general idea here is to provide userspace programs with well-defined
sources of entropy, in a fashion that doesn't require opening a new file
descriptor (ulimits) or accessing paths (/dev/urandom may be restricted
by chroot or capsicum).

getrandom(2) is the more general API, and comes from the Linux world.
Since our urandom and random devices are identical, the GRND_RANDOM flag
is ignored.

getentropy(3) is added as a compatibility shim for the OpenBSD API.

truss(1) support is included.

Tests for both system calls are provided.  Coverage is believed to be at
least as comprehensive as LTP getrandom(2) test coverage.  Additionally,
instructions for running the LTP tests directly against FreeBSD are provided
in the "Test Plan" section of the Differential revision linked below.  (They
pass, of course.)

PR: 194204
Reported by: David CARLIER <david.carlier AT hardenedbsd.org>
Discussed with: cperciva, delphij, jhb, markj
Relnotes: maybe
Differential Revision: https://reviews.freebsd.org/D14500

6 years agoRepresent boolean jail options as an array of structures containing the
jamie [Tue, 20 Mar 2018 23:08:42 +0000 (23:08 +0000)]
Represent boolean jail options as an array of structures containing the
flag and both the regular and "no" names, instead of two different string
arrays whose indices need to match the flag's bit position.  This makes
them similar to the say "jailsys" options are represented.

Loop through either kind of option array with a structure pointer rather
then an integer index.

6 years agoCorrect comment date in r331255
emaste [Tue, 20 Mar 2018 23:08:04 +0000 (23:08 +0000)]
Correct comment date in r331255

Reported by: jhb

6 years agoUse count(9) api for the bpf(4) statistics.
melifaro [Tue, 20 Mar 2018 22:57:06 +0000 (22:57 +0000)]
Use count(9) api for the bpf(4) statistics.

Currently each bfp descriptor uses u64 variables to maintain its counters.
On interfaces with high packet rate this leads to unnecessary contention
and inaccurate reporting.

PR: kern/205320
Reported by: elofu17 at hotmail.com
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D14726

6 years agoExtend the description of ALTQ to call it a system which is a framework in
sevan [Tue, 20 Mar 2018 22:41:26 +0000 (22:41 +0000)]
Extend the description of ALTQ to call it a system which is a framework in
altq(4) to match altq(9). This makes preserving the history section as the
author of ALTQ easier in the history section, rather than calling it a framework
in the description & a system in the history.
Add a history section to altq(4) and extend the history section in altq(9)

Approved by: bcr (mentor)
MFC after: 5 days
Differential Revision:  https://reviews.freebsd.org/D14774

6 years agoRelease the "TUR" reference when clearing the TUR work flag. We mostly
imp [Tue, 20 Mar 2018 22:07:45 +0000 (22:07 +0000)]
Release the "TUR" reference when clearing the TUR work flag. We mostly
do this right, except when there's no BP and we do a TUR by request.
In that case, we clear the flag, but don't release the reference,
leaking the reference on rare occasion.

PR: 226510
Sponsored by: Netflix

6 years agoAt this point iwmesg isn't initialized yet, so print pointer to lock
glebius [Tue, 20 Mar 2018 22:05:21 +0000 (22:05 +0000)]
At this point iwmesg isn't initialized yet, so print pointer to lock
rather than panic before panicing.

6 years agoPush down Giant one layer. In the days of yore, back when Penitums
imp [Tue, 20 Mar 2018 22:01:18 +0000 (22:01 +0000)]
Push down Giant one layer. In the days of yore, back when Penitums
were the new kids on the block and F00F hacks were all the rage, one
needed to take out Giant to do anything moderately complicated with
the VM, mappings and such. So the pccard / cardbus code held Giant for
the entire insertion or removal process.

Today, the VM is MP safe. The lock is only needed for dealing with
newbus things. Move locking and unlocking Giant to be only around
adding and probing devices in pccard and cardbus.

6 years agoFix whitespace issues in r330034. No functional changes.
glebius [Tue, 20 Mar 2018 22:00:58 +0000 (22:00 +0000)]
Fix whitespace issues in r330034. No functional changes.

6 years agoRemove reference to lint. We no longer support it, so exceptions for
imp [Tue, 20 Mar 2018 21:37:33 +0000 (21:37 +0000)]
Remove reference to lint. We no longer support it, so exceptions for
it are no longer relevant.

6 years agoRevert part of r331264: disable interrupts before disabling WP.
markj [Tue, 20 Mar 2018 21:36:35 +0000 (21:36 +0000)]
Revert part of r331264: disable interrupts before disabling WP.

We might otherwise be preempted, leaving WP disabled while another
thread runs on the CPU.

Reported by: kib
X-MFC with: r331264

6 years agoUpdate to include information about using SPDX-License-Identifier
imp [Tue, 20 Mar 2018 21:31:18 +0000 (21:31 +0000)]
Update to include information about using SPDX-License-Identifier
lines.

6 years agoDrop support for lint for cdefs.h.
imp [Tue, 20 Mar 2018 21:18:40 +0000 (21:18 +0000)]
Drop support for lint for cdefs.h.

6 years agoRemove obsolete lint support.
imp [Tue, 20 Mar 2018 21:17:48 +0000 (21:17 +0000)]
Remove obsolete lint support.

6 years agoMake use of the KPI added in r331252.
markj [Tue, 20 Mar 2018 21:16:26 +0000 (21:16 +0000)]
Make use of the KPI added in r331252.

MFC after: 2 weeks

6 years agoRestore close quote lost in r331254
emaste [Tue, 20 Mar 2018 21:04:47 +0000 (21:04 +0000)]
Restore close quote lost in r331254

6 years agoUse <stdarg.h> instead of <machine/stdarg.h> in userland.
jhb [Tue, 20 Mar 2018 21:00:45 +0000 (21:00 +0000)]
Use <stdarg.h> instead of <machine/stdarg.h> in userland.

<machine/stdarg.h> is a kernel-only header.  The standard header for
userland is <stdarg.h>.  Using the standard header in userland avoids
weird build errors when building with external compilers that include
their own stdarg.h header.

Reviewed by: arichardson, brooks, imp
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D14776

6 years agoRemove a lingering inaccuracy from mlock.2.
markj [Tue, 20 Mar 2018 20:45:47 +0000 (20:45 +0000)]
Remove a lingering inaccuracy from mlock.2.

User wirings of the same address range don't stack.

Noted by: Dan Nelson
MFC after: 3 days

6 years agolualoader: Use less atomic options for resetting colors/attributes
kevans [Tue, 20 Mar 2018 20:26:24 +0000 (20:26 +0000)]
lualoader: Use less atomic options for resetting colors/attributes

Noted by dteske:

CSI 1m ... CSI 22m
CSI 2m ... CSI 22m
CSI 4m ... CSI 24m
CSI 5m ... CSI 25m
CSI 7m ... CSI 27m
CSI 8m ... CSI 28m
CSI (30-37)m ... CSI 39m
CSI (40-47)m ... CSI 49m

- Provide resetf/resetb to match escapef/escapeb
- Use CSI 22m to undo a bold

This is a more reasonable approach than what was previously taken.

Reported by: dteske

6 years agoMove the CR0.WP manipulation KPI to x86.
kib [Tue, 20 Mar 2018 20:20:49 +0000 (20:20 +0000)]
Move the CR0.WP manipulation KPI to x86.

This should allow to avoid some #ifdefs in the common x86/ code.

Requested by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

6 years agolualoader: Reset attributes and color scheme with color.highlight()
kevans [Tue, 20 Mar 2018 20:05:11 +0000 (20:05 +0000)]
lualoader: Reset attributes and color scheme with color.highlight()

Previously, we sent a CSI 0m sequence to reset attributes, which also reset
the color scheme if the terminal defaults didn't match what we're expecting.
Go all-in and reset the color scheme, too, just in case.

Reported by: emaste

6 years agoMake linuxulator fn declaration match definition
emaste [Tue, 20 Mar 2018 19:28:52 +0000 (19:28 +0000)]
Make linuxulator fn declaration match definition

I accidentally swapped 'linux_fixup_elf' to 'linux_elf_fixup' in amd64's
declaration (only),  while bringing this change over from git and
encountering a conflict.

6 years agoRemove stale generated assym.s files after r331254
emaste [Tue, 20 Mar 2018 18:02:21 +0000 (18:02 +0000)]
Remove stale generated assym.s files after r331254

So that -DNO_CLEAN builds work.

This should be reverted after a sufficient transition period (perhaps 3
or 6 months).

Sponsored by: The FreeBSD Foundation

6 years agoRename assym.s to assym.inc
emaste [Tue, 20 Mar 2018 17:58:51 +0000 (17:58 +0000)]
Rename assym.s to assym.inc

assym is only to be included by other .s files, and should never
actually be assembled by itself.

Reviewed by: imp, bdrewery (earlier)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D14180

6 years agoDisable write protection around patching of XSAVE instruction in the
kib [Tue, 20 Mar 2018 17:47:29 +0000 (17:47 +0000)]
Disable write protection around patching of XSAVE instruction in the
context switch code.

Some BIOSes give control to the OS with CR0.WP already set, making the
kernel text read-only before cpu_startup().

Reported by: Peter Lei <peter.lei@ieee.org>
Reviewed by: jtl
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D14768

6 years agoProvide KPI for handling of rw/ro kernel text.
kib [Tue, 20 Mar 2018 17:43:50 +0000 (17:43 +0000)]
Provide KPI for handling of rw/ro kernel text.

This is a pure syntax patch to create an interface to enable and later
restore write access to the kernel text and other read-only mapped
regions.  It is in line with e.g. vm_fault_disable_pagefaults() by
allowing the nesting.

Discussed with: Peter Lei <peter.lei@ieee.org>
Reviewed by: jtl
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D14768

6 years agoSet the proper vnet in IPsec callback functions.
jhb [Tue, 20 Mar 2018 17:05:23 +0000 (17:05 +0000)]
Set the proper vnet in IPsec callback functions.

When using hardware crypto engines, the callback functions used to handle
an IPsec packet after it has been encrypted or decrypted can be invoked
asynchronously from a worker thread that is not associated with a vnet.
Extend 'struct xform_data' to include a vnet pointer and save the current
vnet in this new member when queueing crypto requests in IPsec.  In the
IPsec callback routines, use the new member to set the current vnet while
processing the modified packet.

This fixes a panic when using hardware offload such as ccr(4) with IPsec
after VIMAGE was enabled in GENERIC.

Reported by: Sony Arpita Das and Harsh Jain @ Chelsio
Reviewed by: bz
MFC after: 1 week
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D14763

6 years agoCheck for wrap-around in vm_phys_alloc_seg_contig().
kib [Tue, 20 Mar 2018 16:17:55 +0000 (16:17 +0000)]
Check for wrap-around in vm_phys_alloc_seg_contig().

It is possible to provide insane values for size in contigmalloc(9)
request, which usually not reaches the phys allocator due to failing
KVA allocation.  But with the forthcoming 4/4 i386, where 32bit
architecture has almost 4G KVA, contigmalloc(1G) is not unreasonable
outright and KVA might be available sometimes.

Then, the calculation of pa_end could wrap around, depending on the
physical address, and the checks in vm_phys_alloc_seg_contig() would
pass while the iteration in the loop after the 'done' label goes out
of the vm_page_array bounds.

Fix it by detecting the wrap.

Reported and tested by: pho
Reviewed by: alc, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D14767

6 years agoDrop KTR_CONTENTION.
markj [Tue, 20 Mar 2018 15:51:05 +0000 (15:51 +0000)]
Drop KTR_CONTENTION.

It is incomplete, has not been adopted in the other locking primitives,
and we have other means of measuring lock contention (lock_profiling,
lockstat, KTR_LOCK). Drop it to slightly de-clutter the mutex code and
free up a precious KTR class index.

Reviewed by: jhb, mjg
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D14771

6 years agoAdd support for MIPS to LLVM's libunwind.
jhb [Tue, 20 Mar 2018 15:44:17 +0000 (15:44 +0000)]
Add support for MIPS to LLVM's libunwind.

This is originally based on a patch from David Chisnall for soft-float
N64 but has since been updated to support O32, N32, and hard-float ABIs.
The soft-float O32, N32, and N64 support has been committed upstream.
The hard-float changes are still in review upstream.

Enable LLVM_LIBUNWIND on mips when building with a suitable (C+11-capable)
toolchain.  This has been tested with external GCC for all ABIs and
O32 and N64 with clang.

Reviewed by: emaste
Obtained from: CheriBSD (original N64 patch)
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D14701

6 years agoRemove the entry about loader.efi needing to be updated before the kernel.
andrew [Tue, 20 Mar 2018 13:39:41 +0000 (13:39 +0000)]
Remove the entry about loader.efi needing to be updated before the kernel.
The kernel now handles the situation it's warning against as of r331241.

Sponsored by: DARPA, AFRL

6 years agoCheck if the gettime runtime service is valid.
andrew [Tue, 20 Mar 2018 13:35:20 +0000 (13:35 +0000)]
Check if the gettime runtime service is valid.

The U-Boot efi runtime service expects us to set the address map before
calling any runtime services. It will then remap a few functions to their
runtime version. One of these is the gettime function. If we call into
this without having set a runtime map we get a page fault.

Add a check to see if this is valid in efi_init() so we don't try to use
the possibly invalid pointer.

Reviewed by: imp, kevans (both previous version)
X-MFC-With: r330868
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14759

6 years agoKill assert I shouldn't have committed
imp [Tue, 20 Mar 2018 13:14:10 +0000 (13:14 +0000)]
Kill assert I shouldn't have committed

6 years agoStarting LBA is a 64bit number, so use htole64 instead of htole32. The
imp [Tue, 20 Mar 2018 03:37:14 +0000 (03:37 +0000)]
Starting LBA is a 64bit number, so use htole64 instead of htole32. The
latter casts the LBA to a 32-bit number before assigning it to the 64
bit structure entity. This works fine on the first 2TB of TRIMs, but
terrible beyond that due to trucation.

Also, add an assert to make sure we don't end too many DSM TRIM
entries in one request.

Sponsored by: Netflix

6 years agoMake kern.cam.nda.num_trim tunable to limit the number of BIO_DELETE
imp [Tue, 20 Mar 2018 03:37:09 +0000 (03:37 +0000)]
Make kern.cam.nda.num_trim tunable to limit the number of BIO_DELETE
requests that we'll collapse into one DSM_TRIM. By default it is a
256, which is the max that will fit into a 4k page.

Sponsored by: Netflix

6 years agoRemove some redundant MPSAFE flags.
imp [Tue, 20 Mar 2018 03:37:04 +0000 (03:37 +0000)]
Remove some redundant MPSAFE flags.

This was pointed out in a code review I'm having trouble finding right
now, but go ahead and eliminate these.

Sponsored by: Netfix

6 years agoNote: this isn't a general thing. It only affects u-boot-based arm64
imp [Tue, 20 Mar 2018 03:36:51 +0000 (03:36 +0000)]
Note: this isn't a general thing. It only affects u-boot-based arm64
systems. Make sure the note says that specific case only. Also,
provide a recipe to do it.

Sponsored by: Netflix

6 years agoRationalize license text on Linuxolator files
emaste [Tue, 20 Mar 2018 02:50:11 +0000 (02:50 +0000)]
Rationalize license text on Linuxolator files

i386 linux.h missed in r330239.

Approved by: sos
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

6 years agoCast through uintptr_t to narrow the buf domain pointer on 32-bit archs
jhibbits [Tue, 20 Mar 2018 02:01:30 +0000 (02:01 +0000)]
Cast through uintptr_t to narrow the buf domain pointer on 32-bit archs

arg2 is an intmax_t, which on 32-bit architectures is 64 bits, wider than a
pointer.  When &bdomain[i] is added to arg2 it widens from uintptr_t to
intmax_t, then gcc whines when it gets cast to a pointer.  Casting through
uintptr_t silences this warning.

6 years agoAdd /boot/overlays to ObsoleteFiles
kevans [Tue, 20 Mar 2018 01:33:04 +0000 (01:33 +0000)]
Add /boot/overlays to ObsoleteFiles

It has been replaced by /boot/dtb/overlays. We haven't yet populated it with
any of our own overlays, so no further damage from here.

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

6 years agoFix powerpc Book-E build post-331018/331048.
jhibbits [Tue, 20 Mar 2018 01:07:22 +0000 (01:07 +0000)]
Fix powerpc Book-E build post-331018/331048.

pagedaemon_wakeup() was moved from vm_pageout.h to vm_pagequeue.h.

6 years agoblacklist: Fix minor memory leak in configuration parsing error case
cem [Tue, 20 Mar 2018 00:16:24 +0000 (00:16 +0000)]
blacklist: Fix minor memory leak in configuration parsing error case

Ordinarily, the continue clause of the for-loop would free 'line.'  In this
case we instead return early, missing the free.  Add an explicit free to
avoid the leak.

Reported by: Coverity
Sponsored by: Dell EMC Isilon

6 years ago[ofw] fix errneous checks for OF_finddevice(9) return value
gonzo [Tue, 20 Mar 2018 00:03:49 +0000 (00:03 +0000)]
[ofw] fix errneous checks for OF_finddevice(9) return value

OF_finddevices returns ((phandle_t)-1) in case of failure. Some code
in existing drivers checked return value to be equal to 0 or
less/equal to 0 which is also wrong because phandle_t is unsigned
type. Most of these checks were for negative cases that were never
triggered so trhere was no impact on functionality.

Reviewed by: nwhitehorn
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D14645

6 years agoUpdate mpr(4) driver from v15 to v18 from Broadcom site.
mav [Mon, 19 Mar 2018 23:21:45 +0000 (23:21 +0000)]
Update mpr(4) driver from v15 to v18 from Broadcom site.

Version 16 is just a number bump, since we already had those changes.

Version 17 introduces new AdapterType value, that allows new user-space
tools from Broadcom to differentiate adapter generations 3 and 3.5.

Version 18 updates headers and adds SAS_DEVICE_DISCOVERY_ERROR reporting.

MFC after: 2 weeks