|Summary:||KASAN (sw-tags): add global variables support|
|Product:||Memory Management||Reporter:||Andrey Konovalov (andreyknvl)|
|Component:||Sanitizers||Assignee:||MM/Sanitizers virtual assignee (mm_sanitizers)|
|Severity:||normal||CC:||dvyukov, glider, kasan-dev, melver, ndesaulniers, walter-zh.wu|
Description Andrey Konovalov 2019-05-03 15:55:26 UTC
Global variables are only supported in GCC right now.
Comment 1 Walter Wu 2019-10-08 12:18:50 UTC
Hi Andrey, We try to reproduce this issue on my environment(Linus 5.3-rc1 + clang 9), but it seem like not to support detection of out-of-bounds accesses for global variables yet. so Does this issue exist? If yes, Should this issue be fixed by compiler or kernel?
Comment 2 Andrey Konovalov 2019-10-08 12:27:52 UTC
Hi Walter, Yes, this issues is still valid. This definitely requires changes in Clang and probably in the kernel too. Thanks!
Comment 3 Walter Wu 2020-04-21 07:45:22 UTC
Hi Andrey, Sorry to lately respond to you. We recently use tag-based KASAN, it looks like STACK and GLOBAL variable checking are invalid. Because I saw the config has -mllvm -hwasan-instrument-stack=0. We think tag-based KASAN's advantage is exciting, so we want to use KASAN from generic KASAN to tag-based KASAN. Unfortunately, we are not familiar with Clang. Do you know whether any Clang experts have a plan to support it? Walter
Comment 4 Dmitry Vyukov 2020-04-21 13:18:59 UTC
First we need to remember what's the actual problem with global variables and clang. The root problem is not captured in the report. Potentially the problem is with kernel than clang, because I would assume global variables work in user-space with clang. -hwasan-instrument-stack=0 it related to stack instrumentation, not global variables.
Comment 5 Walter Wu 2020-04-21 13:53:59 UTC
Hi Dmitry, Thanks for your reply. I agree with what you said about global variable. We try to get the clang which is work in user-space. but it is sad because it doesn't work in kernel-space. so we stopped. why stack checking is invalid with tag-based KASAN? unit test has something wrong? or?
Comment 6 Andrey Konovalov 2020-04-21 15:06:27 UTC
I don't know what was the problem with global variables in generic KASAN, perhaps Alex remembers. For tag-based KASAN, I think there's no support for global variables even in userspace HWASAN implementation. For stack instrumentation in tag-based KASAN there's a separate bug: https://bugzilla.kernel.org/show_bug.cgi?id=203497. The compiler supports it, but it was never implemented in the kernel runtime. (I remember trying to enable it and seeing some false-positive reports, but I've never debugged those.)
Comment 7 Marco Elver 2020-06-05 18:30:48 UTC
Globals supported added in: https://github.com/llvm/llvm-project/commit/866ee2353f7d0224644799d0d1faed53c7f3a06d
Comment 9 Andrey Konovalov 2020-10-16 19:43:38 UTC
This is fixed for generic mode, but not for sw-tags.