Commit Graph

218213 Commits

Author SHA1 Message Date
Bryan Drewery
2d22bf634a Support spaces in group names.
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2016-12-06 23:43:04 +00:00
Mark Johnston
77edd8fa00 Provide dummy sysctls for v_cache_count and v_tcached.
Some utilities (notably top(1)) exit if any of their input sysctls don't
exist, and the removal of the above-mentioned PG_CACHE-related sysctls
makes it difficult to run such utilities on different versions of the
kernel without recompiling.

Requested by:	bde
2016-12-06 22:52:45 +00:00
Mark Johnston
10c480e775 Require the STACK option for code that captures stacks of running threads.
stack_machdep.c is compiled if either of the DDB or STACK options is
specified, but stack_save_td_running() isn't useable from DDB. Moreover,
stack_save_td_running() works by raising an NMI on the CPU running the
target thread, and the corresponding handler is compiled only if STACK is
configured.

Reported by:	kib
MFC after:	1 week
2016-12-06 22:48:28 +00:00
Dimitry Andric
c130a785e4 During the bootstrap phase, when building the minimal llvm library on
PowerPC, add lib/Support/Atomic.cpp.  This is needed because upstream
llvm revision r271821 disabled the use of std::call_once, which causes
some fallback functions from Atomic.cpp to be used instead.

Reported by:	Mark Millard
PR:		214902
X-MFC-With:	309124
2016-12-06 20:44:40 +00:00
Ed Schouten
8ab00b8fbc Properly sign extend the result of jrand48() and mrand48().
These functions are supposed to return a value between [_2^31, 2^31).
This doesn't seem to work on 64-bit systems, where we return a value
between [0, 3^32). Patch up the function to use proper casts to int32_t.
While there, fix some other style bugs.

MFC after:	2 weeks
2016-12-06 19:08:29 +00:00
Mariusz Zaborski
b02f20f47e tcpdump: allow to use BIOCROTZBUF in capability mode
The libpcap library can use a BIOCROTZBUF ioctl when net.bpf.zerocopy_enable
sysctl is set.

Reported by:	olivier@
Tested by:	olivier@
2016-12-06 18:58:42 +00:00
Gleb Smirnoff
edc816d625 Fix possible integer overflow in guest memory bounds checking, which could
lead to access from the virtual machine to the heap of the bhyve(8) process.

Submitted by:	Felix Wilhelm <fwilhelm ernw.de>
Patch by:	grehan
Security:	FreeBSD-SA-16:38.bhyve
2016-12-06 18:50:44 +00:00
Gleb Smirnoff
74e540d788 Fix possible buffer overflow(s) in link_ntoa(3).
A specially crafted sockaddr_dl argument can trigger a static buffer overflow
in the libc library, with possibility to rewrite with arbitrary data following
static buffers that belong to other library functions.

Reviewed by:	kib
Security:	FreeBSD-SA-16:37.libc
2016-12-06 18:50:33 +00:00
Gleb Smirnoff
f5c44977ff When telnetd(8) composes argument list for login(1), an unexpected sequence
of memory allocation failures combined with insufficient error checking
could result in the construction and execution of an argument sequence that
was not intended.

Fix that treating malloc(3) failures as fatal condition.

Submitted by:	brooks
Security:	FreeBSD-SA-16:36.telnetd
2016-12-06 18:50:22 +00:00
Maxim Sobolev
0d49655f96 Auto-generate 2 test cases that differ only in structure and SCM_XXX constant
used. We can do it programmatically, but that would make code convoluted
and more complex. I have two more of those types coming for the CLOCK_REALTIME
and CLOCK_MONOTONIC. This seems like an elegant and scallable approach.
2016-12-06 18:22:25 +00:00
Konstantin Belousov
4dafad49c6 Do not leak curthread->inact_mtx when cancelling in pthread_cond_wait(3).
Leave robust-protected region before checking for cancellation by
calling _thr_testcancel().  Otherwise, if cancelling request was
pending, the cancel handler is called with the dandling inact_mtx,
which triggers an assert if any mutex operation is performed by the
handler.

Reported and tested by:	Dimitri Staessens <dimitri.staessens@intec.ugent.be>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2016-12-06 17:13:17 +00:00
Bryan Drewery
b4af531e83 Remove unneeded hack fixed by r309626.
strvis(3) being tainted by our mbtowc(3) calls was causing
spurious failures here.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2016-12-06 17:06:14 +00:00
Bryan Drewery
f0a6d7e204 strvis(3): Avoid internal state of multibyte functions being tainted.
The mbtoc(3) and wctomb(3) functions use internal state which may be
tainted before the call to strvis(3).  In this context we can just use
the thread-safe versions mbrtoc(3) and wcrtomb(3) which allow passing
our own state from our stack.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2016-12-06 17:05:02 +00:00
Eric van Gyzen
2830098671 Add rcorder-visualize.sh, which generates graphviz from rc.d scripts
This is imported from NetBSD.  The author--Joerg Sonnenberger--agreed
to apply a two-clause BSD license, just so the license was clear.

This source tree location matches NetBSD, and is the first place someone
might look for such a tool.

Obtained from:	Joerg Sonnenberger via NetBSD
MFC after:	3 days
Sponsored by:	Dell EMC
2016-12-06 15:49:39 +00:00
Eric van Gyzen
b54d51ac86 locale: fix the powerpc build
Reported by:	markj (and bde, in a way)
MFC after:	3 days
X-MFC with:	r309364
Sponsored by:	Dell EMC
2016-12-06 15:42:18 +00:00
Andrew Turner
0afaf183d0 Add the missing gic_common.h include for GIC_BUS_FDT.
Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-12-06 15:16:00 +00:00
Andrew Turner
be04b41da2 Create two GIC ivars to find the bus type and GIC hardware version. These
will be used by the gicv2m and ITS ACPI drivers to only attach to the
correct parent.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-12-06 15:12:14 +00:00
Mateusz Guzik
ef32958e5d ifndef atomic_cas_* in cddl code in preparation for native implementations
This is a temporary change to not require all architectures to import at once.

Discussed with:	jhb
2016-12-06 14:08:49 +00:00
Andrew Turner
c417fba9eb Move the common bit manipulation macros from the GICv3 header to the
common GIC header file.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-12-06 13:55:19 +00:00
Andrew Turner
31b892557f Move the stored signal mask later in the jump buf. It was being clobbered
by a later store of a VFP register.

Sponsored by:	ABT Systems Ltd
2016-12-06 13:46:12 +00:00
Andrew Turner
4d7d72fb23 Adda new common GIC header to handle the common parts of the GICv2 and
GICv3 drivers. For now it just contains common distributor registers.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-12-06 12:57:28 +00:00
Navdeep Parhar
3cbaf64f2e cxgbe(4): Update firmwares from version 1.16.12.0 to 1.16.22.0.
Obtained from:	Chelsio Communications
MFC after:	3 days
Sponsored by:	Chelsio Communications
2016-12-06 12:43:07 +00:00
Andrew Turner
00e61f254c Add the full set of GICD_PIDR* registers
Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-12-06 11:41:19 +00:00
Michael Tuexen
5b495f17a5 Whitespace changes.
The tools using to generate the sources has been updated and produces
different whitespaces. Commit this seperately to avoid intermixing
these with real code changes.

MFC after:	3 days
2016-12-06 10:21:25 +00:00
Luiz Otavio O Souza
ff30498384 Fix the armv6 build after r309553.
Sponsored by:	Rubicon Communications, LLC (Netgate)
2016-12-06 06:15:28 +00:00
Andriy Voskoboinyk
8e61c3f8e3 rsu: fix printf format specifiers. 2016-12-06 06:12:01 +00:00
Enji Cooper
8d4ddada63 Remove svn[lite]{bench,fsfs} if either MK_SVN == no or MK_SVNLITE == no
MFC after:	1 week
2016-12-06 06:04:13 +00:00
Mark Johnston
e0d70fc1dc libdtrace: Don't use a read-only handle for enumerating pid probes.
Enumeration of return probes involves disassembling subroutines in the
target process, and ptrace(2) is currently used to read from the target
process. libproc could read from the backing file instead to avoid this
problem, but in the common case libdtrace will have a writeable handle
on the process anyway. In particular, a writeable handle is needed to list
USDT probes, and libdtrace will cache such a handle for processes that it
controls via dtrace -c and -p.
2016-12-06 04:28:56 +00:00
Mark Johnston
fe2521b980 Bump the libproc library version. 2016-12-06 04:23:32 +00:00
Mark Johnston
b043b5dc6b libproc: Add support for some proc_attach() flags.
This change adds some handling for the equivalent of Solaris' PGRAB_*
flags. In particular, support for PGRAB_RDONLY is needed to avoid a
nasty deadlock: dtrace(1) may otherwise stop the master process for its
pseudo-terminal and end up blocking while writing to standard output.
2016-12-06 04:22:38 +00:00
Mark Johnston
c156354ff8 libproc: Cache symbol tables for mapped objects upon access.
Extend the file handle cache entries to include symbol tables as well. An
index is used to implement binary search by symbol value. Lookups by
name are comparatively rare and are thus still implemented with a linear
search, but support for a binary search by name would be straightforward
to add if needed.
2016-12-06 04:21:35 +00:00
Mark Johnston
d42df2a447 libproc: Match prefixes when looking up mapped object by name.
When looking up an object by name, allow prefix matches if no direct match
is found. This allows one to, for example, match libc entry probes with:

 # dtrace -n 'pid$target:libc.so::entry' -c ./foo

