]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoDisable AUTO_OBJ as a make argument to ensure it really is disabled.
bdrewery [Sun, 29 Oct 2017 01:21:15 +0000 (01:21 +0000)]
Disable AUTO_OBJ as a make argument to ensure it really is disabled.

If the user sets this to yes as a make argument too we still want
to ensure these do not get enabled.

Sponsored by: Dell EMC Isilon

6 years agoMAKEOBJDIR should be an absolute path, not any path with a slash.
bdrewery [Sun, 29 Oct 2017 01:21:12 +0000 (01:21 +0000)]
MAKEOBJDIR should be an absolute path, not any path with a slash.

Using MAKEOBJDIR=foo did not work but MAKEOBJDIR=foo/ did, but
really it needs to be absolute.

Sponsored by: Dell EMC Isilon

6 years agoRework r254951 to not reach into private OBJDIR areas.
bdrewery [Sun, 29 Oct 2017 01:21:09 +0000 (01:21 +0000)]
Rework r254951 to not reach into private OBJDIR areas.

The original change was dealing with the build wanting to run a newer
install(1) that was not yet installed.  The solution to look into the private
legacy directory of the existing build conflicts with 2 upcoming features: a
changed OBJDIR format, and splitting the host tools into arch-dependent and
arch-independent directories.  Rather than hardcoding and changing the paths in
this script, just let kernel-toolchain do the work, while disabling much of the
meat.  With -j15 this finishes in 25 seconds for me and 117 seconds with -j1.
All that is really needed is bootstrap-tools, but the system is not currently
written in a way that all previous dependent steps will have ran.  The previous
steps, such as _worldtmp, are being reworked and renamed and so cannot be
relied upon to be right.

Sponsored by: Dell EMC Isilon

6 years agoRemove comment: debug files can be useful for build tools.
bdrewery [Sun, 29 Oct 2017 01:21:06 +0000 (01:21 +0000)]
Remove comment: debug files can be useful for build tools.

Sponsored by: Dell EMC Isilon

6 years agoMove some LIBCOMPAT tmpdir logic setup to its own build target.
bdrewery [Sun, 29 Oct 2017 01:21:02 +0000 (01:21 +0000)]
Move some LIBCOMPAT tmpdir logic setup to its own build target.

Its own build target was already handling mtree extractions
just as _worldtmp did, so the other cleaning of the
tmpdir makes sense here as well.

Sponsored by: Dell EMC Isilon

6 years agoMK_TESTS is disabled in early phases, no need for TESTBASE extraction here.
bdrewery [Sun, 29 Oct 2017 01:20:59 +0000 (01:20 +0000)]
MK_TESTS is disabled in early phases, no need for TESTBASE extraction here.

Sponsored by: Dell EMC Isilon

6 years agoFAST_DEPEND clean hack: Remove lib32/soft files properly.
bdrewery [Sun, 29 Oct 2017 01:20:56 +0000 (01:20 +0000)]
FAST_DEPEND clean hack: Remove lib32/soft files properly.

Only remove them if the option is enabled and also handle libsoft
by using the proper LIBCOMPAT_OBJTREE.  LIBCOMPAT:D will expand
the text after it as a proper glob to the command line if LIBCOMPAT
is defined.

Sponsored by: Dell EMC Isilon

6 years agoMove FAST_DEPEND cleanup hack into its own target and call from _cleanobj.
bdrewery [Sun, 29 Oct 2017 01:20:53 +0000 (01:20 +0000)]
Move FAST_DEPEND cleanup hack into its own target and call from _cleanobj.

The _worldtmp target is for setting up WORLDTMP.  Nothing between _worldtmp
and _cleanobj will read these files.  Move to its own target since it is
so large.

Sponsored by: Dell EMC Isilon

6 years agoWe don't need LIB32 directories extracted in early phase legacy/WORLDTMP dirs.
bdrewery [Sun, 29 Oct 2017 01:20:50 +0000 (01:20 +0000)]
We don't need LIB32 directories extracted in early phase legacy/WORLDTMP dirs.

This reverts some changes from r289662

Sponsored by: Dell EMC Isilon

6 years agoDisallow using a colon ':' in source checkout paths.
bdrewery [Sun, 29 Oct 2017 01:20:47 +0000 (01:20 +0000)]
Disallow using a colon ':' in source checkout paths.

This leaks into the PATH handling for WORLDTMP and breaks
finding cross-tools.  The PATH handling could be fixed to
properly quote but is not worth the effort.

Also allow this sanity check to always run even with 'make -n'.

MFC after: 2 weeks
Sponsored by: Dell EMC Isilon

6 years agoMove sendmail special check into a _sanity_check target.
bdrewery [Sun, 29 Oct 2017 01:20:43 +0000 (01:20 +0000)]
Move sendmail special check into a _sanity_check target.

MFC after: 2 weeks
Sponsored by: Dell EMC Isilon

6 years agobsnmpd: Only refresh devtree if devd event is a new or removed device.
pfg [Sat, 28 Oct 2017 21:26:49 +0000 (21:26 +0000)]
bsnmpd: Only refresh devtree if devd event is a new or removed device.

It makes sense to refresh the tree only when a device is inserted or
removed, otherwise bsnmpd wastes lot of CPU.

PR: 209368
MFC after: 1 week

6 years agoFix out-of-bounds read in libc/regex.
pfg [Sat, 28 Oct 2017 20:09:34 +0000 (20:09 +0000)]
Fix out-of-bounds read in libc/regex.

The bug is an out-of-bounds read detected with address sanitizer that
happens when 'sp' in p_b_coll_elems() includes NUL byte[s], e.g. if it's
equal to "GS\x00". In that case len will be equal to 4, and the
strncmp(cp->name, sp, len) call will succeed when cp->name is "GS" but the
cp->name[len] == '\0' comparison will cause the read to go out-of-bounds.

Checking the length using strlen() instead eliminates the issue.

The bug was found in LLVM with oss-fuzz:
https://reviews.llvm.org/D39380

