powerpc: Randomise PIEs
authorAnton Blanchard <anton@samba.org>
Sun, 22 Feb 2009 01:50:07 +0000 (01:50 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Mon, 23 Feb 2009 04:53:21 +0000 (15:53 +1100)
Randomise ELF_ET_DYN_BASE, which is used when loading position independent
executables.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/include/asm/elf.h
arch/powerpc/kernel/process.c

index 968b37f7a9f8a9c98ef9e7f3e3f723165ad115d8..1a856b15226e70e1c40f7b4d8d2f347c19cc2af8 100644 (file)
@@ -179,7 +179,8 @@ typedef elf_fpreg_t elf_vsrreghalf_t32[ELF_NVSRHALFREG];
    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         (0x20000000)
+extern unsigned long randomize_et_dyn(unsigned long base);
+#define ELF_ET_DYN_BASE                (randomize_et_dyn(0x20000000))
 
 /*
  * Our registers are always unsigned longs, whether we're a 32 bit
index 30b149ce7598d9cd27d93fb8740eb08fabc7bd1a..eac064948780bed15a57c634aa363c4145349f96 100644 (file)
@@ -1170,3 +1170,13 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
 
        return ret;
 }
+
+unsigned long randomize_et_dyn(unsigned long base)
+{
+       unsigned long ret = PAGE_ALIGN(base + brk_rnd());
+
+       if (ret < base)
+               return base;
+
+       return ret;
+}