]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agofusefs: don't leak memory of unsent operations on unmount
asomers [Fri, 28 Jun 2019 18:48:02 +0000 (18:48 +0000)]
fusefs: don't leak memory of unsent operations on unmount

Sponsored by: The FreeBSD Foundation

4 years ago[skip ci] update copyright headers in fusefs files
asomers [Fri, 28 Jun 2019 04:18:10 +0000 (04:18 +0000)]
[skip ci] update copyright headers in fusefs files

Sponsored by: The FreeBSD Foundation

4 years agoMFHead @349476
asomers [Thu, 27 Jun 2019 23:50:54 +0000 (23:50 +0000)]
MFHead @349476

Sponsored by: The FreeBSD Foundation

4 years agoAdd non-blocking trylock variants for the rangelock functions.
rmacklem [Thu, 27 Jun 2019 23:10:40 +0000 (23:10 +0000)]
Add non-blocking trylock variants for the rangelock functions.

A future patch that will add a Linux compatible copy_file_range(2) syscall
needs to be able to lock the byte ranges of two files concurrently.
To do this without a risk of deadlock, a non-blocking variant of
vn_rangelock_rlock() called vn_rangelock_tryrlock() was needed.
This patch adds this, along with vn_rangelock_trywlock(), in order to
do this.
The patch also adds a couple of comments, that I hope clarify how the
algorithm used in kern_rangelock.c works.

Reviewed by: kib, asomers (previous version)
Differential Revision: https://reviews.freebsd.org/D20645

4 years agoFix comment in sofree() to reference sbdestroy().
jhb [Thu, 27 Jun 2019 22:50:11 +0000 (22:50 +0000)]
Fix comment in sofree() to reference sbdestroy().

r160875 added sbdestroy() as a wrapper around sbrelease_internal to be
called from sofree(), yet the comment added in the same revision to
sofree() still mentions sbrelease_internal().

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20488

4 years agoReject attempts to register a TCP stack being unloaded.
jhb [Thu, 27 Jun 2019 22:34:05 +0000 (22:34 +0000)]
Reject attempts to register a TCP stack being unloaded.

Reviewed by: gallatin
MFC after: 2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20617

4 years agofusefs: fix a memory leak regarding FUSE_INTERRUPT
asomers [Thu, 27 Jun 2019 22:24:56 +0000 (22:24 +0000)]
fusefs: fix a memory leak regarding FUSE_INTERRUPT

We were leaking the fuse ticket if the original operation completed before
the daemon received the INTERRUPT operation.  Fixing this was easier than I
expected.

Sponsored by: The FreeBSD Foundation

4 years agoFollow r349460 to complete removing "flags" in struct gpiobus_ivar
lwhsu [Thu, 27 Jun 2019 22:18:21 +0000 (22:18 +0000)]
Follow r349460 to complete removing "flags" in struct gpiobus_ivar

MFC with: r349460
Sponsored by: The FreeBSD Foundation

4 years agoIncrease EFI_STAGING_SIZE to 100MB on x64
bcran [Thu, 27 Jun 2019 22:06:41 +0000 (22:06 +0000)]
Increase EFI_STAGING_SIZE to 100MB on x64

To avoid failures when the large 18MB nvidia.ko module is being loaded,
increase EFI_STAGING_SIZE from 64MB to 100MB on x64 systems.
Leave the other platforms at 64MB.

4 years agoUse __FBSDID() and sort #includes.
jhb [Thu, 27 Jun 2019 21:45:40 +0000 (21:45 +0000)]
Use __FBSDID() and sort #includes.

No functional change.

4 years agoExpose the kernel's build-ID through `uname -b`
emaste [Thu, 27 Jun 2019 20:34:50 +0000 (20:34 +0000)]
Expose the kernel's build-ID through `uname -b`

After r348611 the kernel's build-ID is available via sysctl.  Add a -b flag
to uname to report it.

Submitted by: Ali Mashtizadeh <ali_mashtizadeh.com>
Reviewed by: markj, imp
Relnotes: Yes
Event: Waterloo Hackathon 2019
Differential Revision: https://reviews.freebsd.org/D20511

4 years agofusefs: recycle vnodes after their last unlink
asomers [Thu, 27 Jun 2019 20:18:12 +0000 (20:18 +0000)]
fusefs: recycle vnodes after their last unlink

Previously fusefs would never recycle vnodes.  After VOP_INACTIVE, they'd
linger around until unmount or the vnlru reclaimed them.  This commit
essentially actives and inlines the old reclaim_revoked sysctl, and fixes
some issues dealing with the attribute cache and multiply linked files.

Sponsored by: The FreeBSD Foundation

4 years agoHold an explicit reference on the socket for the aiotx task.
jhb [Thu, 27 Jun 2019 19:36:30 +0000 (19:36 +0000)]
Hold an explicit reference on the socket for the aiotx task.

Previously, the aiotx task relied on the aio jobs in the queue to hold
a reference on the socket.  However, when the last job is completed,
there is nothing left to hold a reference to the socket buffer lock
used to check if the queue is empty.  In addition, if the last job on
the queue is cancelled, the task can run with no queued jobs holding a
reference to the socket buffer lock the task uses to notice the queue
is empty.

Fix these races by holding an explicit reference on the socket when
the task is queued and dropping that reference when the task
completes.

Reviewed by: np
MFC after: 1 week
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D20539

4 years agoAdd support for extended descriptor format to Altera mSGDMA driver.
br [Thu, 27 Jun 2019 18:08:18 +0000 (18:08 +0000)]
Add support for extended descriptor format to Altera mSGDMA driver.

The format to use depends on hardware configuration (synthesis-time),
so make it compile-time kernel option.

Extended format allows DMA engine to operate with 64-bit memory addresses.

Sponsored by: DARPA, AFRL

4 years agofusefs: counter(9) variables should not be statically initialized
asomers [Thu, 27 Jun 2019 17:59:15 +0000 (17:59 +0000)]
fusefs: counter(9) variables should not be statically initialized

Reported by: rpokala
Sponsored by: The FreeBSD Foundation

4 years agofusefs: fix a memory leak in the forget test
asomers [Thu, 27 Jun 2019 17:44:21 +0000 (17:44 +0000)]
fusefs: fix a memory leak in the forget test

Sponsored by: The FreeBSD Foundation

4 years agofusefs: convert statistical sysctls to use counter(9)
asomers [Thu, 27 Jun 2019 16:30:25 +0000 (16:30 +0000)]
fusefs: convert statistical sysctls to use counter(9)

counter(9) is more performant than using atomic instructions to update
sysctls that just report statistics to userland.

Sponsored by: The FreeBSD Foundation

4 years agorevert r349460, printf -> KASSERT in bus.h, until I can fix it
avg [Thu, 27 Jun 2019 15:51:50 +0000 (15:51 +0000)]
revert r349460, printf -> KASSERT in bus.h, until I can fix it

I tested only kernel builds naively assuming that sys/bus.h cannot
affect userland builds.

Pointyhat to: me

4 years agogpiobus: provide a new hint, pin_list
avg [Thu, 27 Jun 2019 15:46:06 +0000 (15:46 +0000)]
gpiobus: provide a new hint, pin_list

"pin_list" allows to specify child pins as a list of pin numbers.
Existing hint "pins" serves the same purpose but with a 32-bit wide bit
mask.  One problem with that is that a controller can have more than 32
pins.  One example is amdgpio.  Also, a list of numbers is a little bit
more human friendly than a matching bit mask.  As a side note, it seems
that in FDT pins are typically specified by their numbers as well.

This commit also adds accessors for instance variables (IVARs) that
define the child pins.  My primary goal is to allow a child to be
configured programmatically rather than via hints (assuming that FDT is
not supported on a platform).  Also, while a child should not care about
specific pin numbers that are allocated to it, it could be interested in
how many were actually assigned to it.

While there, I removed "flags" instance variable.  It was unused.

Reviewed by: mizhka
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20459

4 years agoupgrade the warning printf-s in bus accessors to KASSERT-s
avg [Thu, 27 Jun 2019 15:07:06 +0000 (15:07 +0000)]
upgrade the warning printf-s in bus accessors to KASSERT-s

After this change sys/bus.h includes sys/systm.h.

Discussed with: cem, imp
MFC after: 2 weeks

4 years agobectl(8): create non-recursive boot environments
kevans [Thu, 27 Jun 2019 14:03:32 +0000 (14:03 +0000)]
bectl(8): create non-recursive boot environments

bectl advertises that it has the ability to create recursive and
non-recursive boot environments. This patch implements that functionality
using the be_create_depth API provided by libbe. With this patch, bectl now
works as bectl(8) describes in regards to creating recursive/non-recursive
boot environments.

Submitted by: Rob Fairbanks <rob.fx907 gmail com> (with minor changes)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D20240

4 years agopicobsd: also exclude .git where we exclude .svn today
emaste [Thu, 27 Jun 2019 13:31:55 +0000 (13:31 +0000)]
picobsd: also exclude .git where we exclude .svn today

Sponsored by: The FreeBSD Foundation

4 years agoCreate a link to the ipmon.conf.5 man page as documented in ipmon.5.
cy [Thu, 27 Jun 2019 12:37:44 +0000 (12:37 +0000)]
Create a link to the ipmon.conf.5 man page as documented in ipmon.5.
Add its corresponding optional removal entry.

PR: 238816
MFC after: 1 week

4 years agoReturn a return code scripts might expect. I missed this while
cy [Thu, 27 Jun 2019 03:50:13 +0000 (03:50 +0000)]
Return a return code scripts might expect. I missed this while
reviewing and rewriting a patch in PR/238816.

PR: 238816
Reported by: rgrimes@
Pointy hat to: cy@
MFC after: 1 week
X-MFC with: r349450

4 years agoUpdate usage() to refect the current state of ipmon.
cy [Thu, 27 Jun 2019 02:43:30 +0000 (02:43 +0000)]
Update usage() to refect the current state of ipmon.

PR: 238816
MFC after: 1 week

4 years agoAdd the ipmon.5 man page.
cy [Thu, 27 Jun 2019 02:43:26 +0000 (02:43 +0000)]
Add the ipmon.5 man page.

PR/238816 initially addressed updates to usage() however the PR has
morphed into a shopping list of updates to usage() and man pages.

PR: 238816 (I added to the list during discussion)
MFC after: 1 week

4 years agoFix a typo.
cy [Thu, 27 Jun 2019 02:42:56 +0000 (02:42 +0000)]
Fix a typo.

PR/238816 initially addressed updates to usage() however it has now
become a shopping list of fixes to ipmon man pages and usage().

PR: 238816
MFC after: 3 days

4 years agofusefs: fix some memory leaks
asomers [Thu, 27 Jun 2019 00:00:48 +0000 (00:00 +0000)]
fusefs: fix some memory leaks

Fix memory leaks relating to FUSE_BMAP and FUSE_CREATE.  There are still
leaks relating to FUSE_INTERRUPT, but they'll be harder to fix since the
server is legally allowed to never respond to a FUSE_INTERRUPT operation.

