UBSAN, -Wstringop-overflow=, and other compiler features detect the issues deliberately present in KASAN tests. We need more OPTIMIZER_HIDE_VAR() annotations. For example, as reported-by Gustavo A. R. Silva [1]: lib/test_kasan.c:274:49: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] lib/test_kasan.c:194:63: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] lib/test_kasan.c:139:57: warning: writing 1 byte into a region of size 0 lib/test_kasan.c:145:53: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] lib/test_kasan.c:760:19: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] Peter and Kees also encountered similar issues and sent patches [2, 3], but looks like those have not been picked up. [1] https://twitter.com/embeddedgus/status/1507546690160664579 [2] https://patchwork.kernel.org/project/linux-hardening/patch/20220213183232.4038718-1-keescook@chromium.org/ [3] https://patchwork.kernel.org/project/linux-mm/patch/20220224002024.429707-1-pcc@google.com/
All of the mentioned warnings has been already fixed. I just mailed a patch to fix the remaining warnings produced by -Warray-bounds [1]. [1] https://lore.kernel.org/linux-mm/9c0210393a8da6fb6887a111a986eb50dfc1b895.1664050880.git.andreyknvl@google.com/
The patch has been merged, this issue is now resolved.