]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoMerge ^/head r344178 through r344512.
dim [Mon, 25 Feb 2019 11:59:29 +0000 (11:59 +0000)]
Merge ^/head r344178 through r344512.

5 years agonetmap: remove redundant call to nm_set_native_flags()
vmaffione [Mon, 25 Feb 2019 09:57:06 +0000 (09:57 +0000)]
netmap: remove redundant call to nm_set_native_flags()

This redundant call was introduced by mistake in r343772.

MFC after: 3 days
Sponsored by: Sunny Valley Networks

5 years agoSwitch to using config_intrhook_oneshot(). That allows the error handling
ian [Mon, 25 Feb 2019 03:29:12 +0000 (03:29 +0000)]
Switch to using config_intrhook_oneshot().  That allows the error handling
in the delayed attach to use early returns, which allows reducing the level
of indentation.  So all in all, what looks like a lot of changes is really
no change in behavior, mostly just moving whitespace around.

5 years agoAdd support for probing/attaching on FDT-based systems.
ian [Sun, 24 Feb 2019 23:16:33 +0000 (23:16 +0000)]
Add support for probing/attaching on FDT-based systems.

5 years agoAdd a functional detach() implementation to make module unloading possible.
ian [Sun, 24 Feb 2019 23:08:53 +0000 (23:08 +0000)]
Add a functional detach() implementation to make module unloading possible.

5 years agoMake arp code return (more) errors.
bz [Sun, 24 Feb 2019 22:49:56 +0000 (22:49 +0000)]
Make arp code return (more) errors.

arprequest() is a void function and in case of error we simply
return without any feedback. In case of any local operation
or *if_output() failing no feedback is send up the stack for the
packet which triggered the arp request to be sent.
arpresolve_full() has three pre-canned possible errors returned
(if we have not yet sent enough arp requests or if we tried
often enough without success) otherwise "no error" is returned.

Make arprequest() an "internal" function arprequest_internal() which
does return a possible error to the caller. Preserve arprequest()
as a void wrapper function for external consumers.
In arpresolve_full() add an extra error checking. Use the
arprequest_internal() function and only return an error if non
of the three ones (mentioend above) are already set.

This will return possible errors all the way up the stack and
allows functions and programs to react on the send errors rather
than leaving them in the dark. Also they might get more detailed
feedback of why packets cannot be sent and they will receive it
quicker.

Reviewed by: karels, hselasky
Differential Revision: https://reviews.freebsd.org/D18904

5 years agoPull in r354756 from upstream llvm trunk (by Craig Topper):
dim [Sun, 24 Feb 2019 21:22:16 +0000 (21:22 +0000)]
Pull in r354756 from upstream llvm trunk (by Craig Topper):

  [X86] Fix tls variable lowering issue with large code model

  Summary:
  The problem here is the lowering for tls variable. Below is the DAG
  for the code. SelectionDAG has 11 nodes:

  t0: ch = EntryToken
t8: i64,ch = load<(load 8 from `i8 addrspace(257)* null`,
addrspace 257)> t0, Constant:i64<0>, undef:i64
  t10: i64 = X86ISD::WrapperRIP TargetGlobalTLSAddress:i64<i32*
  @x> 0 [TF=10]
t11: i64,ch = load<(load 8 from got)> t0, t10, undef:i64
      t12: i64 = add t8, t11
    t4: i32,ch = load<(dereferenceable load 4 from @x)> t0, t12,
    undef:i64
  t6: ch = CopyToReg t0, Register:i32 %0, t4

  And when mcmodel is large, below instruction can NOT be folded.

    t10: i64 = X86ISD::WrapperRIP TargetGlobalTLSAddress:i64<i32* @x> 0
    [TF=10]
  t11: i64,ch = load<(load 8 from got)> t0, t10, undef:i64

  So "t11: i64,ch = load<(load 8 from got)> t0, t10, undef:i64" is
  lowered to " Morphed node: t11: i64,ch = MOV64rm<Mem:(load 8 from
  got)> t10, TargetConstant:i8<1>, Register:i64 $noreg,
  TargetConstant:i32<0>, Register:i32 $noreg, t0"

  When llvm start to lower "t10: i64 = X86ISD::WrapperRIP
  TargetGlobalTLSAddress:i64<i32* @x> 0 [TF=10]", it fails.

  The patch is to fold the load and X86ISD::WrapperRIP.

  Fixes PR26906

  Patch by LuoYuanke

  Reviewers: craig.topper, rnk, annita.zhang, wxiao3

  Reviewed By: rnk

  Subscribers: llvm-commits

  Tags: #llvm

  Differential Revision: https://reviews.llvm.org/D58336

This should fix "fatal error: error in backend: Cannot select" messages
when compiling <ctype.h> functions using -mcmodel=large.

Reported by: phk
PR: 233143
MFC after: 3 days

5 years agosh: Add set -o pipefail
jilles [Sun, 24 Feb 2019 21:05:13 +0000 (21:05 +0000)]
sh: Add set -o pipefail

The pipefail option allows checking the exit status of all commands in a
pipeline more easily, at a limited cost of complexity in sh itself. It works
similarly to the option in bash, ksh93 and mksh.

Like ksh93 and unlike bash and mksh, the state of the option is saved when a
pipeline is started. Therefore, even in the case of commands like
  A | B &
a later change of the option does not change the exit status, the same way
  (A | B) &
works.

Since SIGPIPE is not handled specially, more work in the script is required
for a proper exit status for pipelines containing commands such as head that
may terminate successfully without reading all input. This can be something
like

(
        cmd1
        r=$?
        if [ "$r" -gt 128 ] && [ "$(kill -l "$r")" = PIPE ]; then
                exit 0
        else
                exit "$r"
        fi
) | head

PR: 224270
Relnotes: yes

5 years agoFix build when EVDEV_SUPPORT is option disabled after r344494
wulf [Sun, 24 Feb 2019 19:31:42 +0000 (19:31 +0000)]
Fix build when EVDEV_SUPPORT is option disabled after r344494

MFC with: 344494

5 years agoevdev: export event device properties through sysctl interface
wulf [Sun, 24 Feb 2019 18:47:04 +0000 (18:47 +0000)]
evdev: export event device properties through sysctl interface

