All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] MIPS: Quit clobbering personality bits.
@ 2010-11-02  0:43 David Daney
  2010-11-02  0:43 ` [PATCH 2/2] MIPS: Don't clobber personality bits in 32-bit sys_personality() David Daney
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: David Daney @ 2010-11-02  0:43 UTC (permalink / raw)
  To: linux-mips, ralf; +Cc: David Daney, Camm Maguire

The high bits of current->personality carry settings that we don't
want to clobber on each exec.  Only clobber them if the lower bits
that indicate either PER_LINUX or PER_LINUX32 are invalid.

The clobbering prevents us from using useful bits like
ADDR_NO_RANDOMIZE.

Reported-by: Camm Maguire <camm@maguirefamily.org>
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Cc: Camm Maguire <camm@maguirefamily.org>
---
 arch/mips/include/asm/elf.h |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
index fd1d39e..2ef5e82 100644
--- a/arch/mips/include/asm/elf.h
+++ b/arch/mips/include/asm/elf.h
@@ -249,7 +249,8 @@ extern struct mips_abi mips_abi_n32;
 
 #define SET_PERSONALITY(ex)						\
 do {									\
-	set_personality(PER_LINUX);					\
+	if (personality(current->personality) != PER_LINUX)		\
+		set_personality(PER_LINUX);				\
 									\
 	current->thread.abi = &mips_abi;				\
 } while (0)
@@ -296,6 +297,7 @@ do {									\
 
 #define SET_PERSONALITY(ex)						\
 do {									\
+	unsigned int p;							\
 	clear_thread_flag(TIF_32BIT_REGS);				\
 	clear_thread_flag(TIF_32BIT_ADDR);				\
 									\
@@ -304,7 +306,8 @@ do {									\
 	else								\
 		current->thread.abi = &mips_abi;			\
 									\
-	if (current->personality != PER_LINUX32)			\
+	p = personality(current->personality);				\
+	if (p != PER_LINUX32 && p != PER_LINUX)				\
 		set_personality(PER_LINUX);				\
 } while (0)
 
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-11-05 15:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-02  0:43 [PATCH 1/2] MIPS: Quit clobbering personality bits David Daney
2010-11-02  0:43 ` [PATCH 2/2] MIPS: Don't clobber personality bits in 32-bit sys_personality() David Daney
2010-11-02 16:11   ` Sergei Shtylyov
2010-11-05 15:17   ` Ralf Baechle
2010-11-02 18:43 ` [PATCH 1/2] MIPS: Quit clobbering personality bits Camm Maguire
2010-11-05 11:12 ` Ralf Baechle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.