Commit Graph

228942 Commits

Author SHA1 Message Date
Andriy Gapon
be5060c116 zfs_mount: restore a bit of ifdef-out illumos code
And correctly mark the end of the replacement FreeBSD code.

MFC after:	1 week
2018-01-09 13:43:04 +00:00
Andriy Gapon
fac38b96d2 usbdevs: add ASMedia vendor ID
MFC after:	1 week
2018-01-09 13:42:08 +00:00
Konstantin Belousov
c999b43527 Generalize the fix from r322757 and apply it to several more places.
The code accesses bp->b_dep without owning the ufs mount softdep lock,
which makes it possible for the derefenced workitem to be freed in
parallel.  In particular, the deallocate_dependencies(),
softdep_disk_io_initiation() and softdep_disk_write_complete() are
affected.

Move the code to safely calculate ump from the buffer with
dependencies into the helper softdep_bp_to_mp() and use it for all
found cases.

Tested by:	pho (as part of the bigger patch)
Reviewed by:	mckusick (as part of the bigger patch)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2018-01-09 10:51:44 +00:00
Konstantin Belousov
e51e3c7e73 When handling write completion, take SU lock around calls to
handle_written_XXX() in case of processing the buffer with an error.

Tested by:	pho (as part of the bigger patch)
Reviewed by:	mckusick (as part of the bigger patch)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2018-01-09 10:44:17 +00:00
Konstantin Belousov
377f88fb08 Postpone the disassotiation of the background write buffer with devvp
so that buf_complete() sees fully constructed buffer.

This is a NOP right now, but will be needed by the forthcoming SU change.

Reported and tested by:	pho
Reviewed by:	mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2018-01-09 10:33:11 +00:00
Eitan Adler
d85e65cb35 ldconfig(8): use .Nm instead of 'ldconfig' 2018-01-09 06:51:41 +00:00
Cy Schubert
bdb0c28072 When growing the state, also grow the seed array. Otherwise memory
that was not allocated will be accessed.

This necessitated refactoring state seed allocation from
ipf_state_soft_init() into a new common ipf_state_seed_alloc() function
as it is now also used by ipf_state_rehash() when changing the size of
the state hash table in addition to by ipf_state_soft_init() during
initialization.

According to Christos Zoulas <christos@NetBSD.org>:

The bug was encountered by a NetBSD vendor who's customer machines had
large ipfilter states. The bug was reliably triggered by resizing the
state variables using "ipf -T".

Submitted by:	Christos Zoulas <christos@NetBSD.org>
Reviewed by:	delphij, rgrimes
Obtained from:	NetBSD ip_state.c CVS revs r1.9 and r1.10
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D13755
2018-01-09 06:43:58 +00:00
Conrad Meyer
4b42739b37 Fix Zstd kernel build with GCC 4.2
By disabling the -Winline warning.  Fixes the powerpc and sparc64 build
after r327706.

Note: MIPS and RISCV builds still broken due to absense of __ctzdi2 (aka
__builtin_ctzll) in their libgcc or libcompiler-rt libraries.

Reported by:	markj
Sponsored by:	Dell EMC Isilon
2018-01-09 03:28:24 +00:00
Scott Long
bff0b56cdf Don't hold the periph locks during dump.
Obtained from:	Netflix
2018-01-09 00:17:15 +00:00
Scott Long
04e814aecd Don't hold the periph lock when calling into cam_periph_runccb()
from the ada and da dump routines.  This avoids difficult locking
problems from needing to be handled.  While it might seem like this
would leave the periphs unprotected during dump, they were aleady
at risk of unexpected removal due to the dump functions not
keeping refcount state across the many calls that come in during
a dump.  This is an exercise for future work.

Obtained from:	Netflix
2018-01-09 00:10:59 +00:00
Scott Long
329e7a8b51 Protect against a possible NULL deference from an accessor
function.

Obtained from:	Netflix
2018-01-09 00:00:55 +00:00
Mark Johnston
78f57a9cde Generalize the gzio API.
We currently use a set of subroutines in kern_gzio.c to perform
compression of user and kernel core dumps. In the interest of adding
support for other compression algorithms (zstd) in this role without
complicating the API consumers, add a simple compressor API which can be
used to select an algorithm.

Also change the (non-default) GZIO kernel option to not enable
compressed user cores by default. It's not clear that such a default
would be desirable with support for multiple algorithms implemented,
and it's inconsistent in that it isn't applied to kernel dumps.

Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D13632
2018-01-08 21:27:41 +00:00
Conrad Meyer
d3692a4dee Integrate zstd into the kernel
Mock userspace headers and include mocked headers first in compilation
command to inject kernel headers and override e.g., malloc(3) with
malloc(9).

Submitted by:	allanjude
Reviewed by:	imp (earlier version), bapt (earlier version)
Differential Revision:	https://reviews.freebsd.org/D10407
2018-01-08 20:14:16 +00:00
John Baldwin
349b6dad63 Use <stand.h> instead of <inttypes.h> and <stdio.h> in boot code.
In the freestanding boot compile environment, standard headers are not
available.  Curiously, only building with clang exposed this as compiles
with external GCC still succeeded.

Sponsored by:	DARPA / AFRL
2018-01-08 18:47:35 +00:00
John Baldwin
9bd8ae10e3 Fix printf missing format variables warnings.
Include the failing kernel file name for errors in beri_elf64_exec().

Sponsored by:	DARPA / AFRL
2018-01-08 18:46:10 +00:00
John Baldwin
9433594417 Define __dmadat after #include'ing ufsread.c.
The __dmadat variable is a statically allocated I/O buffer.  The type is
declared in the ufsread.c source file and clang warns if a variable is
defined before it's type is declared.

Sponsored by:	DARPA / AFRL
2018-01-08 18:44:36 +00:00
Mark Johnston
8b0a00b745 Sort and remove unneeded includes.
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2018-01-08 15:56:40 +00:00
Pedro F. Giffuni
d6d1add4ea Revert r327697:
malloc(9): drop the __result_use_check attribute for the kernel allocator.

My bad: __result_use_check just checks the for the general and we always
want to make sure allocated memory is used, not only checked for nullness.

Add it to reallocf since that was missing.
2018-01-08 15:54:29 +00:00
Mark Johnston
7653e6d781 Release the queue lock before restarting the worker loop.
Reported and tested by:	pho
MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2018-01-08 15:41:49 +00:00
Pedro F. Giffuni
6db47c9d5b malloc(9): drop the __result_use_check attribute for the kernel allocator.
The __result_use_check attribute was brought to the kernel malloc in
r281203 for consistency with the userland malloc.

For the case of the M_WAITOK flag, the kernel malloc(), realloc(), and
reallocf() cannot return NULL so in that case the __result_use_check
attribute makes no sense.

We don't have any way of conditionalizing such attributes so just drop it.

MFC after:	3 days
2018-01-08 15:41:48 +00:00
Fabien Thomas
de2b2c908a Fix uninitialized crp_retw_id when using asynchronous crypto drivers
with defered callbacks.

Submitted by:	emeric.poupon@stormshield.eu
Reported by:	mav@
Reviewed by:	fabient@
2018-01-08 13:43:12 +00:00
Andrew Turner
dde4c2fc9d Only install the new pagetable pointer into ttbr0_el1 when it differs from
the existing value.

MFC after:	1 week
Sponsored by:	DARPA, AFRL
2018-01-08 11:08:45 +00:00
Andrew Turner
45a91d4538 Move some of the common thread switching code into C. This will help with
future optimisations, e.g. using Address Space IDs (asid).

