2005-04-17 06:20:36 +08:00
|
|
|
#
|
2008-12-03 17:39:53 +08:00
|
|
|
# Makefile for x86-compatible CPU details, features and quirks
|
2005-04-17 06:20:36 +08:00
|
|
|
#
|
|
|
|
|
2008-12-25 06:30:02 +08:00
|
|
|
# Don't trace early stages of a secondary CPU boot
|
|
|
|
ifdef CONFIG_FUNCTION_TRACER
|
|
|
|
CFLAGS_REMOVE_common.o = -pg
|
2009-11-23 17:19:20 +08:00
|
|
|
CFLAGS_REMOVE_perf_event.o = -pg
|
2008-12-25 06:30:02 +08:00
|
|
|
endif
|
|
|
|
|
kernel: add kcov code coverage
kcov provides code coverage collection for coverage-guided fuzzing
(randomized testing). Coverage-guided fuzzing is a testing technique
that uses coverage feedback to determine new interesting inputs to a
system. A notable user-space example is AFL
(http://lcamtuf.coredump.cx/afl/). However, this technique is not
widely used for kernel testing due to missing compiler and kernel
support.
kcov does not aim to collect as much coverage as possible. It aims to
collect more or less stable coverage that is function of syscall inputs.
To achieve this goal it does not collect coverage in soft/hard
interrupts and instrumentation of some inherently non-deterministic or
non-interesting parts of kernel is disbled (e.g. scheduler, locking).
Currently there is a single coverage collection mode (tracing), but the
API anticipates additional collection modes. Initially I also
implemented a second mode which exposes coverage in a fixed-size hash
table of counters (what Quentin used in his original patch). I've
dropped the second mode for simplicity.
This patch adds the necessary support on kernel side. The complimentary
compiler support was added in gcc revision 231296.
We've used this support to build syzkaller system call fuzzer, which has
found 90 kernel bugs in just 2 months:
https://github.com/google/syzkaller/wiki/Found-Bugs
We've also found 30+ bugs in our internal systems with syzkaller.
Another (yet unexplored) direction where kcov coverage would greatly
help is more traditional "blob mutation". For example, mounting a
random blob as a filesystem, or receiving a random blob over wire.
Why not gcov. Typical fuzzing loop looks as follows: (1) reset
coverage, (2) execute a bit of code, (3) collect coverage, repeat. A
typical coverage can be just a dozen of basic blocks (e.g. an invalid
input). In such context gcov becomes prohibitively expensive as
reset/collect coverage steps depend on total number of basic
blocks/edges in program (in case of kernel it is about 2M). Cost of
kcov depends only on number of executed basic blocks/edges. On top of
that, kernel requires per-thread coverage because there are always
background threads and unrelated processes that also produce coverage.
With inlined gcov instrumentation per-thread coverage is not possible.
kcov exposes kernel PCs and control flow to user-space which is
insecure. But debugfs should not be mapped as user accessible.
Based on a patch by Quentin Casasnovas.
[akpm@linux-foundation.org: make task_struct.kcov_mode have type `enum kcov_mode']
[akpm@linux-foundation.org: unbreak allmodconfig]
[akpm@linux-foundation.org: follow x86 Makefile layout standards]
Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Cc: syzkaller <syzkaller@googlegroups.com>
Cc: Vegard Nossum <vegard.nossum@oracle.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Tavis Ormandy <taviso@google.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Cc: Kostya Serebryany <kcc@google.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Kees Cook <keescook@google.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Sasha Levin <sasha.levin@oracle.com>
Cc: David Drysdale <drysdale@google.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Kirill A. Shutemov <kirill@shutemov.name>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-03-23 05:27:30 +08:00
|
|
|
# If these files are instrumented, boot hangs during the first second.
|
|
|
|
KCOV_INSTRUMENT_common.o := n
|
|
|
|
KCOV_INSTRUMENT_perf_event.o := n
|
|
|
|
|
2009-08-18 03:25:41 +08:00
|
|
|
# Make sure load_percpu_segment has no stackprotector
|
|
|
|
nostackp := $(call cc-option, -fno-stack-protector)
|
|
|
|
CFLAGS_common.o := $(nostackp)
|
|
|
|
|
2010-07-20 09:32:04 +08:00
|
|
|
obj-y := intel_cacheinfo.o scattered.o topology.o
|
2013-10-30 23:09:45 +08:00
|
|
|
obj-y += common.o
|
2011-08-01 05:02:19 +08:00
|
|
|
obj-y += rdrand.o
|
2012-01-26 07:09:05 +08:00
|
|
|
obj-y += match.o
|
2016-10-25 01:38:43 +08:00
|
|
|
obj-y += bugs.o
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-10-30 22:21:53 +08:00
|
|
|
obj-$(CONFIG_PROC_FS) += proc.o
|
2013-10-30 23:09:45 +08:00
|
|
|
obj-$(CONFIG_X86_FEATURE_NAMES) += capflags.o powerflags.o
|
2013-10-30 22:21:53 +08:00
|
|
|
|
2008-09-10 07:40:37 +08:00
|
|
|
obj-$(CONFIG_CPU_SUP_INTEL) += intel.o
|
2008-09-08 08:58:56 +08:00
|
|
|
obj-$(CONFIG_CPU_SUP_AMD) += amd.o
|
2008-08-05 17:45:19 +08:00
|
|
|
obj-$(CONFIG_CPU_SUP_CYRIX_32) += cyrix.o
|
2009-03-14 19:24:02 +08:00
|
|
|
obj-$(CONFIG_CPU_SUP_CENTAUR) += centaur.o
|
2008-08-05 17:45:19 +08:00
|
|
|
obj-$(CONFIG_CPU_SUP_TRANSMETA_32) += transmeta.o
|
|
|
|
obj-$(CONFIG_CPU_SUP_UMC_32) += umc.o
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-10-29 06:04:47 +08:00
|
|
|
obj-$(CONFIG_INTEL_RDT_A) += intel_rdt.o intel_rdt_rdtgroup.o intel_rdt_schemata.o
|
2016-10-22 21:19:53 +08:00
|
|
|
|
2008-12-03 17:39:53 +08:00
|
|
|
obj-$(CONFIG_X86_MCE) += mcheck/
|
|
|
|
obj-$(CONFIG_MTRR) += mtrr/
|
2013-12-02 01:09:58 +08:00
|
|
|
obj-$(CONFIG_MICROCODE) += microcode/
|
2008-12-03 17:39:53 +08:00
|
|
|
|
2016-02-09 00:09:06 +08:00
|
|
|
obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o
|
2008-08-28 08:56:44 +08:00
|
|
|
|
2013-03-05 04:20:21 +08:00
|
|
|
obj-$(CONFIG_HYPERVISOR_GUEST) += vmware.o hypervisor.o mshyperv.o
|
|
|
|
|
2013-10-30 23:09:45 +08:00
|
|
|
ifdef CONFIG_X86_FEATURE_NAMES
|
2008-08-28 08:56:44 +08:00
|
|
|
quiet_cmd_mkcapflags = MKCAP $@
|
2013-04-30 06:05:53 +08:00
|
|
|
cmd_mkcapflags = $(CONFIG_SHELL) $(srctree)/$(src)/mkcapflags.sh $< $@
|
2008-08-28 08:56:44 +08:00
|
|
|
|
2016-01-27 05:12:04 +08:00
|
|
|
cpufeature = $(src)/../../include/asm/cpufeatures.h
|
2008-08-28 08:56:44 +08:00
|
|
|
|
|
|
|
targets += capflags.c
|
2013-04-30 06:05:53 +08:00
|
|
|
$(obj)/capflags.c: $(cpufeature) $(src)/mkcapflags.sh FORCE
|
2008-08-28 08:56:44 +08:00
|
|
|
$(call if_changed,mkcapflags)
|
2013-10-30 23:09:45 +08:00
|
|
|
endif
|
2014-12-23 19:57:43 +08:00
|
|
|
clean-files += capflags.c
|