]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
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.

5 years agoLimit the number of entries allocated for a REPORT_ZONES command.
markj [Tue, 19 Feb 2019 21:33:02 +0000 (21:33 +0000)]
Limit the number of entries allocated for a REPORT_ZONES command.

The DIOCGETZONE ioctl can be used to fetch the zone list of an SMR
drive, and the caller specifies the number of entries it wants to fetch.
Clamp the caller's request to a sane limit so that a user cannot attempt
large allocations. Callers already need to invoke the ioctl multiple
times to fetch the full list in general, so there's no harm in limiting
the number of entries returned.

Fix style while here.

admbug: 807
Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Reviewed by: asomers, ken
Tested by: ken
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19249

5 years agosh: Send normal output from bind builtin to stdout
jilles [Tue, 19 Feb 2019 21:27:30 +0000 (21:27 +0000)]
sh: Send normal output from bind builtin to stdout

PR: 233343
Submitted by: Yuichiro NAITO (original version)

5 years agoImpose a limit on the number of GEOM_CTL arguments.
markj [Tue, 19 Feb 2019 21:22:22 +0000 (21:22 +0000)]
Impose a limit on the number of GEOM_CTL arguments.

Otherwise a privileged user can trigger a memory allocation of
unbounded size, or an integer overflow in the subsequent
geom_alloc_copyin() call, leading to out-of-bounds accesses.

Hard-code a large limit to circumvent this problem.

admbug: 854
Reported by: Anonymous of the Shellphish Grill Team
Reviewed by: ae
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19251

5 years agoRemove drm from LINT kernels
imp [Tue, 19 Feb 2019 21:20:50 +0000 (21:20 +0000)]
Remove drm from LINT kernels

drm was accidentally left in the LINT kernels.

Pointy hat to: imp

5 years agoMinor cleanup for mkuzip(8) man page.
kib [Tue, 19 Feb 2019 20:26:03 +0000 (20:26 +0000)]
Minor cleanup for mkuzip(8) man page.

List all single-letter options in summary.
Order options alphabetically.

Sponsored by: Mellanox Technologies
MFC after: 3 days

5 years agoEnsure that inode updates are properly flushed out during the first
mckusick [Tue, 19 Feb 2019 20:12:12 +0000 (20:12 +0000)]
Ensure that inode updates are properly flushed out during the first
pass of fsck_ffs. Some changes, such as check-hash corrections were
being lost.

Reported by: Michael Tuexen (tuexen@)
Tested by:   Michael Tuexen (tuexen@)
MFC after:   3 days

5 years agoWhen dropping a fragment queue count the number of fragments in the queue
thj [Tue, 19 Feb 2019 19:57:55 +0000 (19:57 +0000)]
When dropping a fragment queue count the number of fragments in the queue

When dropping a fragment queue, account for the number of fragments in the
queue. This improves accounting between the number of fragments received and
the number of fragments dropped.

Reviewed by: jtl, bz, transport
Approved by: jtl (mentor), bz (mentor)
Differential Revision: https://review.freebsd.org/D17521

5 years agoAdd an UPDATING entry for the removal of drm and drm2
imp [Tue, 19 Feb 2019 19:37:09 +0000 (19:37 +0000)]
Add an UPDATING entry for the removal of drm and drm2

Also bump FreeBSD version to 1300013 since this series is a big
change.

5 years agoRemove the i915 and radeon drivers.
imp [Tue, 19 Feb 2019 19:37:02 +0000 (19:37 +0000)]
Remove the i915 and radeon drivers.

Per discussions on arch@ and elsewhere, the maintenance of this code
has moved to the drm-kmod and drm-legacy-kmod ports. Remove the i915
and radeon drivers from the tree.

Approved by: graphics team
Reviewed by: manu@, mmel@
Differential Revision: https://reviews.freebsd.org/D19196

5 years agoRemove drm2 modules.
imp [Tue, 19 Feb 2019 19:36:56 +0000 (19:36 +0000)]
Remove drm2 modules.

Remove support for compiling drm2 as a module. This has transitioned
to the drm-kmod or drm-legacy-kmodw ports.

Approved by: graphics team
Reviewed by: manu@, mmel@
Differential Revision: https://reviews.freebsd.org/D19196

