Skip to contentSkip to conversation

gcc-plugins: Remove SANCOV plugin

PATCH In review Kees Cook 2 participants 6 messages Apr 9, 2025

Subsystems (4)
lore
Share & tools
lore

Kees Cook

author maintainer
#0 lore raw

PATCH 1/1 gcc-plugins: Remove SANCOV plugin

There are very few users of this plugin[1], and since it's features are available in GCC 6 and later (and Clang), users can update their compilers if they need support on newer kernels.

---
Cc: Masahiro Yamada <[email protected]>
Cc: Nathan Chancellor <[email protected]>
Cc: Nicolas Schier <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: Andrey Konovalov <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 lib/Kconfig.debug                   |   4 +-
 scripts/Makefile.gcc-plugins        |   2 -
 scripts/Makefile.kcov               |   1 -
 scripts/gcc-plugins/Kconfig         |  10 ---
 scripts/gcc-plugins/sancov_plugin.c | 134 ----------------------------
 5 files changed, 1 insertion(+), 150 deletions(-)
 delete mode 100644 scripts/gcc-plugins/sancov_plugin.c
lib/Kconfig.debug +1 -3
index 1af972a92d06..e7347419ffc5 100644
@@ -2135,15 +2135,13 @@ config ARCH_HAS_KCOV
 config CC_HAS_SANCOV_TRACE_PC
 	def_bool $(cc-option,-fsanitize-coverage=trace-pc)
 
-
 config KCOV
 	bool "Code coverage for fuzzing"
 	depends on ARCH_HAS_KCOV
-	depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS
+	depends on CC_HAS_SANCOV_TRACE_PC
 	depends on !ARCH_WANTS_NO_INSTR || HAVE_NOINSTR_HACK || \
 		   GCC_VERSION >= 120000 || CC_IS_CLANG
 	select DEBUG_FS
-	select GCC_PLUGIN_SANCOV if !CC_HAS_SANCOV_TRACE_PC
 	select OBJTOOL if HAVE_NOINSTR_HACK
 	help
 	  KCOV exposes kernel code coverage information in a form suitable
scripts/Makefile.gcc-plugins +0 -2
index e4deaf5fa571..6da109d563a5 100644
@@ -52,8 +52,6 @@ KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
 
 # Some plugins are enabled outside of this Makefile, but they still need to
 # be included in GCC_PLUGIN so they can get built.
-gcc-plugin-external-$(CONFIG_GCC_PLUGIN_SANCOV)			\
-	+= sancov_plugin.so
 gcc-plugin-external-$(CONFIG_GCC_PLUGIN_RANDSTRUCT)		\
 	+= randomize_layout_plugin.so
 
scripts/Makefile.kcov +0 -1
index 67e8cfe3474b..67de7942b3e7 100644
@@ -1,6 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
 kcov-flags-$(CONFIG_CC_HAS_SANCOV_TRACE_PC)	+= -fsanitize-coverage=trace-pc
 kcov-flags-$(CONFIG_KCOV_ENABLE_COMPARISONS)	+= -fsanitize-coverage=trace-cmp
-kcov-flags-$(CONFIG_GCC_PLUGIN_SANCOV)		+= -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so
 
 export CFLAGS_KCOV := $(kcov-flags-y)
scripts/gcc-plugins/Kconfig +0 -10
index e383cda05367..ba868d1eef3d 100644
@@ -19,16 +19,6 @@ menuconfig GCC_PLUGINS
 
 if GCC_PLUGINS
 
-config GCC_PLUGIN_SANCOV
-	bool
-	# Plugin can be removed once the kernel only supports GCC 6+
-	depends on !CC_HAS_SANCOV_TRACE_PC
-	help
-	  This plugin inserts a __sanitizer_cov_trace_pc() call at the start of
-	  basic blocks. It supports all gcc versions with plugin support (from
-	  gcc-4.5 on). It is based on the commit "Add fuzzing coverage support"
-	  by Dmitry Vyukov <[email protected]>.
-
 config GCC_PLUGIN_LATENT_ENTROPY
 	bool "Generate some entropy during boot and runtime"
 	help
scripts/gcc-plugins/sancov_plugin.c deleted +0 -134

134 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw
Quoted 15 lines · Kees Cook

There are very few users of this plugin[1], and since it's features are available in GCC 6 and later (and Clang), users can update their compilers if they need support on newer kernels.

Link:
https://lore.kernel.org/all/[email protected]/

lib/Kconfig.debug +0 -0
index 1af972a92d06..e7347419ffc5 100644

lib/Kconfig.debug config ARCH_HAS_KCOV · line 2137

Quoted 3 lines
lib/Kconfig.debug +0 -0
@@ -2135,15 +2135,13 @@ config ARCH_HAS_KCOV
 config CC_HAS_SANCOV_TRACE_PC
 	def_bool $(cc-option,-fsanitize-coverage=trace-pc)
 

My version removed CC_HAS_SANCOV_TRACE_PC as well, as I planned to have this on top of my patch to require gcc-8.1 as the minimum version.

