Skip to contentSkip to conversation

ppc32: Don't clobber personality flags on exec

PATCH Andreas Schwab 2 participants 2 messages Apr 16, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Now that ppc32 implements address randomization it also wants to inherit personality flags like ADDR_NO_RANDOMIZE across exec, for things like `setarch ppc -R' to work. But the ppc32 version of SET_PERSONALITY forcefully sets PER_LINUX, clearing all personality flags. So be careful about preserving the flags.

---
 arch/powerpc/include/asm/elf.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/elf.h +2 -1
Index: linux-2.6.30-rc1/arch/powerpc/include/asm/elf.h
===================================================================
@@ -258,7 +258,8 @@ do {								\
 # define elf_read_implies_exec(ex, exec_stk) (test_thread_flag(TIF_32BIT) ? \
 		(exec_stk != EXSTACK_DISABLE_X) : 0)
 #else 
-# define SET_PERSONALITY(ex) set_personality(PER_LINUX)
+# define SET_PERSONALITY(ex) \
+  set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
 #endif /* __powerpc64__ */
 
 extern int dcache_bsize;
Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#1 lore raw

From: Andreas Schwab <[email protected]>
Date: Thu, 16 Apr 2009 18:22:01 +0200

Quoted 7 lines

Now that ppc32 implements address randomization it also wants to inherit personality flags like ADDR_NO_RANDOMIZE across exec, for things like `setarch ppc -R' to work. But the ppc32 version of SET_PERSONALITY forcefully sets PER_LINUX, clearing all personality flags. So be careful about preserving the flags.

Grumble, sparc has the same bugs... thanks for finding this.