Sponsored by: The FreeBSD Foundation

4 years agolibsecureboot: allow OpenPGP support to be dormant
sjg [Wed, 26 Jun 2019 23:33:32 +0000 (23:33 +0000)]
libsecureboot: allow OpenPGP support to be dormant

Since we can now add OpenPGP trust anchors at runtime,
ensure the latent support is available.

Ensure we do not add duplicate keys to trust store.

Also allow reporting names of trust anchors added/revoked

We only do this for loader and only after initializing trust store.
Thus only changes to initial trust store will be logged.

Reviewed by: stevek
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D20700

4 years agofusefs: tighten expectations in mmap tests
asomers [Wed, 26 Jun 2019 23:10:20 +0000 (23:10 +0000)]
fusefs: tighten expectations in mmap tests

In r349378 I fixed mmap's habit of reading more data than was available.

Sponsored by: The FreeBSD Foundation

4 years agoIn get_fpcontext32() and set_fpcontext32(), we can't just use memcpy() to
cognet [Wed, 26 Jun 2019 22:06:40 +0000 (22:06 +0000)]
In get_fpcontext32() and set_fpcontext32(), we can't just use memcpy() to
copy the VFP registers.
arvm7 VFP uses 32 64bits fp registers (but those could be used in pairs to
make 16 128bits registers), while aarch64 uses 32 128bits fp registers, so
we have to copy the value of each register.

4 years agoRevert one of the changes from r349323. Specifically, undo the change
alc [Wed, 26 Jun 2019 21:43:41 +0000 (21:43 +0000)]
Revert one of the changes from r349323.  Specifically, undo the change
that replaced a pmap_invalidate_page() with a dsb(ishst) in
pmap_enter_quick_locked().  Even though this change is in principle
correct, I am seeing occasional, spurious bus errors that are only
reproducible without this pmap_invalidate_page().  (None of adding an
isb, "upgrading" the dsb to wait on loads as well as stores, or
disabling superpage mappings eliminates the bus errors.)  Add an XXX
comment explaining why the pmap_invalidate_page() is being performed.

Discussed with:      andrew, markj

4 years agoEmulate the "TEST r/m{16,32,64}, imm{16,32,32}" instructions (opcode F7H).
rgrimes [Wed, 26 Jun 2019 21:19:43 +0000 (21:19 +0000)]
Emulate the "TEST r/m{16,32,64}, imm{16,32,32}" instructions (opcode F7H).

This adds emulation for:
test r/m16, imm16
test r/m32, imm32
test r/m64, imm32 sign-extended to 64

OpenBSD guests compiled with clang 8.0.0 use TEST directly against a
Local APIC register instead of separate read via MOV followed by a
TEST against the register.

PR: 238794
Submitted by: jhb
Reported by: Jason Tubnor jason@tubnor.net
Tested by: Jason Tubnor jason@tubnor.net
Reviewed by: markj, Patrick Mooney patrick.mooney@joyent.com
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D20755

4 years agofusefs: annotate deliberate file descriptor leaks in the tests
asomers [Wed, 26 Jun 2019 20:25:57 +0000 (20:25 +0000)]
fusefs: annotate deliberate file descriptor leaks in the tests

closing a file descriptor causes FUSE activity that is superfluous to the
purpose of most tests, but would nonetheless require matching expectations.
Rather than do that, most tests deliberately leak file descriptors instead.
This commit moves the leakage from each test into two trivial functions:
leak and leakdir.  Hopefully Coverity will only complain about those
functions and not all of their callers.

Sponsored by: The FreeBSD Foundation

4 years agoFree DHCP options with length zero.
markj [Wed, 26 Jun 2019 20:19:48 +0000 (20:19 +0000)]
Free DHCP options with length zero.

Otherwise they are leaked, allowing an attacker to trigger memory
exhaustion.

This is options.c rev. 1.70 from OpenBSD.

admbugs: 552
Obtained from: OpenBSD
MFC after: 3 days

4 years agoAvoid a divide-by-zero when bad checksum counters overflow.
markj [Wed, 26 Jun 2019 20:11:52 +0000 (20:11 +0000)]
Avoid a divide-by-zero when bad checksum counters overflow.

A mixture of IP or UDP packets with valid and invalid checksum could
cause {ip,udp}_packets_bad_checksum to wrap around to 0, resulting
in a division by zero.

This is packet.c rev. 1.27 from OpenBSD.

admbugs: 552
Obtained from: OpenBSD
MFC after: 3 days

4 years agofusefs.5: remove deleted sysctls from man page
asomers [Wed, 26 Jun 2019 20:07:16 +0000 (20:07 +0000)]
fusefs.5: remove deleted sysctls from man page

Sponsored by: The FreeBSD Foundation

4 years agofusefs: run the io tests with direct io, too
asomers [Wed, 26 Jun 2019 19:10:39 +0000 (19:10 +0000)]
fusefs: run the io tests with direct io, too

Now the io tests are run in all cache modes.  The fusefs test suite can now
get adequate coverage without changing the value of
vfs.fusefs.data_cache_mode, which is only needed for legacy file systems
now.

Sponsored by: The FreeBSD Foundation

4 years agofix up r349428, fix a typo made during "fdt" removal
avg [Wed, 26 Jun 2019 17:38:38 +0000 (17:38 +0000)]
fix up r349428, fix a typo made during "fdt" removal

Reported by: ian
MFC after: 11 days

4 years agoAdd a return value to vm_page_remove().
markj [Wed, 26 Jun 2019 17:37:51 +0000 (17:37 +0000)]
Add a return value to vm_page_remove().

Use it to indicate whether the page may be safely freed following
its removal from the object.  Also change vm_page_remove() to assume
that the page's object pointer is non-NULL, and have callers perform
this check instead.

This is a step towards an implementation of an atomic reference counter
for each physical page structure.

Reviewed by: alc, dougm, kib
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20758

4 years agofusefs: implement protocol 7.23's FUSE_WRITEBACK_CACHE option
asomers [Wed, 26 Jun 2019 17:32:31 +0000 (17:32 +0000)]
fusefs: implement protocol 7.23's FUSE_WRITEBACK_CACHE option

As of protocol 7.23, fuse file systems can specify their cache behavior on a
per-mountpoint basis.  If they set FUSE_WRITEBACK_CACHE in
fuse_init_out.flags, then they'll get the writeback cache.  If not, then
they'll get the writethrough cache.  If they set FOPEN_DIRECT_IO in every
FUSE_OPEN response, then they'll get no cache at all.

The old vfs.fusefs.data_cache_mode sysctl is ignored for servers that use
protocol 7.23 or later.  However, it's retained for older servers,
especially for those running in jails that lack access to the new protocol.

This commit also fixes two other minor test bugs:
* WriteCluster:SetUp was using an uninitialized variable.
* Read.direct_io_pread wasn't verifying that the cache was actually
  bypassed.

Sponsored by: The FreeBSD Foundation

4 years agoowc_gpiobus: clean / fix up the driver module things
avg [Wed, 26 Jun 2019 17:17:33 +0000 (17:17 +0000)]
owc_gpiobus: clean / fix up the driver module things

"fdt" is removed from the driver module name as the driver does not
require FDT and can work very well on hints based systems.

A module dependency is added for gpiobus.  Without that owc cannot
resolve symbols in gpiobus if both are loaded as kernel modules.

Finally, a driver module module version is added.

Reviewed by: imp
MFC after: 11 days

4 years agoamd64 pmap: Fix pkru handling in pmap_remove().
kib [Wed, 26 Jun 2019 17:16:26 +0000 (17:16 +0000)]
amd64 pmap: Fix pkru handling in pmap_remove().

When pmap_pkru_on_remove() is called, the sva argument value was
advanced.  Clear PKRU earlier when sva still specifies the start of
the region.

Noted and reviewed by: alc
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

4 years agoFix debugging of 32bits arm binaries on arm64.
cognet [Wed, 26 Jun 2019 16:56:56 +0000 (16:56 +0000)]
Fix debugging of 32bits arm binaries on arm64.

In set_regs32()/fill_regs32(), we have to get/set SP and LR from/to
tf_x[13] and tf_x[14].
set_regs() and fill_regs() may be called for a 32bits process, if the process
is ptrace'd from a 64bits debugger. So, in set_regs() and fill_regs(), get
or set PC and SPSR from where the debugger expects it, from tf_x[15] and
tf_x[16].

4 years agolibdwarf: Use the cached strtab pointer when reading string attributes.
markj [Wed, 26 Jun 2019 16:38:30 +0000 (16:38 +0000)]
libdwarf: Use the cached strtab pointer when reading string attributes.

Previously we would perform a linear search of the DWARF section
list for ".debug_str".  However, libdwarf always caches a pointer to
the strtab image in its debug descriptor.  Using it gives a modest
performance improvement when iterating over the attributes of each
DIE.

Reviewed by: emaste
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20759

4 years agoelfcopy: Provide a size hint when creating the section string table.
markj [Wed, 26 Jun 2019 16:35:37 +0000 (16:35 +0000)]
elfcopy: Provide a size hint when creating the section string table.

Use the input file's .shstrtab size as the hint if it exists.  This
gives a small performance improvement when processing files with
many sections.

Reviewed by: emaste
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20544

4 years agolibelftc: Fix the documented prototype for elftc_string_table_destroy().
markj [Wed, 26 Jun 2019 16:32:41 +0000 (16:32 +0000)]
libelftc: Fix the documented prototype for elftc_string_table_destroy().

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agolibelftc: Consistently use size_t for string table offsets and sizes.
markj [Wed, 26 Jun 2019 16:31:50 +0000 (16:31 +0000)]
libelftc: Consistently use size_t for string table offsets and sizes.

Reviewed by: emaste
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20702

4 years agolibelftc: Micro-optimize string table insertion.
markj [Wed, 26 Jun 2019 16:30:14 +0000 (16:30 +0000)]
libelftc: Micro-optimize string table insertion.

The string's length is already known, so use memcpy() instead of
strcpy() to add it to the string table image.

Reviewed by: emaste
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20760

4 years agoRemove references to splbio in ffs_softdep.c.
markj [Wed, 26 Jun 2019 16:28:42 +0000 (16:28 +0000)]
Remove references to splbio in ffs_softdep.c.

Assert that the per-mountpoint softdep mutex is held in modified
functions that do not already have this assertion.  No functional
change intended.

Reviewed by: kib, mckusick (previous version)
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20741

4 years agoFix qlxgbe(4) static build.
mav [Wed, 26 Jun 2019 16:23:24 +0000 (16:23 +0000)]
Fix qlxgbe(4) static build.

MFC after: 2 weeks

4 years agoUse rtld_putstr() instead of write() for the rtld msg() macro
arichardson [Wed, 26 Jun 2019 15:43:26 +0000 (15:43 +0000)]
Use rtld_putstr() instead of write() for the rtld msg() macro

This removes an unnecessary libc dependency from rtld.
See https://reviews.freebsd.org/D20663 for more details.

4 years agoFix -Wsign-compare warnings in realpath.c
arichardson [Wed, 26 Jun 2019 15:43:20 +0000 (15:43 +0000)]
Fix -Wsign-compare warnings in realpath.c

