Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1400423 > unrolled thread
| Started by | Emese Revfy <re.emese@gmail.com> |
|---|---|
| First post | 2016-05-13 01:50 +0200 |
| Last post | 2016-05-20 12:20 +0200 |
| Articles | 15 — 5 participants |
Back to article view | Back to linux.kernel
[PATCH v8 0/4] Introduce GCC plugin infrastructure Emese Revfy <re.emese@gmail.com> - 2016-05-13 01:50 +0200
[PATCH v8 4/4] Add sancov plugin Emese Revfy <re.emese@gmail.com> - 2016-05-13 02:00 +0200
[PATCH v8 3/4] Add Cyclomatic complexity GCC plugin Emese Revfy <re.emese@gmail.com> - 2016-05-13 02:00 +0200
Re: [kernel-hardening] [PATCH v8 3/4] Add Cyclomatic complexity GCC plugin Andrew Donnellan <andrew.donnellan@au1.ibm.com> - 2016-05-18 10:30 +0200
Re: [kernel-hardening] [PATCH v8 3/4] Add Cyclomatic complexity GCC plugin Emese Revfy <re.emese@gmail.com> - 2016-05-18 12:50 +0200
Re: [PATCH v8 2/4] GCC plugin infrastructure Michal Marek <mmarek@suse.com> - 2016-05-17 16:30 +0200
Re: [PATCH v8 2/4] GCC plugin infrastructure Emese Revfy <re.emese@gmail.com> - 2016-05-18 12:50 +0200
Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure Andrew Donnellan <andrew.donnellan@au1.ibm.com> - 2016-05-18 11:00 +0200
Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure Emese Revfy <re.emese@gmail.com> - 2016-05-18 12:30 +0200
Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure Andrew Donnellan <andrew.donnellan@au1.ibm.com> - 2016-05-18 23:20 +0200
Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure Michael Ellerman <mpe@ellerman.id.au> - 2016-05-19 08:30 +0200
Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure Andrew Donnellan <andrew.donnellan@au1.ibm.com> - 2016-05-19 08:50 +0200
Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure "PaX Team" <pageexec@freemail.hu> - 2016-05-19 10:50 +0200
Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure Andrew Donnellan <andrew.donnellan@au1.ibm.com> - 2016-05-20 08:30 +0200
Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure Michael Ellerman <mpe@ellerman.id.au> - 2016-05-20 12:20 +0200
| From | Emese Revfy <re.emese@gmail.com> |
|---|---|
| Date | 2016-05-13 01:50 +0200 |
| Subject | [PATCH v8 0/4] Introduce GCC plugin infrastructure |
| Message-ID | <ry8wG-81C-3@gated-at.bofh.it> |
This patch set introduce the GCC plugin infrastructure with examples for testing
and documentation.
GCC plugins are loadable modules that provide extra features to the compiler.
They are useful for runtime instrumentation and static analysis.
The infrastructure supports all gcc versions from 4.5 to 6.0, building
out-of-tree modules and building in a separate directory. Cross-compilation
is supported too but currently only the x86, arm, arm64 and uml architectures enable plugins.
This infrastructure was ported from grsecurity/PaX. It is a CII project
supported by the Linux Foundation.
Emese Revfy (4):
Shared library support
GCC plugin infrastructure
Add Cyclomatic complexity plugin
Add sancov plugin
Changes from v7:
* Moved the "The GCC plugin infrastructure supports the arm and arm64 architectures too"
and the "Documentations of the GCC plugin infrastructre" patches
into the "GCC plugin infrastructure" patch
(Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>)
* Add gcc-plugin.sh to MAINTAINERS
(Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>)
* Makefile.host: Remove *shobjs from multi-depend
(Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>)
* Have distclean and mrproper targets clean the *.so files
(Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>)
* Simplied gcc-plugin-y to add plugins to HOSTLIBS
(Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>)
* Simplified Makefile.host
(Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>)
* Clean *.c.[012]*.*
(Suggested-by: Michal Marek <mmarek@suse.com>)
* Documentation: gcc plugins have to compilable as C and C++
* Enable GCC plugins for UML
Changes from v6:
* Disable the sancov plugin whenever KCOV_INSTRUMENT is disabled
(Reported-by: Huang Ying <ying.huang@linux.intel.com>)
* Disable KCOV/sancov plugin because this is not a regular kernel code
(Reported-by: Huang Ying <ying.huang@linux.intel.com>)
* Removed unnecessary gcc plugin cflags
(Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>)
* Removed unnecessary gcc plugin aflags
Changes from v5:
* Set important properties on the external fndecl (Add sancov plugin)
* Revert documentation change too (Shared library support)
(Suggested-by: Kees Cook <keescook@chromium.org>)
* The GCC plugin infrastructure now supports the arm and arm64 architectures too
(Signed-off-by: David Brown <david.brown@linaro.org>)
* Simplify the computation of PLUGINCC (GCC plugin infrastructure)
(Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>)
* Simplify the invocation of gcc-plugin.sh (GCC plugin infrastructure)
(Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>)
* Make use of multi-depend (Shared library support)
(Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>)
* Remove unnecessary exports (GCC plugin infrastructure)
(Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>)
* Simplify Makefile by using addprefix (GCC plugin infrastructure)
(Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>)
* Moved the gcc plugins from tools/ to scripts/ (GCC plugin infrastructure)
(Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>)
* Removed plugins from KBUILD_CFLAGS_32 (GCC plugin infrastructure)
* Remove gcc-plugin target everywhere
(Suggested-by and partly Written-by: Masahiro Yamada <yamada.masahiro@socionext.com>)
* There is no leaf gcc attribute in gcc-4.5 (Add sancov plugin)
* Added support to the sancov plugin with kcov (Add sancov plugin)
Changes from v4:
* Moved shared library support from the GCC plugin infrastructure patch into
a different patch
* Update gcc-*.h from PaX
* Fixed gcc-common.h for gcc 6
* Added pass cloning support to the gcc pass generators
* Disable all plugins in vdso because it is userland code
* Add sancov gcc plugin: another use case for gcc plugin support in the kernel
is when there is a feature in the latest gcc version and we would like to use
it with older gcc versions as well (e.g., distros).
Changes from v3:
* Fix some indentation related warnings
(Suggested by checkpatch.pl)
* Add maintainer entries
* Don't run gcc_plugin.sh when the GCC_PLUGINS option is disabled or unsupported
(Reported-by: Fengguang Wu <fengguang.wu@intel.com>)
Changes from v2:
* Fixed incorrectly encoded characters
* Generate the GIMPLE, IPA, SIMPLE_IPA and RTL pass structures
(Suggested-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>)
* Write plugin related warning messages to stderr instead of stdout
(Suggested-by: Kees Cook <keescook@chromium.org>)
* Mention the installation of the gcc plugin headers (Documentation)
Changes from v1:
* Move the gcc-plugins make target into a separate Makefile because there may
be a lot of plugins (Suggested-by: Rasmus Villemoes)
* Simplify the dependencies of the plugin related config option
(Suggested-by: Kees Cook <keescook@chromium.org>)
* Removed the unnecessary example plugin
---
.gitignore | 1 +
Documentation/dontdiff | 1 +
Documentation/gcc-plugins.txt | 87 +++
MAINTAINERS | 9 +
Makefile | 24 +-
arch/Kconfig | 36 +
arch/arm/Kconfig | 1 +
arch/arm64/Kconfig | 1 +
arch/um/Kconfig.common | 1 +
arch/x86/Kconfig | 1 +
arch/x86/entry/vdso/Makefile | 3 +-
arch/x86/purgatory/Makefile | 2 +
lib/Kconfig.debug | 2 +
scripts/Makefile | 2 +-
scripts/Makefile.build | 2 +-
scripts/Makefile.clean | 4 +-
scripts/Makefile.gcc-plugins | 41 +
scripts/Makefile.host | 55 +-
scripts/gcc-plugin.sh | 51 ++
scripts/gcc-plugins/Makefile | 27 +
scripts/gcc-plugins/cyc_complexity_plugin.c | 73 ++
scripts/gcc-plugins/gcc-common.h | 830 +++++++++++++++++++++
scripts/gcc-plugins/gcc-generate-gimple-pass.h | 175 +++++
scripts/gcc-plugins/gcc-generate-ipa-pass.h | 289 +++++++
scripts/gcc-plugins/gcc-generate-rtl-pass.h | 175 +++++
scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h | 175 +++++
scripts/gcc-plugins/sancov_plugin.c | 144 ++++
scripts/link-vmlinux.sh | 2 +-
scripts/package/builddeb | 1 +
29 files changed, 2199 insertions(+), 16 deletions(-)
[toc] | [next] | [standalone]
| From | Emese Revfy <re.emese@gmail.com> |
|---|---|
| Date | 2016-05-13 02:00 +0200 |
| Subject | [PATCH v8 4/4] Add sancov plugin |
| Message-ID | <ry8Gm-868-3@gated-at.bofh.it> |
| In reply to | #1400423 |
The sancov gcc plugin inserts a __sanitizer_cov_trace_pc() call
at the start of basic blocks.
This plugin is a helper plugin for the kcov feature. It supports
all gcc versions with plugin support (from gcc-4.5 on).
It is based on the gcc commit "Add fuzzing coverage support" by Dmitry Vyukov
(https://gcc.gnu.org/viewcvs/gcc?limit_changes=0&view=revision&revision=231296).
Signed-off-by: Emese Revfy <re.emese@gmail.com>
---
Makefile | 12 +--
arch/Kconfig | 9 +++
arch/x86/purgatory/Makefile | 2 +
lib/Kconfig.debug | 2 +
scripts/Makefile.gcc-plugins | 19 +++++
scripts/gcc-plugins/Makefile | 6 ++
scripts/gcc-plugins/sancov_plugin.c | 144 ++++++++++++++++++++++++++++++++++++
7 files changed, 184 insertions(+), 10 deletions(-)
create mode 100644 scripts/gcc-plugins/sancov_plugin.c
diff --git a/Makefile b/Makefile
index 972d845..2eed43f 100644
--- a/Makefile
+++ b/Makefile
@@ -369,7 +369,7 @@ LDFLAGS_MODULE =
CFLAGS_KERNEL =
AFLAGS_KERNEL =
CFLAGS_GCOV = -fprofile-arcs -ftest-coverage -fno-tree-loop-im -Wno-maybe-uninitialized
-CFLAGS_KCOV = -fsanitize-coverage=trace-pc
+CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,)
# Use USERINCLUDE when you must reference the UAPI directories only.
@@ -422,7 +422,7 @@ export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
export KBUILD_ARFLAGS
-export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN
+export PLUGINCC GCC_PLUGINS_CFLAGS SANCOV_PLUGIN GCC_PLUGIN
# When compiling out-of-tree modules, put MODVERDIR in the module
# tree rather than in the kernel tree. The kernel tree might
@@ -693,14 +693,6 @@ endif
endif
KBUILD_CFLAGS += $(stackp-flag)
-ifdef CONFIG_KCOV
- ifeq ($(call cc-option, $(CFLAGS_KCOV)),)
- $(warning Cannot use CONFIG_KCOV: \
- -fsanitize-coverage=trace-pc is not supported by compiler)
- CFLAGS_KCOV =
- endif
-endif
-
ifeq ($(cc-name),clang)
KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,)
diff --git a/arch/Kconfig b/arch/Kconfig
index 74f0d63..5feadad 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -384,6 +384,15 @@ config GCC_PLUGIN_CYC_COMPLEXITY
N = the number of nodes
P = the number of connected components (exit nodes).
+config GCC_PLUGIN_SANCOV
+ bool
+ depends on GCC_PLUGINS
+ 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 <dvyukov@google.com>.
+
config HAVE_CC_STACKPROTECTOR
bool
help
diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile
index 12734a9..ac58c16 100644
--- a/arch/x86/purgatory/Makefile
+++ b/arch/x86/purgatory/Makefile
@@ -8,6 +8,8 @@ PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y))
LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined -nostdlib -z nodefaultlib
targets += purgatory.ro
+KCOV_INSTRUMENT := n
+
# Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That
# in turn leaves some undefined symbols like __fentry__ in purgatory and not
# sure how to relocate those. Like kexec-tools, use custom flags.
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 5d57177..a377fd7 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -712,6 +712,8 @@ config KCOV
bool "Code coverage for fuzzing"
depends on ARCH_HAS_KCOV
select DEBUG_FS
+ select GCC_PLUGINS
+ select GCC_PLUGIN_SANCOV
help
KCOV exposes kernel code coverage information in a form suitable
for coverage-guided fuzzing (randomized testing).
diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins
index bf0eaf1..372c73a 100644
--- a/scripts/Makefile.gcc-plugins
+++ b/scripts/Makefile.gcc-plugins
@@ -2,7 +2,23 @@ ifdef CONFIG_GCC_PLUGINS
__PLUGINCC := $(call cc-ifversion, -ge, 0408, $(HOSTCXX), $(HOSTCC))
PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)")
+ SANCOV_PLUGIN := -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so
+
gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) += cyc_complexity_plugin.so
+
+ ifdef CONFIG_GCC_PLUGIN_SANCOV
+ ifeq ($(CFLAGS_KCOV),)
+ # It is needed because of the gcc-plugin.sh and gcc version checks.
+ gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV) += sancov_plugin.so
+
+ ifneq ($(PLUGINCC),)
+ CFLAGS_KCOV := $(SANCOV_PLUGIN)
+ else
+ $(error Cannot use CONFIG_KCOV: -fsanitize-coverage=trace-pc is not supported by compiler)
+ endif
+ endif
+ endif
+
GCC_PLUGINS_CFLAGS := $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y))
ifeq ($(PLUGINCC),)
@@ -14,6 +30,9 @@ ifdef CONFIG_GCC_PLUGINS
$(error error, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least)
endif
endif
+ else
+ # SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication.
+ GCC_PLUGINS_CFLAGS := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGINS_CFLAGS))
endif
KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
diff --git a/scripts/gcc-plugins/Makefile b/scripts/gcc-plugins/Makefile
index c60ba4b..88c8ec4 100644
--- a/scripts/gcc-plugins/Makefile
+++ b/scripts/gcc-plugins/Makefile
@@ -14,8 +14,14 @@ endif
export GCCPLUGINS_DIR HOSTLIBS
+ifneq ($(CFLAGS_KCOV), $(SANCOV_PLUGIN))
+ GCC_PLUGIN := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGIN))
+endif
+
$(HOSTLIBS)-y := $(GCC_PLUGIN)
always := $($(HOSTLIBS)-y)
cyc_complexity_plugin-objs := cyc_complexity_plugin.o
+sancov_plugin-objs := sancov_plugin.o
+
clean-files += *.so
diff --git a/scripts/gcc-plugins/sancov_plugin.c b/scripts/gcc-plugins/sancov_plugin.c
new file mode 100644
index 0000000..aedd611
--- /dev/null
+++ b/scripts/gcc-plugins/sancov_plugin.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2011-2016 by Emese Revfy <re.emese@gmail.com>
+ * Licensed under the GPL v2, or (at your option) v3
+ *
+ * Homepage:
+ * https://github.com/ephox-gcc-plugins/sancov
+ *
+ * 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 <dvyukov@google.com>.
+ *
+ * You can read about it more here:
+ * https://gcc.gnu.org/viewcvs/gcc?limit_changes=0&view=revision&revision=231296
+ * http://lwn.net/Articles/674854/
+ * https://github.com/google/syzkaller
+ * https://lwn.net/Articles/677764/
+ *
+ * Usage:
+ * make run
+ */
+
+#include "gcc-common.h"
+
+int plugin_is_GPL_compatible;
+
+tree sancov_fndecl;
+
+static struct plugin_info sancov_plugin_info = {
+ .version = "20160402",
+ .help = "sancov plugin\n",
+};
+
+static unsigned int sancov_execute(void)
+{
+ basic_block bb;
+
+ /* Remove this line when this plugin and kcov will be in the kernel.
+ if (!strcmp(DECL_NAME_POINTER(current_function_decl), DECL_NAME_POINTER(sancov_fndecl)))
+ return 0;
+ */
+
+ FOR_EACH_BB_FN(bb, cfun) {
+ const_gimple stmt;
+ gcall *gcall;
+ gimple_stmt_iterator gsi = gsi_after_labels(bb);
+
+ if (gsi_end_p(gsi))
+ continue;
+
+ stmt = gsi_stmt(gsi);
+ gcall = as_a_gcall(gimple_build_call(sancov_fndecl, 0));
+ gimple_set_location(gcall, gimple_location(stmt));
+ gsi_insert_before(&gsi, gcall, GSI_SAME_STMT);
+ }
+ return 0;
+}
+
+#define PASS_NAME sancov
+
+#define NO_GATE
+#define TODO_FLAGS_FINISH TODO_dump_func | TODO_verify_stmts | TODO_update_ssa_no_phi | TODO_verify_flow
+
+#include "gcc-generate-gimple-pass.h"
+
+static void sancov_start_unit(void __unused *gcc_data, void __unused *user_data)
+{
+ tree leaf_attr, nothrow_attr;
+ tree BT_FN_VOID = build_function_type_list(void_type_node, NULL_TREE);
+
+ sancov_fndecl = build_fn_decl("__sanitizer_cov_trace_pc", BT_FN_VOID);
+
+ DECL_ASSEMBLER_NAME(sancov_fndecl);
+ TREE_PUBLIC(sancov_fndecl) = 1;
+ DECL_EXTERNAL(sancov_fndecl) = 1;
+ DECL_ARTIFICIAL(sancov_fndecl) = 1;
+ DECL_PRESERVE_P(sancov_fndecl) = 1;
+ DECL_UNINLINABLE(sancov_fndecl) = 1;
+ TREE_USED(sancov_fndecl) = 1;
+
+ nothrow_attr = tree_cons(get_identifier("nothrow"), NULL, NULL);
+ decl_attributes(&sancov_fndecl, nothrow_attr, 0);
+ gcc_assert(TREE_NOTHROW(sancov_fndecl));
+#if BUILDING_GCC_VERSION > 4005
+ leaf_attr = tree_cons(get_identifier("leaf"), NULL, NULL);
+ decl_attributes(&sancov_fndecl, leaf_attr, 0);
+#endif
+}
+
+int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
+{
+ int i;
+ struct register_pass_info sancov_plugin_pass_info;
+ const char * const plugin_name = plugin_info->base_name;
+ const int argc = plugin_info->argc;
+ const struct plugin_argument * const argv = plugin_info->argv;
+ bool enable = true;
+
+ static const struct ggc_root_tab gt_ggc_r_gt_sancov[] = {
+ {
+ .base = &sancov_fndecl,
+ .nelt = 1,
+ .stride = sizeof(sancov_fndecl),
+ .cb = >_ggc_mx_tree_node,
+ .pchw = >_pch_nx_tree_node
+ },
+ LAST_GGC_ROOT_TAB
+ };
+
+ /* BBs can be split afterwards?? */
+ sancov_plugin_pass_info.pass = make_sancov_pass();
+#if BUILDING_GCC_VERSION >= 4009
+ sancov_plugin_pass_info.reference_pass_name = "asan";
+#else
+ sancov_plugin_pass_info.reference_pass_name = "nrv";
+#endif
+ sancov_plugin_pass_info.ref_pass_instance_number = 0;
+ sancov_plugin_pass_info.pos_op = PASS_POS_INSERT_BEFORE;
+
+ if (!plugin_default_version_check(version, &gcc_version)) {
+ error(G_("incompatible gcc/plugin versions"));
+ return 1;
+ }
+
+ for (i = 0; i < argc; ++i) {
+ if (!strcmp(argv[i].key, "no-sancov")) {
+ enable = false;
+ continue;
+ }
+ error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
+ }
+
+ register_callback(plugin_name, PLUGIN_INFO, NULL, &sancov_plugin_info);
+
+ if (!enable)
+ return 0;
+
+#if BUILDING_GCC_VERSION < 6000
+ register_callback(plugin_name, PLUGIN_START_UNIT, &sancov_start_unit, NULL);
+ register_callback(plugin_name, PLUGIN_REGISTER_GGC_ROOTS, NULL, (void *)>_ggc_r_gt_sancov);
+ register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &sancov_plugin_pass_info);
+#endif
+
+ return 0;
+}
--
2.8.1
[toc] | [prev] | [next] | [standalone]
| From | Emese Revfy <re.emese@gmail.com> |
|---|---|
| Date | 2016-05-13 02:00 +0200 |
| Subject | [PATCH v8 3/4] Add Cyclomatic complexity GCC plugin |
| Message-ID | <ry8Gm-868-7@gated-at.bofh.it> |
| In reply to | #1400423 |
Add a very simple plugin to demonstrate the GCC plugin infrastructure. This GCC
plugin computes the cyclomatic complexity of each function.
The complexity M of a function's control flow graph is defined as:
M = E - N + 2P
where
E = the number of edges
N = the number of nodes
P = the number of connected components (exit nodes).
Signed-off-by: Emese Revfy <re.emese@gmail.com>
---
arch/Kconfig | 12 +++++
scripts/Makefile.gcc-plugins | 1 +
scripts/gcc-plugins/Makefile | 1 +
scripts/gcc-plugins/cyc_complexity_plugin.c | 73 +++++++++++++++++++++++++++++
4 files changed, 87 insertions(+)
create mode 100644 scripts/gcc-plugins/cyc_complexity_plugin.c
diff --git a/arch/Kconfig b/arch/Kconfig
index 2821cfe..74f0d63 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -372,6 +372,18 @@ menuconfig GCC_PLUGINS
See Documentation/gcc-plugins.txt for details.
+config GCC_PLUGIN_CYC_COMPLEXITY
+ bool "Compute the cyclomatic complexity of a function"
+ depends on GCC_PLUGINS
+ help
+ The complexity M of a function's control flow graph is defined as:
+ M = E - N + 2P
+ where
+
+ E = the number of edges
+ N = the number of nodes
+ P = the number of connected components (exit nodes).
+
config HAVE_CC_STACKPROTECTOR
bool
help
diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins
index 78d81fc..bf0eaf1 100644
--- a/scripts/Makefile.gcc-plugins
+++ b/scripts/Makefile.gcc-plugins
@@ -2,6 +2,7 @@ ifdef CONFIG_GCC_PLUGINS
__PLUGINCC := $(call cc-ifversion, -ge, 0408, $(HOSTCXX), $(HOSTCC))
PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)")
+ gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) += cyc_complexity_plugin.so
GCC_PLUGINS_CFLAGS := $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y))
ifeq ($(PLUGINCC),)
diff --git a/scripts/gcc-plugins/Makefile b/scripts/gcc-plugins/Makefile
index a4c9341..c60ba4b 100644
--- a/scripts/gcc-plugins/Makefile
+++ b/scripts/gcc-plugins/Makefile
@@ -17,4 +17,5 @@ export GCCPLUGINS_DIR HOSTLIBS
$(HOSTLIBS)-y := $(GCC_PLUGIN)
always := $($(HOSTLIBS)-y)
+cyc_complexity_plugin-objs := cyc_complexity_plugin.o
clean-files += *.so
diff --git a/scripts/gcc-plugins/cyc_complexity_plugin.c b/scripts/gcc-plugins/cyc_complexity_plugin.c
new file mode 100644
index 0000000..34df974
--- /dev/null
+++ b/scripts/gcc-plugins/cyc_complexity_plugin.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2011-2016 by Emese Revfy <re.emese@gmail.com>
+ * Licensed under the GPL v2, or (at your option) v3
+ *
+ * Homepage:
+ * https://github.com/ephox-gcc-plugins/cyclomatic_complexity
+ *
+ * http://en.wikipedia.org/wiki/Cyclomatic_complexity
+ * The complexity M is then defined as:
+ * M = E - N + 2P
+ * where
+ *
+ * E = the number of edges of the graph
+ * N = the number of nodes of the graph
+ * P = the number of connected components (exit nodes).
+ *
+ * Usage (4.5 - 5):
+ * $ make clean; make run
+ */
+
+#include "gcc-common.h"
+
+int plugin_is_GPL_compatible;
+
+static struct plugin_info cyc_complexity_plugin_info = {
+ .version = "20160225",
+ .help = "Cyclomatic Complexity\n",
+};
+
+static unsigned int cyc_complexity_execute(void)
+{
+ int complexity;
+ expanded_location xloc;
+
+ /* M = E - N + 2P */
+ complexity = n_edges_for_fn(cfun) - n_basic_blocks_for_fn(cfun) + 2;
+
+ xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
+ fprintf(stderr, "Cyclomatic Complexity %d %s:%s\n", complexity,
+ xloc.file, DECL_NAME_POINTER(current_function_decl));
+
+ return 0;
+}
+
+#define PASS_NAME cyc_complexity
+
+#define NO_GATE
+#define TODO_FLAGS_FINISH TODO_dump_func
+
+#include "gcc-generate-gimple-pass.h"
+
+int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
+{
+ const char * const plugin_name = plugin_info->base_name;
+ struct register_pass_info cyc_complexity_pass_info;
+
+ cyc_complexity_pass_info.pass = make_cyc_complexity_pass();
+ cyc_complexity_pass_info.reference_pass_name = "ssa";
+ cyc_complexity_pass_info.ref_pass_instance_number = 1;
+ cyc_complexity_pass_info.pos_op = PASS_POS_INSERT_AFTER;
+
+ if (!plugin_default_version_check(version, &gcc_version)) {
+ error(G_("incompatible gcc/plugin versions"));
+ return 1;
+ }
+
+ register_callback(plugin_name, PLUGIN_INFO, NULL,
+ &cyc_complexity_plugin_info);
+ register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL,
+ &cyc_complexity_pass_info);
+
+ return 0;
+}
--
2.8.1
[toc] | [prev] | [next] | [standalone]
| From | Andrew Donnellan <andrew.donnellan@au1.ibm.com> |
|---|---|
| Date | 2016-05-18 10:30 +0200 |
| Subject | Re: [kernel-hardening] [PATCH v8 3/4] Add Cyclomatic complexity GCC plugin |
| Message-ID | <rA51E-7Zz-19@gated-at.bofh.it> |
| In reply to | #1400427 |
On 13/05/16 09:58, Emese Revfy wrote: > Add a very simple plugin to demonstrate the GCC plugin infrastructure. This GCC > plugin computes the cyclomatic complexity of each function. ... > +config GCC_PLUGIN_CYC_COMPLEXITY > + bool "Compute the cyclomatic complexity of a function" > + depends on GCC_PLUGINS > + help > + The complexity M of a function's control flow graph is defined as: > + M = E - N + 2P > + where > + > + E = the number of edges > + N = the number of nodes > + P = the number of connected components (exit nodes). > + If this plugin is intended primarily as a demonstration it's probably worth mentioning this in the Kconfig description. -- Andrew Donnellan OzLabs, ADL Canberra andrew.donnellan@au1.ibm.com IBM Australia Limited
[toc] | [prev] | [next] | [standalone]
| From | Emese Revfy <re.emese@gmail.com> |
|---|---|
| Date | 2016-05-18 12:50 +0200 |
| Subject | Re: [kernel-hardening] [PATCH v8 3/4] Add Cyclomatic complexity GCC plugin |
| Message-ID | <rA7d7-WC-1@gated-at.bofh.it> |
| In reply to | #1402790 |
On Wed, 18 May 2016 18:25:00 +1000 Andrew Donnellan <andrew.donnellan@au1.ibm.com> wrote: > On 13/05/16 09:58, Emese Revfy wrote: > > Add a very simple plugin to demonstrate the GCC plugin infrastructure. This GCC > > plugin computes the cyclomatic complexity of each function. > > ... > > > +config GCC_PLUGIN_CYC_COMPLEXITY > > + bool "Compute the cyclomatic complexity of a function" > > + depends on GCC_PLUGINS > > + help > > + The complexity M of a function's control flow graph is defined as: > > + M = E - N + 2P > > + where > > + > > + E = the number of edges > > + N = the number of nodes > > + P = the number of connected components (exit nodes). > > + > > If this plugin is intended primarily as a demonstration it's probably > worth mentioning this in the Kconfig description. Hi, Before sancov this plugin demonstrated the gcc plugin infrastructure but otherwise this is a fully working plugin not a test plugin. Also it doesn't demonstrate all aspects of writing gcc plugins. -- Emese
[toc] | [prev] | [next] | [standalone]
| From | Michal Marek <mmarek@suse.com> |
|---|---|
| Date | 2016-05-17 16:30 +0200 |
| Subject | Re: [PATCH v8 2/4] GCC plugin infrastructure |
| Message-ID | <rzOat-5Hf-1@gated-at.bofh.it> |
| In reply to | #1400423 |
Dne 13.5.2016 v 01:57 Emese Revfy napsal(a): > --- /dev/null > +++ b/scripts/Makefile.gcc-plugins > @@ -0,0 +1,21 @@ > +ifdef CONFIG_GCC_PLUGINS > + __PLUGINCC := $(call cc-ifversion, -ge, 0408, $(HOSTCXX), $(HOSTCC)) > + PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)") > + > + GCC_PLUGINS_CFLAGS := $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) > + > + ifeq ($(PLUGINCC),) > + ifneq ($(GCC_PLUGINS_CFLAGS),) > + ifeq ($(call cc-ifversion, -ge, 0405, y), y) > + PLUGINCC := $(shell $(CO, NFIG_SHELL) -x $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)") > + $(error error, your gcc installation does not support plugins, perhaps the necessary headers are missing?) > + else > + $(error error, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least) > + endif > + endif > + endif > + > + KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS) > + GCC_PLUGIN := $(gcc-plugin-y) > + > +endif Hi Emese, sorry for the late feedback. A problem I ran into now is that if you have a compiler that is either too old or built with plugin support disabled, scripts/Makefile.gcc-plugins errors out immediately. This is going to be an issue with allmodconfig/allyesconfig test builds. A solution would either be to make the respective options depend on !COMPILE_TEST, or turn the errors into warnings and do nothing if the compiler lacks plugin support. We are handling CONFIG_CC_STACKPROTECTOR on x86 this way already. Michal
[toc] | [prev] | [next] | [standalone]
| From | Emese Revfy <re.emese@gmail.com> |
|---|---|
| Date | 2016-05-18 12:50 +0200 |
| Subject | Re: [PATCH v8 2/4] GCC plugin infrastructure |
| Message-ID | <rA7d7-WC-17@gated-at.bofh.it> |
| In reply to | #1402365 |
On Tue, 17 May 2016 16:28:05 +0200 Michal Marek <mmarek@suse.com> wrote: > Dne 13.5.2016 v 01:57 Emese Revfy napsal(a): > > --- /dev/null > > +++ b/scripts/Makefile.gcc-plugins > > @@ -0,0 +1,21 @@ > > +ifdef CONFIG_GCC_PLUGINS > > + __PLUGINCC := $(call cc-ifversion, -ge, 0408, $(HOSTCXX), $(HOSTCC)) > > + PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)") > > + > > + GCC_PLUGINS_CFLAGS := $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) > > + > > + ifeq ($(PLUGINCC),) > > + ifneq ($(GCC_PLUGINS_CFLAGS),) > > + ifeq ($(call cc-ifversion, -ge, 0405, y), y) > > + PLUGINCC := $(shell $(CO, NFIG_SHELL) -x $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)") > > + $(error error, your gcc installation does not support plugins, perhaps the necessary headers are missing?) > > + else > > + $(error error, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least) > > + endif > > + endif > > + endif > > + > > + KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS) > > + GCC_PLUGIN := $(gcc-plugin-y) > > + > > +endif > > Hi Emese, > > sorry for the late feedback. A problem I ran into now is that if you > have a compiler that is either too old or built with plugin support > disabled, scripts/Makefile.gcc-plugins errors out immediately. This is > going to be an issue with allmodconfig/allyesconfig test builds. A > solution would either be to make the respective options depend on > !COMPILE_TEST, or turn the errors into warnings and do nothing if the > compiler lacks plugin support. We are handling CONFIG_CC_STACKPROTECTOR > on x86 this way already. Hi, I'll change the errors to warnings in the next patch set. -- Emese
[toc] | [prev] | [next] | [standalone]
| From | Andrew Donnellan <andrew.donnellan@au1.ibm.com> |
|---|---|
| Date | 2016-05-18 11:00 +0200 |
| Subject | Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure |
| Message-ID | <rA5uF-8b8-19@gated-at.bofh.it> |
| In reply to | #1400423 |
On 13/05/16 09:57, Emese Revfy wrote:
> This patch allows to build the whole kernel with GCC plugins. It was ported from
> grsecurity/PaX. The infrastructure supports building out-of-tree modules and
> building in a separate directory. Cross-compilation is supported too.
> Currently the x86, arm, arm64 and uml architectures enable plugins.
>
> The directory of the gcc plugins is scripts/gcc-plugins. You can use a file or a directory
> there. The plugins compile with these options:
> * -fno-rtti: gcc is compiled with this option so the plugins must use it too
> * -fno-exceptions: this is inherited from gcc too
> * -fasynchronous-unwind-tables: this is inherited from gcc too
> * -ggdb: it is useful for debugging a plugin (better backtrace on internal
> errors)
> * -Wno-narrowing: to suppress warnings from gcc headers (ipa-utils.h)
> * -Wno-unused-variable: to suppress warnings from gcc headers (gcc_version
> variable, plugin-version.h)
>
> The infrastructure introduces a new Makefile target called gcc-plugins. It
> supports all gcc versions from 4.5 to 6.0. The scripts/gcc-plugin.sh script
> chooses the proper host compiler (gcc-4.7 can be built by either gcc or g++).
> This script also checks the availability of the included headers in
> scripts/gcc-plugins/gcc-common.h.
>
> The gcc-common.h header contains frequently included headers for GCC plugins
> and it has a compatibility layer for the supported gcc versions.
>
> The gcc-generate-*-pass.h headers automatically generate the registration
> structures for GIMPLE, SIMPLE_IPA, IPA and RTL passes.
>
> Note that 'make clean' keeps the *.so files (only the distclean or mrproper
> targets clean all) because they are needed for out-of-tree modules.
>
> The arm and arm64 architectures were tested by David Brown <david.brown@linaro.org>.
>
> Signed-off-by: Emese Revfy <re.emese@gmail.com>
I've done some basic sanity testing on powerpc with the cyclomatic
complexity plugin (with LE native + cross-compilers) and it seems to
work with the patch below.
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index a18a0dc..0cfed5b 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -97,6 +97,7 @@ config PPC
select HAVE_DYNAMIC_FTRACE_WITH_REGS if MPROFILE_KERNEL
select HAVE_FUNCTION_TRACER
select HAVE_FUNCTION_GRAPH_TRACER
+ select HAVE_GCC_PLUGINS
select SYSCTL_EXCEPTION_TRACE
select ARCH_WANT_OPTIONAL_GPIOLIB
select VIRT_TO_BUS if !PPC64
--
Andrew Donnellan OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com IBM Australia Limited
[toc] | [prev] | [next] | [standalone]
| From | Emese Revfy <re.emese@gmail.com> |
|---|---|
| Date | 2016-05-18 12:30 +0200 |
| Subject | Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure |
| Message-ID | <rA6TN-Pd-53@gated-at.bofh.it> |
| In reply to | #1402815 |
> I've done some basic sanity testing on powerpc with the cyclomatic > complexity plugin (with LE native + cross-compilers) and it seems to > work with the patch below. > > Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> > > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig > index a18a0dc..0cfed5b 100644 > --- a/arch/powerpc/Kconfig > +++ b/arch/powerpc/Kconfig > @@ -97,6 +97,7 @@ config PPC > select HAVE_DYNAMIC_FTRACE_WITH_REGS if MPROFILE_KERNEL > select HAVE_FUNCTION_TRACER > select HAVE_FUNCTION_GRAPH_TRACER > + select HAVE_GCC_PLUGINS > select SYSCTL_EXCEPTION_TRACE > select ARCH_WANT_OPTIONAL_GPIOLIB > select VIRT_TO_BUS if !PPC64 Hi, Did you test the plugins with all gcc versions (4.5-6)? -- Emese
[toc] | [prev] | [next] | [standalone]
| From | Andrew Donnellan <andrew.donnellan@au1.ibm.com> |
|---|---|
| Date | 2016-05-18 23:20 +0200 |
| Subject | Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure |
| Message-ID | <rAh2N-7md-17@gated-at.bofh.it> |
| In reply to | #1402871 |
On 18/05/16 20:33, Emese Revfy wrote: > Did you test the plugins with all gcc versions (4.5-6)? No, I tested with 4.8 and 5.2 as those are the toolchains I have on hand - I'll try to test with the rest of 4.5 - 6.1. -- Andrew Donnellan OzLabs, ADL Canberra andrew.donnellan@au1.ibm.com IBM Australia Limited
[toc] | [prev] | [next] | [standalone]
| From | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| Date | 2016-05-19 08:30 +0200 |
| Subject | Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure |
| Message-ID | <rApD3-4yo-1@gated-at.bofh.it> |
| In reply to | #1402871 |
On Wed, 2016-05-18 at 12:33 +0200, Emese Revfy wrote: > > I've done some basic sanity testing on powerpc with the cyclomatic > > complexity plugin (with LE native + cross-compilers) and it seems to > > work with the patch below. > > > > Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> > > > > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig > > index a18a0dc..0cfed5b 100644 > > --- a/arch/powerpc/Kconfig > > +++ b/arch/powerpc/Kconfig > > @@ -97,6 +97,7 @@ config PPC > > select HAVE_DYNAMIC_FTRACE_WITH_REGS if MPROFILE_KERNEL > > select HAVE_FUNCTION_TRACER > > select HAVE_FUNCTION_GRAPH_TRACER > > + select HAVE_GCC_PLUGINS > > select SYSCTL_EXCEPTION_TRACE > > select ARCH_WANT_OPTIONAL_GPIOLIB > > select VIRT_TO_BUS if !PPC64 > > Hi, > > Did you test the plugins with all gcc versions (4.5-6)? What's the concern about gcc versions? Just not breaking the build on old compilers? I'm pretty sure powerpc big endian still builds with gcc 4.4. However if Andrew's only tested on little endian, then that select should be guarded with an "if CPU_LITTLE_ENDIAN". And to build LE you need gcc >= 4.9. cheers
[toc] | [prev] | [next] | [standalone]
| From | Andrew Donnellan <andrew.donnellan@au1.ibm.com> |
|---|---|
| Date | 2016-05-19 08:50 +0200 |
| Subject | Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure |
| Message-ID | <rApWp-4EM-5@gated-at.bofh.it> |
| In reply to | #1403450 |
On 19/05/16 16:22, Michael Ellerman wrote: >> Did you test the plugins with all gcc versions (4.5-6)? > > What's the concern about gcc versions? Just not breaking the build on old > compilers? > I'm pretty sure powerpc big endian still builds with gcc 4.4. gcc's plugin support only landed in 4.5, so we don't care about <=4.4. > However if Andrew's only tested on little endian, then that select should be > guarded with an "if CPU_LITTLE_ENDIAN". And to build LE you need gcc >= 4.9. I'm going to give BE a test too just to be sure. -- Andrew Donnellan OzLabs, ADL Canberra andrew.donnellan@au1.ibm.com IBM Australia Limited
[toc] | [prev] | [next] | [standalone]
| From | "PaX Team" <pageexec@freemail.hu> |
|---|---|
| Date | 2016-05-19 10:50 +0200 |
| Subject | Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure |
| Message-ID | <rArOx-5P2-5@gated-at.bofh.it> |
| In reply to | #1403450 |
On 19 May 2016 at 16:22, Michael Ellerman wrote: > On Wed, 2016-05-18 at 12:33 +0200, Emese Revfy wrote: > > Did you test the plugins with all gcc versions (4.5-6)? > > What's the concern about gcc versions? Just not breaking the build on old > compilers? the earlier plugin capable gcc versions used to install gcc headers in a somewhat ad-hoc manner resulting in compile time breakage for plugins and since some of those potentially missing headers are target specific, each target arch should be verified before enabling plugin support on them. things have much improved with gcc 5 (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61176) though there's still an occasional missing header but with wider use of plugins they will hopefully be discovered earlier now. perhaps linux-arch should be cc'ed on the plugin infrastructure so that arch maintainers are aware of this? > I'm pretty sure powerpc big endian still builds with gcc 4.4. > > However if Andrew's only tested on little endian, then that select should be > guarded with an "if CPU_LITTLE_ENDIAN". And to build LE you need gcc >= 4.9. i guess that's part of the target tuple so in general arch maintainers should test the target tuples used on their arch with all the supported gcc versions (speaking of CC, not HOSTCC/HOSTCXX). cheers, PaX Team
[toc] | [prev] | [next] | [standalone]
| From | Andrew Donnellan <andrew.donnellan@au1.ibm.com> |
|---|---|
| Date | 2016-05-20 08:30 +0200 |
| Subject | Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure |
| Message-ID | <rAM6C-1Zw-21@gated-at.bofh.it> |
| In reply to | #1403503 |
On 19/05/16 18:24, PaX Team wrote: > the earlier plugin capable gcc versions used to install gcc headers in a somewhat > ad-hoc manner resulting in compile time breakage for plugins and since some of > those potentially missing headers are target specific, each target arch should > be verified before enabling plugin support on them. things have much improved with > gcc 5 (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61176) though there's still > an occasional missing header but with wider use of plugins they will hopefully be > discovered earlier now. perhaps linux-arch should be cc'ed on the plugin infrastructure > so that arch maintainers are aware of this? Upon further testing it does seem we've got header issues as well as hitting a segfault on 4.7.0. Looking into it further... -- Andrew Donnellan OzLabs, ADL Canberra andrew.donnellan@au1.ibm.com IBM Australia Limited
[toc] | [prev] | [next] | [standalone]
| From | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| Date | 2016-05-20 12:20 +0200 |
| Subject | Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure |
| Message-ID | <rAPHc-4eE-15@gated-at.bofh.it> |
| In reply to | #1403503 |
On Thu, 2016-05-19 at 10:24 +0200, PaX Team wrote: > On 19 May 2016 at 16:22, Michael Ellerman wrote: > > On Wed, 2016-05-18 at 12:33 +0200, Emese Revfy wrote: > > > Did you test the plugins with all gcc versions (4.5-6)? > > > > What's the concern about gcc versions? Just not breaking the build on old > > compilers? > > the earlier plugin capable gcc versions used to install gcc headers in a somewhat > ad-hoc manner resulting in compile time breakage for plugins and since some of > those potentially missing headers are target specific, each target arch should > be verified before enabling plugin support on them. things have much improved with > gcc 5 (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61176) though there's still > an occasional missing header but with wider use of plugins they will hopefully be > discovered earlier now. OK thanks. > perhaps linux-arch should be cc'ed on the plugin infrastructure > so that arch maintainers are aware of this? linux-arch is still fairly high traffic, so it's no guarantee arch maintainers will see it, but it's probably worth a try. > > I'm pretty sure powerpc big endian still builds with gcc 4.4. > > > > However if Andrew's only tested on little endian, then that select should be > > guarded with an "if CPU_LITTLE_ENDIAN". And to build LE you need gcc >= 4.9. > > i guess that's part of the target tuple so in general arch maintainers should test > the target tuples used on their arch with all the supported gcc versions (speaking > of CC, not HOSTCC/HOSTCXX). Yeah. I think we'll probably enable it gradually as folks get time to test it. ie. ppc64le first, then ppc64 (BE), and then 32-bit if someone is interested. cheers
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web