Global variables are only supported in GCC right now.
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?
Yes, this issues is still valid. This definitely requires changes in Clang and probably in the kernel too.
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?
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.
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?
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.)
Globals supported added in: https://github.com/llvm/llvm-project/commit/866ee2353f7d0224644799d0d1faed53c7f3a06d
This is fixed for generic mode, but not for sw-tags.