5 years agoPer discussions on arch@ and elsewhere, retire drm module / drives.
imp [Tue, 19 Feb 2019 19:36:43 +0000 (19:36 +0000)]
Per discussions on arch@ and elsewhere, retire drm module / drives.

Retire the drm modules / drivers. These are now handled by the
drm-legacy-kmod port and/or the drm-kmod port. All future
development and maintanace will be handled there.

Approved by: graphics team
Reviewed by: manu@, mmel@
Differential Revision: https://reviews.freebsd.org/D19196

5 years agoProvide convenience C wrappers for RDPKRU and WRPKRU instructions.
kib [Tue, 19 Feb 2019 19:17:20 +0000 (19:17 +0000)]
Provide convenience C wrappers for RDPKRU and WRPKRU instructions.

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

5 years agoRemove some redundant code in _posix1e_acl_strip_np
sef [Tue, 19 Feb 2019 19:15:15 +0000 (19:15 +0000)]
Remove some redundant code in _posix1e_acl_strip_np

This was discovered through examination -- acl_copy_entry() copies the
tag type and permset fields.

Reviewed by: trasz, pfg
Sponsored by: iXsystems Inc.
Differential Revision: https://reviews.freebsd.org/D19240

5 years agoAdd definition for %cr4 PKRU enable bit.
kib [Tue, 19 Feb 2019 19:13:48 +0000 (19:13 +0000)]
Add definition for %cr4 PKRU enable bit.

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

5 years agoFix style after r340832
thj [Tue, 19 Feb 2019 19:04:52 +0000 (19:04 +0000)]
Fix style after r340832

Reported by: jhb
Reviewed by: jhb, jtl
Approved by: jtl (mentor)
MFC after: 3 days
Differential Revision: https://reviews/freebsd.org/D18354

5 years agofreebsd-update: Clarify help text
emaste [Tue, 19 Feb 2019 17:38:24 +0000 (17:38 +0000)]
freebsd-update: Clarify help text

Improve help text to include example release numbers for reference
and clarify the -F option.

PR: 231185, 214619
Submitted by: Gerald Aryeetey <aryeeteygerald_rogers.com>
Reviewed by: delphij, rgrimes
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18944

5 years agoCreate a common function to handle freeing the kcov info struct.
andrew [Tue, 19 Feb 2019 17:03:34 +0000 (17:03 +0000)]
Create a common function to handle freeing the kcov info struct.

Both places that may free the kcov info struct are identical. Create a new
common function to hold the code.

Sponsored by: DARPA, AFRL

5 years agoMove a racy assertion in filt_pipewrite().
markj [Tue, 19 Feb 2019 15:46:43 +0000 (15:46 +0000)]
Move a racy assertion in filt_pipewrite().

EVFILT_WRITE knotes for pipes live on the knlist for the other end of the
pipe.  Since they do not hold a reference on the corresponding file
structure, they may be removed from the knlist by pipeclose() while still
remaining active.  In this case, there is no knlist lock acquired before
filt_pipewrite() is called, so the assertion fails.

Fix the problem by first checking whether that end of the pipe has been
closed.  These checks are memory safe since the knote holds a reference
on one end of the pipe, and the pipe structure is not freed until both
ends are closed.  The checks are not racy since PIPE_EOF is never cleared
after being set, and pipe_present is never set back to PIPE_ACTIVE after
pipeclose() has been called.

PR: 235640
Reported and tested by: pho
Reviewed by: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19224

5 years agoWork around the "nfscl: bad open cnt on server" assertion
trasz [Tue, 19 Feb 2019 12:45:37 +0000 (12:45 +0000)]
Work around the "nfscl: bad open cnt on server" assertion
that can happen when rerooting into NFSv4 rootfs with kernel
built with INVARIANTS.

I've talked to rmacklem@ (back in 2017), and while the root cause
is still unknown, the case guarded by assertion (nfscl_doclose()
being called from VOP_INACTIVE) is believed to be safe, and the
whole thing seems to run just fine.

Obtained from: CheriBSD
MFC after: 2 weeks
Sponsored by: DARPA, AFRL

5 years agoBump the default kern.rpc.gss.client_max from 128 to 1024.
trasz [Tue, 19 Feb 2019 11:07:02 +0000 (11:07 +0000)]
Bump the default kern.rpc.gss.client_max from 128 to 1024.

