[PATCH] lib: kasan: kasan_test: hide buggy access after xzalloc from compiler
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Jul 22 09:26:35 PDT 2024
Commit 187b85361236 ("KASan: test_kasan: hide buggy accesses from
compiler") used OPTIMIZER_HIDE_VAR() to hide the origin of pointers.
This became necessary when __alloc attributes were added to malloc().
We now add the same attributes to xzalloc as well bring back warnings
for the single xzalloc call in the file.
That memory violation, like the ones before it, is intended as
test_kasan is meant to trigger kasan at runtime to verify correct
operation.
Therefore use OPTIMIZER_HIDE_VAR here too to silence the warning.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
lib/kasan/test_kasan.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/kasan/test_kasan.c b/lib/kasan/test_kasan.c
index bacc02b56e98..ba8b84bfd24f 100644
--- a/lib/kasan/test_kasan.c
+++ b/lib/kasan/test_kasan.c
@@ -394,6 +394,8 @@ static noinline void kasan_bitops(void)
if (!bits)
return;
+ OPTIMIZER_HIDE_VAR(bits);
+
/*
* Below calls try to access bit within allocated memory; however, the
* below accesses are still out-of-bounds, since bitops are defined to
--
2.39.2
More information about the barebox
mailing list