lkml.org 
[lkml]   [2012]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] [RFC] cross-arch: don't corrupt personality flags upon exec()
On 8/28/2012 2:49 PM, Jiri Kosina wrote:
> On Tue, 28 Aug 2012, Chris Metcalf wrote:
>>> On tile, the PER_LINUX_32BIT is always set for 32 bit compat tasks in a
>>> 64 bit kernel, which is harmless but wrong anyway. Also this, tile never
>>> calls set_personality, which is also harmless because it just means that
>>> exec_domain switching on tile is broken, but the only non-bogus
>>> exec_domain besides the default one is an experimental support for Acorn
>>> RISC OS binaries that was last updated in 2002 for for linux-2.5.49.
>> Arnd, thanks for the drive-by code review. Is this change the correct fix
>> for your observation?
>>
>> diff --git a/arch/tile/include/asm/elf.h b/arch/tile/include/asm/elf.h
>> index d16d006..fd31920 100644
>> --- a/arch/tile/include/asm/elf.h
>> +++ b/arch/tile/include/asm/elf.h
>> @@ -156,12 +156,12 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
>> #undef SET_PERSONALITY
>> #define SET_PERSONALITY(ex) \
>> do { \
>> - current->personality = PER_LINUX; \
>> + set_personality(PER_LINUX); \
>> current_thread_info()->status &= ~TS_COMPAT; \
>> } while (0)
>> #define COMPAT_SET_PERSONALITY(ex) \
>> do { \
>> - current->personality = PER_LINUX_32BIT; \
>> + set_personality(PER_LINUX); \
>> current_thread_info()->status |= TS_COMPAT; \
>> } while (0)
> Actually this is also wrong. You should be rather doing
>
> set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
>
> otherwise you clobber the upper personality bits upon exec().
>
> Something like the patch below. Either you can take it for tile, or I can
> ask Andrew to fold it into my tree-wide fix currently waiting in -mm. Just
> let me know.

It looks fine for tile, except that your change still uses PER_LINUX_32BIT,
which Arnd points out is wrong; my proposed patch changed it to just
PER_LINUX, though I'm not completely clear as to whether this is correct.
The tilegx compat mode is an ILP32 mode where the compiler emits 32-bit Elf
binaries and the compat layer is used to translate to and from 32-bit
pointer and long, but nothing else. It sounds like PER_LINUX applies
better than PER_LINUX_32BIT based on the fact that the extra 32-bit flag
isn't actually used in any architecture-independent code (nor in tile code,
which just checks whether something is a compat task per se, rather than
looking at the personality bits).

Since you have a treewide fix going anyway, I'm happy for you to push this
to Andrew. If it's OK with the one suggested change, you can add my

Acked-by: Chris Metcalf <cmetcalf@tilera.com>

--
Chris Metcalf, Tilera Corp.
http://www.tilera.com



\
 
 \ /
  Last update: 2012-08-28 21:41    [W:0.037 / U:0.452 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site