The old value resulted in bad performance, with high kernel
and gssd(8) load, with more than ~64 clients; it also triggered
crashes, which are to be fixed by a different patch.

PR: 235582
Discussed with: rmacklem@
MFC after: 2 weeks

5 years agoAdd kern.rpc.gss.client_hash tunable, to make it possible to bump
trasz [Tue, 19 Feb 2019 10:17:49 +0000 (10:17 +0000)]
Add kern.rpc.gss.client_hash tunable, to make it possible to bump
it easily.  This can lower the load on gssd(8) on large NFS servers.

Submitted by: Per Andersson <pa at chalmers dot se>
Reviewed by: rmacklem@
MFC after: 2 weeks
Sponsored by: Chalmers University of Technology

5 years agoWith r343051 UMA switched from atomic counts to counter(9) and now kernel
glebius [Mon, 18 Feb 2019 21:27:13 +0000 (21:27 +0000)]
With r343051 UMA switched from atomic counts to counter(9) and now kernel
reports snap counts of how much a zone alloced and how much it freed.  It
may happen that snap values doesn't match, e.g alloced - freed < 0.
Workaround that in memstat library.

Reported by: pho

5 years agoloader: ptable_close() should check its argument
tsoome [Mon, 18 Feb 2019 20:29:19 +0000 (20:29 +0000)]
loader: ptable_close() should check its argument

If the passed in table is NULL, just return.

5 years agoAdd a compatible string to match recent changes in the upstream dts.
ian [Mon, 18 Feb 2019 19:50:53 +0000 (19:50 +0000)]
Add a compatible string to match recent changes in the upstream dts.

