Skip to content

Commit

Permalink
[S390] Randomize PIEs
Browse files Browse the repository at this point in the history
Randomize ELF_ET_DYN_BASE, which is used when loading position
independent executables.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
  • Loading branch information
Heiko Carstens authored and Martin Schwidefsky committed Jan 12, 2011
1 parent 3351918 commit d2c9dfc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion arch/s390/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ extern unsigned int vdso_enabled;
use of this is to invoke "./ld.so someprog" to test out a new version of
the loader. We need to make sure that it is out of the way of the program
that it will "exec", and that there is sufficient room for the brk. */
#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)

extern unsigned long randomize_et_dyn(unsigned long base);
#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))

/* This yields a mask that user programs can use to figure out what
instruction set this CPU supports. */
Expand Down
11 changes: 11 additions & 0 deletions arch/s390/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,14 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
return mm->brk;
return ret;
}

unsigned long randomize_et_dyn(unsigned long base)
{
unsigned long ret = PAGE_ALIGN(base + brk_rnd());

if (!(current->flags & PF_RANDOMIZE))
return base;
if (ret < base)
return base;
return ret;
}

0 comments on commit d2c9dfc

Please sign in to comment.