Commit Graph

1882 Commits

Author SHA1 Message Date
jakllsch
ad370c5c20 add Analogix DisplayPort core driver 2019-12-19 00:23:57 +00:00
maxv
e67f51b8f7 Retire filemon, discussed on tech-kern@. 2019-12-18 07:37:17 +00:00
riastradh
7ba101b07e Nuke crypto/arc4. Has not been used since 2003. Will not be missed. 2019-12-05 03:22:02 +00:00
maxv
10c5b02320 Add support for Kernel Memory Sanitizer (kMSan). It detects uninitialized
memory used by the kernel at run time, and just like kASan and kCSan, it
is an excellent feature. It has already detected 38 uninitialized variables
in the kernel during my testing, which I have since discreetly fixed.

We use two shadows:
 - "shad", to track uninitialized memory with a bit granularity (1:1).
   Each bit set to 1 in the shad corresponds to one uninitialized bit of
   real kernel memory.
 - "orig", to track the origin of the memory with a 4-byte granularity
   (1:1). Each uint32_t cell in the orig indicates the origin of the
   associated uint32_t of real kernel memory.

The memory consumption of these shadows is consequent, so at least 4GB of
RAM is recommended to run kMSan.

The compiler inserts calls to specific __msan_* functions on each memory
access, to manage both the shad and the orig and detect uninitialized
memory accesses that change the execution flow (like an "if" on an
uninitialized variable).

We mark as uninit several types of memory buffers (stack, pools, kmem,
malloc, uvm_km), and check each buffer passed to copyout, copyoutstr,
bwrite, if_transmit_lock and DMA operations, to detect uninitialized memory
that leaves the system. This allows us to detect kernel info leaks in a way
that is more efficient and also more user-friendly than KLEAK.

Contrary to kASan, kMSan requires comprehensive coverage, ie we cannot
tolerate having one non-instrumented function, because this could cause
false positives. kMSan cannot instrument ASM functions, so I converted
most of them to __asm__ inlines, which kMSan is able to instrument. Those
that remain receive special treatment.

Contrary to kASan again, kMSan uses a TLS, so we must context-switch this
TLS during interrupts. We use different contexts depending on the interrupt
level.

The orig tracks precisely the origin of a buffer. We use a special encoding
for the orig values, and pack together in each uint32_t cell of the orig:
 - a code designating the type of memory (Stack, Pool, etc), and
 - a compressed pointer, which points either (1) to a string containing
   the name of the variable associated with the cell, or (2) to an area
   in the kernel .text section which we resolve to a symbol name + offset.

This encoding allows us not to consume extra memory for associating
information with each cell, and produces a precise output, that can tell
for example the name of an uninitialized variable on the stack, the
function in which it was pushed on the stack, and the function where we
accessed this uninitialized variable.

kMSan is available with LLVM, but not with GCC.

The code is organized in a way that is similar to kASan and kCSan, so it
means that other architectures than amd64 can be supported.
2019-11-14 16:23:52 +00:00
msaitoh
18f068bbc4 Remove acorn26's upc(4) devices. 2019-11-11 04:04:29 +00:00
jmcneill
088b457010 Add support for internal DesignWare HDMI PHYs 2019-11-09 23:27:50 +00:00
maxv
b7edd3d132 Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

 - On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
   describing the access, and delay the calling CPU (10ms).

 - On all memory accesses, we verify if the memory we're reading/writing
   is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.
2019-11-05 20:19:17 +00:00
ozaki-r
b2358a5409 Implement a front-end driver of virtio-9p called vio9p
In conjunction with mount_9p, it enables a NetBSD system running as a VM guest
to mount an exported filesystem by the host via virtio-9p.  It exports a 9p
end-point of virtio-9p via a character device file for mount_9p.

Reviewed by yamaguchi@
2019-10-28 02:56:40 +00:00
mrg
90bf43e918 convert HAVE_GCC == 7 to HAVE_GCC >= 7. 2019-09-30 00:06:02 +00:00
christos
02cdd248ec Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
2019-09-22 22:59:37 +00:00
maxv
054c8b6dea Wrong major. 2019-09-15 11:45:47 +00:00
maxv
250ccf12c0 Add vHCI, a driver which allows to send and receive USB packets directly
from userland via /dev/vhci. Using this, it becomes possible to test and
fuzz the USB stack and all the USB drivers without having the associated
hardware.

The vHCI device has four ports independently addressable.

For each xfer on each port, we create two packets: a setup packet (which
indicates mostly the type of request) and a data packet (which contains
the raw data). These packets are processed by read and write operations
on /dev/vhci: userland poll-reads it to fetch usb_device_request_t
structures, and dispatches the requests depending on bRequest and
bmRequestType.

A few ioctls are available:

	VHCI_IOC_GET_INFO   - Get the current status
	VHCI_IOC_SET_PORT   - Choose a vHCI port
	VHCI_IOC_USB_ATTACH - Attach a USB device on the current port
	VHCI_IOC_USB_DETACH - Detach the USB device on the current port

vHCI has already allowed me to automatically find several bugs in the USB
stack and its drivers.
2019-09-14 06:57:51 +00:00
riastradh
8e07b51739 Switch from NIST CTR_DRBG with AES to NIST Hash_DRBG with SHA-256.
Benefits:

- larger seeds -- a 128-bit key alone is not enough for `128-bit security'
- better resistance to timing side channels than AES
- a better-understood security story (https://eprint.iacr.org/2018/349)
- no loss in compliance with US government standards that nobody ever
  got fired for choosing, at least in the US-dominated western world
- no dirty endianness tricks
- self-tests

Drawbacks:

- performance hit: throughput is reduced to about 1/3 in naive measurements
  => possible to mitigate by using hardware SHA-256 instructions
  => all you really need is 32 bytes to seed a userland PRNG anyway
  => if we just used ChaCha this would go away...

XXX pullup-7
XXX pullup-8
XXX pullup-9
2019-09-02 20:09:29 +00:00
christos
23eed71e48 comment out CHFS to fix build issues 2019-06-17 17:06:39 +00:00
christos
14325cec89 Add more missing fs's 2019-06-17 03:34:01 +00:00
maxv
71e9a696c0 Add KASAN_PANIC, an option to turn KASAN warning into kernel panics,
requested by Siddharth. While here clarify a little.
2019-06-15 06:40:34 +00:00
sevan
93a3eadbe7 Add APPLE_UFS (disabled) 2019-05-21 16:56:10 +00:00
mlelstv
b1f23fc946 Add experimental userland interface to IPMI driver. Currently, transactions
(like sensor readout) are locked, so that a userland program may interfere with
envsys operation.

To use this you need a program like ipmitool built with OpenIPMI support.
2019-05-18 08:38:00 +00:00
ozaki-r
7fc219a5ee Implement an aggressive psref leak detector
It is yet another psref leak detector that enables to tell where a leak occurs
while a simpler version that is already committed just tells an occurrence of a
leak.

Investigating of psref leaks is hard because once a leak occurs a percpu list of
psref that tracks references can be corrupted.  A reference to a tracking object
is memorized in the list via an intermediate object (struct psref) that is
normally allocated on a stack of a thread.  Thus, the intermediate object can be
overwritten on a leak resulting in corruption of the list.

The tracker makes a shadow entry to an intermediate object and stores some hints
into it (currently it's a caller address of psref_acquire).  We can detect a
leak by checking the entries on certain points where any references should be
released such as the return point of syscalls and the end of each softint
handler.

The feature is expensive and enabled only if the kernel is built with
PSREF_DEBUG.

Proposed on tech-kern
2019-05-17 03:34:26 +00:00
sevan
035b462fcd Oops, disable FILECORE as intended.
heads up <leot> <wiz>
2019-05-06 11:59:46 +00:00
sevan
1850e1c560 Add ADOSFS & FILECORE (both disabled) 2019-05-06 01:43:09 +00:00
sevan
d8c01e6105 Add V7FS (disabled) 2019-05-06 01:20:42 +00:00
sevan
851e065a7d Add autofs pseudo device (disabled)
Add a description for existing pseudo devices
2019-05-06 01:11:42 +00:00
sevan
edda628cc6 Include EFS support.
Tested on amd64 & macppc
2019-05-06 00:33:17 +00:00
mlelstv
26894afa16 Now the real number for ipmi 2019-05-05 17:24:00 +00:00
mlelstv
a8f0d58e5b reservation for IPMI driver 2019-05-05 17:22:31 +00:00
sevan
73b544c720 Sort more 2019-04-27 00:37:40 +00:00
sevan
70b5869091 Sort 2019-04-27 00:30:37 +00:00
jmcneill
2237cf1d59 Remove Designware timer code. This was used by the old Rockchip port and
is no longer required.
2019-04-26 10:11:03 +00:00
christos
1aa59a61e4 change -h to -n because it is more "portable" 2019-04-24 20:53:10 +00:00
christos
40f68d003f Add -h to the link command so that we replace the target file each time; this
should fix:

*** Failed target:  .BEGIN
*** Failed command: ln -sf /usr/src/sys/external/gpl2/dts/dist/arch/arm/boot/dts dts/arm
*** Error code 1 (ignored)
ln: dts/arm/dts: Permission denied
2019-04-23 13:36:42 +00:00
maxv
0bf8272f89 Introduce POOL_QUARANTINE, a feature that creates a window during which a
freed buffer cannot be reallocated. This greatly helps detecting
use-after-frees, because they are not short-lived anymore.

We maintain a per-pool fifo of 128 buffers. On each pool_put, we do a real
free of the oldest buffer, and insert the new buffer. Before insertion, we
mark the buffer as invalid with KASAN. On each pool_cache_put, we destruct
the object, so it lands in pool_put, and the quarantine is handled there.

POOL_QUARANTINE can be used in conjunction with KASAN to detect more
use-after-free bugs.
2019-04-13 08:41:36 +00:00
pgoyette
a6e79f8f23 defparam all of the config variables associated with SYSV IPC stuff.
The variables were removed from sys/conf/param.c and moved into the
SYSV IPC code, but config options were never propagated via any opt_*
file.

This should fix an issue reported on netbsd-users list from Dima Veselov.

Note that this does not address other parameters included in that report,
including CHILD_MAX and NOFILE; this commit only affects items related to
the SYSV IPC code.  Also note that this does not affect non-built-in
sysv_ipc modules, for which you need to update the Makefile to use any
non-standard config values - just like any other non-built-in modules
which have config params.

XXX Pull-up to -8 and -8-0

XXX Note that there are a couple of panic() calls in msginit() which
XXX really should be changed to simple printf() and then result in
XXX msginit failure.  Unfortunately msginit() currently doesn't return
XXX a value so we cannot indicate failure to the caller.  I will fix
XXX this is a future commit.
2019-04-09 22:05:27 +00:00
maxv
ba0aa175c4 Remove compat_osf1, discussed on tech-kern@. 2019-03-25 19:24:29 +00:00
tnn
426e969cbb config glue for ssdfb 2019-03-17 01:06:42 +00:00
kamil
e7e18034ff Reserve DTrace sdt and fdt major numbers
Register cmajor 252 for fbt and 253 for sdt.

Previously the major number was picked randomly and it causes conflicts
with preallocated values for different devices.
2019-03-09 18:53:52 +00:00
kamil
83b223f69d Reserve majors for HAXM and example loadable kernel modules
348-350 are reserved for HAXM
351 is reserved for sys/modules/examples

Discussed on tech-kern@
2019-02-23 12:25:33 +00:00
mlelstv
8e117ced4e Reserve major number for spi driver 2019-02-23 07:33:20 +00:00
kamil
0fe7e51662 Add KCOV - kernel code coverage tracing device
The KCOV driver implements collection of code coverage inside the kernel.
It can be enabled on a per process basis from userland, allowing the kernel
program counter to be collected during syscalls triggered by the same
process.

The device is oriented towards kernel fuzzers, in particular syzkaller.

Currently the only supported coverage type is -fsanitize-coverage=trace-pc.

The KCOV driver was initially developed in Linux. A driver based on the
same concept was then implemented in FreeBSD and OpenBSD.

Documentation is borrowed from OpenBSD and ATF tests from FreeBSD.

This patch has been prepared by Siddharth Muralee, improved by <maxv>
and polished by myself before importing into the mainline tree.

All ATF tests pass.
2019-02-23 03:10:05 +00:00
mrg
db4c90ad36 compat_sunos depends upon compat_09. fixes:
[   1.8785495] WARNING: module error: built-in module compat_sunos can't find builtin dependency `compat_09'
[   1.8785495] WARNING: module error: built-in module compat_sunos prerequisite compat_09 failed, error 2
2019-02-12 07:16:55 +00:00
mrg
30a7fe7f13 mark pf.c, radeon_cs.c and via_dmablit.c for no fall thru error.
this was already done in the various modules, but not in the main
kernel.
2019-02-10 05:01:59 +00:00
mrg
978a4e65e0 be sure to only apply zlib.c's -Wno-error=implicit-fallthrough to GCC 7.
push the setting into the rump and module version too.
2019-02-05 09:29:19 +00:00
mrg
a9f7df428e pass -Wno-error=implicit-fallthrough for zlib.c.
XXX: consider using copts.mk for various warning/copt flags passed
in kernel builds currently set via 'makeoptions' in files.* files.
this is suboptimal, as those all get embedded into the kernel with
config_file.h.
2019-02-05 08:33:25 +00:00
jmcneill
c23685ad1c Add driver for Designware HDMI TX controller. 2019-01-30 01:19:49 +00:00
pgoyette
6d11babf08 Move COMPAT_43 to preceed anything that depends on it 2019-01-28 01:00:23 +00:00
pgoyette
48ac274ea1 Spell COMPAT_43 correctly - no NETBSD in the middle 2019-01-28 00:26:53 +00:00
christos
3d1ed1a037 comma police. 2019-01-28 00:00:18 +00:00
pgoyette
1aa60dc42a COMPAT_FREEBSD also requires COMPAT_43 2019-01-27 22:06:07 +00:00
pgoyette
a6b4123a81 Adjust dependencies for COMPAT_FREEBSD and COMPAT_LINUX
Should address kern/53915
2019-01-27 22:00:14 +00:00
pgoyette
d91f98a871 Merge the [pgoyette-compat] branch 2019-01-27 02:08:33 +00:00