summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorHelge Deller <deller@kernel.org>2024-09-08 21:51:17 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-10-10 12:57:49 +0300
commit62f3e58c4e395074c81d1abead71599713143f93 (patch)
treea5bb66ed111bbaa43162b941f60c73e0e9f06cba /arch
parent42451ba0d6e1e7e1aaed42cbbf495721a3a39a8f (diff)
downloadlinux-62f3e58c4e395074c81d1abead71599713143f93.tar.xz
parisc: Allow mmap(MAP_STACK) memory to automatically expand upwards
commit 5d698966fa7b452035c44c937d704910bf3440dd upstream. When userspace allocates memory with mmap() in order to be used for stack, allow this memory region to automatically expand upwards up until the current maximum process stack size. The fault handler checks if the VM_GROWSUP bit is set in the vm_flags field of a memory area before it allows it to expand. This patch modifies the parisc specific code only. A RFC for a generic patch to modify mmap() for all architectures was sent to the mailing list but did not get enough Acks. Reported-by: Camm Maguire <camm@maguirefamily.org> Signed-off-by: Helge Deller <deller@gmx.de> Cc: stable@vger.kernel.org # v5.10+ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/parisc/include/asm/mman.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/arch/parisc/include/asm/mman.h b/arch/parisc/include/asm/mman.h
index 47c5a1991d10..89b6beeda0b8 100644
--- a/arch/parisc/include/asm/mman.h
+++ b/arch/parisc/include/asm/mman.h
@@ -11,4 +11,18 @@ static inline bool arch_memory_deny_write_exec_supported(void)
}
#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported
+static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags)
+{
+ /*
+ * The stack on parisc grows upwards, so if userspace requests memory
+ * for a stack, mark it with VM_GROWSUP so that the stack expansion in
+ * the fault handler will work.
+ */
+ if (flags & MAP_STACK)
+ return VM_GROWSUP;
+
+ return 0;
+}
+#define arch_calc_vm_flag_bits(flags) arch_calc_vm_flag_bits(flags)
+
#endif /* __ASM_MMAN_H__ */