diff options
author | Victor Chibotaru <tchibo@google.com> | 2017-11-17 18:30:50 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-11-17 19:10:04 -0500 |
commit | d677a4d6019385488e794cc47bd3d6f9c2aab874 (patch) | |
tree | 5c94f48e2a9acfb553a359c30bcbb2c0f76ba266 | |
parent | ded97d2c2b2c5f1dcced0bc57133f7753b037dfc (diff) |
Makefile: support flag -fsanitizer-coverage=trace-cmp
The flag enables Clang instrumentation of comparison operations
(currently not supported by GCC). This instrumentation is needed by the
new KCOV device to collect comparison operands.
Link: http://lkml.kernel.org/r/20171011095459.70721-2-glider@google.com
Signed-off-by: Victor Chibotaru <tchibo@google.com>
Signed-off-by: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Popov <alex.popov@linux.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Vegard Nossum <vegard.nossum@oracle.com>
Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Cc: <syzkaller@googlegroups.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | lib/Kconfig.debug | 10 | ||||
-rw-r--r-- | scripts/Makefile.kcov | 7 |
3 files changed, 18 insertions, 2 deletions
@@ -375,8 +375,6 @@ CFLAGS_KERNEL = | |||
375 | AFLAGS_KERNEL = | 375 | AFLAGS_KERNEL = |
376 | LDFLAGS_vmlinux = | 376 | LDFLAGS_vmlinux = |
377 | CFLAGS_GCOV := -fprofile-arcs -ftest-coverage -fno-tree-loop-im $(call cc-disable-warning,maybe-uninitialized,) | 377 | CFLAGS_GCOV := -fprofile-arcs -ftest-coverage -fno-tree-loop-im $(call cc-disable-warning,maybe-uninitialized,) |
378 | CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,) | ||
379 | |||
380 | 378 | ||
381 | # Use USERINCLUDE when you must reference the UAPI directories only. | 379 | # Use USERINCLUDE when you must reference the UAPI directories only. |
382 | USERINCLUDE := \ | 380 | USERINCLUDE := \ |
@@ -659,6 +657,7 @@ ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLA | |||
659 | KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO | 657 | KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO |
660 | endif | 658 | endif |
661 | 659 | ||
660 | include scripts/Makefile.kcov | ||
662 | include scripts/Makefile.gcc-plugins | 661 | include scripts/Makefile.gcc-plugins |
663 | 662 | ||
664 | ifdef CONFIG_READABLE_ASM | 663 | ifdef CONFIG_READABLE_ASM |
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index ce813731269f..947d3e2ed5c2 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
@@ -756,6 +756,16 @@ config KCOV | |||
756 | 756 | ||
757 | For more details, see Documentation/dev-tools/kcov.rst. | 757 | For more details, see Documentation/dev-tools/kcov.rst. |
758 | 758 | ||
759 | config KCOV_ENABLE_COMPARISONS | ||
760 | bool "Enable comparison operands collection by KCOV" | ||
761 | depends on KCOV | ||
762 | default n | ||
763 | help | ||
764 | KCOV also exposes operands of every comparison in the instrumented | ||
765 | code along with operand sizes and PCs of the comparison instructions. | ||
766 | These operands can be used by fuzzing engines to improve the quality | ||
767 | of fuzzing coverage. | ||
768 | |||
759 | config KCOV_INSTRUMENT_ALL | 769 | config KCOV_INSTRUMENT_ALL |
760 | bool "Instrument all code by default" | 770 | bool "Instrument all code by default" |
761 | depends on KCOV | 771 | depends on KCOV |
diff --git a/scripts/Makefile.kcov b/scripts/Makefile.kcov new file mode 100644 index 000000000000..5cc72037e423 --- /dev/null +++ b/scripts/Makefile.kcov | |||
@@ -0,0 +1,7 @@ | |||
1 | ifdef CONFIG_KCOV | ||
2 | CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,) | ||
3 | ifeq ($(CONFIG_KCOV_ENABLE_COMPARISONS),y) | ||
4 | CFLAGS_KCOV += $(call cc-option,-fsanitize-coverage=trace-cmp,) | ||
5 | endif | ||
6 | |||
7 | endif | ||