freebsd-skq/sys
Andrew Turner b3c0d957a2 Add support for the Clang Coverage Sanitizer in the kernel (KCOV).
When building with KCOV enabled the compiler will insert function calls
to probes allowing us to trace the execution of the kernel from userspace.
These probes are on function entry (trace-pc) and on comparison operations
(trace-cmp).

Userspace can enable the use of these probes on a single kernel thread with
an ioctl interface. It can allocate space for the probe with KIOSETBUFSIZE,
then mmap the allocated buffer and enable tracing with KIOENABLE, with the
trace mode being passed in as the int argument. When complete KIODISABLE
is used to disable tracing.

The first item in the buffer is the number of trace event that have
happened. Userspace can write 0 to this to reset the tracing, and is
expected to do so on first use.

The format of the buffer depends on the trace mode. When in PC tracing just
the return address of the probe is stored. Under comparison tracing the
comparison type, the two arguments, and the return address are traced. The
former method uses on entry per trace event, while the later uses 4. As
such they are incompatible so only a single mode may be enabled.

KCOV is expected to help fuzzing the kernel, and while in development has
already found a number of issues. It is required for the syzkaller system
call fuzzer [1]. Other kernel fuzzers could also make use of it, either
with the current interface, or by extending it with new modes.

A man page is currently being worked on and is expected to be committed
soon, however having the code in the kernel now is useful for other
developers to use.

[1] https://github.com/google/syzkaller

Submitted by:	Mitchell Horne <mhorne063@gmail.com> (Earlier version)
Reviewed by:	kib
Testing by:	tuexen
Sponsored by:	DARPA, AFRL
Sponsored by:	The FreeBSD Foundation (Mitchell Horne)
Differential Revision:	https://reviews.freebsd.org/D14599
2019-01-12 11:21:28 +00:00
..
amd64 Add support for the Clang Coverage Sanitizer in the kernel (KCOV). 2019-01-12 11:21:28 +00:00
arm Add a missing \n to a bootverbose printf. 2019-01-07 16:36:45 +00:00
arm64 Add support for the Clang Coverage Sanitizer in the kernel (KCOV). 2019-01-12 11:21:28 +00:00
bsm
cam Add NO_SYNC_CACHE quirk for PENTAX cameras 2019-01-08 20:55:02 +00:00
cddl Change ZFS quotas to return EINVAL when not present (matches man page). 2019-01-11 02:53:46 +00:00
compat Mechanical cleanup of epoch(9) usage in network stack. 2019-01-09 01:11:19 +00:00
conf Add support for the Clang Coverage Sanitizer in the kernel (KCOV). 2019-01-12 11:21:28 +00:00
contrib Remove support for FreeBSD 9 kernel, which used to change byte order 2019-01-10 23:27:29 +00:00
crypto Generalize AES iov optimization 2018-12-13 04:40:53 +00:00
ddb ddb: Enable 'thread <address>' 2018-10-20 20:45:49 +00:00
dev snd_uaudio: Add quirks for Edirol UA-25EX in advanced driver mode. 2019-01-12 11:14:59 +00:00
dts arm64: allwinner: Fix pwm dtso 2018-12-12 21:10:34 +00:00
fs When loading an inode from disk, verify that its mode is valid. 2018-12-27 07:18:53 +00:00
gdb
geom Use g_handleattr() to reply to GEOM::candelete queries. 2019-01-02 15:52:16 +00:00
gnu Import DTS from Linux 4.20 2019-01-11 09:40:34 +00:00
i386 Fix errno values returned from DUMMY_XATTR linuxulator calls 2019-01-11 07:58:25 +00:00
isa Reapply, with minor tweaks, r338025, from the original commit: 2018-09-26 17:12:14 +00:00
kern Add support for the Clang Coverage Sanitizer in the kernel (KCOV). 2019-01-12 11:21:28 +00:00
kgssapi
libkern mcount: tidy up ANSIfication 2018-10-20 22:39:35 +00:00
mips Add note to 32-bit mips smp config files documenting the status 2018-12-19 23:22:14 +00:00
modules dtb: allwinner: Add orangepi-pc to the build 2019-01-11 01:42:47 +00:00
net Remove recursive NET_EPOCH_ENTER() from sysctl_ifmalist(), missed in r342872. 2019-01-11 00:45:22 +00:00
net80211 net80211: fix panic when device is removed during initialization 2019-01-09 12:50:24 +00:00
netgraph Allow ng_nat to be attached to a ethernet interface directly via ng_ether(4) 2018-12-17 16:00:35 +00:00
netinet Fix getsockopt() for IP_OPTIONS/IP_RETOPTS. 2019-01-09 06:36:57 +00:00
netinet6 Remove unnecessary ifdef. With INVARIANTS all KASSERTs are empty statements, 2019-01-10 00:52:06 +00:00
netipsec Remove unused argument to priv_check_cred. 2018-12-11 19:32:16 +00:00
netpfil Relax requirement to packet size of CARP protocol and remove version check. 2019-01-11 01:54:15 +00:00
netsmb Remove unused argument to priv_check_cred. 2018-12-11 19:32:16 +00:00
nfs
nfsclient
nfsserver
nlm
ofed Mechanical cleanup of epoch(9) usage in network stack. 2019-01-09 01:11:19 +00:00
opencrypto Plug memory leak for AES_*_NIST_GMAC algorithms. 2018-12-13 08:59:51 +00:00
powerpc powerpc: Fix regression introduced in r342771 2019-01-07 19:39:31 +00:00
riscv Don't enable interrupts in init_secondary(). 2019-01-04 17:14:50 +00:00
rpc Add kern.rpc.gss.client_max, to make it possible to bump it easily. 2018-12-15 11:32:11 +00:00
security mac: reduce pessimization of sdt probe handling 2018-12-19 22:30:26 +00:00
sparc64 Remove iBCS2, part2: general kernel 2018-12-19 21:57:58 +00:00
sys Add support for the Clang Coverage Sanitizer in the kernel (KCOV). 2019-01-12 11:21:28 +00:00
teken Implement ECMA-48 "REP", some Linuxen have started emitting them recently. 2018-10-21 08:29:36 +00:00
tests
tools make_dtb.sh: Use $CPP instead of assuming that cpp is in $PATH 2018-12-14 23:53:28 +00:00
ufs Move ASSERT_VOP_LOCKED to top of ufs_vinit() as it should be true 2018-12-30 06:03:20 +00:00
vm Fix regression in r331368, that broke dumping of UMA startup pages 2019-01-07 23:17:09 +00:00
x86 Expose threads-per-core and physical core count information 2019-01-04 18:31:17 +00:00
xdr
xen
Makefile