This is needed in order to build realpath.c as part of rtld.

4 years agoo In iflib_txq_drain():
marius [Wed, 26 Jun 2019 15:28:21 +0000 (15:28 +0000)]
o In iflib_txq_drain():
  - Remove desc_used, which is only ever written to.
  - Remove a dead store to reclaimed.
  - Don't recycle avail.
  - Sort variables according to style(9).
  These changes will make a subsequent commit easier to read.
o In iflib_tx_credits_update(), don't bother checking whether the
  ift_txd_credits_update method pointer is NULL; _iflib_pre_assert()
  asserts upfront that this method has been assigned and functions
  like iflib_{fast_intr_rxtx,netmap_timer_adjust,txq_can_drain}()
  and _task_fn_tx() were already unconditionally relying on the
  method being callable.

4 years agofusefs: delete some unused mount options
asomers [Wed, 26 Jun 2019 15:15:24 +0000 (15:15 +0000)]
fusefs: delete some unused mount options

The fusefs kernel module allegedly supported no_attrcache, no_readahed,
no_datacache, no_namecache, and no_mmap mount options, but the mount_fusefs
binary never did.  So there was no way to ever activate these options.
Delete them.  Some of them have alternatives:

no_attrcache: set the attr_valid time to 0 in FUSE_LOOKUP and FUSE_GETATTR
responses.
no_readahed: set max_readahead to 0 in the FUSE_INIT response.
no_datacache: set the vfs.fusefs.data_cache_mode sysctl to 0, or (coming
soon) set the attr_valid time to 0 and set FUSE_AUTO_INVAL_DATA in
the FUSE_INIT response.
no_namecache: set entry_valid time to 0 in FUSE_LOOKUP and FUSE_GETATTR
responses.

Sponsored by: The FreeBSD Foundation

4 years agoOnly call libusb_hotplug_enumerate() once from libusb_hotplug_register_callback().
hselasky [Wed, 26 Jun 2019 12:04:54 +0000 (12:04 +0000)]
Only call libusb_hotplug_enumerate() once from libusb_hotplug_register_callback().
Else when registering multiple filters the same USB device may appear twice in
the list.

MFC after: 3 days
Sponsored by: Mellanox Technologies

4 years agoFix support for LIBUSB_HOTPLUG_ENUMERATE in libusb. Currently all
hselasky [Wed, 26 Jun 2019 11:28:08 +0000 (11:28 +0000)]
Fix support for LIBUSB_HOTPLUG_ENUMERATE in libusb. Currently all
devices are enumerated regardless of of the LIBUSB_HOTPLUG_ENUMERATE
flag. Make sure when the flag is not specified no arrival events are
generated for currently enumerated devices.

MFC after: 3 days
Sponsored by: Mellanox Technologies

4 years agogpio.4: document device hints common to all devices on gpiobus
avg [Wed, 26 Jun 2019 07:38:31 +0000 (07:38 +0000)]
gpio.4: document device hints common to all devices on gpiobus

"at" keyword is documented in device.hints(5) for all buses, but it does
hurt to add another reference to it.
"pins" keyword is specific to gpiobus.
At least these two hints should be configured for any gpiobus device on
a hints based system.

MFC after: 10 days

4 years agofix up r349406, add missing .El
avg [Wed, 26 Jun 2019 07:08:51 +0000 (07:08 +0000)]
fix up r349406, add missing .El

MFC after: 1 week

4 years agoowc.4: document how to set up the 1-wire bus on a device.hints system
avg [Wed, 26 Jun 2019 06:40:30 +0000 (06:40 +0000)]
owc.4: document how to set up the 1-wire bus on a device.hints system

MFC after: 1 week

4 years agoRevert r349393, which leads to an assertion failure on bootup, in vm_map_stack_locked.
dougm [Wed, 26 Jun 2019 03:12:57 +0000 (03:12 +0000)]
Revert r349393, which leads to an assertion failure on bootup, in vm_map_stack_locked.

Reported by: ler@lerctr.org
Approved by: kib, markj (mentors, implicit)

4 years agoRe-enable loader efi http boot and fix dv_open bug if dv_init failed
bcran [Wed, 26 Jun 2019 03:06:57 +0000 (03:06 +0000)]
Re-enable loader efi http boot and fix dv_open bug if dv_init failed

The code in efihttp.c was assuming that dv_open wouldn't be called if
dv_init failed. But the dv_init return value is currently ignored.

Add a new variable, `efihttp_init_done` and only proceed in dv_open if
it's true. This fixes the loader on systems without efi http support.

4 years agofusefs: implement the "time_gran" feature.
asomers [Wed, 26 Jun 2019 02:09:22 +0000 (02:09 +0000)]
fusefs: implement the "time_gran" feature.

If a server supports a timestamp granularity other than 1ns, it can tell the
client this as of protocol 7.23.  The client will use that granularity when
updating its cached timestamps during write.  This way the timestamps won't
appear to change following flush.

Sponsored by: The FreeBSD Foundation

4 years agopowerpc/booke: Handle misaligned floating point loads/stores as on AIM
jhibbits [Wed, 26 Jun 2019 01:14:39 +0000 (01:14 +0000)]
powerpc/booke: Handle misaligned floating point loads/stores as on AIM

Misaligned floating point loads and stores are already handled for AIM, but
use the DSISR to obtain the necessary data.  Book-E does not have the DSISR,
so these fixups are not performed, leading to a SIGBUS on misaligned FP
loads or stores.  Obtain the necessary data on the Book-E side, similar to
how is done for SPE.

