sizeof(struct input_device_id)=164 is not a modulo of the size of section #1208
Comments
|
#1045 has a similar error, but that one is marked fixed |
|
I did a bisect on this a little while ago and it appears related to KASAN. |
|
I have a minimized test case at https://godbolt.org/z/ozzjTE This shows the 'joydev_ids' array being padded from 100 to 160 bytes with 'clang -fsanitize=kernel-address'. |
|
A bisect confirms that llvm/llvm-project@d3f8931 (v2 of the patch that caused #1045) introduced this failure:
|
|
Clang should not add redzones to:
But clearly, somewhere this is going wrong. Let me check. |
|
adding a __ prefix to the variable avoids the redzone, so I guess the problem is the alias detection. |
|
I can see what's going wrong: the optimizer turns an alias to a I have no idea why this would ever be a good optimization, but I guess we have to deal with that. [I'll only have time to resume work on this late tomorrow, so if anybody has spare cycles, help appreciated.] |
|
https://reviews.llvm.org/D92846 Still need to write tests for that, then I'll send for review. If you can test, that'd be good. Thank you. |
|
@melver I can confirm that patch fixes the issue. |
GlobalAlias::getAliasee() may not always point directly to a GlobalVariable. In such cases, try to find the canonical GlobalVariable that the alias refers to. Link: ClangBuiltLinux/linux#1208 Reviewed By: dvyukov, nickdesaulniers Differential Revision: https://reviews.llvm.org/D92846
|
This is now fixed for LLVM/Clang 12. |
|
We should try to get that fix into LLVM 11.0.1, cc @tstellar, I can try to open an LLVM bug today if you need it. |
|
@nathanchance It's pretty late, so it might not get in, but you can go ahead and file the bug anyway. |
|
I have submitted https://bugs.llvm.org/show_bug.cgi?id=48492. If it cannot be added, this will need to be added to the kernel :( diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index b2bf019dcefa..a05653a17dbd 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -67,7 +67,8 @@ config ARM
select HAVE_ARCH_BITREVERSE if (CPU_32v7M || CPU_32v7) && !CPU_32v6
select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU
select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 && MMU
- select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL
+ # https://github.com/ClangBuiltLinux/linux/issues/1208
+ select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL && (CC_IS_GCC || (CLANG_VERSION >= 120000 || CLANG_VERSION <= 100001))
select HAVE_ARCH_MMAP_RND_BITS if MMU
select HAVE_ARCH_SECCOMP
select HAVE_ARCH_SECCOMP_FILTER if AEABI && !OABI_COMPAT |
GlobalAlias::getAliasee() may not always point directly to a GlobalVariable. In such cases, try to find the canonical GlobalVariable that the alias refers to. Link: ClangBuiltLinux/linux#1208 Reviewed By: dvyukov, nickdesaulniers Differential Revision: https://reviews.llvm.org/D92846 (cherry picked from commit c28b18a)
GlobalAlias::getAliasee() may not always point directly to a GlobalVariable. In such cases, try to find the canonical GlobalVariable that the alias refers to. Link: ClangBuiltLinux/linux#1208 Reviewed By: dvyukov, nickdesaulniers Differential Revision: https://reviews.llvm.org/D92846 (cherry picked from commit c28b18a)
Thank you!
Just FYI, this is overkill. We just need '-mllvm -asan-globals=0' as a last resort. |
GlobalAlias::getAliasee() may not always point directly to a GlobalVariable. In such cases, try to find the canonical GlobalVariable that the alias refers to. Link: ClangBuiltLinux/linux#1208 Reviewed By: dvyukov, nickdesaulniers Differential Revision: https://reviews.llvm.org/D92846 (cherry picked from commit c28b18a)
This happens on a few arch/arm randconfig builds with clang-12 on linux-next (currently 20201203):
FATAL: modpost: drivers/input/mousedev: sizeof(struct input_device_id)=164 is not a modulo of the size of section mod_input_device_table=1216.
Example .config: https://pastebin.com/MEDgUh6T
The text was updated successfully, but these errors were encountered: