Use after scope bugs detector seems to be almost entirely useless for the linux kernel. It exists over two years, but I've seen only one valid bug so far [1]. And the bug was fixed before it has been reported. There were some other use-after-scope reports, but they were false-positives due to different reasons like incompatibility with structleak plugin. This feature significantly increases stack usage, especially with GCC < 9 version, and causes a 32K stack overflow. It probably adds performance penalty too. Given all that, let's remove use-after-scope detector entirely. While preparing this patch I've noticed that we mistakenly enable use-after-scope detection for clang compiler regardless of CONFIG_KASAN_EXTRA setting. This is also fixed now. [1] http://lkml.kernel.org/r/<20171129052106.rhgbjhhis53hkgfn@wfg-t540p.sh.intel.com>
Showing the changes to scripts (2 of 9 files). Show all
Unified · Split
| @@ -27,14 +27,9 @@ else · 26 unmodified lines | |||
| 27 | $(call cc-param,asan-globals=1) \ | 27 | $(call cc-param,asan-globals=1) \ |
| 28 | $(call cc-param,asan-instrumentation-with-call-threshold=$(call_threshold)) \ | 28 | $(call cc-param,asan-instrumentation-with-call-threshold=$(call_threshold)) \ |
| 29 | $(call cc-param,asan-stack=$(CONFIG_KASAN_STACK)) \ | 29 | $(call cc-param,asan-stack=$(CONFIG_KASAN_STACK)) \ |
| 30 | $(call cc-param,asan-use-after-scope=1) \ | ||
| 31 | $(call cc-param,asan-instrument-allocas=1) | 30 | $(call cc-param,asan-instrument-allocas=1) |
| 32 | endif | 31 | endif |
| 33 | 32 | ||
| 34 | ifdef CONFIG_KASAN_EXTRA | ||
| 35 | CFLAGS_KASAN += $(call cc-option, -fsanitize-address-use-after-scope) | ||
| 36 | endif | ||
| 37 | |||
| 38 | endif # CONFIG_KASAN_GENERIC | 33 | endif # CONFIG_KASAN_GENERIC |
| 39 | 34 | ||
| 40 | ifdef CONFIG_KASAN_SW_TAGS | 35 | ifdef CONFIG_KASAN_SW_TAGS |
| @@ -68,10 +68,6 @@ config GCC_PLUGIN_LATENT_ENTROPY · 67 unmodified lines | |||
| 68 | 68 | ||
| 69 | config GCC_PLUGIN_STRUCTLEAK | 69 | config GCC_PLUGIN_STRUCTLEAK |
| 70 | bool "Force initialization of variables containing userspace addresses" | 70 | bool "Force initialization of variables containing userspace addresses" |
| 71 | # Currently STRUCTLEAK inserts initialization out of live scope of | ||
| 72 | # variables from KASAN point of view. This leads to KASAN false | ||
| 73 | # positive reports. Prohibit this combination for now. | ||
| 74 | depends on !KASAN_EXTRA | ||
| 75 | help | 71 | help |
| 76 | This plugin zero-initializes any structures containing a | 72 | This plugin zero-initializes any structures containing a |
| 77 | __user attribute. This can prevent some classes of information | 73 | __user attribute. This can prevent some classes of information |