MFC after: 1 week

4 years agoWhile working on PR/238796 I discovered an unused variable in frdest,
cy [Wed, 26 Jun 2019 00:53:49 +0000 (00:53 +0000)]
While working on PR/238796 I discovered an unused variable in frdest,
the next hop structure. It is likely this contributes to PR/238796
though other factors remain to be investigated.

PR: 238796
MFC after: 1 week

4 years agoRemove a tautological compare for offset != 0.
cy [Wed, 26 Jun 2019 00:53:46 +0000 (00:53 +0000)]
Remove a tautological compare for offset != 0.

MFC after: 1 week

4 years agoPrompted by r349366, ipfilter is also does not conform to RFC 3128
cy [Wed, 26 Jun 2019 00:53:43 +0000 (00:53 +0000)]
Prompted by r349366, ipfilter is also does not conform to RFC 3128
by dropping TCP fragments with offset = 1.

In addition to dropping these fragments, add a DTrace probe to allow
for more detailed monitoring and diagnosis if required.

MFC after: 1 week

4 years agofusefs: delete obsolete comments in the tests
asomers [Wed, 26 Jun 2019 00:06:41 +0000 (00:06 +0000)]
fusefs: delete obsolete comments in the tests

I originally thought that the kernel would be responsible for ctime in
protocol 7.23.  But now I realize that's not the case.  The server is
responsible for ctime.  The kernel only sets it when there are dirty writes
cached, because that's when the server can't.

Sponsored by: The FreeBSD Foundation

4 years agofusefs: set ctime during FUSE_SETATTR following a write
asomers [Wed, 26 Jun 2019 00:03:37 +0000 (00:03 +0000)]
fusefs: set ctime during FUSE_SETATTR following a write

As of r349396 the kernel will internally update the mtime and ctime of files
on write.  It will also flush the mtime should a SETATTR happen before the
data cache gets flushed.  Now it will flush the ctime too, if the server is
using protocol 7.23 or higher.

This is the only case in which the kernel will explicitly set a file's
ctime, since neither utimensat(2) nor any other user interfaces allow it.

Sponsored by: The FreeBSD Foundation

4 years agofusefs: automatically update mtime and ctime on write
asomers [Tue, 25 Jun 2019 23:40:18 +0000 (23:40 +0000)]
fusefs: automatically update mtime and ctime on write

Writing should implicitly update a file's mtime and ctime.  For fuse, the
server is supposed to do that.  But the client needs to do it too, because
the FUSE_WRITE response does not include time attributes, and it's not
desirable to issue a GETATTR after every WRITE.  When using the writeback
cache, there's another hitch: the kernel should ignore the mtime and ctime
fields in any GETATTR response for files with a dirty write cache.

Sponsored by: The FreeBSD Foundation

4 years agoDisconnect EFI HTTP support
bcran [Tue, 25 Jun 2019 21:26:57 +0000 (21:26 +0000)]
Disconnect EFI HTTP support

The EFI HTTP code has been causing boot failures for people, so disable it
while a fix is being worked on.

4 years agofusefs: fix the tests for non-default values of MAXPHYS
asomers [Tue, 25 Jun 2019 21:21:34 +0000 (21:21 +0000)]
fusefs: fix the tests for non-default values of MAXPHYS

Sponsored by: The FreeBSD Foundation

4 years agoEliminate some uses of the prev and next fields of vm_map_entry_t.
dougm [Tue, 25 Jun 2019 20:25:16 +0000 (20:25 +0000)]
Eliminate some uses of the prev and next fields of vm_map_entry_t.

Since the only caller to vm_map_splay is vm_map_lookup_entry, move the
implementation of vm_map_splay into vm_map_lookup_helper, called by
vm_map_lookup_entry.

vm_map_lookup_entry returns the greatest entry less than or equal to a
given address, but in many cases the caller wants the least entry
greater than or equal to the address and uses the next pointer to get
to it. Provide an alternative interface to lookup,
vm_map_lookup_entry_ge, to provide the latter behavior, and let
callers use one or the other rather than having them use the next
pointer after a lookup miss to get what they really want.

In vm_map_growstack, the caller wants an entry that includes a given
address, and either the preceding or next entry depending on the value
of eflags in the first entry. Incorporate that behavior into
vm_map_lookup_helper, the function that implements all of these
lookups.

Eliminate some temporary variables used with vm_map_lookup_entry, but
inessential.

Reviewed by: markj (earlier version)
Approved by: kib (mentor)
Differential Revision: https://reviews.freebsd.org/D20664

4 years agoFix annoying whitespace issue.
julian [Tue, 25 Jun 2019 19:55:42 +0000 (19:55 +0000)]
Fix annoying whitespace issue.
NO real change

4 years agofcntl: style changes to r349248
asomers [Tue, 25 Jun 2019 19:44:22 +0000 (19:44 +0000)]
fcntl: style changes to r349248

Reported by: bde
MFC after: 2 weeks
MFC-With: 349248
Sponsored by: The FreeBSD Foundation

4 years agobhyve: avoid theoretical stack buffer overflow from integer overflow
emaste [Tue, 25 Jun 2019 19:06:43 +0000 (19:06 +0000)]
bhyve: avoid theoretical stack buffer overflow from integer overflow

Use the proper size_t type to match strlen's return type.  This is not
exploitable in practice as this parses command line arguments, which
are limited to well below 2^31 bytes.

This is a minimal change to address the reported issue; hda_parse_config
and the rest of this file will benefit from further review.

Reported by: Fakhri Zulkifli
Reviewed by: jhb, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

