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

* [PATCH 2/2] MIPS: Don't clobber personality bits in 32-bit sys_personality().
  2010-11-02  0:43 [PATCH 1/2] MIPS: Quit clobbering personality bits David Daney
@ 2010-11-02  0:43 ` 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
  2 siblings, 2 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

If PER_LINUX32 has been set on a 32-bit kernel, only twiddle with the
low-order personality bits, let the upper bits pass through.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Cc: Camm Maguire <camm@maguirefamily.org>
---
 arch/mips/kernel/linux32.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index 6343b4a..a63f4e2 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -252,13 +252,13 @@ SYSCALL_DEFINE5(n32_msgrcv, int, msqid, u32, msgp, size_t, msgsz,
 SYSCALL_DEFINE1(32_personality, unsigned long, personality)
 {
 	int ret;
-	personality &= 0xffffffff;
+	unsigned int p = personality & 0xffffffff;
 	if (personality(current->personality) == PER_LINUX32 &&
-	    personality == PER_LINUX)
-		personality = PER_LINUX32;
-	ret = sys_personality(personality);
-	if (ret == PER_LINUX32)
-		ret = PER_LINUX;
+	    personality(p) == PER_LINUX)
+		p = (p & ~PER_MASK) | PER_LINUX32;
+	ret = sys_personality(p);
+	if (ret != -1 && personality(ret) == PER_LINUX32)
+		ret = (ret & ~PER_MASK) | PER_LINUX;
 	return ret;
 }
 
-- 
1.7.2.3

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

* Re: [PATCH 2/2] MIPS: Don't clobber personality bits in 32-bit sys_personality().
  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
  1 sibling, 0 replies; 6+ messages in thread
From: Sergei Shtylyov @ 2010-11-02 16:11 UTC (permalink / raw)
  To: David Daney; +Cc: linux-mips, ralf, Camm Maguire

Hello.

David Daney wrote:

> If PER_LINUX32 has been set on a 32-bit kernel, only twiddle with the
> low-order personality bits, let the upper bits pass through.

> Signed-off-by: David Daney <ddaney@caviumnetworks.com>
> Cc: Camm Maguire <camm@maguirefamily.org>
> ---
>  arch/mips/kernel/linux32.c |   12 ++++++------
>  1 files changed, 6 insertions(+), 6 deletions(-)

> diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
> index 6343b4a..a63f4e2 100644
> --- a/arch/mips/kernel/linux32.c
> +++ b/arch/mips/kernel/linux32.c
> @@ -252,13 +252,13 @@ SYSCALL_DEFINE5(n32_msgrcv, int, msqid, u32, msgp, size_t, msgsz,
>  SYSCALL_DEFINE1(32_personality, unsigned long, personality)
>  {
>  	int ret;
> -	personality &= 0xffffffff;
> +	unsigned int p = personality & 0xffffffff;

    I'd have inserted an empty line here...

>  	if (personality(current->personality) == PER_LINUX32 &&
> -	    personality == PER_LINUX)
> -		personality = PER_LINUX32;
> -	ret = sys_personality(personality);
> -	if (ret == PER_LINUX32)
> -		ret = PER_LINUX;
> +	    personality(p) == PER_LINUX)
> +		p = (p & ~PER_MASK) | PER_LINUX32;
> +	ret = sys_personality(p);
> +	if (ret != -1 && personality(ret) == PER_LINUX32)
> +		ret = (ret & ~PER_MASK) | PER_LINUX;
>  	return ret;
>  }

WBR, Sergei

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

* Re: [PATCH 1/2] MIPS: Quit clobbering personality bits.
  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 18:43 ` Camm Maguire
  2010-11-05 11:12 ` Ralf Baechle
  2 siblings, 0 replies; 6+ messages in thread
From: Camm Maguire @ 2010-11-02 18:43 UTC (permalink / raw)
  To: David Daney; +Cc: linux-mips, ralf

Thank you!
-- 
Camm Maguire			     		    camm@maguirefamily.org
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah

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

* Re: [PATCH 1/2] MIPS: Quit clobbering personality bits.
  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 18:43 ` [PATCH 1/2] MIPS: Quit clobbering personality bits Camm Maguire
@ 2010-11-05 11:12 ` Ralf Baechle
  2 siblings, 0 replies; 6+ messages in thread
From: Ralf Baechle @ 2010-11-05 11:12 UTC (permalink / raw)
  To: David Daney; +Cc: linux-mips, Camm Maguire

Thanks, applied.

  Ralf

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

* Re: [PATCH 2/2] MIPS: Don't clobber personality bits in 32-bit sys_personality().
  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
  1 sibling, 0 replies; 6+ messages in thread
From: Ralf Baechle @ 2010-11-05 15:17 UTC (permalink / raw)
  To: David Daney; +Cc: linux-mips, Camm Maguire, Sergei Shtylyov

Applied, including some whitespace whitewash according to my personal
religion :)

Thanks,

  Ralf

^ permalink raw reply	[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.