MFC after: 1 week
Obtained from: Vlad Tsyrklevich through posting on openbsd-tech

6 years agoSplit the hardware type enum and the hw feature flags bits into separate
ian [Sat, 28 Oct 2017 20:03:29 +0000 (20:03 +0000)]
Split the hardware type enum and the hw feature flags bits into separate
fields in the softc; they're ORed together in the ofw_compat_data.

I already caught myself doing 'sc->fectype == <enum val>' without masking
out the feature bits in one place, and that's sure to happen again.
Glomming them together is convenient for storing them in the ofw_compat_data
array, but there's no reason to keep them together in the softc.

6 years agoSimplify ping sandbox.
oshogbo [Sat, 28 Oct 2017 19:39:22 +0000 (19:39 +0000)]
Simplify ping sandbox.

We don't need to check if casper is present, this is done in the library itself.

Reviewed by: emaste, cem, ed
Differential Revision: https://reviews.freebsd.org/D8754

6 years agoUse the 16-bit receive shift feature in ffec hardware that supports it.
ian [Sat, 28 Oct 2017 19:34:08 +0000 (19:34 +0000)]
Use the 16-bit receive shift feature in ffec hardware that supports it.

When available, enabling this feature causes the hardware to write data
to the receive buffer starting at a 16-bit offset from the start address.
This eliminates the need to copy the data after receiving to re-align
the protocol headers to a 32-bit boundary.

PR: 222634
Submitted by: sebastian.huber@embedded-brains.de

6 years agoIntroduce caspermocks.
oshogbo [Sat, 28 Oct 2017 19:23:57 +0000 (19:23 +0000)]
Introduce caspermocks.

The idea behinds mocks is that we don't need to ifdef a lot of code in
tools itself but those defines are hidden in the casper library.
Right now the mocks are implemented as define/inlines functions.
There was a very long discussion how this should be implemented.
This approach has some advantages like we don't need to link to any additional
libraries. Unfortunately there are also some disadvantages for example it is
easy to get library out of sync between two versions of functions or that we
need extra define to compile program with casper support.
This isn't an ideal solution but it's good enough for now and should simplify
capsicumizing programs. This also doesn't close us any other ways to do those
mocks and this should evolve in time.

Discussed with: pjd, emaste, ed, rwatson, bapt, cem, bdrewery
Differential Revision:    https://reviews.freebsd.org/D8753

6 years agoSupport up to 3 IRQs in the ffec driver.
ian [Sat, 28 Oct 2017 19:08:06 +0000 (19:08 +0000)]
Support up to 3 IRQs in the ffec driver.

Newer hardware splits the interrupts onto 3 different irq lines, but the
docs barely mention that there are multiple interrupts, and do not detail
how they're split up.  The code now supports 1-3 irqs, and uses the same
interrupt service routine to handle all of them.