4 years agofusefs: fix the tests for nondefault values of vfs.maxbcachebuf
asomers [Tue, 25 Jun 2019 18:58:51 +0000 (18:58 +0000)]
fusefs: fix the tests for nondefault values of vfs.maxbcachebuf

Sponsored by: The FreeBSD Foundation

4 years agolibbe(3): restructure be_mount, skip canmount check for BE dataset
kevans [Tue, 25 Jun 2019 18:47:40 +0000 (18:47 +0000)]
libbe(3): restructure be_mount, skip canmount check for BE dataset

Further cleanup after r349380; loader and kernel will both ignore canmount
on the root dataset as well, so we should not be so strict about it when
mounting it. be_mount is restructured to make it more clear that depth==0 is
special, and to not try fetching these properties that we won't care about.

MFC after: 3 days

4 years agofusefs: writes should update the file size, even when data_cache_mode=0
asomers [Tue, 25 Jun 2019 18:36:11 +0000 (18:36 +0000)]
fusefs: writes should update the file size, even when data_cache_mode=0

Writes that extend a file should update the file's size.  r344185 restricted
that behavior for fusefs to only happen when the data cache was enabled.
That probably made sense at the time because the attribute cache wasn't
fully baked yet.  Now that it is, we should always update the cached file
size during write.

Sponsored by: The FreeBSD Foundation

4 years agoAvoid extra taskq_dispatch() calls by DMU.
mav [Tue, 25 Jun 2019 18:35:23 +0000 (18:35 +0000)]
Avoid extra taskq_dispatch() calls by DMU.

DMU sync code calls taskq_dispatch() for each sublist of os_dirty_dnodes
and os_synced_dnodes.  Since the number of sublists by default is equal
to number of CPUs, it will dispatch equal, potentially large, number of
tasks, waking up many CPUs to handle them, even if only one or few of
sublists actually have any work to do.

This change adds check for empty sublists to avoid this.

4 years agolibbe(3): mount: the BE dataset is mounted at /
kevans [Tue, 25 Jun 2019 18:13:39 +0000 (18:13 +0000)]
libbe(3): mount: the BE dataset is mounted at /

Other parts of libbe(3) were fairly strict on the mountpoint property of the
BE dataset, and be_mount was not much better. It was improved in r347027 to
allow mountpoint=none for depth==0, but this bit was still sensitive to
mountpoint != / and mountpoint != none. Given that other parts of libbe(3)
no longer restrict the mountpoint property here, and the rest of the base
system is generally OK and will assume that a BE is mounted at /, let's do
the same.

Reported by: ler
MFC after: 3 days

4 years agoDocument the KERN_PROTECTION_FAILURE return value from vm_map_protect().
dougm [Tue, 25 Jun 2019 17:27:37 +0000 (17:27 +0000)]
Document the KERN_PROTECTION_FAILURE return value from vm_map_protect().

Reviewed by: alc (earlier version)
Approved by: kib, markj (mentors)
Differential Revision: https://reviews.freebsd.org/D20751

4 years agofusefs: rewrite vop_getpages and vop_putpages
asomers [Tue, 25 Jun 2019 17:24:43 +0000 (17:24 +0000)]
fusefs: rewrite vop_getpages and vop_putpages

Use the standard facilities for getpages and putpages instead of bespoke
implementations that don't work well with the writeback cache.  This has
several corollaries:

* Change the way we handle short reads _again_.  vfs_bio_getpages doesn't
  provide any way to handle unexpected short reads.  Plus, I found some more
  lock-order problems.  So now when the short read is detected we'll just
  clear the vnode's attribute cache, forcing the file size to be requeried
  the next time it's needed.  VOP_GETPAGES doesn't have any way to indicate
  a short read to the "caller", so we just bzero the rest of the page
  whenever a short read happens.

* Change the way we decide when to set the FUSE_WRITE_CACHE bit.  We now set
  it for clustered writes even when the writeback cache is not in use.

Sponsored by:   The FreeBSD Foundation

4 years ago[PowerPC64] Don't mark module data as static
luporl [Tue, 25 Jun 2019 17:15:44 +0000 (17:15 +0000)]
[PowerPC64] Don't mark module data as static

Fixes panic when loading ipfw.ko and if_epair.ko built with modern compiler.

Similar to arm64 and riscv, when using a modern compiler (!gcc4.2), code
generated tries to access data in the wrong location, causing kernel panic
(data storage interrupt trap) when loading if_epair and ipfw.

Issue was reproduced with kernel/module compiled using gcc8 and clang8. It
affects both ELFv1 and ELFv2 ABI environments.

PR: 232387
Submitted by: alfredo.junior_eldorado.org.br
Reported by: Mark Millard
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D20461

4 years agoFix strsep_quote() on strings without quotes.
mav [Tue, 25 Jun 2019 17:00:53 +0000 (17:00 +0000)]
Fix strsep_quote() on strings without quotes.

For strings without quotes and escapes dstptr and srcptr are equal, so
zeroing *dstptr before checking *srcptr is not a good idea.  In practice
it means that in -maproot=65534:65533 everything after the colon is lost.

The problem was there since r293305, but before r346976 it was covered by
improper strsep_quote() usage.

PR: 238725
MFC after: 3 days
Sponsored by: iXsystems, Inc.

4 years agofusefs: fix multiple issues with the io tests
asomers [Tue, 25 Jun 2019 16:49:20 +0000 (16:49 +0000)]
fusefs: fix multiple issues with the io tests

* During TearDown, close the test file before the backing file.  That way
  the backing file artifact will have the correct contents after the test
  completes.  It doesn't matter when running in Kyua, but it may when
  running the test manually.