lib/Kconfig.debug config ARCH_HAS_KCOV · line 2141

Quoted 5 lines
lib/Kconfig.debug +1 -1
 config KCOV
 	bool "Code coverage for fuzzing"
 	depends on ARCH_HAS_KCOV
-	depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS
+	depends on CC_HAS_SANCOV_TRACE_PC

So this dependency would also disappear. I think either way is fine.

The rest of the patch is again identical to my version.

Arnd

author maintainer
#2 lore raw
Quoted 32 lines · Arnd Bergmann
Quoted 15 lines · Kees Cook

There are very few users of this plugin[1], and since it's features are available in GCC 6 and later (and Clang), users can update their compilers if they need support on newer kernels.

Link:
https://lore.kernel.org/all/[email protected]/

lib/Kconfig.debug +0 -0
index 1af972a92d06..e7347419ffc5 100644

lib/Kconfig.debug config ARCH_HAS_KCOV · line 2137

Quoted 3 lines
lib/Kconfig.debug +0 -0
@@ -2135,15 +2135,13 @@ config ARCH_HAS_KCOV
 config CC_HAS_SANCOV_TRACE_PC
 	def_bool $(cc-option,-fsanitize-coverage=trace-pc)
 

My version removed CC_HAS_SANCOV_TRACE_PC as well, as I planned to have this on top of my patch to require gcc-8.1 as the minimum version.

lib/Kconfig.debug config ARCH_HAS_KCOV · line 2141

Quoted 5 lines
lib/Kconfig.debug +1 -1
 config KCOV
 	bool "Code coverage for fuzzing"
 	depends on ARCH_HAS_KCOV
-	depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS
+	depends on CC_HAS_SANCOV_TRACE_PC

So this dependency would also disappear. I think either way is fine.

Quoted 1 line

The rest of the patch is again identical to my version.

Ah! How about you keep the patch as part of your gcc-8.1 clean up, then? That seems more clear, etc.

-Kees

Signature · 1 line
Kees Cook
#3 lore raw
Quoted 11 lines · Kees Cook
Quoted 10 lines · Arnd Bergmann

lib/Kconfig.debug config ARCH_HAS_KCOV · line 2141

Quoted 5 lines · Kees Cook

config KCOV

lib/Kconfig.debug +1 -1
 	bool "Code coverage for fuzzing"
 	depends on ARCH_HAS_KCOV
-	depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS
+	depends on CC_HAS_SANCOV_TRACE_PC

So this dependency would also disappear. I think either way is fine.

Quoted 4 lines
Quoted 1 line

The rest of the patch is again identical to my version.

Ah! How about you keep the patch as part of your gcc-8.1 clean up, then? That seems more clear, etc.

Sure, I can probably keep that all in a branch of the asm-generic tree, or alternatively send it through the kbuild tree.

Shall I include the patch to remove the structleak plugin as well?

Arnd

author maintainer
#4 lore raw
Quoted 14 lines · Arnd Bergmann
Quoted 13 lines · Kees Cook
Quoted 11 lines · Arnd Bergmann

lib/Kconfig.debug config ARCH_HAS_KCOV · line 2141

Quoted 5 lines · Kees Cook

config KCOV

lib/Kconfig.debug +1 -1
 	bool "Code coverage for fuzzing"
 	depends on ARCH_HAS_KCOV
-	depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS
+	depends on CC_HAS_SANCOV_TRACE_PC

So this dependency would also disappear. I think either way is fine.

The rest of the patch is again identical to my version.

Quoted 7 lines
Quoted 2 lines

Ah! How about you keep the patch as part of your gcc-8.1 clean up, then? That seems more clear, etc.

Sure, I can probably keep that all in a branch of the asm-generic tree, or alternatively send it through the kbuild tree.

Shall I include the patch to remove the structleak plugin as well?

No, structleak needs to stay for now.

Signature · 1 line
Kees Cook
author maintainer
#5 lore raw
In reply to Arnd Bergmann
Quoted 14 lines · Arnd Bergmann
Quoted 13 lines · Kees Cook
Quoted 11 lines · Arnd Bergmann

lib/Kconfig.debug config ARCH_HAS_KCOV · line 2141

Quoted 5 lines · Kees Cook

config KCOV

lib/Kconfig.debug +1 -1
 	bool "Code coverage for fuzzing"
 	depends on ARCH_HAS_KCOV
-	depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS
+	depends on CC_HAS_SANCOV_TRACE_PC

So this dependency would also disappear. I think either way is fine.

The rest of the patch is again identical to my version.

Quoted 7 lines
Quoted 2 lines

Ah! How about you keep the patch as part of your gcc-8.1 clean up, then? That seems more clear, etc.

Sure, I can probably keep that all in a branch of the asm-generic tree, or alternatively send it through the kbuild tree.

Shall I include the patch to remove the structleak plugin as well?

Sorry, I misread, *stackleak* needs to stay. structleak can go. I'll carry that.

Signature · 1 line
Kees Cook