riscv: kasan: Fix MODULES_VADDR evaluation due to local variables' name
PATCH 1/1 riscv: kasan: Fix MODULES_VADDR evaluation due to local variables' name
From: Jisheng Zhang <[email protected]>
commit 2bfc6cd81bd1 ("riscv: Move kernel mapping outside of linear mapping") makes use of MODULES_VADDR to populate kernel, BPF, modules mapping. Currently, MODULES_VADDR is defined as below for RV64:
| #define MODULES_VADDR (PFN_ALIGN((unsigned long)&_end) - SZ_2G)
But kasan_init() has two local variables which are also named as _start, _end, so MODULES_VADDR is evaluated with the local variable _end rather than the global "_end" as we expected. Fix this issue by renaming the two local variables.
--- arch/riscv/mm/kasan_init.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/riscv/mm/kasan_init.c +4 -4
@@ -169,7 +169,7 @@ static void __init kasan_shallow_populate(void *start, void *end)void __init kasan_init (void ) { -phys_addr_t _start, _end; +phys_addr_t p_start, p_end;u64 i;/*
@@ -189,9 +189,9 @@ void __init kasan_init(void) (void *)kasan_mem_to_shadow((void *)VMALLOC_END));/* Populate the linear mapping */ -for_each_mem_range (i, &_start, &_end) { -void *start = (void *)__va (_start); -void *end = (void *)__va (_end); +for_each_mem_range (i, &p_start, &p_end) { +void *start = (void *)__va (p_start); +void *end = (void *)__va (p_end);if (start >= end)break ;
Signature · 1 line
2.32.0
Palmer Dabbelt
maintainerQuoted 35 lines · On Fri, 18 Jun 2021 07:01:36 PDT (-0700), [email protected] wrote:
From: Jisheng Zhang <[email protected]>
commit
2bfc6cd81bd1("riscv: Move kernel mapping outside of linear mapping") makes use ofMODULES_VADDRto populate kernel, BPF, modules mapping. Currently,MODULES_VADDRis defined as below for RV64:| #define
MODULES_VADDR(PFN_ALIGN((unsigned long)&_end)-SZ_2G)But
kasan_init()has two local variables which are also named as_start,_end, soMODULES_VADDRis evaluated with the local variable_endrather than the global "_end" as we expected. Fix this issue by renaming the two local variables.Fixes 2bfc6cd81bd1 ("riscv: Move kernel mapping outside of linear mapping")Signed-off-by Jisheng Zhang <[email protected]>--- arch/riscv/mm/kasan_init.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)arch/riscv/mm/kasan_init.c +1
-1@@ -169,7 +169,7 @@ static void __init kasan_shallow_populate(void *start, void *end)void __init kasan_init (void ) { -phys_addr_t _start, _end; +phys_addr_t p_start, p_end;u64 i;/* @@ -189,9 +189,9 @@ void __init kasan_init(void) (void *)kasan_mem_to_shadow((void *)VMALLOC_END));
arch/riscv/mm/kasan_init.c void __init kasan_init(void) · line 197
Quoted 10 lines
arch/riscv/mm/kasan_init.c +3
-3/* Populate the linear mapping */ -for_each_mem_range (i, &_start, &_end) { -void *start = (void *)__va (_start); -void *end = (void *)__va (_end); +for_each_mem_range (i, &p_start, &p_end) { +void *start = (void *)__va (p_start); +void *end = (void *)__va (p_end);if (start >= end)break ;
Thanks for this. I'd prefer a cleaner fix for tihs (maybe more '_'s in _end?), but I don't think we can do that without touching a bunch of code. Given that this is necessary to make the fix work for me, I'm just going to take it as-is.
This is on fixes.
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv