aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-08-15 15:06:16 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-08-15 15:06:16 -0400
commit7c7b562c6f0a4fb13eee01cb39b111addfb165e6 (patch)
treef18c6969676d314dba55255a839179ae139617d5
parentb125d903881901a53117dfe404c789850b4e98ed (diff)
parent45d9a1e3cc45efee6c0ef82b77269d6944d9d8a5 (diff)
Merge tag 'gcc-plugin-cleanup-v4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull gcc plugin cleanups from Kees Cook: - Kconfig and Makefile clean-ups (Masahiro Yamada, Kees Cook) - gcc-common.h definition clean-ups (Alexander Popov) * tag 'gcc-plugin-cleanup-v4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: gcc-plugins: Clean up the cgraph_create_edge* macros gcc-plugins: Regularize Makefile.gcc-plugins gcc-plugins: split out Kconfig entries to scripts/gcc-plugins/Kconfig gcc-plugins: remove unused GCC_PLUGIN_SUBDIR
-rw-r--r--arch/Kconfig146
-rw-r--r--scripts/Makefile.gcc-plugins37
-rw-r--r--scripts/gcc-plugins/Kconfig142
-rw-r--r--scripts/gcc-plugins/Makefile5
-rw-r--r--scripts/gcc-plugins/gcc-common.h26
5 files changed, 184 insertions, 172 deletions
diff --git a/arch/Kconfig b/arch/Kconfig
index d1f2ed462ac8..8543bc3c21fe 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -408,150 +408,6 @@ config SECCOMP_FILTER
408 408
409 See Documentation/userspace-api/seccomp_filter.rst for details. 409 See Documentation/userspace-api/seccomp_filter.rst for details.
410 410
411preferred-plugin-hostcc := $(if-success,[ $(gcc-version) -ge 40800 ],$(HOSTCXX),$(HOSTCC))
412
413config PLUGIN_HOSTCC
414 string
415 default "$(shell,$(srctree)/scripts/gcc-plugin.sh "$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)")"
416 help
417 Host compiler used to build GCC plugins. This can be $(HOSTCXX),
418 $(HOSTCC), or a null string if GCC plugin is unsupported.
419
420config HAVE_GCC_PLUGINS
421 bool
422 help
423 An arch should select this symbol if it supports building with
424 GCC plugins.
425
426menuconfig GCC_PLUGINS
427 bool "GCC plugins"
428 depends on HAVE_GCC_PLUGINS
429 depends on PLUGIN_HOSTCC != ""
430 help
431 GCC plugins are loadable modules that provide extra features to the
432 compiler. They are useful for runtime instrumentation and static analysis.
433
434 See Documentation/gcc-plugins.txt for details.
435
436config GCC_PLUGIN_CYC_COMPLEXITY
437 bool "Compute the cyclomatic complexity of a function" if EXPERT
438 depends on GCC_PLUGINS
439 depends on !COMPILE_TEST # too noisy
440 help
441 The complexity M of a function's control flow graph is defined as:
442 M = E - N + 2P
443 where
444
445 E = the number of edges
446 N = the number of nodes
447 P = the number of connected components (exit nodes).
448
449 Enabling this plugin reports the complexity to stderr during the
450 build. It mainly serves as a simple example of how to create a
451 gcc plugin for the kernel.
452
453config GCC_PLUGIN_SANCOV
454 bool
455 depends on GCC_PLUGINS
456 help
457 This plugin inserts a __sanitizer_cov_trace_pc() call at the start of
458 basic blocks. It supports all gcc versions with plugin support (from
459 gcc-4.5 on). It is based on the commit "Add fuzzing coverage support"
460 by Dmitry Vyukov <dvyukov@google.com>.
461
462config GCC_PLUGIN_LATENT_ENTROPY
463 bool "Generate some entropy during boot and runtime"
464 depends on GCC_PLUGINS
465 help
466 By saying Y here the kernel will instrument some kernel code to
467 extract some entropy from both original and artificially created
468 program state. This will help especially embedded systems where
469 there is little 'natural' source of entropy normally. The cost
470 is some slowdown of the boot process (about 0.5%) and fork and
471 irq processing.
472
473 Note that entropy extracted this way is not cryptographically
474 secure!
475
476 This plugin was ported from grsecurity/PaX. More information at:
477 * https://grsecurity.net/
478 * https://pax.grsecurity.net/
479
480config GCC_PLUGIN_STRUCTLEAK
481 bool "Force initialization of variables containing userspace addresses"
482 depends on GCC_PLUGINS
483 # Currently STRUCTLEAK inserts initialization out of live scope of
484 # variables from KASAN point of view. This leads to KASAN false
485 # positive reports. Prohibit this combination for now.
486 depends on !KASAN_EXTRA
487 help
488 This plugin zero-initializes any structures containing a
489 __user attribute. This can prevent some classes of information
490 exposures.
491
492 This plugin was ported from grsecurity/PaX. More information at:
493 * https://grsecurity.net/
494 * https://pax.grsecurity.net/
495
496config GCC_PLUGIN_STRUCTLEAK_BYREF_ALL
497 bool "Force initialize all struct type variables passed by reference"
498 depends on GCC_PLUGIN_STRUCTLEAK
499 depends on !COMPILE_TEST
500 help
501 Zero initialize any struct type local variable that may be passed by
502 reference without having been initialized.
503
504config GCC_PLUGIN_STRUCTLEAK_VERBOSE
505 bool "Report forcefully initialized variables"
506 depends on GCC_PLUGIN_STRUCTLEAK
507 depends on !COMPILE_TEST # too noisy
508 help
509 This option will cause a warning to be printed each time the
510 structleak plugin finds a variable it thinks needs to be
511 initialized. Since not all existing initializers are detected
512 by the plugin, this can produce false positive warnings.
513
514config GCC_PLUGIN_RANDSTRUCT
515 bool "Randomize layout of sensitive kernel structures"
516 depends on GCC_PLUGINS
517 select MODVERSIONS if MODULES
518 help
519 If you say Y here, the layouts of structures that are entirely
520 function pointers (and have not been manually annotated with
521 __no_randomize_layout), or structures that have been explicitly
522 marked with __randomize_layout, will be randomized at compile-time.
523 This can introduce the requirement of an additional information
524 exposure vulnerability for exploits targeting these structure
525 types.
526
527 Enabling this feature will introduce some performance impact,
528 slightly increase memory usage, and prevent the use of forensic
529 tools like Volatility against the system (unless the kernel
530 source tree isn't cleaned after kernel installation).
531
532 The seed used for compilation is located at
533 scripts/gcc-plgins/randomize_layout_seed.h. It remains after
534 a make clean to allow for external modules to be compiled with
535 the existing seed and will be removed by a make mrproper or
536 make distclean.
537
538 Note that the implementation requires gcc 4.7 or newer.
539
540 This plugin was ported from grsecurity/PaX. More information at:
541 * https://grsecurity.net/
542 * https://pax.grsecurity.net/
543
544config GCC_PLUGIN_RANDSTRUCT_PERFORMANCE
545 bool "Use cacheline-aware structure randomization"
546 depends on GCC_PLUGIN_RANDSTRUCT
547 depends on !COMPILE_TEST # do not reduce test coverage
548 help
549 If you say Y here, the RANDSTRUCT randomization will make a
550 best effort at restricting randomization to cacheline-sized
551 groups of elements. It will further not randomize bitfields
552 in structures. This reduces the performance hit of RANDSTRUCT
553 at the cost of weakened randomization.
554
555config HAVE_STACKPROTECTOR 411config HAVE_STACKPROTECTOR
556 bool 412 bool
557 help 413 help
@@ -975,3 +831,5 @@ config REFCOUNT_FULL
975 security flaw exploits. 831 security flaw exploits.
976 832
977source "kernel/gcov/Kconfig" 833source "kernel/gcov/Kconfig"
834
835source "scripts/gcc-plugins/Kconfig"
diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins
index c961b9a65d11..0a482f341576 100644
--- a/scripts/Makefile.gcc-plugins
+++ b/scripts/Makefile.gcc-plugins
@@ -1,33 +1,44 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2
2gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) += cyc_complexity_plugin.so 3gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) += cyc_complexity_plugin.so
3 4
4gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += latent_entropy_plugin.so 5gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += latent_entropy_plugin.so
5gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += -DLATENT_ENTROPY_PLUGIN 6gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) \
7 += -DLATENT_ENTROPY_PLUGIN
6ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY 8ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY
7 DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable 9 DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable
8endif 10endif
11export DISABLE_LATENT_ENTROPY_PLUGIN
9 12
10gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV) += sancov_plugin.so 13gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV) += sancov_plugin.so
14
11gcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += structleak_plugin.so 15gcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += structleak_plugin.so
12gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE) += -fplugin-arg-structleak_plugin-verbose 16gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE) \
13gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL) += -fplugin-arg-structleak_plugin-byref-all 17 += -fplugin-arg-structleak_plugin-verbose
14gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += -DSTRUCTLEAK_PLUGIN 18gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL) \
19 += -fplugin-arg-structleak_plugin-byref-all
20gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) \
21 += -DSTRUCTLEAK_PLUGIN
15 22
16gcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += randomize_layout_plugin.so 23gcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += randomize_layout_plugin.so
17gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += -DRANDSTRUCT_PLUGIN 24gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) \
18gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE) += -fplugin-arg-randomize_layout_plugin-performance-mode 25 += -DRANDSTRUCT_PLUGIN
26gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE) \
27 += -fplugin-arg-randomize_layout_plugin-performance-mode
19 28
29# All the plugin CFLAGS are collected here in case a build target needs to