Skip to content

Commit 7df1ff5

Browse files
samitolvanenpalmer-dabbelt
authored andcommitted
riscv: mm: Update mmap_rnd_bits_max
ARCH_MMAP_RND_BITS_MAX is based on Sv39, which leaves a few potential bits of mmap randomness on the table if we end up enabling 4/5-level paging. Update mmap_rnd_bits_max to take the final address space size into account. This increases mmap_rnd_bits_max from 24 to 33 with Sv48/57. Signed-off-by: Sami Tolvanen <[email protected]> Reviewed-by: Kees Cook <[email protected]> Reviewed-by: Palmer Dabbelt <[email protected]> Acked-by: Palmer Dabbelt <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 71a5849 commit 7df1ff5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/riscv/mm/init.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,11 @@ static int __init print_no5lvl(char *p)
767767
}
768768
early_param("no5lvl", print_no5lvl);
769769

770+
static void __init set_mmap_rnd_bits_max(void)
771+
{
772+
mmap_rnd_bits_max = MMAP_VA_BITS - PAGE_SHIFT - 3;
773+
}
774+
770775
/*
771776
* There is a simple way to determine if 4-level is supported by the
772777
* underlying hardware: establish 1:1 mapping in 4-level page table mode
@@ -1081,6 +1086,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa)
10811086

10821087
#if defined(CONFIG_64BIT) && !defined(CONFIG_XIP_KERNEL)
10831088
set_satp_mode(dtb_pa);
1089+
set_mmap_rnd_bits_max();
10841090
#endif
10851091

10861092
/*

0 commit comments

Comments
 (0)