* [PATCH master 1/2] KASan: test_kasan: silence warning with newer GCC
@ 2022-12-12 16:39 Ahmad Fatoum
2022-12-12 16:39 ` [PATCH master 2/2] KASan: fix handling of devices with MMIO above SDRAM memory region Ahmad Fatoum
2022-12-13 8:37 ` [PATCH master 1/2] KASan: test_kasan: silence warning with newer GCC Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2022-12-12 16:39 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
Newer GCC will rightly complain about this being an out-of-bounds
access. This is intended as the kasan command is meant to cause
out-of-bounds accesses to test proper operation of KASan.
Thus silence the warning for this specific instance.
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 d0ea91547711..14511cdb80bd 100644
--- a/lib/kasan/test_kasan.c
+++ b/lib/kasan/test_kasan.c
@@ -290,6 +290,8 @@ static noinline void kasan_alloca_oob_left(void)
char alloca_array[i];
char *p = alloca_array - 1;
+ OPTIMIZER_HIDE_VAR(p);
+
pr_info("out-of-bounds to left on alloca\n");
*(volatile char *)p;
}
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH master 2/2] KASan: fix handling of devices with MMIO above SDRAM memory region
2022-12-12 16:39 [PATCH master 1/2] KASan: test_kasan: silence warning with newer GCC Ahmad Fatoum
@ 2022-12-12 16:39 ` Ahmad Fatoum
2022-12-13 8:37 ` [PATCH master 1/2] KASan: test_kasan: silence warning with newer GCC Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2022-12-12 16:39 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
check_memory_region_inline will discard KASan reports before start of
RAM as false positives. This is sufficient for i.MX SoCs where the RAM
starts after all device MMIO regions. On the AT91, the EBI memory
controller's memory region follows the SDRAM memory region. This
results in a KASan warning the first time NAND is accessed.
Record the end of the shadowed SDRAM area to fix this.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
lib/kasan/generic.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/kasan/generic.c b/lib/kasan/generic.c
index b33a6c1a6c0c..1eccacf2b4b0 100644
--- a/lib/kasan/generic.c
+++ b/lib/kasan/generic.c
@@ -22,6 +22,7 @@
unsigned long kasan_shadow_start;
unsigned long kasan_shadow_base;
+unsigned long kasan_shadowed_end;
/*
* All functions below always inlined so compiler could
@@ -160,6 +161,9 @@ static __always_inline bool check_memory_region_inline(unsigned long addr,
if (addr < kasan_shadow_start)
return true;
+ if (addr > kasan_shadowed_end)
+ return true;
+
if (unlikely(size == 0))
return true;
@@ -180,6 +184,7 @@ void kasan_init(unsigned long membase, unsigned long memsize,
{
kasan_shadow_start = membase;
kasan_shadow_base = shadow_base;
+ kasan_shadowed_end = membase + memsize - 1;
kasan_unpoison_shadow((void *)membase, memsize);
kasan_initialized = true;
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH master 1/2] KASan: test_kasan: silence warning with newer GCC
2022-12-12 16:39 [PATCH master 1/2] KASan: test_kasan: silence warning with newer GCC Ahmad Fatoum
2022-12-12 16:39 ` [PATCH master 2/2] KASan: fix handling of devices with MMIO above SDRAM memory region Ahmad Fatoum
@ 2022-12-13 8:37 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2022-12-13 8:37 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Mon, Dec 12, 2022 at 05:39:06PM +0100, Ahmad Fatoum wrote:
> Newer GCC will rightly complain about this being an out-of-bounds
> access. This is intended as the kasan command is meant to cause
> out-of-bounds accesses to test proper operation of KASan.
>
> Thus silence the warning for this specific instance.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> lib/kasan/test_kasan.c | 2 ++
> 1 file changed, 2 insertions(+)
Applied, thanks
Sascha
>
> diff --git a/lib/kasan/test_kasan.c b/lib/kasan/test_kasan.c
> index d0ea91547711..14511cdb80bd 100644
> --- a/lib/kasan/test_kasan.c
> +++ b/lib/kasan/test_kasan.c
> @@ -290,6 +290,8 @@ static noinline void kasan_alloca_oob_left(void)
> char alloca_array[i];
> char *p = alloca_array - 1;
>
> + OPTIMIZER_HIDE_VAR(p);
> +
> pr_info("out-of-bounds to left on alloca\n");
> *(volatile char *)p;
> }
> --
> 2.30.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-13 8:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-12 16:39 [PATCH master 1/2] KASan: test_kasan: silence warning with newer GCC Ahmad Fatoum
2022-12-12 16:39 ` [PATCH master 2/2] KASan: fix handling of devices with MMIO above SDRAM memory region Ahmad Fatoum
2022-12-13 8:37 ` [PATCH master 1/2] KASan: test_kasan: silence warning with newer GCC Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox