parisc: fix mmap_base calculation when stack grows upwards
authorHelge Deller <deller@gmx.de>
Mon, 13 Nov 2023 10:12:57 +0000 (11:12 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Nov 2023 17:20:08 +0000 (17:20 +0000)
commit2345ef960d6663c9b52f8f73fb5ca05732c56144
treeb81a09ad441ce7c653f58c452ea899f5b1aeebf7
parentc0940ebe428777c9fe5856d6b305d75ca3e610ae
parisc: fix mmap_base calculation when stack grows upwards

commit 5f74f820f6fc844b95f9e5e406e0a07d97510420 upstream.

Matoro reported various userspace crashes on the parisc platform with kernel
6.6 and bisected it to commit 3033cd430768 ("parisc: Use generic mmap top-down
layout and brk randomization").

That commit switched parisc to use the common infrastructure to calculate
mmap_base, but missed that the mmap_base() function takes care for
architectures where the stack grows downwards only.

Fix the mmap_base() calculation to include the stack-grows-upwards case
and thus fix the userspace crashes on parisc.

Link: https://lkml.kernel.org/r/ZVH2qeS1bG7/1J/l@p100
Fixes: 3033cd430768 ("parisc: Use generic mmap top-down layout and brk randomization")
Signed-off-by: Helge Deller <deller@gmx.de>
Reported-by: matoro <matoro_mailinglist_kernel@matoro.tk>
Tested-by: matoro <matoro_mailinglist_kernel@matoro.tk>
Cc: <stable@vger.kernel.org> [6.6+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/parisc/Kconfig
arch/parisc/include/asm/elf.h
arch/parisc/include/asm/processor.h
arch/parisc/kernel/sys_parisc.c
mm/util.c