* [PATCH] parisc: Allow mmap(MAP_STACK) memory to automatically expand upwards
@ 2024-09-08 18:51 Helge Deller
0 siblings, 0 replies; only message in thread
From: Helge Deller @ 2024-09-08 18:51 UTC (permalink / raw)
To: linux-parisc; +Cc: Camm Maguire
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.
Reported-by: Camm Maguire <camm@maguirefamily.org>
Signed-off-by: Helge Deller <deller@gmx.de>
Cc: stable@vger.kernel.org # v5.10+
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__ */
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-09-08 18:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-08 18:51 [PATCH] parisc: Allow mmap(MAP_STACK) memory to automatically expand upwards Helge Deller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox