Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

gcc-plugins: remove SANCOV gcc plugin

With the minimum gcc version raised to 8.1, all supported compilers
now understand the -fsanitize-coverage=trace-pc option, and there
is no longer a need for the separate compiler plugin.

Since only gcc-5 was able to use the plugin for several year now,
it was already likely unused.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

-153
-6
lib/Kconfig.debug
··· 2153 2153 build and run with CONFIG_KCOV. This typically requires 2154 2154 disabling instrumentation for some early boot code. 2155 2155 2156 - config CC_HAS_SANCOV_TRACE_PC 2157 - def_bool $(cc-option,-fsanitize-coverage=trace-pc) 2158 - 2159 - 2160 2156 config KCOV 2161 2157 bool "Code coverage for fuzzing" 2162 2158 depends on ARCH_HAS_KCOV 2163 - depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS 2164 2159 depends on !ARCH_WANTS_NO_INSTR || HAVE_NOINSTR_HACK || \ 2165 2160 GCC_VERSION >= 120000 || CC_IS_CLANG 2166 2161 select DEBUG_FS 2167 - select GCC_PLUGIN_SANCOV if !CC_HAS_SANCOV_TRACE_PC 2168 2162 select OBJTOOL if HAVE_NOINSTR_HACK 2169 2163 help 2170 2164 KCOV exposes kernel code coverage information in a form suitable
-2
scripts/Makefile.gcc-plugins
··· 38 38 39 39 # Some plugins are enabled outside of this Makefile, but they still need to 40 40 # be included in GCC_PLUGIN so they can get built. 41 - gcc-plugin-external-$(CONFIG_GCC_PLUGIN_SANCOV) \ 42 - += sancov_plugin.so 43 41 gcc-plugin-external-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) \ 44 42 += randomize_layout_plugin.so 45 43
-1
scripts/Makefile.kcov
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 kcov-flags-$(CONFIG_CC_HAS_SANCOV_TRACE_PC) += -fsanitize-coverage=trace-pc 3 3 kcov-flags-$(CONFIG_KCOV_ENABLE_COMPARISONS) += -fsanitize-coverage=trace-cmp 4 - kcov-flags-$(CONFIG_GCC_PLUGIN_SANCOV) += -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so 5 4 6 5 export CFLAGS_KCOV := $(kcov-flags-y)
-10
scripts/gcc-plugins/Kconfig
··· 19 19 20 20 if GCC_PLUGINS 21 21 22 - config GCC_PLUGIN_SANCOV 23 - bool 24 - # Plugin can be removed once the kernel only supports GCC 6+ 25 - depends on !CC_HAS_SANCOV_TRACE_PC 26 - help 27 - This plugin inserts a __sanitizer_cov_trace_pc() call at the start of 28 - basic blocks. It supports all gcc versions with plugin support (from 29 - gcc-4.5 on). It is based on the commit "Add fuzzing coverage support" 30 - by Dmitry Vyukov <dvyukov@google.com>. 31 - 32 22 config GCC_PLUGIN_LATENT_ENTROPY 33 23 bool "Generate some entropy during boot and runtime" 34 24 help
-134
scripts/gcc-plugins/sancov_plugin.c
··· 1 - /* 2 - * Copyright 2011-2016 by Emese Revfy <re.emese@gmail.com> 3 - * Licensed under the GPL v2, or (at your option) v3 4 - * 5 - * Homepage: 6 - * https://github.com/ephox-gcc-plugins/sancov 7 - * 8 - * This plugin inserts a __sanitizer_cov_trace_pc() call at the start of basic blocks. 9 - * It supports all gcc versions with plugin support (from gcc-4.5 on). 10 - * It is based on the commit "Add fuzzing coverage support" by Dmitry Vyukov <dvyukov@google.com>. 11 - * 12 - * You can read about it more here: 13 - * https://gcc.gnu.org/viewcvs/gcc?limit_changes=0&view=revision&revision=231296 14 - * https://lwn.net/Articles/674854/ 15 - * https://github.com/google/syzkaller 16 - * https://lwn.net/Articles/677764/ 17 - * 18 - * Usage: 19 - * make run 20 - */ 21 - 22 - #include "gcc-common.h" 23 - 24 - __visible int plugin_is_GPL_compatible; 25 - 26 - tree sancov_fndecl; 27 - 28 - static struct plugin_info sancov_plugin_info = { 29 - .version = PLUGIN_VERSION, 30 - .help = "sancov plugin\n", 31 - }; 32 - 33 - static unsigned int sancov_execute(void) 34 - { 35 - basic_block bb; 36 - 37 - /* Remove this line when this plugin and kcov will be in the kernel. 38 - if (!strcmp(DECL_NAME_POINTER(current_function_decl), DECL_NAME_POINTER(sancov_fndecl))) 39 - return 0; 40 - */ 41 - 42 - FOR_EACH_BB_FN(bb, cfun) { 43 - const_gimple stmt; 44 - gcall *gcall; 45 - gimple_stmt_iterator gsi = gsi_after_labels(bb); 46 - 47 - if (gsi_end_p(gsi)) 48 - continue; 49 - 50 - stmt = gsi_stmt(gsi); 51 - gcall = as_a_gcall(gimple_build_call(sancov_fndecl, 0)); 52 - gimple_set_location(gcall, gimple_location(stmt)); 53 - gsi_insert_before(&gsi, gcall, GSI_SAME_STMT); 54 - } 55 - return 0; 56 - } 57 - 58 - #define PASS_NAME sancov 59 - 60 - #define NO_GATE 61 - #define TODO_FLAGS_FINISH TODO_dump_func | TODO_verify_stmts | TODO_update_ssa_no_phi | TODO_verify_flow 62 - 63 - #include "gcc-generate-gimple-pass.h" 64 - 65 - static void sancov_start_unit(void __unused *gcc_data, void __unused *user_data) 66 - { 67 - tree leaf_attr, nothrow_attr; 68 - tree BT_FN_VOID = build_function_type_list(void_type_node, NULL_TREE); 69 - 70 - sancov_fndecl = build_fn_decl("__sanitizer_cov_trace_pc", BT_FN_VOID); 71 - 72 - DECL_ASSEMBLER_NAME(sancov_fndecl); 73 - TREE_PUBLIC(sancov_fndecl) = 1; 74 - DECL_EXTERNAL(sancov_fndecl) = 1; 75 - DECL_ARTIFICIAL(sancov_fndecl) = 1; 76 - DECL_PRESERVE_P(sancov_fndecl) = 1; 77 - DECL_UNINLINABLE(sancov_fndecl) = 1; 78 - TREE_USED(sancov_fndecl) = 1; 79 - 80 - nothrow_attr = tree_cons(get_identifier("nothrow"), NULL, NULL); 81 - decl_attributes(&sancov_fndecl, nothrow_attr, 0); 82 - gcc_assert(TREE_NOTHROW(sancov_fndecl)); 83 - leaf_attr = tree_cons(get_identifier("leaf"), NULL, NULL); 84 - decl_attributes(&sancov_fndecl, leaf_attr, 0); 85 - } 86 - 87 - __visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) 88 - { 89 - int i; 90 - const char * const plugin_name = plugin_info->base_name; 91 - const int argc = plugin_info->argc; 92 - const struct plugin_argument * const argv = plugin_info->argv; 93 - bool enable = true; 94 - 95 - static const struct ggc_root_tab gt_ggc_r_gt_sancov[] = { 96 - { 97 - .base = &sancov_fndecl, 98 - .nelt = 1, 99 - .stride = sizeof(sancov_fndecl), 100 - .cb = &gt_ggc_mx_tree_node, 101 - .pchw = &gt_pch_nx_tree_node 102 - }, 103 - LAST_GGC_ROOT_TAB 104 - }; 105 - 106 - /* BBs can be split afterwards?? */ 107 - PASS_INFO(sancov, "asan", 0, PASS_POS_INSERT_BEFORE); 108 - 109 - if (!plugin_default_version_check(version, &gcc_version)) { 110 - error(G_("incompatible gcc/plugin versions")); 111 - return 1; 112 - } 113 - 114 - for (i = 0; i < argc; ++i) { 115 - if (!strcmp(argv[i].key, "no-sancov")) { 116 - enable = false; 117 - continue; 118 - } 119 - error(G_("unknown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key); 120 - } 121 - 122 - register_callback(plugin_name, PLUGIN_INFO, NULL, &sancov_plugin_info); 123 - 124 - if (!enable) 125 - return 0; 126 - 127 - #if BUILDING_GCC_VERSION < 6000 128 - register_callback(plugin_name, PLUGIN_START_UNIT, &sancov_start_unit, NULL); 129 - register_callback(plugin_name, PLUGIN_REGISTER_GGC_ROOTS, NULL, (void *)&gt_ggc_r_gt_sancov); 130 - register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &sancov_pass_info); 131 - #endif 132 - 133 - return 0; 134 - }