[PATCH] lib: kasan: kasan_test: hide buggy access after xzalloc from compiler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux