riscv: Fix KASAN memory mapping.
authorNick Hu <nickhu@andestech.com>
Wed, 13 Jan 2021 02:24:10 +0000 (10:24 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Jan 2021 17:27:20 +0000 (18:27 +0100)
commit c25a053e15778f6b4d6553708673736e27a6c2cf upstream.

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

Signed-off-by: Nick Hu <nickhu@andestech.com>
Signed-off-by: Nylon Chen <nylon7@andestech.com>
Fixes: b10d6bca8720 ("arch, drivers: replace for_each_membock() with for_each_mem_range()")
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/riscv/mm/kasan_init.c

index 12ddd1f..a8a2ffd 100644 (file)
@@ -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;