MFC after:	1 week
Sponsored by:	DARPA, AFRL
2018-01-08 10:23:31 +00:00
Mariusz Zaborski
d06b4cefed Document the DNS Casper service.
Reviewed by:	brueffer@, bcr@
Differential Revision:	https://reviews.freebsd.org/D13762
2018-01-08 09:20:08 +00:00
Alan Somers
1d23aa6ec7 geli: optimize tests
Reduce the geli tests' runtime by about a third:

* In integrity_test:copy, use a file-backed md(4) device instead of a
  malloc'd one.  That way we can corrupt the underlying storage without
  needing to detach and reattach the geli device.

* In integrity_test:{copy, hmac, data} and onetime_test:{onetime,
  onetime_a}, move reads of /dev/random out of the loop.

MFC after:	2 weeks
2018-01-08 00:10:45 +00:00
Ed Schouten
4b6b56b32b Use mallocarray(9) in CloudABI kernel code where possible.
Submitted by:	pfg@
2018-01-07 22:38:45 +00:00
Alan Somers
565a0a2c65 geli: convert remaining TAP tests to ATF
MFC after:	2 weeks
2018-01-07 22:21:07 +00:00
Alan Somers
48c29f849e Fix typo from r327666
MFC after:	13 days
X-MFC-With:	327666
2018-01-07 21:57:52 +00:00
Justin Hibbits
f1a48eaf0d Add missing file to gpiobus module
ofw_gpiobus.c is needed when FDT is used.

MFC after:	2 weeks
2018-01-07 20:28:17 +00:00
Ian Lepore
ac579135b0 Use EVENTHANDLER_DIRECT_INVOKE for [un]mount events, for better performance. 2018-01-07 18:07:22 +00:00
Ian Lepore
f031a3b25f Use EVENTHANDLER_DIRECT_INVOKE() for device events, for better performance. 2018-01-07 18:06:30 +00:00
Kristof Provost
5cf32a6e95 vchiq: Use mallocarray() to provide kcalloc()
This means we now also provide integer overflow protection, like the
Linux kcalloc().
2018-01-07 13:41:06 +00:00
Kristof Provost
e70c77ca17 linuxkpi: Implement kcalloc() based on mallocarray()
This means we now get integer overflow protection, which Linux code
might expect as it is also provided by kcalloc() in Linux.
2018-01-07 13:39:12 +00:00
Kristof Provost
6273ba66f2 pf: Avoid integer overflow issues by using mallocarray() iso. malloc()
pfioctl() handles several ioctl that takes variable length input, these
include:
- DIOCRADDTABLES
- DIOCRDELTABLES
- DIOCRGETTABLES
- DIOCRGETTSTATS
- DIOCRCLRTSTATS
- DIOCRSETTFLAGS

All of them take a pfioc_table struct as input from userland. One of
its elements (pfrio_size) is used in a buffer length calculation.
The calculation contains an integer overflow which if triggered can lead
to out of bound reads and writes later on.

Reported by:	Ilja Van Sprundel <ivansprundel@ioactive.com>
2018-01-07 13:35:15 +00:00
Kristof Provost
fd91e076c1 Introduce mallocarray() in the kernel
Similar to calloc() the mallocarray() function checks for integer
overflows before allocating memory.
It does not zero memory, unless the M_ZERO flag is set.

Reviewed by:	pfg, vangyzen (previous version), imp (previous version)
Obtained from:	OpenBSD
Differential Revision:	https://reviews.freebsd.org/D13766
2018-01-07 13:21:01 +00:00
Xin LI
6d5343e38e stddef.h is not used by cat.c, remove the include. 2018-01-07 07:08:59 +00:00
Eitan Adler
f0c0c1daec ldconfig(8): clarify language for files
The previous language did not make it clear that 'Files' are
the files specified above. Clarify it.

