Skip to content

Commit d677a4d

Browse files
Victor Chibotarutorvalds
authored andcommitted
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>
1 parent ded97d2 commit d677a4d

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎Makefile‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,6 @@ CFLAGS_KERNEL =
375375
AFLAGS_KERNEL =
376376
LDFLAGS_vmlinux =
377377
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-
380378

381379
# Use USERINCLUDE when you must reference the UAPI directories only.
382380
USERINCLUDE := \
@@ -659,6 +657,7 @@ ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLA
659657
KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
660658
endif
661659

660+
include scripts/Makefile.kcov
662661
include scripts/Makefile.gcc-plugins
663662

664663
ifdef CONFIG_READABLE_ASM

‎lib/Kconfig.debug‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,16 @@ config KCOV
756756

757757
For more details, see Documentation/dev-tools/kcov.rst.
758758

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+
759769
config KCOV_INSTRUMENT_ALL
760770
bool "Instrument all code by default"
761771
depends on KCOV

‎scripts/Makefile.kcov‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)