Bug 215759 - KASAN: more OPTIMIZER_HIDE_VAR annotations in tests
Summary: KASAN: more OPTIMIZER_HIDE_VAR annotations in tests
Status: RESOLVED CODE_FIX
Alias: None
Product: Memory Management
Classification: Unclassified
Component: Sanitizers (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: MM/Sanitizers virtual assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-27 16:09 UTC by Andrey Konovalov
Modified: 2022-10-18 18:58 UTC (History)
1 user (show)

See Also:
Kernel Version: upstream
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Andrey Konovalov 2022-03-27 16:09:47 UTC
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/
Comment 1 Andrey Konovalov 2022-09-24 20:30:14 UTC
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/
Comment 2 Andrey Konovalov 2022-10-18 18:58:02 UTC
The patch has been merged, this issue is now resolved.

Note You need to log in before you can comment on or make changes to this bug.