A big security advantage of Wayland is not allowing applications to read
input devices all the time. Having /dev/input/* accessible to the user
account subverts this advantage.

libudev-devd was opening the evdev devices to detect their types (mouse,
keyboard, touchpad, etc). This don't work if /dev/input/* is inaccessible.
With the kernel exposing this information as sysctls (kern.evdev.input.*),
we can work w/o /dev/input/* access, preserving the Wayland security model.

Submitted by: Greg V <greg@unrelenting.technology>
Reviewed by: wulf, imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D18694

5 years agopf: Small performance tweak
kp [Sun, 24 Feb 2019 17:23:55 +0000 (17:23 +0000)]
pf: Small performance tweak

Because fetching a counter is a rather expansive function we should use
counter_u64_fetch() in pf_state_expires() only when necessary. A "rdr
pass" rule should not cause more effort than separate "rdr" and "pass"
rules. For rules with adaptive timeout values the call of
counter_u64_fetch() should be accepted, but otherwise not.

From the man page:
    The adaptive timeout values can be defined both globally and for
    each rule.  When used on a per-rule basis, the values relate to the
    number of states created by the rule, otherwise to the total number
    of states.

This handling of adaptive timeouts is done in pf_state_expires().  The
calculation needs three values: start, end and states.

1. Normal rules "pass .." without adaptive setting meaning "start = 0"
   runs in the else-section and therefore takes "start" and "end" from
   the global default settings and sets "states" to pf_status.states
   (= total number of states).

2. Special rules like
   "pass .. keep state (adaptive.start 500 adaptive.end 1000)"
   have start != 0, run in the if-section and take "start" and "end"
   from the rule and set "states" to the number of states created by
   their rule using counter_u64_fetch().

Thats all ok, but there is a third case without special handling in the
above code snippet:

3. All "rdr/nat pass .." statements use together the pf_default_rule.
   Therefore we have "start != 0" in this case and we run the
   if-section but we better should run the else-section in this case and
   do not fetch the counter of the pf_default_rule but take the total
   number of states.

Submitted by: Andreas Longwitz <longwitz@incore.de>
MFC after: 2 weeks

5 years agostyle.mdoc.5: Fix a typo
0mp [Sun, 24 Feb 2019 14:20:47 +0000 (14:20 +0000)]
style.mdoc.5: Fix a typo

Reviewed by: eadler
Approved by: eadler (doc)
Approved by: krion (mentor, implicit), mat (mentor, implicit)
Differential Revision: https://reviews.freebsd.org/D19328

5 years agoAn IPv6 address matching should be fixed. Specifying an IPv6
ume [Sun, 24 Feb 2019 03:41:05 +0000 (03:41 +0000)]
An IPv6 address matching should be fixed.  Specifying an IPv6
address by the -a option was broken since r309933.

Reported by: "O. Hartmann" <ohartmann [...] walstatt.org>
MFC after: 1 week

5 years agoFree some space in struct ctl_io_hdr for better use.
mav [Sat, 23 Feb 2019 23:35:52 +0000 (23:35 +0000)]
Free some space in struct ctl_io_hdr for better use.

 - Collapse original_sc and serializing_sc fields into one, since they
are never used simultanously, we have only one local I/O and one remote.

 - Move remote_sglist and local_sglist fields into CTL_PRIV_BACKEND,
since they are used only on Originating SC in XFER mode, where requests
don't ever reach backends, so we can reuse backend's private storage.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

5 years agoFurther refine r336195: do not even attempt to verify/update interface's
sobomax [Sat, 23 Feb 2019 23:31:13 +0000 (23:31 +0000)]
Further refine r336195: do not even attempt to verify/update interface's
MTU if we've set it once and there were no changes on the DHCP server
side since the last refresh. This is consistent I believe with how dhclient
handles other settings like IP address, mask etc.

Approved by: cem, eugen
Differential Revision: https://reviews.freebsd.org/D18546

5 years agogcov support
mmacy [Sat, 23 Feb 2019 21:14:00 +0000 (21:14 +0000)]
gcov support

add gcov support and export results as files in debugfs

Reviewed by: hps@
MFC after: 1 week
Sponsored by: iX Systems
Differential Revision: https://reviews.freebsd.org/D19260

5 years agoChange seq_read to seq_load to avoid namespace conflicts with lkpi
mmacy [Sat, 23 Feb 2019 21:04:48 +0000 (21:04 +0000)]
Change seq_read to seq_load to avoid namespace conflicts with lkpi

MFC after: 1 week
Sponsored by: iX Systems

5 years agoimport linux debugfs support
mmacy [Sat, 23 Feb 2019 20:56:41 +0000 (20:56 +0000)]
import linux debugfs support

Reviewed by: hps@
MFC after: 1 week
Sponsored by: iX Systems
Differential Revision: https://reviews.freebsd.org/D19258

5 years agolinux/fs: simplify interop and correct definition of loff_t
mmacy [Sat, 23 Feb 2019 20:45:45 +0000 (20:45 +0000)]
linux/fs: simplify interop and correct definition of loff_t

- offsets can be negative, loff_t needs to be signed, it also simplifies
  interop with the rest of the code base to use off_t than the actual linux
  definition "long long"
- don't rely on the defining "file" to "linux_file" in interface definitions
  as that causes heartache with includes

Reviewed by: hps@
MFC after: 1 week
Sponsored by: iX Systems
Differential Revision: https://reviews.freebsd.org/D19274

5 years agoFix a slew of mdoc errors and warnings.
brueffer [Sat, 23 Feb 2019 09:34:57 +0000 (09:34 +0000)]
Fix a slew of mdoc errors and warnings.

MFC after: 1 week

5 years agoSupport struct ip_mreqn as argument for IP_ADD_MEMBERSHIP. Legacy support
glebius [Sat, 23 Feb 2019 06:03:18 +0000 (06:03 +0000)]
Support struct ip_mreqn as argument for IP_ADD_MEMBERSHIP. Legacy support
for struct ip_mreq remains in place.

The struct ip_mreqn is Linux extension to classic BSD multicast API. It
has extra field allowing to specify the interface index explicitly. In
Linux it used as argument for IP_MULTICAST_IF and IP_ADD_MEMBERSHIP.
FreeBSD kernel also declares this structure and supports it as argument
to IP_MULTICAST_IF since r170613. So, we have structure declared but
not fully supported, this confused third party application configure
scripts.

Code handling IP_ADD_MEMBERSHIP was mixed together with code for
IP_ADD_SOURCE_MEMBERSHIP.  Bringing legacy and new structure support
into the mess would made the "argument switcharoo" intolerable, so
code was separated into its own switch case clause.

MFC after: 3 months
Differential Revision: https://reviews.freebsd.org/D19276

5 years agoRemove disabled CTL_LEGACY_STATS support.
mav [Sat, 23 Feb 2019 04:24:44 +0000 (04:24 +0000)]
Remove disabled CTL_LEGACY_STATS support.

It was not only disabled for quite a while, but also appeared to be broken
at r325517, when maximum number of ports was made configurable.

MFC after: 1 week

5 years agoo Get rid of silly comment which seems to have got life of its own via
sobomax [Sat, 23 Feb 2019 00:00:49 +0000 (00:00 +0000)]
o Get rid of silly comment which seems to have got life of its own via
  copy-and-paste process;

o Return geom_uzip(4) usage back to how manual page prescribes it to be
  used while I am here.

5 years agolkpi: allow late binding of linux_alloc_current
mmacy [Fri, 22 Feb 2019 23:15:32 +0000 (23:15 +0000)]
lkpi: allow late binding of linux_alloc_current

Some consumers may be loosely coupled with the lkpi.
This allows them to call linux_alloc_current without
having a static dependency.

Reviewed by: hps@
MFC after: 1 week
Sponsored by: iX Systems
Differential Revision: https://reviews.freebsd.org/D19257

5 years agoAdd new USB quirk.
hselasky [Fri, 22 Feb 2019 21:57:27 +0000 (21:57 +0000)]
Add new USB quirk.

PR: 235897
MFC after: 1 week
Sponsored by: Mellanox Technologies

5 years agonvdimm: Simple namespace support
bwidawsk [Fri, 22 Feb 2019 19:54:28 +0000 (19:54 +0000)]
nvdimm: Simple namespace support

Add support for simple NVDIMM v1.2 namespaces from the UEFI
version 2.7 specification. The combination of NVDIMM regions and
labels can lead to a wide variety of namespace layouts. Here we
support a simple subset of namespaces where each NVDIMM SPA range
is composed of a single region per member dimm.

Submitted by: D Scott Phillips <d.scott.phillips@intel.com>
Discussed with: kib
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D18736

5 years agonvdimm: Read NVDIMM namespace labels
bwidawsk [Fri, 22 Feb 2019 19:54:24 +0000 (19:54 +0000)]
nvdimm: Read NVDIMM namespace labels

When attaching to NVDIMM devices, read and verify the namespace
labels from the special namespace label storage area. A later
change will expose NVDIMM namespaces derived from this label data.

Submitted by: D Scott Phillips <d.scott.phillips@intel.com>
Discussed with: kib
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D18735

5 years agonvdimm: split spa dev into a separate entity
bwidawsk [Fri, 22 Feb 2019 19:54:21 +0000 (19:54 +0000)]
nvdimm: split spa dev into a separate entity

Separate code for exposing a device backed by a system physical
address range away from the NVDIMM spa code. This will allow a
future patch to add support for NVDIMM namespaces while using the
same device code.

Submitted by: D Scott Phillips <d.scott.phillips@intel.com>
Reviewed by: bwidawsk
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D18736

5 years agoCID 1332000: Logically dead code in sys/dev/pms/RefTisa/tisa/sassata/sas/ini/itdio.c
dab [Fri, 22 Feb 2019 18:43:27 +0000 (18:43 +0000)]
CID 1332000: Logically dead code in sys/dev/pms/RefTisa/tisa/sassata/sas/ini/itdio.c

A pointer is first tested for NULL. If non-NULL, another pointer is
set equal to the first. The second pointer is then checked for NULL
and an error path taken if so. This second test and the associated
path is dead code as the pointer value, having just been checked for
NULL, cannot be NULL at this point. Remove the dead code.

Reported by: Coverity
Reviewed by: daniel.william.ryan_gmail.com, vangyzen
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19165

5 years agoFix several Coverity-detected issues in newsyslog.
dab [Fri, 22 Feb 2019 15:31:50 +0000 (15:31 +0000)]
Fix several Coverity-detected issues in newsyslog.

- CID 1394815, CID 1305673: Dereference before null check - memory was
  allocated and the allocation checked for NULL with a call to errx()
  if it failed. Code below that was guaranteed that the pointer was
  non-NULL, but there was another check for NULL at the exit of the
  function (after the memory had already been referenced). Eliminate
  the useless NULL check.

- CID 1007452: Resource leak - Storage intended to be allocated and
  returned to the caller was never freed. This was the result of a
  regression in the function signature introduced in r208648 (2010)
  (thanks for that find, @cem!). Fixed by altering the function
  signature and passing the allocated memory to the caller as
  intended. This also fixes PR158794.

- CID 1008620: Logically dead code in newsyslog.c - This was a direct
  result of CID 1007452. Since the memory allocated as described there
  was not returned to the caller, a subsequent check for the memory
  having been allocated was dead code. Returning the memory
  re-animates the code that is the subject of this CID.

- CID 1006131: Unused value - in parsing a configuration file, a
  pointer to the end of the last field was saved, but not used after
  that. Rewrite to use the pointer value. This could have been fixed
  by avoiding the assignment altogether, but this solutions more
  closely follows the pattern used in the preceding code.

PR: 158794
Reported by: Coverity, Ken-ichi EZURA <k.ezura@gmail.com> (PR158794)
Reviewed by: cem, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19105

5 years agoRework logpage extensibility.
imp [Fri, 22 Feb 2019 15:15:36 +0000 (15:15 +0000)]
Rework logpage extensibility.

Move from using a linker set to a constructor function that's
called. This simplifies the code and is slightly more obvious.  We now
keep a list of page decoders rather than having an array we managed
before. Commands will move to something similar in the future.

Reviewed by: jhb@
Differential Revision: https://reviews.freebsd.org/D19275

5 years agoRevert r344389 & r343906 - Fix Coverity errors in newsyslog
dab [Fri, 22 Feb 2019 14:59:40 +0000 (14:59 +0000)]
Revert r344389 & r343906 - Fix Coverity errors in newsyslog

It was pointed out that a couple of the "memory leak" CIDs that I
fixed were arguably Coverity errors rather than errors in the
newsyslog code and the cure was worse than the disease. Revert both
changes. The first change, which included fixes for other Coverity
errors, will be re-worked to omit the troublesome changes and then
re-committed with the remaining fixes.

Reported by: bde
Sponsored by: Dell EMC Isilon

5 years agoQuick fix for building LINT on i386. A fix is needed on all arches and
bde [Fri, 22 Feb 2019 11:52:40 +0000 (11:52 +0000)]
Quick fix for building LINT on i386.  A fix is needed on all arches and
this one should also work on amd64 and sparc64.

LINT was broken in r312910 with the removal of pc98 support, by changing
the pathname in UKBD_DFLT_KEYBAP from a removed pc98 file to a nonexistent
file.

There are many bugs nearby.  Some are:
- the error is not properly detected and handled by make(1), because
  kbdcontrol(8) exits with status 0 after failing to find the keymap file
- UKBD_DFLT_KEYBAP is supposed to be MI, and is in MI NOTES to try enforce
  this, but 5 out of 8 arches don't support it
- LINT seems to have been broken by this in only 7 out of 8 arches.  mips
  breaks test coverage instead, by killing this option in its MD NOTES.
  arm kills ukbd but that is not enough to configure an unsupported option
  used only by ukbd.

5 years agoOops, actually fix warnings from -Wpointer-sign.
bde [Fri, 22 Feb 2019 07:00:23 +0000 (07:00 +0000)]
Oops, actually fix warnings from -Wpointer-sign.

5 years agoFix warnings from -Wpointer-sign.
bde [Fri, 22 Feb 2019 06:57:46 +0000 (06:57 +0000)]
Fix warnings from -Wpointer-sign.

5 years agoConnect the restored dumb and sc terminal emulators to the kernel build.
bde [Fri, 22 Feb 2019 06:41:47 +0000 (06:41 +0000)]
Connect the restored dumb and sc terminal emulators to the kernel build.
Add or fix options to control static and dynamic configuration.  Keep
the default of scteken, but default to statically configuring all available
emulators (now 3 instead of 1).

The dumb emulator is almost usable.  libedit and libreadline handle
dumb terminals perfectly for at least shell history.  less(1) works
as well as possible except on exit.  But curses programs make messes.
The dumb emulator has strange color support, with 2 dumb colors for
normal output but fancy colorization for the cursor, mouse pointer and
(with a non-dumb initial emulator) for low-level console output.

Using the sc emulator instead of the default of scteken fixes at least
the following bugs:
- NUL is a printing character in cons25 but not in teken
- teken doesn't support fixed colors for "reverse" video.
- The best versions of sc are about 10 times faster than scteken (for
  printing to the frame buffer).  This version is only about 5 times
  faster.

Fix configuration features:
- make SC_DFLT_TERM (for setting the initial emulator) a normal option.

Add configuration features:
- negative options SC_NO_TERM_* for omitting emulators in the static config.
  Modules for emulators might work, but I don't know of any
- vidcontrol -e shows the available emulators
- vidcontrol -E <emulator> sets the active emulator.

5 years agoAdd base to the warning threshold.
ganbold [Fri, 22 Feb 2019 03:11:27 +0000 (03:11 +0000)]
Add base to the warning threshold.

5 years agoCommit a missing piece of r344452.
markj [Thu, 21 Feb 2019 22:56:54 +0000 (22:56 +0000)]
Commit a missing piece of r344452.

MFC with: r344452

5 years agoFix a tracepoint lookup race in fasttrap_pid_probe().
markj [Thu, 21 Feb 2019 22:54:17 +0000 (22:54 +0000)]
Fix a tracepoint lookup race in fasttrap_pid_probe().

fasttrap hooks the userspace breakpoint handler; the hook looks up the
breakpoint address in a hash table of tracepoints.  It is possible for
the tracepoint to be removed by a different thread in between the
breakpoint trap and the hash table lookup, in which case SIGTRAP gets
delivered to the target process.  Fix the problem by adding a
per-process generation counter that gets incremented when a tracepoint
belonging to that process is removed.  Then, when a lookup fails, the
trapping instruction is restarted if the thread's counter doesn't match
that of the process.

Reviewed by: cem
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19273

5 years agoFix the usage error I introduced in r344192.
sef [Thu, 21 Feb 2019 22:49:39 +0000 (22:49 +0000)]
Fix the usage error I introduced in r344192.

Specifically, I put the new option line in the wrong place, and then fixed
up the rest without realizing it.  This puts the usage statement back to
what it was, with an additional line for the new -V option.

Reported by: mav
Sponsored by: iXsystems Inc.

5 years agoDisconnect fasttrap from the 32-bit powerpc build.
markj [Thu, 21 Feb 2019 22:49:21 +0000 (22:49 +0000)]
Disconnect fasttrap from the 32-bit powerpc build.

An upcoming bug fix requires 64-bit atomics, which aren't implemented on
powerpc.  The powerpc port of fasttrap is incomplete anyway and doesn't
get loaded by dtraceall.ko on powerpc because of a missing dependency;
it's presumed that it's effectively unused.

Discussed with: jhibbits
MFC after: 2 weeks

5 years agoscp: validate filenames provided by server against wildcard in client
emaste [Thu, 21 Feb 2019 22:45:54 +0000 (22:45 +0000)]
scp: validate filenames provided by server against wildcard in client

OpenSSH-portable commits:

check in scp client that filenames sent during remote->local directory
copies satisfy the wildcard specified by the user.

This checking provides some protection against a malicious server
sending unexpected filenames, but it comes at a risk of rejecting wanted
files due to differences between client and server wildcard expansion rules.

For this reason, this also adds a new -T flag to disable the check.

reported by Harry Sintonen
fix approach suggested by markus@;
has been in snaps for ~1wk courtesy deraadt@

OpenBSD-Commit-ID: 00f44b50d2be8e321973f3c6d014260f8f7a8eda

Minor patch conflict (getopt) resolved.

Obtained from: OpenSSH-portable 391ffc4b9d31fa1f4ad566499fef9176ff8a07dc

scp: add -T to usage();

OpenBSD-Commit-ID: a7ae14d9436c64e1bd05022329187ea3a0ce1899

Obtained from: OpenSSH-portable 2c21b75a7be6ebdcbceaebb43157c48dbb36f3d8

PR: 234965
Approved by: des
MFC after: 3 days
Obtained from: OpenSSH-portable 391ffc4b9d2c21b75a7b
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19076

5 years agoMFV: r344447
jkim [Thu, 21 Feb 2019 21:33:27 +0000 (21:33 +0000)]
MFV: r344447

Fix missing comma in array declaration.

5 years agoCatch up with ACPICA 20190215.
jkim [Thu, 21 Feb 2019 21:15:49 +0000 (21:15 +0000)]
Catch up with ACPICA 20190215.

PR: 235922

5 years agoFix the dumb and sc terminal emulators to compile and work.
bde [Thu, 21 Feb 2019 19:19:30 +0000 (19:19 +0000)]
Fix the dumb and sc terminal emulators to compile and work.

First remove ifdefs of the unsupported option SC_DUMB_TERMINAL which
prevented building using both in the same kernel and broke regression
tests.  This option will be replaced by per-emulator supported options.

The dumb emulator rotted with KSE in r83366, but usually compiled since
it is ifdefed to nothing unless SC_DUMB_TERMINAL is defined.  The type
of an unused function parameter changed.

Both emulators rotted when 2 new methods were added while the emulators
were removed.  Only null methods are needed, but null function pointers
give panics instead.

The wildcard in the default for the unsupported option SC_DFLT_TERM
never really worked.  It tends to prefer the dumb emulator when multiple
emulators are configured.  Change it to prefer scteken for compatibility.

5 years agoPull in r353299 from upstream lld trunk (by George Rimar):
dim [Thu, 21 Feb 2019 18:41:41 +0000 (18:41 +0000)]
Pull in r353299 from upstream lld trunk (by George Rimar):

  Recommit r353293 "[LLD][ELF] - Set DF_STATIC_TLS flag for i386 target."

  With the following changes:
  1) Compilation fix:
  std::atomic<bool> HasStaticTlsModel = false; ->
  std::atomic<bool> HasStaticTlsModel{false};

  2) Adjusted the comment in code.

  Initial commit message:

  DF_STATIC_TLS flag indicates that the shared object or executable
  contains code using a static thread-local storage scheme.

  Patch checks if IE/LE relocations were used to check if the code uses
  a static model. If so it sets the DF_STATIC_TLS flag.

  Differential revision: https://reviews.llvm.org/D57749

Pull in r353378 from upstream lld trunk (by George Rimar):

  [LLD][ELF] - Set DF_STATIC_TLS flag for X64 target

  This is the same as D57749, but for x64 target.

  "ELF Handling For Thread-Local Storage" p41 says
  (https://www.akkadia.org/drepper/tls.pdf):
  R_X86_64_GOTTPOFF relocation is used for IE TLS models.
  Hence if linker sees this relocation we should add DF_STATIC_TLS flag.

  Differential revision: https://reviews.llvm.org/D57821

This adds support to lld for the DF_STATIC_TLS flag in shared objects,
which signals to the dynamic linker that the shared object requires
static thread local storage.

See also: https://reviews.freebsd.org/D19072
MFC after: 1 week

5 years agoMove scterm_teken.c from 6 MD files lists to the MI files list so that it
bde [Thu, 21 Feb 2019 17:31:33 +0000 (17:31 +0000)]
Move scterm_teken.c from 6 MD files lists to the MI files list so that it
is easier to configure.  It is MI, unlike some of the other syscons files
already in the MI list.

Move scvtb.c similarly.  It is needed whenever sc is configured, and is
more MI than most of the files already in the MI list.

This only changes the combined list for arm64 and mips.  These arches
already cannot build sc or even NOTES.

5 years agoFix few issues in ioat(4) driver.
mav [Thu, 21 Feb 2019 16:47:36 +0000 (16:47 +0000)]
Fix few issues in ioat(4) driver.

 - Do not explicitly count active descriptors.  It allows hardware reset
to happen while device is still referenced, plus simplifies locking.
 - Do not stop/start callout each time the queue becomes empty.  Let it
run to completion and rearm if needed, that is much cheaper then to touch
it every time, plus also simplifies locking.
 - Decouple submit and cleanup locks, making driver reentrant.
 - Avoid memory mapped status register read on every interrupt.
 - Improve locking during device attach/detach.
 - Remove some no longer used variables.

Reviewed by: cem
MFC after: 1 week
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D19231

5 years agoClear pointers to indicate that the respective locks are released.
markj [Thu, 21 Feb 2019 15:44:32 +0000 (15:44 +0000)]
Clear pointers to indicate that the respective locks are released.

This fixes a problem in r344231: vm_pageout_launder() may scan two
queues when swap is disabled.

Reported by: pho
MFC with: r344231

5 years agosvn: support building with WITH_PIE
emaste [Thu, 21 Feb 2019 15:08:25 +0000 (15:08 +0000)]
svn: support building with WITH_PIE

Subversion builds and links against its own .a archives using local
rules, so did not benefit from with the WITH_PIE library support added
in r344179.  Apply the same _pie suffix locally.

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

5 years agoAllow I/OAT of present Xeon E5/E7 to work thorugh PLX NTB.
mav [Thu, 21 Feb 2019 14:10:14 +0000 (14:10 +0000)]
Allow I/OAT of present Xeon E5/E7 to work thorugh PLX NTB.

Its a hack, we can't know/list all DMA engines, but this covers all
I/OAT of Xeon E5/E7 at least from Sandy Bridge till Skylake I saw.

MFC after: 1 week
Sponsored by: iXsystems, Inc.

5 years agoThe receive buffer autoscaling for TCP is based on a linear growth, which
tuexen [Thu, 21 Feb 2019 10:35:32 +0000 (10:35 +0000)]
The receive buffer autoscaling for TCP is based on a linear growth, which
is acceptable in the congestion avoidance phase, but not during slow start.
The MTU is is also not taken into account.
Use a method instead, which is based on exponential growth working also in
slow start and being independent from the MTU.

This is joint work with rrs@.

Reviewed by: rrs@, Richard Scheffenegger
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D18375

5 years agoAllow the kcov buffer to be mmaped multiple times.
andrew [Thu, 21 Feb 2019 10:11:15 +0000 (10:11 +0000)]
Allow the kcov buffer to be mmaped multiple times.

After r344391 this restriction is no longer needed.

Sponsored by: DARPA, AFRL

5 years agoUse KCOV_ENTRY_SIZE for the entry size.
andrew [Thu, 21 Feb 2019 09:43:14 +0000 (09:43 +0000)]
Use KCOV_ENTRY_SIZE for the entry size.

Previously it was sizeof(uint64_t). While this is currently true, it may
not be on all future architectures.

Sponsored by: DARPA, AFRL

5 years agoThis patch addresses an issue brought up by bz@ in D18968:
tuexen [Thu, 21 Feb 2019 09:34:47 +0000 (09:34 +0000)]
This patch addresses an issue brought up by bz@ in D18968:
When TCP_REASS_LOGGING is defined, a NULL pointer dereference would happen,
if user data was received during the TCP handshake and BB logging is used.

A KASSERT is also added to detect tcp_reass() calls with illegal parameter
combinations.

Reported by: bz@
Reviewed by: rrs@
MFC after: 3 days
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D19254

5 years agoRestore syscons' terminal emulators. The trivial fixes to make them compile
bde [Thu, 21 Feb 2019 08:37:39 +0000 (08:37 +0000)]
Restore syscons' terminal emulators.  The trivial fixes to make them compile
will be committed later.

The "sc" emulator has the advantages of full support for cons25 and running
about 8 times faster than teken (for writing to the frame buffer).

The "dumb" emulator has the advantage of being simple.

Runtime choice of the emulator is good, but compile time choice is bad.

5 years agofuse: Fix a regression introduced in r337165
cem [Thu, 21 Feb 2019 02:41:57 +0000 (02:41 +0000)]
fuse: Fix a regression introduced in r337165

On systems with non-default DFLTPHYS and/or MAXBSIZE, FUSE would attempt to
use a buf cache block size in excess of permitted size.  This did not affect
most configurations, since DFLTPHYS and MAXBSIZE both default to 64kB.
The issue was discovered and reported using a custom kernel with a DFLTPHYS
of 512kB.

PR: 230260 (comment #9)
Reported by: ken@
MFC after: π/𝑒 weeks

5 years ago* Handle SIGPIPE in gssd
sef [Thu, 21 Feb 2019 01:30:37 +0000 (01:30 +0000)]
* Handle SIGPIPE in gssd
We've got some cases where the other end of gssd's AF_LOCAL socket gets
closed, resulting in an error (and SIGPIPE) when it tries to do I/O to it.
Closing without cleaning up means the next time nfsd starts up, it hangs,
unkillably; this allows gssd to handle that particular error.

* Limit the retry cound in gssd_syscall to 5.
The default is INT_MAX, which effectively means forever.  And it's an
uninterruptable RPC call, so it will never stop.

The two changes mitigate the problem.

Reviewed by: macklem
MFC after: 2 weeks
Sponsored by: iXsystems Inc.
Differential Revision: https://reviews.freebsd.org/D19153

5 years agoMFV: r344395
jkim [Wed, 20 Feb 2019 23:53:39 +0000 (23:53 +0000)]
MFV: r344395

Import ACPICA 20190215.

5 years agoUnwire the kcov buffer when freeing the info struct.
andrew [Wed, 20 Feb 2019 22:41:14 +0000 (22:41 +0000)]
Unwire the kcov buffer when freeing the info struct.

Without this the physical memory will not be returned to the kernel.

While here call vm_object_reference on the object when mmapping the buffer.
This removed the need for buggy tracking of if it has been mapped or not.

This fixes issues where kcov could use all the system memory.

Reported by: tuexen
Reviewed by: kib
Sponsored by: DARPA, AFTL
Differential Revision: https://reviews.freebsd.org/D19252

5 years agoCall pmap_qenter for each page when creating the kcov buffer.
andrew [Wed, 20 Feb 2019 22:32:28 +0000 (22:32 +0000)]
Call pmap_qenter for each page when creating the kcov buffer.

This removes the need to allocate a buffer to hold the vm_page_t objects
at the cost of extra IPIs on some architectures.

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

5 years agoComplete fix for CID 1007454, CID 1007453: Resource leak in newsyslog
dab [Wed, 20 Feb 2019 22:05:44 +0000 (22:05 +0000)]
Complete fix for CID 1007454, CID 1007453: Resource leak in newsyslog

The result of a strdup() was stored in a global variable and not freed
before program exit. This is a follow-up to r343906. That change
attempted to plug these resource leaks but managed to miss a code path
on which the leak still occurs. Plug the leak on that path, too.

MFC after: 3 days
Sponsored by: Dell EMC Isilon

5 years agoIt turns out that setting the IV length is necessary with CCM in OpenSSL.
sef [Wed, 20 Feb 2019 21:24:56 +0000 (21:24 +0000)]
It turns out that setting the IV length is necessary with CCM in OpenSSL.
This adds that back.

Reviewed by: cem

5 years agoloader: really fix cd9660 dirmatch
tsoome [Wed, 20 Feb 2019 21:07:09 +0000 (21:07 +0000)]
loader: really fix cd9660 dirmatch

The cd9660_open() does pass whole path to dirmatch() and we need to
compare only the current path component, not full path.

Additinally, skip over duplicate / (if any) and check if the last component
in the path was meant to be directory (having trailing /). If it is in fact
a file, error out.

5 years agoPull in r354515 from upstream libc++ trunk:
dim [Wed, 20 Feb 2019 21:06:11 +0000 (21:06 +0000)]
Pull in r354515 from upstream libc++ trunk:

  Fix the build with gcc when `-Wredundant-decls` is passed

  Summary:

  gcc warns that `__throw_runtime_error` is declared both in
  `<__locale>` and `<stdexcept>`, if `-Wredundant-decls` is passed on
  the command line; this is the case with FreeBSD when ${WARNS} == 6.

  Since `<__locale>` gets its first declaration via a transitive
  include of `<stdexcept>`, and the second declaration is after the
  first invocation of `__throw_runtime_error`, delete that second
  declaration.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
  Reviewers: kristina, MaskRay, EricWF, ldionne, ngie

  Reviewed By: EricWF

  Subscribers: krytarowski, brooks, emaste, dim, christof, jdoerfert, libcxx-commits

  Tags: #libc

  Differential Revision: https://reviews.llvm.org/D58425

Submitted by: ngie
MFC after: 3 days

5 years agoPFS: Bump NAMELEN and don't require clients to be sleepable
mmacy [Wed, 20 Feb 2019 20:55:02 +0000 (20:55 +0000)]
PFS: Bump NAMELEN and don't require clients to be sleepable

- debugfs consumers expect to be able to export names more than 48 characters

- debugfs consumers expect to be able to hold locks across calls and are able
  to handle allocation failures

Reviewed by: hps@
MFC after: 1 week
Sponsored by: iX Systems
Differential Revision: https://reviews.freebsd.org/D19256

5 years agoAdd non-sleepable strdup variant strdup_flags
mmacy [Wed, 20 Feb 2019 20:48:10 +0000 (20:48 +0000)]
Add non-sleepable strdup variant strdup_flags

debugfs expects to do non-sleepable allocations

Reviewed by: hps@
MFC after: 1 week
Sponsored by: iX Systems
Differential Revision: https://reviews.freebsd.org/D19259

5 years agoFix more AddressSanitizer violations in usr.bin/top
dim [Wed, 20 Feb 2019 20:17:54 +0000 (20:17 +0000)]
Fix more AddressSanitizer violations in usr.bin/top

In line_update(), set lastcol correctly after moving to any non-zero
column, so the "overwrite old stuff" part does not attempt to address
negative offsets in the current line.

Rewrite setup_buffer() to always allocate at least 80 characters,
otherwise various calls to summary_format() will overwrite the end of
the buffers, if the screen width gets small enough.

MFC after: 1 week

5 years agoRemove an obsolete comment.
markj [Wed, 20 Feb 2019 18:29:52 +0000 (18:29 +0000)]
Remove an obsolete comment.

MFC after: 3 days

5 years agoReduce the TCP initial retransmission timeout from 3 seconds to
tuexen [Wed, 20 Feb 2019 18:03:43 +0000 (18:03 +0000)]
Reduce the TCP initial retransmission timeout from 3 seconds to
1 second as allowed by RFC 6298.

Reviewed by: kbowling@, Richard Scheffenegger
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D18941

5 years agoUse exponential backoff for retransmitting SYN segments as specified
tuexen [Wed, 20 Feb 2019 17:56:38 +0000 (17:56 +0000)]
Use exponential backoff for retransmitting SYN segments as specified
in the TCP RFCs.

Reviewed by: rrs@, Richard Scheffenegger
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D18974

5 years agoMFV r344364:
markj [Wed, 20 Feb 2019 17:10:30 +0000 (17:10 +0000)]
MFV r344364:
9058 postmortem DTrace frequently broken under vmware

illumos/illumos-gate@793bd7e3617ae7d3d24e8c6b7d6befe35f07ec1f

MFC after: 1 week

5 years agoDefine a constant for the maximum number of GEOM_CTL arguments.
markj [Wed, 20 Feb 2019 17:07:08 +0000 (17:07 +0000)]
Define a constant for the maximum number of GEOM_CTL arguments.

Reviewed by: eugen
MFC with: r344305
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19271

5 years agozpool.8: sort zpool status flags in the same order as in illumos manual
avg [Wed, 20 Feb 2019 13:37:27 +0000 (13:37 +0000)]
zpool.8: sort zpool status flags in the same order as in illumos manual

Just in case, while I was here.

MFC after: 1 week

5 years agozpool.8: document -D flag for zpool status
avg [Wed, 20 Feb 2019 13:34:16 +0000 (13:34 +0000)]
zpool.8: document -D flag for zpool status

The description is taken from the illumos manual.

Reported by: stilezy@gmail.com
MFC after: 1 week

5 years agofix userland illumos taskq code to pass relative timeout to cv_timedwait
avg [Wed, 20 Feb 2019 13:19:08 +0000 (13:19 +0000)]
fix userland illumos taskq code to pass relative timeout to cv_timedwait

Unlike illumos, FreeBSD cv_timedwait requires a relative timeout.  That
applies both to the kernel illumos compatibility code and to the
userland "fake kernel" code.

MFC after: 2 weeks
Sponsored by: Panzura

5 years agopkru(3) man page.
kib [Wed, 20 Feb 2019 10:03:03 +0000 (10:03 +0000)]
pkru(3) man page.

Reviewed by: alc, markj, jilles
With more input from: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19211

5 years agoAdd usermode helpers for for Intel userspace protection keys feature.
kib [Wed, 20 Feb 2019 09:56:23 +0000 (09:56 +0000)]
Add usermode helpers for for Intel userspace protection keys feature.

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

5 years agoAdd kernel support for Intel userspace protection keys feature on
kib [Wed, 20 Feb 2019 09:51:13 +0000 (09:51 +0000)]
Add kernel support for Intel userspace protection keys feature on
Skylake Xeons.

See SDM rev. 68 Vol 3 4.6.2 Protection Keys and the description of the
RDPKRU and WRPKRU instructions.

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

5 years agoamd64: add defines and decode protection keys and SGX page faults reasons.
kib [Wed, 20 Feb 2019 09:46:44 +0000 (09:46 +0000)]
amd64: add defines and decode protection keys and SGX page faults reasons.

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

5 years agoImplement rangesets.
kib [Wed, 20 Feb 2019 09:38:19 +0000 (09:38 +0000)]
Implement rangesets.

The data structure implements non-intersecting intervals over the [0,
UINT64_MAX] range, and supports fast insert, predicated clearing of
subrange, and lookup of an interval containing the specified address.
Internally it is a pctrie over the interval start addresses.

Implementation provides additional guarantees over the structure state
in case of memory allocation failures.

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

5 years agoClarify notifications when battery capacity ratio
ganbold [Wed, 20 Feb 2019 07:10:38 +0000 (07:10 +0000)]
Clarify notifications when battery capacity ratio
reaches warning and shutdown thresholds.

5 years agocalendar: use iconv to respect the output encoding
bapt [Wed, 20 Feb 2019 06:40:52 +0000 (06:40 +0000)]
calendar: use iconv to respect the output encoding

calendar(1) can have input in various encoding, specifying
LANG=<locale_name> to enable calendar(1) to determine which one to use.

The problem is the content of the calendar itself is exposed as is making it
unreadable in many cases. For example french calendar which is encoded
ISO8859-1 is rendered badly in a fr_FR.UTF-8 environment.

Using iconv allows to solve this issue.
This will also allow to keep only 1 encoding in base for those files without
breaking user existing setup

Reported by: many
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D19221

5 years agoAdd the unix path to the output of `efivar --load-option`
bcran [Wed, 20 Feb 2019 05:19:16 +0000 (05:19 +0000)]
Add the unix path to the output of `efivar --load-option`

Reviewed by: imp
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D19242

5 years agoFix the handling of legacy-format devices in the u-boot loaderdev variable.
ian [Wed, 20 Feb 2019 03:00:55 +0000 (03:00 +0000)]
Fix the handling of legacy-format devices in the u-boot loaderdev variable.
When I added support for the standard loader(8) disk0s2a: type formats,
the parsing of legacy format was broken because it also contains a colon,
but it comes before the slice and partition. That would cause disk_parsedev()
to return success with the slice and partition set to wildcard values.

This change examines the string first, and if it contains spaces, dots, or
a colon at any position other than the end, it must be a legacy-format
string and we don't even try to use disk_parsedev() on it.

Reported by: Manuel Stuhn

5 years agoFuse: whitespace and style(9) cleanup
cem [Wed, 20 Feb 2019 02:49:26 +0000 (02:49 +0000)]
Fuse: whitespace and style(9) cleanup

Take a pass through fixing some of the most egregious whitespace issues in
fs/fuse.  Also fix some style(9) warts while here.  Not 100% cleaned up, but
somewhat less painful to look at and edit.

No functional change.

5 years agofuse: add descriptions for remaining sysctls
cem [Wed, 20 Feb 2019 02:48:59 +0000 (02:48 +0000)]
fuse: add descriptions for remaining sysctls

(Except reclaim revoked; I don't know what that goal of that one is.)

5 years agoFix hangs in r341810 waiting for AP startup.
bde [Wed, 20 Feb 2019 02:40:38 +0000 (02:40 +0000)]
Fix hangs in r341810 waiting for AP startup.

idle_td is dereferenced without thread-locking it to make its contents is
invariant, and was accessed without telling the compiler that its contents
is invariant.  Some compilers optimized accesses to the supposedly invariant
contents by moving the critical checks for changes outside of the loop that
waits for changes.  Fix this using atomic ops.

This bug only showed up for the following configuration: a Turion2
system, amd64 kernels, compiled by gcc, and SCHED_4BSD.  clang fails
to do the optimization with all CFLAGS that I tried, because it doesn't
fully optimize the '__asm __volatile' for cpu_spinwait() although this
asm has no memory clobber.  gcc only does the optimization with most
CFLAGS.  I mostly used -Os with all compilers.  i386 works because gcc
-m32 -Os only moves 1 or the 2 accesses outside of the loop.
Non-Turion2 systems and SCHED_ULE worked due to different timing (when
all APs start before the BP checks them outside of the loop).

Reviewed by: kib

5 years agoAttempt to complete fixing programmable function keys for syscons.
bde [Wed, 20 Feb 2019 02:14:41 +0000 (02:14 +0000)]
Attempt to complete fixing programmable function keys for syscons.

The flag for the driver capability of supporting the fix is independent
of the flag for cons25 mode so that it can be managed independently, but
I forget to preserve it when resetting the terminal.

5 years agoSimplify the code. No functional changes.
pjd [Wed, 20 Feb 2019 00:25:45 +0000 (00:25 +0000)]
Simplify the code. No functional changes.

Reviewed by: rpokala

5 years agoSimplify the code.
pjd [Tue, 19 Feb 2019 23:53:33 +0000 (23:53 +0000)]
Simplify the code.

5 years agoCorrect typo in the comment.
pjd [Tue, 19 Feb 2019 23:44:00 +0000 (23:44 +0000)]
Correct typo in the comment.

5 years agoChange assertion to log the incorrect io_type we've got.
pjd [Tue, 19 Feb 2019 23:43:15 +0000 (23:43 +0000)]
Change assertion to log the incorrect io_type we've got.

5 years agoGrabage-collect no longer used variable.
pjd [Tue, 19 Feb 2019 23:41:23 +0000 (23:41 +0000)]
Grabage-collect no longer used variable.

5 years agoThe way ZFS searches for its vdevs is the following: first it looks for
pjd [Tue, 19 Feb 2019 23:35:55 +0000 (23:35 +0000)]
The way ZFS searches for its vdevs is the following: first it looks for
a vdev that has the same name as the one stored in metadata and that has
all VDEV labels in place. If it cannot find a GEOM provider with the given
name and all VDEV labels it will scan all GEOM providers for the best match
(the most VDEV labels available), but here the name is ignored.

In case the ZFS pool is created, eg. using GPT partition label:

# zpool create tank /dev/gpt/tank

everything works, and on every import ZFS will pick /dev/gpt/tank and
not /dev/da0p4.

The problem occurs when da0p4 is extended and ZFS is unable to find all
VDEV labels in /dev/gpt/tank anymore (the VDEV labels stored at the end
of the partition are now somewhere else). In this case it will scan all
GEOM providers and will pick the first one with the best match, ie. da0p4.

Fix this problem by checking the VDEV/provider name even if we get the same
match. If the name is the same as the one we have in pool's metadata, prefer
this GEOM provider.

Reported by: oshogbo, Michal Mroz <m.mroz@fudosecurity.com>
Tested by: Michal Mroz <m.mroz@fudosecurity.com>
Obtained from: Fudo Security

5 years agoFix sed script to insert Amazon NTP server into ntp.conf once rather
cperciva [Tue, 19 Feb 2019 23:24:39 +0000 (23:24 +0000)]
Fix sed script to insert Amazon NTP server into ntp.conf once rather
than twice.

Reported by: Rafal Lukawiecki
MFC after: 1 week

5 years agoIn the vdev_geom_open_by_path() function we assume that vdev path starts
pjd [Tue, 19 Feb 2019 23:22:39 +0000 (23:22 +0000)]
In the vdev_geom_open_by_path() function we assume that vdev path starts
with "/dev/". Make sure this is the case.

5 years agoMake `server_cat(..)` handle short receives
ngie [Tue, 19 Feb 2019 22:19:31 +0000 (22:19 +0000)]
Make `server_cat(..)` handle short receives

In short, the prior code was far too simplistic when it came to calling recv(2)
and failed intermittently (or in the case of Jenkins, deterministically).

Handle short recv(2)s by checking the return code and incrementing the window
into the buffer by the number of received bytes. If the number of received
bytes <= 0, then bail out of the loop, and test the total number of received
bytes vs the expected number of bytes sent for equality, and base whether or
not the test passes/fails on that fact.

Remove the expected failure, now that the hdtr testcases deterministically pass
on my host after this change [1].

PR: 234809 [1], 235200
Reviewed by: asomers
Approved by: emaste (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19188

5 years agoPlace an upper bound on the number of iterations for REP.
ed [Tue, 19 Feb 2019 21:58:23 +0000 (21:58 +0000)]
Place an upper bound on the number of iterations for REP.

Right now it's possible to invoke the REP escape sequence with a maximum
of tens of millions of iterations. In practice, there is never any need
to do this. Calling it more frequently than the number of cells in the
terminal hardly makes any sense. By placing a limit on it, we can
prevent users from exhausting resources in inside the terminal emulator.

As support for this escape sequence is not present in any of the stable
branches, there is no need to MFC.

Reported by: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11255

5 years agoAdd missing __unused attributes to unused function arguments.
ed [Tue, 19 Feb 2019 21:49:48 +0000 (21:49 +0000)]
Add missing __unused attributes to unused function arguments.

This fixes the userspace build of libteken.