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/[email protected] Signed-off-by: Victor Chibotaru <[email protected]> Signed-off-by: Alexander Potapenko <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Andrey Konovalov <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Alexander Popov <[email protected]> Cc: Andrey Ryabinin <[email protected]> Cc: Kees Cook <[email protected]> Cc: Vegard Nossum <[email protected]> Cc: Quentin Casasnovas <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent ded97d2 commit d677a4d

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

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)