linux/scripts/gcc-plugins
Kees Cook 81a56f6dcd gcc-plugins: structleak: Generalize to all variable types
This adjusts structleak to also work with non-struct types when they
are passed by reference, since those variables may leak just like
anything else. This is exposed via an improved set of Kconfig options.
(This does mean structleak is slightly misnamed now.)

Building with CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL should give the
kernel complete initialization coverage of all stack variables passed
by reference, including padding (see lib/test_stackinit.c).

Using CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE to count added initializations
under defconfig:

	..._BYREF:      5945 added initializations
	..._BYREF_ALL: 16606 added initializations

There is virtually no change to text+data size (both have less than 0.05%
growth):

   text    data     bss     dec     hex filename
19502103        5051456 1917000 26470559        193e89f vmlinux.stock
19513412        5051456 1908808 26473676        193f4cc vmlinux.byref
19516974        5047360 1900616 26464950        193d2b6 vmlinux.byref_all

The measured performance difference is in the noise for hackbench and
kernel build benchmarks:

Stock:

	5x hackbench -g 20 -l 1000
	Mean:   10.649s
	Std Dev: 0.339

	5x kernel build (4-way parallel)
	Mean:  261.98s
	Std Dev: 1.53

CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF:

	5x hackbench -g 20 -l 1000
	Mean:   10.540s
	Std Dev: 0.233

	5x kernel build (4-way parallel)
	Mean:  260.52s
	Std Dev: 1.31

CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL:

	5x hackbench -g 20 -l 1000
	Mean:   10.320
	Std Dev: 0.413

	5x kernel build (4-way parallel)
	Mean:  260.10
	Std Dev: 0.86

This does not yet solve missing padding initialization for structures
on the stack that are never passed by reference (which should be a tiny
minority). Hopefully this will be more easily addressed by upstream
compiler fixes after clarifying the C11 padding initialization
specification.

Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
2019-03-04 09:29:41 -08:00
..
.gitignore gcc-plugins: Add the randstruct plugin 2017-06-22 16:15:45 -07:00
arm_ssp_per_task_plugin.c gcc-plugins: arm_ssp_per_task_plugin: fix for GCC 9+ 2019-01-20 14:06:40 -08:00
cyc_complexity_plugin.c gcc-plugins: consolidate on PASS_INFO macro 2017-01-13 14:20:03 -08:00
gcc-common.h gcc-plugins: Clean up the cgraph_create_edge* macros 2018-07-24 16:14:06 -07:00
gcc-generate-gimple-pass.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
gcc-generate-ipa-pass.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
gcc-generate-rtl-pass.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
gcc-generate-simple_ipa-pass.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
gen-random-seed.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Kconfig gcc-plugins: structleak: Generalize to all variable types 2019-03-04 09:29:41 -08:00
latent_entropy_plugin.c gcc-plugins: Use dynamic initializers 2018-02-05 17:27:46 -08:00
Makefile gcc-plugins: remove unused GCC_PLUGIN_SUBDIR 2018-07-02 19:27:00 -07:00
randomize_layout_plugin.c security: convert security hooks to use hlist 2018-03-31 13:18:27 +11:00
sancov_plugin.c gcc-plugins: fix sancov_plugin for gcc-5 2017-02-27 14:10:10 -08:00
stackleak_plugin.c stackleak: Register the 'stackleak_cleanup' pass before the '*free_cfg' pass 2018-12-06 09:10:23 -08:00
structleak_plugin.c gcc-plugins: structleak: Generalize to all variable types 2019-03-04 09:29:41 -08:00