freebsd-dev/tests/sys/kern
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
..
acct DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
execve DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
pipe Revert r337929 2018-08-16 22:04:00 +00:00
coredump_phnum_helper.c
coredump_phnum_test.sh Make test scripts under tests/... non-executable 2017-08-08 04:59:16 +00:00
kcov.c Add support for the Clang Coverage Sanitizer in the kernel (KCOV). 2019-01-12 11:21:28 +00:00
kern_copyin.c Revert r337929 2018-08-16 22:04:00 +00:00
kern_descrip_test.c
libkern_crc32.c
Makefile Add support for the Clang Coverage Sanitizer in the kernel (KCOV). 2019-01-12 11:21:28 +00:00
Makefile.depend DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
Makefile.inc
pdeathsig_helper.c Rename PROC_PDEATHSIG_SET -> PROC_PDEATHSIG_CTL and PROC_PDEATHSIG_GET 2018-04-20 15:19:27 +00:00
pdeathsig.c Remove redundant pipe from pdeathsig.c test. 2018-04-27 16:34:28 +00:00
ptrace_test.c Don't report stale signal information for non-signal events in ptrace_lwpinfo. 2018-12-10 19:39:24 +00:00
reaper.c Reparent a child of pdfork(2) to its reaper when the procdesc is closed. 2018-10-16 20:06:56 +00:00
sigaltstack.c Maybe make gcc happy 2018-11-30 23:47:57 +00:00
sys_getrandom.c Appease GCC 4.2 2018-03-21 04:44:19 +00:00
unix_passfd_test.c Revert r337929 2018-08-16 22:04:00 +00:00
unix_seqpacket_test.c Send all of data, not just a portion of it 2017-05-28 09:21:28 +00:00
unix_socketpair_test.c Fix LOCAL_PEERCRED with socketpair(2) 2018-08-03 01:37:00 +00:00
waitpid_nohang.c