I modified the submitted changes to use bus_alloc_resources() instead of
using loops to allocate each irq separately.  Thus, blame any bugs on me (I
can't actually test on imx7 hardware).

PR: 222634
Submitted by: sebastian.huber@embedded-brains.de

6 years agoAdd a #define RESOURCE_SPEC_END. Similar to DEVMETHOD_END and
ian [Sat, 28 Oct 2017 18:56:27 +0000 (18:56 +0000)]
Add a #define RESOURCE_SPEC_END.  Similar to DEVMETHOD_END and
KOBJMETHOD_END, this is to serve as the end marker in an array of
resource_spec structures.

6 years agoImport tzdata 2017c
philip [Sat, 28 Oct 2017 18:54:45 +0000 (18:54 +0000)]
Import tzdata 2017c

Changes: https://mm.icann.org/pipermail/tz-announce/2017-October/000047.html

MFC after: 2 days

6 years agoImport tzdata 2017c
philip [Sat, 28 Oct 2017 17:43:05 +0000 (17:43 +0000)]
Import tzdata 2017c

6 years agoAvoid AXI bus issues due to a MAC reset on imx6sx and imx7.
ian [Sat, 28 Oct 2017 17:30:49 +0000 (17:30 +0000)]
Avoid AXI bus issues due to a MAC reset on imx6sx and imx7.

When the FEC is connected to the AXI bus (indicated by AVB flag), a
MAC reset while a bus transaction is pending can hang the bus.
Instead of resetting, turn off the ENABLE bit, which allows the
hardware to complete any in-progress transfers (appending a bad CRC
to any partial packet) and release the AXI bus.  This could probably
be done unconditionally for all hardware variants, but that hasn't
been tested.

PR: 222634
Submitted by: sebastian.huber@embedded-brains.de

6 years agoAdd FECFLAG_AVB variant flag to support new features on imx7.
ian [Sat, 28 Oct 2017 17:06:13 +0000 (17:06 +0000)]
Add FECFLAG_AVB variant flag to support new features on imx7.

This flag is analogous to the Linux driver FEC_QUIRK_HAS_AVB.  It
indicates an FEC with support for Audio Video Bridging (AVB).  This
indicator is used for various other parts in the Linux driver
(drivers/net/ethernet/freescale/fec_main.c).

Use it to customize the receive/transmit buffer alignment.  The receive
buffer alignment increased to 64-bytes on the i.MX 6SoloX and i.MX
7Dual.  There are no hard alignment restrictions for transmit buffers on
these chips.

Fix the ffec_softc::fectype type to provide enough storage for the
feature flags.

PR: 222634
Submitted by: sebastian.huber@embedded-brains.de

6 years agoIncrease the alignment of the rx/tx descriptor ring buffers to 64 bytes.
ian [Sat, 28 Oct 2017 16:50:23 +0000 (16:50 +0000)]
Increase the alignment of the rx/tx descriptor ring buffers to 64 bytes.

16 was the correct alignment for older hardware, but the imx7 requires
64-byte alignment, which is a fine value to use on all systems.

PR: 222634
Submitted by: sebastian.huber@embedded-brains.de

6 years agoRemove a stale and incorrect comment.
markj [Sat, 28 Oct 2017 02:51:27 +0000 (02:51 +0000)]
Remove a stale and incorrect comment.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

6 years agoRemove workqueue items after updating the workqueue tail pointer.
markj [Sat, 28 Oct 2017 02:48:37 +0000 (02:48 +0000)]
Remove workqueue items after updating the workqueue tail pointer.

When QUEUE_MACRO_DEBUG_TRASH is configured, the queue linkage fields
are trashed upon removal of the item, so be sure to only read them before
removing the item.

No functional change intended.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

6 years agoUpdate manpage date to when the deprecation notice was removed.
jlh [Fri, 27 Oct 2017 21:48:02 +0000 (21:48 +0000)]
Update manpage date to when the deprecation notice was removed.

Reported by: bcr

6 years agoFix MAC address detection regression introduced by r324184
gonzo [Fri, 27 Oct 2017 21:22:38 +0000 (21:22 +0000)]
Fix MAC address detection regression introduced by r324184

To accomodate all variaties of Pi DTS files floating around
we look for MAC address property either in DTS node for
USB ethernet (if it exists) or at predefined path
".../usb/hub/ethernet".

After r324184 smsc_fdt_find_eth_node started to return node
with compatibility string "usb424,ec00" as an eth node.
In imported GNU dts files this node still does not have
MAC address related property, and therefor following check for
"mac-address" and "local-mac-address" fails.

To make this logic more robust do not just search for the node
but also make sure it has required property, so if node with
accepted compatibility string exists but doesn't have the
property we fall back to looking for hardoded path mentioned above.

6 years agodma: fix use-after-free
emaste [Fri, 27 Oct 2017 20:21:09 +0000 (20:21 +0000)]
dma: fix use-after-free

Sponsored by: The FreeBSD Foundation

6 years agoFix parsing error when processing cmsg in SCTP send calls. Thei bug is
tuexen [Fri, 27 Oct 2017 19:27:05 +0000 (19:27 +0000)]
Fix parsing error when processing cmsg in SCTP send calls. Thei bug is
related to a signed/unsigned mismatch.
This should most likely fix the issue in sctp_sosend reported by
Dmitry Vyukov on the freebsd-hackers mailing list and found by
running syzkaller.

6 years agoActually release resources in detach() rather than just returning EBUSY.
ian [Fri, 27 Oct 2017 17:21:43 +0000 (17:21 +0000)]
Actually release resources in detach() rather than just returning EBUSY.
This will enable use of 'devctl disable', allow creation of a module, etc.

6 years agoFix a lock leak in g_mirror_destroy().
markj [Fri, 27 Oct 2017 17:05:14 +0000 (17:05 +0000)]
Fix a lock leak in g_mirror_destroy().

g_mirror_destroy() is supposed to unlock the softc before indicating
success, but it wasn't doing so if the caller raced with another
thread destroying the mirror.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

6 years agoUpdate comment to match r177997 & r178036 changes.
obrien [Fri, 27 Oct 2017 16:36:05 +0000 (16:36 +0000)]
Update comment to match r177997 & r178036 changes.

6 years agolibdtrace: replace "DOODAD" with more descriptive string
emaste [Fri, 27 Oct 2017 16:23:45 +0000 (16:23 +0000)]
libdtrace: replace "DOODAD" with more descriptive string

Previously some unimplemented libdtrace routines printed the function,
file and line number, followed by "DOODAD." That is not particularly
informative, so replace it with a message reporting the actual issue.

Sponsored by: The FreeBSD Foundation

6 years agonvd alias has caused some problems, revert it for the moment.
imp [Fri, 27 Oct 2017 14:57:38 +0000 (14:57 +0000)]
nvd alias has caused some problems, revert it for the moment.

Sponsored by: Netflix

6 years agoRework pass through changes in r305485 to be safer.
jhb [Fri, 27 Oct 2017 14:57:14 +0000 (14:57 +0000)]
Rework pass through changes in r305485 to be safer.

Specifically, devices that do not support PCI-e FLR and were not
gracefully shutdown by the guest OS could continue to issue DMA
requests after the VM was terminated.  The changes in r305485 meant
that those DMA requests were completed against the host's memory which
could result in random memory corruption.  Instead, leave ppt devices
that are not attached to a VM disabled in the IOMMU and only restore
the devices to the host domain if the ppt(4) driver is detached from a
device.

As an added safety belt, disable busmastering for a pass-through device
when before adding it to the host domain during ppt(4) detach.

PR: 222937
Tested by: Harry Schmalzbauer <freebsd@omnilan.de>
Reviewed by: grehan
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D12661

6 years agoMFV r325013,r325034: 640 number_to_scaled_string is duplicated in several commands
avg [Fri, 27 Oct 2017 12:37:22 +0000 (12:37 +0000)]
MFV r325013,r325034: 640 number_to_scaled_string is duplicated in several commands

illumos/illumos-gate@0a0551200ecbcd4f1b17560acaeeb7b6c8b0090e
https://github.com/illumos/illumos-gate/commit/0a0551200ecbcd4f1b17560acaeeb7b6c8b0090e

https://www.illumos.org/issues/640
  du(1), df(1m), ls(1), and swap(1m) all include a copy (it appears literally
  copied) of the 'number_to_scaled_string' function in their source. This should
  be moved to a shared library and all 4 commands should use this instead.

FreeBSD note: of all libcmdutils functionality ZFS (and other illumos
contrib code) currently uses only nicenum() function (which is similar
to humanize_number but has some formatting differences).  For this
reason I decided to not port the whole library.  As a result, nicenum.c
from libcmdutils is compiled into libzfs and libzpool.  This is a bit
ugly, but works.  If one day we are forced to create libillumos, then
the file should be moved to that library.

Reviewed by: Sebastian Wiedenroth <wiedi@frubar.net>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Yuri Pankov <yuripv@gmx.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Jason King <jason.brian.king@gmail.com>

MFC after: 2 weeks

6 years agofollow up to r325013, add libcmdutils.h to the vendor area
avg [Fri, 27 Oct 2017 11:26:36 +0000 (11:26 +0000)]
follow up to r325013, add libcmdutils.h to the vendor area

6 years agoRevert r325031. This breaks the build due to __FBSDID.
cy [Fri, 27 Oct 2017 05:04:29 +0000 (05:04 +0000)]
Revert r325031. This breaks the build due to __FBSDID.

Pointy hat to: cy

6 years agoEnsure all incude statements are kept together by moving the
cy [Fri, 27 Oct 2017 04:51:05 +0000 (04:51 +0000)]
Ensure all incude statements are kept together by moving the
sys/cdefs.h include appropriately.

MFC after: 1 week
X-MFC with: r325030

6 years agoRemove redundant sys/cdefs.h include.
cy [Fri, 27 Oct 2017 04:47:44 +0000 (04:47 +0000)]
Remove redundant sys/cdefs.h include.

MFC after: 1 week

6 years agoDiscard the correct thread event reported for a ptrace stop.
jhb [Fri, 27 Oct 2017 03:16:19 +0000 (03:16 +0000)]
Discard the correct thread event reported for a ptrace stop.

When multiple threads wish to report a tracing event to a debugger,
both threads call ptracestop() and one thread will win the race to be
the reporting thread (p->p_xthread).  The debugger uses PT_LWPINFO
with the process ID to determine which thread / LWP is reporting an
event and the details of that event.  This event is cleared as a side
effect of the subsequent ptrace event that resumed the process
(PT_CONTINUE, PT_STEP, etc.).  However, ptrace() was clearing the
event identified by the LWP ID passed to the resume request even if
that wasn't the 'p_xthread'.  This could result in clearing an event
that had not yet been observed by the debugger and leaving the
existing event for 'p_thread' pending so that it was reported a second
time.

Specifically, if the debugger stopped due to a software breakpoint in
one thread, but then switched to another thread that was used to
resume (e.g. if the user switched to a different thread and issued a
step), the resume request (PT_STEP) cleared a pending event (if any)
for the thread being stepped.  However, the process immediately
stopped and the first thread reported it's breakpoint event a second
time.  The debugger decremented the PC for "both" breakpoint events
which resulted in the PC now pointing into the middle of an
instruction (on x86) and a SIGILL fault when the process was resumed a
second time.

To fix, always clear the pending event for 'p_xthread' when resuming a
process.  ptrace() still honors the requested LWP ID when enabling
single-stepping (PT_STEP) or setting a different PC (PT_CONTINUE).

Reported by: GDB testsuite (gdb.threads/continue-pending-status.exp)
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D12794

6 years agoWe should be call adaerror() instead of cam_periph_error() always.
imp [Thu, 26 Oct 2017 22:53:55 +0000 (22:53 +0000)]
We should be call adaerror() instead of cam_periph_error() always.

Sponsored by: Netflix

6 years agoAlways send STANDBY IMMEDIATE when shutting down
imp [Thu, 26 Oct 2017 22:53:49 +0000 (22:53 +0000)]
Always send STANDBY IMMEDIATE when shutting down

To save SMART data and for a drive to understand that it's been nicely
shutdown, we need to send a STANDBY IMMEDIATE. Modify adaspindown to
use a local CCB on the stack. When we're panicing, used
xpt_polled_action rather than cam_periph_runccb so that we can SEND
IMMEDIATE after we've shutdown the scheduler.

Sponsored by: Netflix
Reviewed by: scottl@, gallatin@
Differential Revision: https://reviews.freebsd.org/D12799

6 years agoMake time we wait for a power cycle tunable.
imp [Thu, 26 Oct 2017 22:53:02 +0000 (22:53 +0000)]
Make time we wait for a power cycle tunable.

hw.ipmi.cycle_time is the time to wait for the power down phase of the
ipmi power cycle before falling back to either reboot or halt.

Sponsored by: Netflix

6 years agoVarious IPMI watchdog timer improvements
imp [Thu, 26 Oct 2017 22:52:51 +0000 (22:52 +0000)]
Various IPMI watchdog timer improvements

o Make hw.ipmi.on a tuneable
o Changes to keep shutdown from hanging indefinitately after the wd
  would normally have been disabled.
o Add support for setting pretimeout (which fires an interrupt
  some time before the actual watchdog expires)
o Allow refinement of the actions to take when the watchdog expires
o Allow special startup timeout to keep us from hanging in boot
  before watchdogd is started, but after we've loaded the kernel.

Obtained From: Netflix OCA Firmware

6 years agopf tests: Remove temporary files
kp [Thu, 26 Oct 2017 20:55:33 +0000 (20:55 +0000)]
pf tests: Remove temporary files

Remove the created_jails.lst and created_interfaces.lst files in the
cleanup code.

6 years agopf tests: Fragmentation (v6) test
kp [Thu, 26 Oct 2017 20:54:52 +0000 (20:54 +0000)]
pf tests: Fragmentation (v6) test

Test fragmentation handling (i.e. scrub fragment reassemble) code for
IPv6.

Two simple tests: Ping a host (jail) and test forwarding of fragmented
packets.

6 years agopf tests: destroy jails before destroying interfaces
kp [Thu, 26 Oct 2017 20:53:56 +0000 (20:53 +0000)]
pf tests: destroy jails before destroying interfaces

When cleaning up we must destroy the jails before we destroy the interfaces.
Otherwise we might try to destroy interfaces that belong to a jail, which won't
work and fail to completely clean up.

6 years agoIntroduce cnvlist_name() and cnvlist_type() functions.
oshogbo [Thu, 26 Oct 2017 20:44:42 +0000 (20:44 +0000)]
Introduce cnvlist_name() and cnvlist_type() functions.

Those function can be used when we are iterating over nvlist to reduce
amount of extra variables we need to declare.

MFC after: 1 month

6 years agoFix aio_suspend in 32-bit emulation
asomers [Thu, 26 Oct 2017 19:45:15 +0000 (19:45 +0000)]
Fix aio_suspend in 32-bit emulation

An off-by-one error has been present since the system call was first present
in 185878.  It additionally became a memory corruption bug after change
324941.  The failure is actually revealed by our existing AIO tests.
However, apparently nobody's been running those in 32-bit emulation mode.

Reported by: Coverity, cem
CID: 1382114
MFC after: 18 days
X-MFC-With: 324941
Sponsored by: Spectra Logic Corp

6 years agolibnv: Fix strict-aliasing violation with cookie
jilles [Thu, 26 Oct 2017 18:32:04 +0000 (18:32 +0000)]
libnv: Fix strict-aliasing violation with cookie

In rS323851, some casts were adjusted in calls to nvlist_next() and
nvlist_get_pararr() in order to make scan-build happy. I think these changes
just confused scan-build into not reporting the strict-aliasing violation.

For example, nvlist_xdescriptors() is causing nvlist_next() to write to its
local variable nvp of type nvpair_t * using the lvalue *cookiep of type
void *, which is not allowed. Given the APIs of nvlist_next(),
nvlist_get_parent() and nvlist_get_pararr(), one possible fix is to create a
local void *cookie in nvlist_xdescriptors() and other places, and to convert
the value to nvpair_t * when necessary. This patch implements that fix.

Reviewed by: oshogbo
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D12760

6 years agoPartially revert r325011: restore Guid's default constructor
asomers [Thu, 26 Oct 2017 17:56:34 +0000 (17:56 +0000)]
Partially revert r325011: restore Guid's default constructor

Reported by: ohartmann
MFC after: 3 weeks
X-MFC-With: 325011
Sponsored by: Spectra Logic Corp

6 years agoAdd a 'place holder' arm struct efi_fb until a real one comes
imp [Thu, 26 Oct 2017 16:36:27 +0000 (16:36 +0000)]
Add a 'place holder' arm struct efi_fb until a real one comes
along. This allows the arm efi boot loader to compile again.

Sponsored by: Netflix

6 years ago640 number_to_scaled_string is duplicated in several commands
avg [Thu, 26 Oct 2017 16:20:47 +0000 (16:20 +0000)]
640 number_to_scaled_string is duplicated in several commands

illumos/illumos-gate@0a0551200ecbcd4f1b17560acaeeb7b6c8b0090e
https://github.com/illumos/illumos-gate/commit/0a0551200ecbcd4f1b17560acaeeb7b6c8b0090e

https://www.illumos.org/issues/640
  du(1), df(1m), ls(1), and swap(1m) all include a copy (it appears literally
  copied) of the 'number_to_scaled_string' function in their source. This should
  be moved to a shared library and all 4 commands should use this instead.

Reviewed by: Sebastian Wiedenroth <wiedi@frubar.net>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Yuri Pankov <yuripv@gmx.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Jason King <jason.brian.king@gmail.com>

6 years agoRemove now-empty directories
imp [Thu, 26 Oct 2017 16:02:38 +0000 (16:02 +0000)]
Remove now-empty directories

6 years agozfsd should be able to online an L2ARC that disappears and returns
asomers [Thu, 26 Oct 2017 15:28:18 +0000 (15:28 +0000)]
zfsd should be able to online an L2ARC that disappears and returns

Previously, this didn't work because L2ARC devices' labels don't contain
pool GUIDs.  Modify zfsd so that the pool GUID won't be required:

lib/libdevdctl/guid.h
Change INVALID_GUID from a uint64_t constant to a function that
returns an invalid Guid object.  Remove the void constructor.
Nothing uses it, and it violates RAII.

cddl/usr.sbin/zfsd/case_file.h
cddl/usr.sbin/zfsd/case_file.cc
Allow CaseFile::Find to match a CaseFile based on Vdev GUID alone.
In CaseFile::ReEvaluate, attempt to online devices even if the newly
arrived device has no pool GUID.

cddl/usr.sbin/zfsd/vdev_iterator.cc
Iterate through a pool's cache devices as well as its regular
devices.

Reported by: avg
Reviewed by: avg
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D12791

6 years agoIf the user-provided password exceeds the maximum password length, don't
des [Thu, 26 Oct 2017 13:23:13 +0000 (13:23 +0000)]
If the user-provided password exceeds the maximum password length, don't
bother passing it to crypt().  It won't succeed and may allow an attacker
to confirm that the user exists.

Reported by: jkim@
MFC after: 1 week
Security: CVE-2016-6210

6 years agoMake gmountver(8) use direct dispatch.
trasz [Thu, 26 Oct 2017 10:18:31 +0000 (10:18 +0000)]
Make gmountver(8) use direct dispatch.

MFC after: 2 weeks

6 years agoFix Dummynet AQM packet marking function ecn_mark() and fq_codel /
truckman [Thu, 26 Oct 2017 10:11:35 +0000 (10:11 +0000)]
Fix Dummynet AQM packet marking function ecn_mark() and fq_codel /
fq_pie schedulers packet classification functions in layer2 (bridge mode).

Dummynet AQM packet marking function ecn_mark() and fq_codel/fq_pie
schedulers packet classification functions (fq_codel_classify_flow()
and fq_pie_classify_flow()) assume mbuf is pointing at L3 (IP)
packet. However, this assumption is incorrect if ipfw/dummynet is
used to manage layer2 traffic (bridge mode) since mbuf will point
at L2 frame.  This patch solves this problem by identifying the
source of the frame/packet (L2 or L3) and adding ETHER_HDR_LEN
offset when converting an mbuf pointer to ip pointer if the traffic
is from layer2.  More specifically, in dummynet packet tagging
function, tag_mbuf(), iphdr_off is set to ETHER_HDR_LEN if the
traffic is from layer2 and set to zero otherwise. Whenever an access
to IP header is required, mtodo(m, dn_tag_get(m)->iphdr_off) is
used instead of mtod(m, struct ip *) to correctly convert mbuf
pointer to ip pointer in both L2 and L3 traffic.

Submitted by: lstewart
MFC after: 2 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D12506

6 years agoMake gmountver(8) use G_PF_ACCEPT_UNMAPPED.
trasz [Thu, 26 Oct 2017 09:29:35 +0000 (09:29 +0000)]
Make gmountver(8) use G_PF_ACCEPT_UNMAPPED.

MFC after: 2 weeks

6 years agoFix typo and bump .Dd date.
imp [Wed, 25 Oct 2017 23:24:30 +0000 (23:24 +0000)]
Fix typo and bump .Dd date.

Noticed by: Richard Tector
Sponsored by: Netflix

6 years agoCleanup pieces missed in r315057 which made mandoc mandatory
bdrewery [Wed, 25 Oct 2017 21:46:39 +0000 (21:46 +0000)]
Cleanup pieces missed in r315057 which made mandoc mandatory

Sponsored by: Dell EMC Isilon

6 years agoFix native-xtools build to use a proper sysroot.
bdrewery [Wed, 25 Oct 2017 21:46:36 +0000 (21:46 +0000)]
Fix native-xtools build to use a proper sysroot.

This takes longer but should reliably produce working binaries.
The old version linked against system libraries and headers
which would be a problem if building a native-xtools against
a newer source than the host system.  With a proper sysroot made
first this is not a problem.

This also allows:
- NXBDIRS to be built in parallel
- NXBDIRS to be installed to NXBDESTDIR in parallel
- SYSTEM_COMPILER logic to work again.  Note that because this change
  is adding a sysroot phase the compiler may be built up to twice now.
  The first is the "cross-compiler" even though it is for the native
  architecture, but it is still built to ensure the latest compiler
  is used to generate the binaries, unless SYSTEM_COMPILER allows
  /usr/bin/cc to be used.  Then the target compiler is built
  which is actually a cross-compiler since it runs on native host
  but generates TARGET.TARGET_ARCH binaries.

Note this also changes the path used for the OBJDIR.  It used to use
/usr/obj/target.target_arch/nxb/<srcdir> for objects and
/usr/obj/target.target_arch/nxb-bin for installed files, but now uses
/usr/obj/nxb/target.target_arch/<srcdir> for objects and
/usr/obj/nxb/target.target_arch/<srcdir>/nxb-bin for installed files.
  - NXBDESTDIR can be specified for where to install or queried with
    `make -f Makefile.inc1 TARGET=... TARGET_ARCH=... -V NXBDESTDIR`

This could potentially be improved to reuse an existing sysroot.  The
problem is with building the SUBDIR_OVERRIDE list it needs to use a
different OBJDIR since it is building all statically.  We don't want to
pollute the existing 'buildworld' OBJDIR and cause confusion on the next
build.  Using a separate OBJDIR for the 'everything' phase mostly works
except for some things like linking in INTERNALLIBS that exist in the
other OBJDIR.

MFC after: 1 month
Sponsored by: Dell EMC Isilon

6 years agonative-xtools: Override proper NXBDESTDIR.
bdrewery [Wed, 25 Oct 2017 21:46:33 +0000 (21:46 +0000)]
native-xtools: Override proper NXBDESTDIR.

The new native-xtools uses 'make toolchain' so overriding DESTDIR
as a make argument may interfere with WORLDTMP handling.
The target also does a 'mkdir -p ${NXBDESTDIR}/usr', so we should
be modifying that rather than DESTDIR.

Note this causes the native-xtools binaries to be installed in
NANO_WORLDDIR/usr NANO_WORLDDIR/bin rather than NANO_WORLDDIR/nxb-bin/usr
and NANO_WORLDDIR/nxb-bin/bin.  This was the case before this change
as well.

MFC after: 2 weeks
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D12782

6 years agoMETA_MODE: Follow-up r319593: Don't use host headers in a fresh new build.
bdrewery [Wed, 25 Oct 2017 21:46:30 +0000 (21:46 +0000)]
META_MODE: Follow-up r319593: Don't use host headers in a fresh new build.

Sponsored by: Dell EMC Isilon

6 years agoPrefix {TARGET,BUILD}_TRIPLE with LLVM_ to avoid Makefile.inc1 collision.
bdrewery [Wed, 25 Oct 2017 21:45:55 +0000 (21:45 +0000)]
Prefix {TARGET,BUILD}_TRIPLE with LLVM_ to avoid Makefile.inc1 collision.

The Makefile.inc1 TARGET_TRIPLE is for specifying which -target is used
during the build of world.

MFC after: 2 weeks
Reviewed by: dim, imp
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D12792

6 years agoEvaluate packet size after the firewall had its chance in the ip6 fast path
kp [Wed, 25 Oct 2017 19:21:48 +0000 (19:21 +0000)]
Evaluate packet size after the firewall had its chance in the ip6 fast path

Defer the packet size check until after the firewall has had a look at it. This
means that the firewall now has the opportunity to (re-)fragment an oversized
packet.
This mirrors what the slow path does.

Reviewed by: ae
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D12779

6 years agoloader.efi: Make framebuffer commands available for arm64
manu [Wed, 25 Oct 2017 18:55:04 +0000 (18:55 +0000)]
loader.efi: Make framebuffer commands available for arm64

Move framebuffer.{c,h} to sys/boot/efi/loader and add the efifb
related metadata and pass it to the kernel

Reviewed by: imp, andrew
Differential Revision: https://reviews.freebsd.org/D12757

6 years agoEnable i386 build of the Cavium LiquidIO driver (lio) module.
sbruno [Wed, 25 Oct 2017 17:49:17 +0000 (17:49 +0000)]
Enable i386 build of the Cavium LiquidIO driver (lio) module.

Submitted by: pkanneganti@cavium.com (Prasad V Kanneganti)
MFC after: 1 week
Sponsored by: Cavium Networks
Differential Revision: https://reviews.freebsd.org/D12415

6 years agoAdd a test for sending a signal while stepping a thread via PT_STEP.
jhb [Wed, 25 Oct 2017 17:23:33 +0000 (17:23 +0000)]
Add a test for sending a signal while stepping a thread via PT_STEP.

MFC after: 1 week

6 years agoMake drain_output() use bufobj_wwait().
markj [Wed, 25 Oct 2017 17:20:18 +0000 (17:20 +0000)]
Make drain_output() use bufobj_wwait().

No functional change intended.

Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D12790

6 years agoFix zpool_read_all_labels when vfs.aio.enable_unsafe=0
asomers [Wed, 25 Oct 2017 16:01:19 +0000 (16:01 +0000)]
Fix zpool_read_all_labels when vfs.aio.enable_unsafe=0

Previously, zpool_read_all_labels was trying to do 256KB reads, which are
greater than the default MAXPHYS and therefore must go through the slow,
unsafe AIO path.  Shrink these reads to 112KB so they can use the safe, fast
AIO path instead.

MFC after: 1 week
X-MFC-With: 324568
Sponsored by: Spectra Logic Corp

6 years agoImplement IPMI support for RB_POWRECYCLE
imp [Wed, 25 Oct 2017 15:30:53 +0000 (15:30 +0000)]
Implement IPMI support for RB_POWRECYCLE

Some BMCs support power cycling the chassis via the chassis control
command 2 subcommand 2 (ipmitool called it 'chassis power cycle').  If
the BMC supports the chassis device, register a shutdown_final handler
that sends the power cycle command if request and waits up to 10s for
it to take effect. To minimize stack strain, we preallocate a ipmi
request in the softc. At the moment, we're verbose about what we're
doing.

Sponsored by: Netflix

6 years agoHandle RB_POWERCYCLE in ada driver
imp [Wed, 25 Oct 2017 15:30:48 +0000 (15:30 +0000)]
Handle RB_POWERCYCLE in ada driver

Allow the disks to be spun down when doing a POWERCYCLE as well as
POWEROFF.

Sponsored by: Netflix

6 years agoHandle RB_POWERCYCLE in the MI part of the kernel
imp [Wed, 25 Oct 2017 15:30:44 +0000 (15:30 +0000)]
Handle RB_POWERCYCLE in the MI part of the kernel

Signal init with SIGWINCH in shutdown_nice for RB_POWERCYCLE.

Sponsored by: Netflix

6 years agoImplement power cycle in init.
imp [Wed, 25 Oct 2017 15:30:40 +0000 (15:30 +0000)]
Implement power cycle in init.

If SIGWINCH is received, then halt with power cycle.

Sponsored by: Netflix

6 years agoAdd power cycle support to reboot/halt as -c.
imp [Wed, 25 Oct 2017 15:30:35 +0000 (15:30 +0000)]
Add power cycle support to reboot/halt as -c.

When -c is specified, the system will be power cycled if the
underlying hardware supports it. Otherwise the system will be halted
or rebooted depending on which command was used.

Sponsored by: Netflix

6 years agoAdd power cycle support (-c) to shutdown.
imp [Wed, 25 Oct 2017 15:30:30 +0000 (15:30 +0000)]
Add power cycle support (-c) to shutdown.

Sponsored by: Netflix

6 years agoRB_POWERCYCLE needs to be handled like RB_POWEROFF for decoding.
imp [Wed, 25 Oct 2017 15:30:25 +0000 (15:30 +0000)]
RB_POWERCYCLE needs to be handled like RB_POWEROFF for decoding.

Sponsored by: Netflix

6 years agoDefine RB_POWERCYCLE
imp [Wed, 25 Oct 2017 15:30:20 +0000 (15:30 +0000)]
Define RB_POWERCYCLE

RB_POWERCYCLE instructs the platform to power off and then power back
on a short time later, if that's possible. Otherwise, degrade to the
RB_POWEROFF behavior.

Sponsored by: Netflix

6 years agoRemove sys/boot/arm/at91 and ixp425
imp [Wed, 25 Oct 2017 15:28:05 +0000 (15:28 +0000)]
Remove sys/boot/arm/at91 and ixp425

Remove at91 bootloader. It only worked on AT91RM9200, and only
specific boards that were all EOLd 10 years ago.

Remove ixp425. It doesn't build anymore and is for boards that were
EOLd 8 years ago.

Sponsored by: Netflix

6 years agoMove BINDIR definition to defs.mk, and override where it isn't /boot
imp [Wed, 25 Oct 2017 15:27:58 +0000 (15:27 +0000)]
Move BINDIR definition to defs.mk, and override where it isn't /boot
(those files already do that so weren't changed).

Sponsored by: Netflix

6 years agoUse BOOTDIR consistently. We need to include bsd.init.mk early to make
imp [Wed, 25 Oct 2017 15:27:53 +0000 (15:27 +0000)]
Use BOOTDIR consistently. We need to include bsd.init.mk early to make
this happen. This will cause src.opts.mk to be included, so remove
that. This needs to propigate through the sys/boot tree.

Sponsored by: Netflix

6 years agoDo a chdir to SRCTOP/sys/boot before starting the run. This lets one
imp [Wed, 25 Oct 2017 15:27:48 +0000 (15:27 +0000)]
Do a chdir to SRCTOP/sys/boot before starting the run. This lets one
run this script from anywhere, but makes it only work on sys/boot.

Sponsored by: Netflix

6 years agoReport only the valid slots in the firmware log page.
imp [Wed, 25 Oct 2017 15:26:03 +0000 (15:26 +0000)]
Report only the valid slots in the firmware log page.

Printing the entire log page is causing confusion over available
slots. Report only those slots that are valid. In the case where the
firmware download isn't supported, assume that only the first slot is
valid (I have no hardware to test this assumption though)

Sponsored by: Netflix

6 years agoAdd nvme_controller_data argument to all print functions.
imp [Wed, 25 Oct 2017 15:25:55 +0000 (15:25 +0000)]
Add nvme_controller_data argument to all print functions.

It's desirable to access controler data to inform printing log pages
(such as limiting the printing to valid ranges).

Sponsored by: Netflix

6 years agoLimit top display of total swap size by the max swap size system can
kib [Wed, 25 Oct 2017 11:44:46 +0000 (11:44 +0000)]
Limit top display of total swap size by the max swap size system can
handle.

Keep both pagesize and the new swap_maxpages in the static variables
to save sysctl calls.

Submitted by: ota@j.email.ne.jp
PR: 223149
MFC after: 2 weeks

6 years agoFix a bug reported by Felix Weinrank using the libfuzzer on the
tuexen [Wed, 25 Oct 2017 09:12:22 +0000 (09:12 +0000)]
Fix a bug reported by Felix Weinrank using the libfuzzer on the
userland stack.

MFC after: 3 days

6 years agoAdd support for compressed kernel dumps.
markj [Wed, 25 Oct 2017 00:51:00 +0000 (00:51 +0000)]
Add support for compressed kernel dumps.

When using a kernel built with the GZIO config option, dumpon -z can be
used to configure gzip compression using the in-kernel copy of zlib.
This is useful on systems with large amounts of RAM, which require a
correspondingly large dump device. Recovery of compressed dumps is also
faster since fewer bytes need to be copied from the dump device.

Because we have no way of knowing the final size of a compressed dump
until it is written, the kernel will always attempt to dump when
compression is configured, regardless of the dump device size. If the
dump is aborted because we run out of space, an error is reported on
the console.

savecore(8) is modified to handle compressed dumps and save them to
vmcore.<index>.gz, as it does when given the -z option.

A new rc.conf variable, dumpon_flags, is added. Its value is added to
the boot-time dumpon(8) invocation that occurs when a dump device is
configured in rc.conf.

Reviewed by: cem (earlier version)
Discussed with: def, rgrimes
Relnotes: yes
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D11723

6 years agobnxt: add support for Flow control setting using sysctl
shurd [Tue, 24 Oct 2017 21:18:50 +0000 (21:18 +0000)]
bnxt: add support for Flow control setting using sysctl

Created sysctl node dev.bnxt.0.fc with following options.

A. dev.bnxt.0.fc.autoneg
B. dev.bnxt.0.fc.rx
C. dev.bnxt.0.fc.tx

Description:-
dev.bnxt.0.fc: flow ctrl
dev.bnxt.0.fc.autoneg: Enable or Disable Autoneg Flow Ctrl: 0 / 1
dev.bnxt.0.fc.rx: Enable or Disable Rx Flow Ctrl: 0 / 1
dev.bnxt.0.fc.tx: Enable or Disable Tx Flow Ctrl: 0 / 1

Submitted by: Bhargava Chenna Marreddy <bhargava.marreddy@broadcom.com>
Reviewed by: shurd, sbruno
Approved by: sbruno (mentor)
Sponsored by: Broadcom Limited
Differential Revision: https://reviews.freebsd.org/D12599

6 years agoFix physical block number overflow in different places.
fsu [Tue, 24 Oct 2017 20:10:08 +0000 (20:10 +0000)]
Fix physical block number overflow in different places.

Approved by:    pfg (mentor)
MFC after:      6 months

6 years agoSet doreallocblks sysctl value to zero by default because of
fsu [Tue, 24 Oct 2017 19:16:25 +0000 (19:16 +0000)]
Set doreallocblks sysctl value to zero by default because of
possibility of filesystem corruption.

Approved by:    pfg (mentor)
MFC after:      2 weeks

6 years agoDo not free bufs in case of extents metadata blocks + remove unneeded asserts.
fsu [Tue, 24 Oct 2017 19:14:33 +0000 (19:14 +0000)]
Do not free bufs in case of extents metadata blocks + remove unneeded asserts.

Approved by:    pfg (mentor)
MFC after:      6 months

6 years agoMicro-optimize the handling of fictitious pages in vm_page_free_prep().
alc [Tue, 24 Oct 2017 17:14:53 +0000 (17:14 +0000)]
Micro-optimize the handling of fictitious pages in vm_page_free_prep().
A fictitious page is always wired, so there is no point in trying to
remove one from the page queues.

Completely remove one inaccurate comment from vm_page_free_prep() and
correct another.

Reviewed by: kib, markj
MFC after: 1 week

6 years agoExtract a set of pmcstat functions and interfaces to the new internal
br [Tue, 24 Oct 2017 16:28:00 +0000 (16:28 +0000)]
Extract a set of pmcstat functions and interfaces to the new internal
library -- libpmcstat.

This includes PMC logging module, symbols lookup functions,
ELF parsing, process management, PMC attachment, etc.

This allows to reuse code while building new hwpmc(4)-based applications.

Also add pmcstat_symbol_search_by_name() function that allows to find
mapped IP range for a given function name.

Reviewed by: kib
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D12718

6 years agoFix a bug in handling special ABORT chunks.
tuexen [Tue, 24 Oct 2017 16:24:12 +0000 (16:24 +0000)]
Fix a bug in handling special ABORT chunks.
Thanks to Felix Weinrank for finding this issue using libfuzzer with
the userland stack.

MFC after: 3 days

6 years agoiscsi_shutdown_post: do nothing if panic-ing
avg [Tue, 24 Oct 2017 14:59:31 +0000 (14:59 +0000)]
iscsi_shutdown_post: do nothing if panic-ing

There is nothing that that routine should or could really do in that
context.

Reported by: Ben RUBSON <ben.rubson@gmail.com>
MFC after: 1 week

6 years agoBump man page revision dates for r324941
asomers [Tue, 24 Oct 2017 14:34:25 +0000 (14:34 +0000)]
Bump man page revision dates for r324941

Reported by: jhb
MFC after: 20 days
X-MFC-with: 324941
Sponsored by: Spectra Logic Corp

6 years agoFix a locking issue found by running AFL on the userland stack.
tuexen [Tue, 24 Oct 2017 14:28:56 +0000 (14:28 +0000)]
Fix a locking issue found by running AFL on the userland stack.
Thanks to Felix Weinrank for reporting the issue.

MFC after: 3 days