Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9046e401 authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky
Browse files

[S390] mmap: consider stack address randomization



Consider stack address randomization when calulating mmap_base for
flexible mmap layout . Because of address randomization the stack
address can be up to 8MB lower than STACK_TOP.
When calculating mmap_base this isn't taken into account, which could
lead to the case that the gap between the real stack top and mmap_base
is lower than what ulimit specifies for the maximum stack size.

Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 7a63fa1a
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -206,6 +206,8 @@ do { \
	current->mm->context.noexec == 0;		\
	current->mm->context.noexec == 0;		\
})
})


#define STACK_RND_MASK	0x7ffUL

#define ARCH_DLINFO							    \
#define ARCH_DLINFO							    \
do {									    \
do {									    \
	if (vdso_enabled)						    \
	if (vdso_enabled)						    \
+10 −1
Original line number Original line Diff line number Diff line
@@ -30,6 +30,15 @@
#include <asm/pgalloc.h>
#include <asm/pgalloc.h>
#include <asm/compat.h>
#include <asm/compat.h>


static unsigned long stack_maxrandom_size(void)
{
	if (!(current->flags & PF_RANDOMIZE))
		return 0;
	if (current->personality & ADDR_NO_RANDOMIZE)
		return 0;
	return STACK_RND_MASK << PAGE_SHIFT;
}

/*
/*
 * Top of mmap area (just below the process stack).
 * Top of mmap area (just below the process stack).
 *
 *
@@ -47,7 +56,7 @@ static inline unsigned long mmap_base(void)
	else if (gap > MAX_GAP)
	else if (gap > MAX_GAP)
		gap = MAX_GAP;
		gap = MAX_GAP;


	return STACK_TOP - (gap & PAGE_MASK);
	return STACK_TOP - stack_maxrandom_size() - (gap & PAGE_MASK);
}
}


static inline int mmap_is_legacy(void)
static inline int mmap_is_legacy(void)