5 years agoAdd one additional file to libllvmminimal, since in some cases (e.g.
dim [Mon, 18 Feb 2019 19:07:15 +0000 (19:07 +0000)]
Add one additional file to libllvmminimal, since in some cases (e.g.
upgrading from stable/10 to stable/11) symbols from it are needed to
link llvm-tblgen and clang-tblgen.

Reported by: kib
MFC after: 3 days

5 years agoPull in r345199 from upstream libc++ trunk (by Petr Hosek):
dim [Mon, 18 Feb 2019 18:34:13 +0000 (18:34 +0000)]
Pull in r345199 from upstream libc++ trunk (by Petr Hosek):

  Revert "Teach __libcpp_is_floating_point that __fp16 and _Float16 are
  floating-point types."

  This reverts commits r333103 and r333108. _Float16 and __fp16 are C11
  extensions and compilers other than Clang don't define these for C++.

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

This prevents "_Float16 is not supported on this target" errors in
libc++'s type_traits header, in some cases.

Reported by: Charlie Li
MFC after: 3 days

5 years agoAllow the u-boot loaderdev env var to be formatted in the "usual" loader(8)
ian [Mon, 18 Feb 2019 17:12:30 +0000 (17:12 +0000)]
Allow the u-boot loaderdev env var to be formatted in the "usual" loader(8)
way: device<unit>[s|p]<slice><partition>.  E.g., disk0s2a or disk3p12.
The code first tries to parse the variable in this format using the
standard disk_parsedev().  If that fails, it falls back to parsing the
legacy format that has been supported by ubldr for years.

In addition to 'disk', all the valid uboot device names can also be used:
mmc, sata, usb, ide, scsi. The 'disk' device serves as an alias for all
those types and will match the Nth storage-type device found (where N is
the unit number).

5 years agoamd64: cleanup pmap_init_pat().
kib [Mon, 18 Feb 2019 16:02:00 +0000 (16:02 +0000)]
amd64: cleanup pmap_init_pat().

The pmap_works variable is always true for amd64.  Remove it, the
branch in the initialization taken when false, and corresponding
sysctl.

Remove pat_table[] local array, work on pat_index[] directly.

Collapse whole initialization to not override already assigned values.

Add comment explaining the choice for PAT4 and PAT7.

Reviewed by: alc, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
MFC note: Leave the sysctl around
Differential revision: https://reviews.freebsd.org/D19225

5 years agoFix more places to use DEV_TYP_NONE instead of -1 to indicate 'no device'.
ian [Mon, 18 Feb 2019 15:28:12 +0000 (15:28 +0000)]
Fix more places to use DEV_TYP_NONE instead of -1 to indicate 'no device'.

5 years agoUse DEV_TYP_NONE instead of -1 to indicate no device was specified.
ian [Mon, 18 Feb 2019 15:09:19 +0000 (15:09 +0000)]
Use DEV_TYP_NONE instead of -1 to indicate no device was specified.

DEV_TYP_NONE has a value of zero, which makes more sense since the device
type is a bunch of bits describing the device, crammed into an int.

5 years agonetmap: don't schedule kqueue notify task when kqueue is not used
vmaffione [Mon, 18 Feb 2019 14:21:41 +0000 (14:21 +0000)]
netmap: don't schedule kqueue notify task when kqueue is not used

This change adds a counter (kqueue_users) to keep track of how many
kqueue users are referencing a given struct nm_selinfo.
In this way, nm_os_selwakeup() can schedule the kevent notification
task only when kqueue is actually being used.
This is important to avoid wasting CPU in the common case where
kqueue is not used.

Reviewed by: Aleksandr Fedorov <aleksandr.fedorov@itglobal.com>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19177

5 years agoAvoid orphan sections between __bss_start and .(s)bss.
br [Mon, 18 Feb 2019 13:14:53 +0000 (13:14 +0000)]
Avoid orphan sections between __bss_start and .(s)bss.

Ensure __bss_start is associated with the next section
in case orphan sections are placed directly after .sdata,
as has been seen to happen with LLD.

Submitted by: "J.R.T. Clarke" <jrtc4@cam.ac.uk>
Differential Revision: https://reviews.freebsd.org/D18429

5 years agocd9660: dirmatch fails to unmatch when name is prefix for directory record
tsoome [Mon, 18 Feb 2019 08:26:18 +0000 (08:26 +0000)]
cd9660: dirmatch fails to unmatch when name is prefix for directory record

Loader does fail to properly match the file name in directory record and
does open file based on prefix match.

For fix, we check the name lengths first.

Reviewed by: allanjude
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19213

5 years agoMake uboot_devdesc properly alias disk_devdesc, so that parsing the u-boot
ian [Mon, 18 Feb 2019 04:44:52 +0000 (04:44 +0000)]
Make uboot_devdesc properly alias disk_devdesc, so that parsing the u-boot
loaderdev variable works correctly.

The uboot_devdesc struct is variously cast back and forth between
uboot_devdesc and disk_devdesc as pointers are handed off through various
opaque interfaces.  uboot_devdesc attempted to mimic the layout of
disk_devdesc by having a devdesc struct, followed by a union of some
device-specific stuff that included a struct that contains the same fields
as a disk_devdesc.  However, one of those fields inside the struct is 64-bit
which causes the entire union to be 64-bit aligned -- 32 bits of padding
is added between the struct devdesc and the union, so the whole mess ends
up NOT properly mimicking a disk_devdesc after all.  (In disk_devdesc there
is also 32 bits of padding, but it shows up immediately before the d_offset
field, rather than before the whole collection of d_* fields.)

This fixes the problem by using an anonymous union to overlay the devdesc
field uboot network devices need with the disk_devdesc that uboot storage
devices need.  This is a different solution than the one contributed with
the PR (so if anything goes wrong, the blame goes to me), but 95% of the
credit for this fix goes to Pawel Worach and Manuel Stuhn who analyzed the
problem and proposed a fix.

PR: 233097

5 years agokdump: expand comment on reasons for CAPFAIL_LOOKUP
emaste [Mon, 18 Feb 2019 03:49:16 +0000 (03:49 +0000)]
kdump: expand comment on reasons for CAPFAIL_LOOKUP

Comment for CAPFAIL_LOOKUP refered only to paths containing ".." but
it is returned for other restricted VFS lookup cases, such as absolute
paths or openat(AT_FDCWD, ...).

5 years agosnmp_hostres(3): fix a typo in sanity checks in handle_chunk()
avos [Mon, 18 Feb 2019 03:23:10 +0000 (03:23 +0000)]
snmp_hostres(3): fix a typo in sanity checks in handle_chunk()

PR: 204253
Submitted by: David Binderman <dcb314@hotmail.com>
MFC after: 5 days

5 years agoFix memory / resource leaks in usr.sbin/rpc.ypupdated/update.c
avos [Mon, 18 Feb 2019 03:15:25 +0000 (03:15 +0000)]
Fix memory / resource leaks in usr.sbin/rpc.ypupdated/update.c

Re-apply r343909 to this file to get the issue fixed.

PR: 204956
Reported by: David Binderman <dcb314@hotmail.com>
MFC after: 5 days

5 years agolualoader: only clear the screen before first password prompt
kevans [Mon, 18 Feb 2019 02:59:47 +0000 (02:59 +0000)]
lualoader: only clear the screen before first password prompt

This was previously an unconditional screen clear, regardless of whether or
not we would be prompting for any passwords. This is pointless, given that
the screen clear is only there to put our screen into a consistent state
before we draw the prompts and do cursor manipulation.

This is also the only screen clear besides that to draw the menu.  One can
now see early pre-loader and loader output with the menu disabled, which may
be useful for diagnostics.

Reported by: ian
MFC after: 3 days

5 years agopowerpc/boot: Move ubldr to /boot/uboot, and make this a separate filesystem
jhibbits [Mon, 18 Feb 2019 01:57:47 +0000 (01:57 +0000)]
powerpc/boot: Move ubldr to /boot/uboot, and make this a separate filesystem

Summary:
Now that mpc85xx can boot via ubldr, move ubldr to a separate
filesystem, mounted on /boot/uboot, so that a fresh install can boot correctly.

Reviewed By: nwhitehorn
Differential Revision: https://reviews.freebsd.org/D18709

5 years agoGarbage collection no-longer-used constant.
ian [Sun, 17 Feb 2019 23:48:51 +0000 (23:48 +0000)]
Garbage collection no-longer-used constant.

5 years agoMake lsdev -v output line up in neat columns by using a fixed width for
ian [Sun, 17 Feb 2019 23:46:11 +0000 (23:46 +0000)]
Make lsdev -v output line up in neat columns by using a fixed width for
the size field and a tab between the partition type and the size.

Changes this

  disk devices:
        disk0 (MMC)
        disk0s1: DOS/Windows            49MB
        disk0s2: FreeBSD                14GB
        disk0s2a: FreeBSD UFS         14GB
        disk0s2b: Unknown             2048KB
        disk0s2d: FreeBSD UFS         2040KB

to this

  disk devices:
        disk0 (MMC)
        disk0s1: DOS/Windows      49MB
        disk0s2: FreeBSD          14GB
        disk0s2a: FreeBSD UFS     14GB
        disk0s2b: Unknown       2048KB
        disk0s2d: FreeBSD UFS   2040KB

5 years agoUse a couple local variables to avoid repetitive long expressions that
ian [Sun, 17 Feb 2019 23:38:17 +0000 (23:38 +0000)]
Use a couple local variables to avoid repetitive long expressions that
cause line-wrapping.

5 years agoRestore loader(8)'s ability for lsdev to show partitions within a bsd slice.
ian [Sun, 17 Feb 2019 23:32:09 +0000 (23:32 +0000)]
Restore loader(8)'s ability for lsdev to show partitions within a bsd slice.

I'm pretty sure this used to work at one time, perhaps long ago.  It has
been failing recently because if you call disk_open() with dev->d_partition
set to -1 when d_slice refers to a bsd slice, it assumes you want it to
open the first partition within that slice.  When you then pass that open
dev instance to ptable_open(), it tries to read the start of the 'a'
partition and decides there is no recognizable partition type there.

This restores the old functionality by resetting d_offset to the start
of the raw slice after disk_open() returns.  For good measure, d_partition
is also set back to -1, although that doesn't currently affect anything.

I would have preferred to make disk_open() avoid such rude assumptions and
if you ask for partition -1 you get the raw slice.  But the commit history
shows that someone already did that once (r239058), and had to revert it
(r239232), so I didn't even try to go down that road.

5 years agolibnv: fix revert
oshogbo [Sun, 17 Feb 2019 18:32:19 +0000 (18:32 +0000)]
libnv: fix revert

Reported by: jenkins

5 years agolibnv: fix double free
oshogbo [Sun, 17 Feb 2019 18:26:27 +0000 (18:26 +0000)]
libnv: fix double free

In r343986 we introduced a double free. The structure was already
freed fixed in the r302966. This problem was introduced
because the GitHub version was out of sync with the FreeBSD one.

Submitted by: Mindaugas Rasiukevicius <rmind@netbsd.org>
MFC with: r343986