powerpc/mm: Enable full randomisation of memory mappings
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Sat, 9 Apr 2022 17:17:35 +0000 (19:17 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 5 May 2022 12:11:58 +0000 (22:11 +1000)
commit5cf7f9a0a54e93a6d3361de5f4ba4358b054c6c2
tree91261076edc16a02ab4f3b99008bc3ac1cc0d20f
parentab57bd7570d4393beb5a91bf092ed54e9c3574a2
powerpc/mm: Enable full randomisation of memory mappings

Do like most other architectures and provide randomisation also to
"legacy" memory mappings, by adding the random factor to
mm->mmap_base in arch_pick_mmap_layout().

See commit 8b8addf891de ("x86/mm/32: Enable full randomization on
i386 and X86_32") for all explanations and benefits of that mmap
randomisation.

At the moment, slice_find_area_bottomup() doesn't use mm->mmap_base
but uses the fixed TASK_UNMAPPED_BASE instead.
slice_find_area_bottomup() being used as a fallback to
slice_find_area_topdown(), it can't use mm->mmap_base
directly.

Instead of always using TASK_UNMAPPED_BASE as base address, leave
it to the caller. When called from slice_find_area_topdown()
TASK_UNMAPPED_BASE is used. Otherwise mm->mmap_base is used.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/417fb10dde828534c73a03138b49621d74f4e5be.1649523076.git.christophe.leroy@csgroup.eu
arch/powerpc/mm/book3s64/slice.c
arch/powerpc/mm/mmap.c