Skip to content

Commit c29fc62

Browse files
Alexandre Ghitipalmer-dabbelt
authored andcommitted
riscv: Fix wrong usage of lm_alias() when splitting a huge linear mapping
lm_alias() can only be used on kernel mappings since it explicitly uses __pa_symbol(), so simply fix this by checking where the address belongs to before. Fixes: 311cd2f ("riscv: Fix set_memory_XX() and set_direct_map_XX() by splitting huge linear mappings") Reported-by: syzbot+afb726d49f84c8d95ee1@syzkaller.appspotmail.com Closes: https://lore.kernel.org/linux-riscv/000000000000620dd0060c02c5e1@google.com/ Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> Reviewed-by: Charlie Jenkins <charlie@rivosinc.com> Link: https://lore.kernel.org/r/20231212195400.128457-1-alexghiti@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 420370f commit c29fc62

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

arch/riscv/mm/pageattr.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,13 @@ static int __set_memory(unsigned long addr, int numpages, pgprot_t set_mask,
305305
goto unlock;
306306
}
307307
} else if (is_kernel_mapping(start) || is_linear_mapping(start)) {
308-
lm_start = (unsigned long)lm_alias(start);
309-
lm_end = (unsigned long)lm_alias(end);
308+
if (is_kernel_mapping(start)) {
309+
lm_start = (unsigned long)lm_alias(start);
310+
lm_end = (unsigned long)lm_alias(end);
311+
} else {
312+
lm_start = start;
313+
lm_end = end;
314+
}
310315

311316
ret = split_linear_mapping(lm_start, lm_end);
312317
if (ret)

0 commit comments

Comments
 (0)