Skip to content

Commit 5d69896

Browse files
committed
parisc: Allow mmap(MAP_STACK) memory to automatically expand upwards
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+
1 parent 75f653f commit 5d69896

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

arch/parisc/include/asm/mman.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,18 @@ static inline bool arch_memory_deny_write_exec_supported(void)
1111
}
1212
#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported
1313

14+
static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags)
15+
{
16+
/*
17+
* The stack on parisc grows upwards, so if userspace requests memory
18+
* for a stack, mark it with VM_GROWSUP so that the stack expansion in
19+
* the fault handler will work.
20+
*/
21+
if (flags & MAP_STACK)
22+
return VM_GROWSUP;
23+
24+
return 0;
25+
}
26+
#define arch_calc_vm_flag_bits(flags) arch_calc_vm_flag_bits(flags)
27+
1428
#endif /* __ASM_MMAN_H__ */

0 commit comments

Comments
 (0)