* Add a closeopen operation that mimics what FSX does with the "-c" option.
* Skip mmap-related tests when vfs.fusefs.data_cache_mode == 0

Sponsored by: The FreeBSD Foundation

4 years agoRemove a couple of harmless stray references to nandfs.
imp [Tue, 25 Jun 2019 16:39:25 +0000 (16:39 +0000)]
Remove a couple of harmless stray references to nandfs.

Submitted by: tsoome@

4 years agonetipsec key_register: check for M_NOWAIT alloc failure
rlibby [Tue, 25 Jun 2019 15:43:52 +0000 (15:43 +0000)]
netipsec key_register: check for M_NOWAIT alloc failure

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

4 years agoInclude files containing metadata specific to the branch in the
gjb [Tue, 25 Jun 2019 14:56:13 +0000 (14:56 +0000)]
Include files containing metadata specific to the branch in the
directory where the individual distribution sets exist.

The new metadata files include the build date, svn branch, and
revision of the build.

Requested by: Mellanox Technologies (via kib)
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoCroatian calendar: update / fix names, dates, group national public
zec [Tue, 25 Jun 2019 14:50:03 +0000 (14:50 +0000)]
Croatian calendar: update / fix names, dates, group national public
holidays, sort by date.

MFC after: 3 days

4 years agoFix parsing of corrupt data in usbdump(8). Check that the transfer
hselasky [Tue, 25 Jun 2019 13:15:29 +0000 (13:15 +0000)]
Fix parsing of corrupt data in usbdump(8). Check that the transfer
type array lookup is within bounds to avoid segfault.

PR: 238801
MFC after: 3 days
Sponsored by: Mellanox Technologies

4 years agoConvert all IPv4 and IPv6 multicast memberships into using a STAILQ
hselasky [Tue, 25 Jun 2019 11:54:41 +0000 (11:54 +0000)]
Convert all IPv4 and IPv6 multicast memberships into using a STAILQ
instead of a linear array.

The multicast memberships for the inpcb structure are protected by a
non-sleepable lock, INP_WLOCK(), which needs to be dropped when
calling the underlying possibly sleeping if_ioctl() method. When using
a linear array to keep track of multicast memberships, the computed
memory location of the multicast filter may suddenly change, due to
concurrent insertion or removal of elements in the linear array. This
in turn leads to various invalid memory access issues and kernel
panics.

To avoid this problem, put all multicast memberships on a STAILQ based
list. Then the memory location of the IPv4 and IPv6 multicast filters
become fixed during their lifetime and use after free and memory leak
issues are easier to track, for example by: vmstat -m | grep multi

All list manipulation has been factored into inline functions
including some macros, to easily allow for a future hash-list
implementation, if needed.

This patch has been tested by pho@ .

Differential Revision: https://reviews.freebsd.org/D20080
Reviewed by: markj @
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoFree all allocated unit IDs in cuse(3) after the client character
hselasky [Tue, 25 Jun 2019 11:46:01 +0000 (11:46 +0000)]
Free all allocated unit IDs in cuse(3) after the client character
devices have been destroyed to avoid creating character devices with
identical name.

MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoFix for deadlock situation in cuse(3)
hselasky [Tue, 25 Jun 2019 11:42:53 +0000 (11:42 +0000)]
Fix for deadlock situation in cuse(3)

The final server unref should be done by the server thread to prevent
deadlock in the client cdevpriv destructor, which cannot destroy
itself.

MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoFollow the RFC 3128 and drop short TCP fragments with offset = 1.
ae [Tue, 25 Jun 2019 11:40:37 +0000 (11:40 +0000)]
Follow the RFC 3128 and drop short TCP fragments with offset = 1.

Reported by: emaste
MFC after: 1 week

4 years agoMark default rule with IPFW_RULE_NOOPT flag, so it can be showed in
ae [Tue, 25 Jun 2019 09:11:22 +0000 (09:11 +0000)]
Mark default rule with IPFW_RULE_NOOPT flag, so it can be showed in
compact form.

MFC after: 1 week

4 years agoRestore ipfw(8)'s compact output support broken after r331668.
ae [Tue, 25 Jun 2019 09:08:24 +0000 (09:08 +0000)]
Restore ipfw(8)'s compact output support broken after r331668.

Also modify it a bit. Now -c option omits only 'from any to any' part
and works for different protocols (not just for ip).

Reported by: Dmitry Selivanov <dseliv at gmail>
MFC after: 1 week

4 years agovm_map_protect may return an INVALID_ARGUMENT or PROTECTION_FAILURE
dougm [Tue, 25 Jun 2019 07:44:37 +0000 (07:44 +0000)]
vm_map_protect may return an INVALID_ARGUMENT or PROTECTION_FAILURE
error response after clipping the first map entry in the region to be
reserved. This creates a pair of matching entries that should have
been "simplified" back into one, or never created. This change defers
the clipping of that entry until those two vm_map_protect failure
cases have been ruled out.

Reviewed by: alc
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D20711

4 years agoThe definition of icmptypes in ip_compt.h is dead code as it already
cy [Tue, 25 Jun 2019 07:04:47 +0000 (07:04 +0000)]
The definition of icmptypes in ip_compt.h is dead code as it already
use the icmptypes in ip_icmp.h.

MFC after: 1 week

4 years agoAdd SPDX tags to bhyve(8) HD Audio device.
araujo [Tue, 25 Jun 2019 06:24:56 +0000 (06:24 +0000)]
Add SPDX tags to bhyve(8) HD Audio device.

Reviewed by: bcran
Differential Revision: https://reviews.freebsd.org/D20750