instead of requiring "libc.so.7" or a glob.

Also remove proc_obj2map() as it currently just duplicates the
functionality of proc_name2map(). It's supposed to take a Solaris
link-map ID as a paramter, but support for this isn't implemented and
isn't required to support DTrace's pid provider.
2016-12-06 04:20:32 +00:00
Mark Johnston
07a9c2e65d libproc: Cache ELF handles for loaded objects.
libproc previously created a new handle for each symbol lookup, which
gives rather egregious performance for DTrace's ustack() action. With
this change libproc will cache the libelf descriptor upon access, making
lookups much faster in the common case.
2016-12-06 04:19:08 +00:00
Mark Johnston
76c6531c65 libproc: Improve .gnu_debuglink support.
As of r278658 libproc looks for debug files under /usr/lib/debug and will
use them if available. This change fleshes out that support a bit further:
- Check for a .gnu_debuglink section and use the file name specified
  there if one is present.
- Validate external debug files with the CRC in the .gnu_debuglink
  section so as to avoid using stale or corrupt debug files.
- Search for debug files in the directory containing the referencing
  object or in the .debug subdirectory, as GDB does.
2016-12-06 04:18:09 +00:00
Mark Johnston
b1bb30e5c5 libproc: Make proc_getpid() an accessor for struct proc_handle.
This allows librtld_db to fetch the PID from a handle without calling into
libproc. Together with r303531, this means that librtld_db no longer
references symbols from libproc.
2016-12-06 04:14:20 +00:00
Mark Johnston
fcf9fc109e Fix style bugs and remove trailing whitespace in libproc and librtld_db.
MFC after:	1 week
2016-12-06 04:13:02 +00:00
Martin Matuska
a2e802b76b MFV r309587:
Sync libarchive with vendor.

Vendor bugfixes:

libarchive #831:
  Spelling fixes
libarchive #832:
  Relax sanity checks of number fields in tar header even more
OSS-Fuzz #16:
  Fix possible hang in uudecode_filter_read()
OSS-Fuzz #220:
  Reject an 'ar' filename table larger than 1GB or a filename larger
  than 1MB.

MFC after:	1 week
2016-12-06 01:35:27 +00:00
John Baldwin
1175b23f77 Rework syscall structure lookups.
Avoid always using an O(n^2) loop over known syscall structures with
strcmp() on each system call.  Instead, use a per-ABI cache indexed by
the system call number. The first 1024 system calls (which should cover
all of the normal system calls in currently-supported ABIs) use a flat array
indexed by the system call number to find system call structure.  For other
system calls, a linked list of structures storing an integer to structure
mapping is stored in the ABI.  The linked list isn't very smart, but it
should only be used by buggy applications invoking unknown system calls.

This also fixes handling of unknown system calls which currently trigger
a NULL pointer dereference.

Reviewed by:	kib
MFC after:	2 weeks
2016-12-06 00:39:00 +00:00
John Baldwin
a1eff92bc8 Don't attach to Host-PCI bridges with a bad bus number.
If the bus number assigned to a Host-PCI bridge doesn't match the first
bus number in the associated producer range from _CRS, print a warning and
fail to attach rather than panicking due to an assertion failure.

At least one single-socket Dell machine leaves a "ghost" Host-PCI bridge
device in the ACPI namespace that seems to correspond to the I/O hub in
the second socket of a two-socket machine.  However, the BIOS doesn't
configure the settings for this "ghost" bridge correctly, nor does it have
any PCI devices behind it.

Tested by:	royger
MFC after:	2 weeks
2016-12-06 00:36:02 +00:00
Martin Matuska
36f3c6516a Update vendor/libarchive to git ddb3954bfdb9a0a98d50fb1c50cbecb603d9adf0
Vendor bugfixes:

libarchive #831:
  Spelling fixes
libarchive #832:
  Relax sanity checks of number fields in tar header even more
OSS-Fuzz #16:
  Fix possible hang in uudecode_filter_read()
OSS-Fuzz #220:
  Reject an 'ar' filename table larger than 1GB or a filename larger
  than 1MB.
2016-12-06 00:35:20 +00:00
Andriy Voskoboinyk
31847d9434 rsu: add hardware crypto support (WEP, TKIP and CCMP).
This change includes firmware commands for key setup +
some additional checking via CAMREAD / CAMWRITE registers.
Nothing (except rsu_delete_key() for pairwise keys) is deferred;
to ensure that things are done in order rsu_set_key() will wait
until key deletion task will be finished.

Tested with Asus USB-N10 (all ciphers).

Differences from initial (reviewed) patch:
- Pause AC queues before disassociation - since CMD_DISCONNECT clears
crypto state all pending frames must be processed / dropped before it.
- Check sc_running flag before trying to set static keys.
- Clear key index from bitmap even when firmware command fails
(it will be invalidated via CAMWRITE anyway).

Reviewed by:	adrian, kevlo
Tested by:	kevlo
Differential Revision:	https://reviews.freebsd.org/D8706
2016-12-06 00:13:49 +00:00
John Baldwin
00aa064f30 Bump Dd for addition of T6.
Pointy hat to:	jhb
2016-12-06 00:05:38 +00:00
John Baldwin
f6e648b896 Document support for Terminator 6 adapters in cxgbe(4) and cxgbev(4).
Approved by:	np
MFC after:	3 days
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D8716
2016-12-06 00:01:53 +00:00
Rick Macklem
a5d19b81b4 Fix the NFSv4.1 server for Open reclaim after a reboot.
The NFSv4.1 server failed to update the nfs-stablerestart file for
a client when the client was issued its first Open. As such, recovery
of Opens after a server reboot failed with NFSERR_NOGRACE.
This patch fixes this.
It also changes the code so that it malloc()'s the 1024 byte array
instead of allocating it on the kernel stack for both NFSv4.0 and NFSv4.1.
Note that this bug only affected NFSv4.1 and only when clients attempted
to reclaim Opens after a server reboot.

MFC after:	2 weeks
2016-12-05 22:36:25 +00:00
Kristof Provost
c3e14afc18 pflog: Correctly initialise subrulenr
subrulenr is considered unset if it's set to -1, not if it's set to 1.
See contrib/tcpdump/print-pflog.c pflog_print() for a user.

This caused incorrect pflog output (tcpdump -n -e -ttt -i pflog0):
  rule 0..16777216(match)
instead of the correct output of
  rule 0/0(match)

PR:		214832
Submitted by:	andywhite@gmail.com
2016-12-05 21:52:10 +00:00
Maxim Sobolev
1fab62b1e1 Refactor the regression test code by splitting huge monolithic C
file into smaller pieces that are hopefully easier to understand
and extend. This is to pave the ground for adding few more
socket timestamp formats that I am working on here.

No functional changes (I hope).
2016-12-05 17:21:04 +00:00
Michal Meloun
65d5084f54 Fix build breakage caused by r309531.
Reported by: andrew
MFC after: 2 weeks
X-MFC with: r309531
2016-12-05 15:55:51 +00:00
Sevan Janiyan
0e922aa308 Fix error in the example section
Adjust formatting highlighted by igor.

PR:		214683
Submitted by:	Anindya Mukherjee <anindya49 AT hotmail DOT com>
Reviewed by:	jilles
Approved by:	bcr (mentor)
MFC after:	5 days
Differential Revision:	https://reviews.freebsd.org/D8591
2016-12-05 13:23:22 +00:00
Konstantin Belousov
3dd3c4503b Release DMAR table after using it.
Reported and tested by:	hps
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2016-12-05 11:42:09 +00:00
Konstantin Belousov
85d99487b8 Rename fast taskqueues used by DMAR to avoid naming conflict of the
sleepable and spin mutexes created by the queues.

Reported and tested by:	hps
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2016-12-05 11:41:09 +00:00