Skip to content

Commit c6f5b00

Browse files
keestorvalds
authored andcommitted
s390: redefine randomize_et_dyn for ELF_ET_DYN_BASE
In preparation for moving ET_DYN randomization into the ELF loader (which requires a static ELF_ET_DYN_BASE), this redefines s390's existing ET_DYN randomization in a call to arch_mmap_rnd(). This refactoring results in the same ET_DYN randomization on s390. Signed-off-by: Kees Cook <[email protected]> Acked-by: Martin Schwidefsky <[email protected]> Cc: Heiko Carstens <[email protected]> Reviewed-by: Ingo Molnar <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 2b68f6c commit c6f5b00

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

arch/s390/include/asm/elf.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,12 @@ extern unsigned int vdso_enabled;
161161
/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
162162
use of this is to invoke "./ld.so someprog" to test out a new version of
163163
the loader. We need to make sure that it is out of the way of the program
164-
that it will "exec", and that there is sufficient room for the brk. */
165-
164+
that it will "exec", and that there is sufficient room for the brk. 64-bit
165+
tasks are aligned to 4GB. */
166166
extern unsigned long randomize_et_dyn(void);
167-
#define ELF_ET_DYN_BASE randomize_et_dyn()
167+
#define ELF_ET_DYN_BASE (randomize_et_dyn() + (is_32bit_task() ? \
168+
(STACK_TOP / 3 * 2) : \
169+
(STACK_TOP / 3 * 2) & ~((1UL << 32) - 1)))
168170

169171
/* This yields a mask that user programs can use to figure out what
170172
instruction set this CPU supports. */

arch/s390/mm/mmap.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
179179

180180
unsigned long randomize_et_dyn(void)
181181
{
182-
unsigned long base;
183-
184-
base = STACK_TOP / 3 * 2;
185-
if (!is_32bit_task())
186-
/* Align to 4GB */
187-
base &= ~((1UL << 32) - 1);
188-
189182
if (current->flags & PF_RANDOMIZE)
190-
base += arch_mmap_rnd();
183+
return arch_mmap_rnd();
191184

192-
return base;
185+
return 0UL;
193186
}
194187

195188
#ifndef CONFIG_64BIT

0 commit comments

Comments
 (0)