Reported by:	dana <dana@dana.is>
Reviewed by:	dana <dana@dana.is>
MFC After:	1 week
2018-01-07 05:38:53 +00:00
Kyle Evans
92e80162f3 aw_sid(4): Add support for Allwinner H3
The sid controller on the H3 is generally identical in location, size, and
efuse offset to the a64 and the a83t. The main difference is that the H3 has
a silicon bug that sometimes causes the rootkey (at least) to be garbled
unless first read by the prctl registers.

This device is currently not in our DTS and, as of now, is not yet present
in mainline Linux DTS.

Tested on:	OrangePi One
2018-01-07 04:59:28 +00:00
Kyle Evans
86c6868161 aw_sid: Add method for reading keys via prctl registers
Technically supported on the later SoCs, this will only really be used to
add support for the H3 sid. The H3 has a silicon bug that manifests itself
by returning garbled rootkeys unless first read via the prctl registers.
2018-01-07 03:31:55 +00:00
Alan Somers
5dce212d67 geli: fix parallel execution of tests
The trick is not to destroy an md(4) device during a test.  That can create
a "double-free" situation, because we also destroy md devices during test
cleanup.

MFC after:	2 weeks
2018-01-07 02:30:08 +00:00
Kyle Evans
ea9e0e28e0 Fix bogus pass for syscon_generic introduced in r327621
ian@ pointed out that BUS_PASS_DEFAULT + $anything is bogus, given that
BUS_PASS_DEFAULT is defined as __INT_MAX. Instead, we take a page out of
imx6_usbphy's book and use BUS_PASS_DEFAULT - 1000 to achieve the desired
effect of syscon_generic attaching before if_awg and other potential
consumers, but late enough that more specialized implementations should have
no problem attaching instead.

Reported by:	ian
2018-01-07 02:19:54 +00:00
Alan Somers
f397a004de geli: convert most tests from TAP to ATF
I'm leaving readonly_test and nokey_test alone for now. In a future commit
they should be broken up into several smaller test cases and distributed
between multiple files.

Reviewed by:	ngie
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D13717
2018-01-07 00:44:22 +00:00
Emmanuel Vadot
98b306dcfd arm64: Remove old clock driver for Allwinner 64bit SoC
All the clocks are now handled by the clkng driver.

Tested On: Pine64-LTS (A64)
Tested On: OrangePi PC2 (H5)
2018-01-06 20:32:14 +00:00
Konstantin Belousov
f3c588e171 Document kern.smp.disabled tunable.
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2018-01-06 16:29:00 +00:00
Eitan Adler
90daf40223 morse(6): update documentation
- bump Dd
- use 'r' instead of 'D' from the original submission
2018-01-06 15:52:28 +00:00
Kyle Evans
e7cfe78afe Move syscon_generic to attach much later
It still needs to be before if_awg at least in order to be available for
other operations, but it should not be attaching before interrupt
controllers at the very least.

This should make errors involving syscon register space colliding with other
devices a little more innocent, but these conflicts should really be tracked
down and resolved. One such conflict is with the Raspberry Pi 3 local
interrupt controller, noticed by tuexen@

Reported by:	tuexen
2018-01-06 14:21:32 +00:00
Warner Losh
90ceddb160 The source strings are from the password database which guarantees
that the data going into it is sane.  Out of an abundance of caution,
limit the string copies to prevent an overflow.

CID: 1019035
2018-01-06 12:46:04 +00:00
Warner Losh
ca23e64eb4 Sanity check sysconf return value to ensure it's positive before we
use it. Use proper cast to convert long to size_t (instead of
blksize_t) to preclude sign extension issues.

CID: 1193754
2018-01-06 12:45:59 +00:00
Warner Losh
1723a6e523 Sanity check media size and sector counts to ensure that we don't
produce negative sector numbers in the testing algorithm.

CID: 1198994
2018-01-06 12:34:03 +00:00
Li-Wen Hsu
917fa2a3e9 Unbreak build after r327614
Approved by:	mjg (on IRC)
Differential Revision:	https://reviews.freebsd.org/D13782
2018-01-06 09:48:04 +00:00