[S390] Randomize PIEs
authorHeiko Carstens <heiko.carstens@de.ibm.com>
Wed, 12 Jan 2011 08:55:31 +0000 (09:55 +0100)
committerMartin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com>
Wed, 12 Jan 2011 08:55:25 +0000 (09:55 +0100)
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>
arch/s390/include/asm/elf.h
arch/s390/kernel/process.c

index 457fb7c162368b516ddbaacda01a294e04794fde..10c029cfcc7d3c7d8e8feda790c6c3e885fa34a9 100644 (file)
@@ -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. */
index 26d48fe72999de2ab257e59e29ec95736eb89523..a895e69379f75233a84ab98681fbd9dc6421fbe1 100644 (file)
@@ -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;
+}
This page took 0.031287 seconds and 5 git commands to generate.