mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] lib: kasan: kasan_test: hide buggy access after xzalloc from compiler
@ 2024-07-22 16:26 Ahmad Fatoum
  2024-07-24  8:07 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-07-22 16:26 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] lib: kasan: kasan_test: hide buggy access after xzalloc from compiler
  2024-07-22 16:26 [PATCH] lib: kasan: kasan_test: hide buggy access after xzalloc from compiler Ahmad Fatoum
@ 2024-07-24  8:07 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-07-24  8:07 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Mon, 22 Jul 2024 18:26:35 +0200, Ahmad Fatoum wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] lib: kasan: kasan_test: hide buggy access after xzalloc from compiler
      https://git.pengutronix.de/cgit/barebox/commit/?id=f5e54a0274fe (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-24  8:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-22 16:26 [PATCH] lib: kasan: kasan_test: hide buggy access after xzalloc from compiler Ahmad Fatoum
2024-07-24  8:07 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox