From: Arjan van de Ven <arjan@infradead.org>

Introduce a personality that disables randomisation, so that users can use
setarch and related commands to run specific applications without
randomisation.

Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/fs/binfmt_elf.c             |    2 +-
 25-akpm/include/linux/personality.h |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff -puN fs/binfmt_elf.c~randomisation-addr_no_randomize-personality fs/binfmt_elf.c
--- 25/fs/binfmt_elf.c~randomisation-addr_no_randomize-personality	2005-02-22 18:16:07.000000000 -0800
+++ 25-akpm/fs/binfmt_elf.c	2005-02-22 18:16:07.000000000 -0800
@@ -753,7 +753,7 @@ static int load_elf_binary(struct linux_
 	if (elf_read_implies_exec(loc->elf_ex, executable_stack))
 		current->personality |= READ_IMPLIES_EXEC;
 
-	if (executable_stack == EXSTACK_DISABLE_X && randomize_va_space)
+	if ( !(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
 		current->flags |= PF_RANDOMIZE;
 	arch_pick_mmap_layout(current->mm);
 
diff -puN include/linux/personality.h~randomisation-addr_no_randomize-personality include/linux/personality.h
--- 25/include/linux/personality.h~randomisation-addr_no_randomize-personality	2005-02-22 18:16:07.000000000 -0800
+++ 25-akpm/include/linux/personality.h	2005-02-22 18:16:07.000000000 -0800
@@ -18,6 +18,7 @@ extern int		__set_personality(unsigned l
  * These occupy the top three bytes.
  */
 enum {
+	ADDR_NO_RANDOMIZE = 	0x0040000,	/* disable randomization of VA space */
 	FDPIC_FUNCPTRS =	0x0080000,	/* userspace function ptrs point to descriptors
 						 * (signal handling)
 						 */
@@ -35,7 +36,7 @@ enum {
  * Security-relevant compatibility flags that must be
  * cleared upon setuid or setgid exec:
  */
-#define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC)
+#define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC|ADDR_NO_RANDOMIZE)
 
 /*
  * Personality types.
_