kasan: turn off -fsanitize-address-use-after-scope for now
Subsystems (3)
PATCH 1/1 kasan: turn off -fsanitize-address-use-after-scope for now
In the upcoming gcc-7 release, the -fsanitize=kernel-address option implies -fsanitize-address-use-after-scope, which relies on the definition of two global functions, causing many link errors if they are not defined, e.g:
arch/x86/built-in.o: In function `x86_pmu_handle_irq':
(.text+0x88e6): undefined reference to __asan_unpoison_stack_memory' arch/x86/built-in.o: In function x86_pmu_handle_irq':
(.text+0x8ad7): undefined reference to __asan_poison_stack_memory' kernel/built-in.o: In function perf_tp_event':
(.text+0x225472): undefined reference to __asan_unpoison_stack_memory' kernel/built-in.o: In function perf_tp_event':
(.text+0x22583a): undefined reference to __asan_unpoison_stack_memory' kernel/built-in.o: In function perf_tp_event':
(.text+0x2258ae): undefined reference to __asan_poison_stack_memory' kernel/built-in.o: In function perf_event_aux_event':
I think we really want to define those two functions so we can make use of a helpful feature, but as I have no idea what they are supposed to do, I'd suggest to turn the option off on existing kernels to allow building with gcc-7 and kasan.
For some reason, the problem showed up in only a few randconfig builds, but it is easy to reproduce using an x86-64 tinyconfig build with CONFIG_KASAN=y.
If we decide to take this approach, we probably want to do the same change on all stable kernels that support KASAN, i.e. v4.0 or higher.
--- scripts/Makefile.kasan | 2 ++ 1 file changed, 2 insertions(+)
scripts/Makefile.kasan +2 -0
@@ -29,3 +29,5 @@ else endif endif endif + +CFLAGS_KASAN += $(call cc-option, -fno-sanitize-address-use-after-scope)
Signature · 1 line
2.9.0
Quoted 22 lines · Arnd Bergmann
In the upcoming gcc-7 release, the -fsanitize=kernel-address option implies -fsanitize-address-use-after-scope, which relies on the definition of two global functions, causing many link errors if they are not defined, e.g:
arch/x86/built-in.o: In function `x86_pmu_handle_irq':
(.text+0x88e6): undefined reference to__asan_unpoison_stack_memory' arch/x86/built-in.o: In functionx86_pmu_handle_irq':
(.text+0x8ad7): undefined reference to__asan_poison_stack_memory' kernel/built-in.o: In functionperf_tp_event':
(.text+0x225472): undefined reference to__asan_unpoison_stack_memory' kernel/built-in.o: In functionperf_tp_event':
(.text+0x22583a): undefined reference to__asan_unpoison_stack_memory' kernel/built-in.o: In functionperf_tp_event':
(.text+0x2258ae): undefined reference to__asan_poison_stack_memory' kernel/built-in.o: In functionperf_event_aux_event':I think we really want to define those two functions so we can make use of a helpful feature, but as I have no idea what they are supposed to do, I'd suggest to turn the option off on existing kernels to allow building with gcc-7 and kasan.
Quoted 7 lines
For some reason, the problem showed up in only a few randconfig builds, but it is easy to reproduce using an x86-64 tinyconfig build with
CONFIG_KASAN=y.If we decide to take this approach, we probably want to do the same change on all stable kernels that support KASAN, i.e. v4.0 or higher.
We have implementation for this feature:
"[PATCH] kasan: support use-after-scope detection" - http://lkml.kernel.org/r/<[email protected]>
and given how simple it is I'd suggest to just backport implementation.
BTW, we also need "[PATCH] kasan: update kasan_global for gcc 7" - http://lkml.kernel.org/r/<[email protected]>
in v4.0+ stable.
Quoted 20 lines
Cc Martin Liška <[email protected]>Cc Andrey Ryabinin <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>--- scripts/Makefile.kasan | 2 ++ 1 file changed, 2 insertions(+)scripts/Makefile.kasan +2
-0@@ -29,3 +29,5 @@ else endif endif endif + +CFLAGS_KASAN += $(call cc-option, -fno-sanitize-address-use-after-scope)
Quoted 7 lines · CET Andrey Ryabinin
We have implementation for this feature:
"[PATCH] kasan: support use-after-scope detection" - http://lkml.kernel.org/r/<[email protected]>and given how simple it is I'd suggest to just backport implementation.
BTW, we also need "[PATCH] kasan: update
kasan_globalfor gcc 7" - http://lkml.kernel.org/r/<[email protected]>
in v4.0+ stable.
Ah, good. What's the plan for this patch? Would you still expect to see that merged into v4.9, or get backported later once it's part of v4.10?
Either way, you proabably want a Cc:stable tag on it to trigger the backport to older kernels.
Arnd
Dmitry Vyukov
reviewerQuoted 6 lines · Arnd Bergmann
Quoted 5 lines · CET Andrey Ryabinin
We have implementation for this feature:
"[PATCH] kasan: support use-after-scope detection" - http://lkml.kernel.org/r/<[email protected]>and given how simple it is I'd suggest to just backport implementation.
Quoted 8 lines
Quoted 2 lines
BTW, we also need "[PATCH] kasan: update
kasan_globalfor gcc 7" - http://lkml.kernel.org/r/<[email protected]>
in v4.0+ stable.Ah, good. What's the plan for this patch? Would you still expect to see that merged into v4.9, or get backported later once it's part of v4.10?
Either way, you proabably want a Cc:stable tag on it to trigger the backport to older kernels.
+Andrew, what is the plan for the "[PATCH] kasan: update kasan_global for gcc 7" patch?
Do I need to remail to include Cc:stable?
Quoted 13 lines · On Wed, 23 Nov 2016 10:33:41 +0100 Dmitry Vyukov <[email protected]> wrote:
Quoted 12 lines · Arnd Bergmann
Quoted 7 lines · CET Andrey Ryabinin
We have implementation for this feature:
"[PATCH] kasan: support use-after-scope detection" - http://lkml.kernel.org/r/<[email protected]>and given how simple it is I'd suggest to just backport implementation.
BTW, we also need "[PATCH] kasan: update
kasan_globalfor gcc 7" - http://lkml.kernel.org/r/<[email protected]>
in v4.0+ stable.Ah, good. What's the plan for this patch? Would you still expect to see that merged into v4.9, or get backported later once it's part of v4.10?
Quoted 6 lines
Quoted 2 lines
Either way, you proabably want a Cc:stable tag on it to trigger the backport to older kernels.
+Andrew, what is the plan for the "[PATCH] kasan: update
kasan_globalfor gcc 7" patch?
Do I need to remail to include Cc:stable?
I'm planning on merging it into 4.10-rc1. There's nothing in the changelog to indicate that it is more urgent than that.
Please send out a new changelog which can be used to justify a merge into 4.9 and -stable.
Dmitry Vyukov
reviewerQuoted 22 lines · Andrew Morton
Quoted 13 lines · On Wed, 23 Nov 2016 10:33:41 +0100 Dmitry Vyukov <[email protected]> wrote:
Quoted 12 lines · Arnd Bergmann
Quoted 7 lines · CET Andrey Ryabinin
We have implementation for this feature:
"[PATCH] kasan: support use-after-scope detection" - http://lkml.kernel.org/r/<[email protected]>and given how simple it is I'd suggest to just backport implementation.
BTW, we also need "[PATCH] kasan: update
kasan_globalfor gcc 7" - http://lkml.kernel.org/r/<[email protected]>
in v4.0+ stable.Ah, good. What's the plan for this patch? Would you still expect to see that merged into v4.9, or get backported later once it's part of v4.10?
Quoted 6 lines
Quoted 2 lines
Either way, you proabably want a Cc:stable tag on it to trigger the backport to older kernels.
+Andrew, what is the plan for the "[PATCH] kasan: update
kasan_globalfor gcc 7" patch?
Do I need to remail to include Cc:stable?
Quoted 5 lines
I'm planning on merging it into 4.10-rc1. There's nothing in the changelog to indicate that it is more urgent than that.
Please send out a new changelog which can be used to justify a merge into 4.9 and -stable.
Remailed the patches with Cc: [email protected] # 4.0+ and with a note that without these patches KASAN is broken with gcc 7.