2021-01-13 03:41:14

by Nylon Chen

[permalink] [raw]
Subject: [PATCH 1/1] riscv: Fix KASAN memory mapping.

From: Nick Hu <[email protected]>

Use virtual address instead of physical address when translating
the address to shadow memory by kasan_mem_to_shadow().

Signed-off-by: Nick Hu <[email protected]>
Signed-off-by: Nylon Chen <[email protected]>
---
arch/riscv/mm/kasan_init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/mm/kasan_init.c b/arch/riscv/mm/kasan_init.c
index 12ddd1f6bf70..a8a2ffd9114a 100644
--- a/arch/riscv/mm/kasan_init.c
+++ b/arch/riscv/mm/kasan_init.c
@@ -93,8 +93,8 @@ void __init kasan_init(void)
VMALLOC_END));

for_each_mem_range(i, &_start, &_end) {
- void *start = (void *)_start;
- void *end = (void *)_end;
+ void *start = (void *)__va(_start);
+ void *end = (void *)__va(_end);

if (start >= end)
break;
--
2.17.1


2021-01-14 05:02:02

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH 1/1] riscv: Fix KASAN memory mapping.

On Tue, 12 Jan 2021 18:24:10 PST (-0800), [email protected] wrote:
> From: Nick Hu <[email protected]>
>
> Use virtual address instead of physical address when translating
> the address to shadow memory by kasan_mem_to_shadow().
>
> Signed-off-by: Nick Hu <[email protected]>
> Signed-off-by: Nylon Chen <[email protected]>
> ---
> arch/riscv/mm/kasan_init.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/mm/kasan_init.c b/arch/riscv/mm/kasan_init.c
> index 12ddd1f6bf70..a8a2ffd9114a 100644
> --- a/arch/riscv/mm/kasan_init.c
> +++ b/arch/riscv/mm/kasan_init.c
> @@ -93,8 +93,8 @@ void __init kasan_init(void)
> VMALLOC_END));
>
> for_each_mem_range(i, &_start, &_end) {
> - void *start = (void *)_start;
> - void *end = (void *)_end;
> + void *start = (void *)__va(_start);
> + void *end = (void *)__va(_end);
>
> if (start >= end)
> break;

Thanks, this is on fixes.