Skip to content

Commit

Permalink
parisc: Allow mmap(MAP_STACK) memory to automatically expand upwards
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
Cc: [email protected]	# v5.10+
  • Loading branch information
hdeller committed Sep 16, 2024
1 parent 75f653f commit 5d69896
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions arch/parisc/include/asm/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */

0 comments on commit 5d69896

Please sign in to comment.