BTW, just as a followup, David Daney supposedly fixed this in the
kernel:

From: David Daney <[email protected]>
Subject: [PATCH 1/2] MIPS: Quit clobbering personality bits.
To: [email protected], [email protected]
Cc: David Daney <[email protected]>,        Camm Maguire 
<[email protected]>
Date: Mon,  1 Nov 2010 17:43:07 -0700

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 <[email protected]>
Signed-off-by: David Daney <[email protected]>
Cc: Camm Maguire <[email protected]>
---
 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





From: David Daney <[email protected]>
Subject: [PATCH 2/2] MIPS: Don't clobber personality bits in 32-bit 
sys_personality().
To: [email protected], [email protected]
Cc: David Daney <[email protected]>,        Camm Maguire 
<[email protected]>
Date: Mon,  1 Nov 2010 17:43:08 -0700

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 <[email protected]>
Cc: Camm Maguire <[email protected]>
---
 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





Take care,

Andreas Barth <[email protected]> writes:

> * Camm Maguire ([email protected]) [101031 20:30]:
>> Thanks so much!  Any idea on what might have caused this recent
>> failure on phrixos:
>> 
>> checking for sbrk... yes
>> checking for ADDR_NO_RANDOMIZE constant... yes, 40000
>> checking for personality(ADDR_NO_RANDOMIZE) support... yes
>> checking that sbrk is (now) non-random... no
>> Cannot build with randomized sbrk. Your options:
>>  - upgrade to a kernel/libc that knows about personality(ADDR_NO_RANDOMIZE)
>
> The output seems to indicate that ADDR_NO_RANDOMIZE is available?
>
>>  - recompile your kernel with CONFIG_COMPAT_BRK (if it has that option)
>>  - run sysctl kernel.randomize_va_space=0 before using gcl
>> 
>> gcl and dependencies re-exec with ADDR_NO_RANDOMIZE set to get
>> traditional sbrk contiguous to the .data segment end.
>
> I upgraded to the Debian 2.6.36-rc6-loongson-2f kernel (the machine
> runs now for the first time an default distribution kernel). That
> might have some impact - I don't know.
>
> Also, kernel.randomize_va_space=2 currently.
>
>
>
> Andi
>
>
>

-- 
Camm Maguire                                        [email protected]
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]
Archive: http://lists.debian.org/[email protected]

Reply via email to