Re: [PATCH] [RFC] cross-arch: don't corrupt personality flags uponexec()

From: Andrew Morton
Date: Wed Aug 15 2012 - 18:45:16 EST


On Mon, 13 Aug 2012 15:19:40 +0200 (CEST)
Jiri Kosina <jkosina@xxxxxxx> wrote:

> On Fri, 3 Aug 2012, Jiri Kosina wrote:
>
> > Historically, the top three bytes of personality have been used for things
> > such as ADDR_NO_RANDOMIZE, which made sense only for specific
> > architectures.
> >
> > We now, however, have a flag there that is general no matter the
> > architecture (UNAME26); generally we have to be careful to preserve the
> > personality flags across exec().
> >
> > This patch tries to fix all architectures that forcefully overwrite
> > personality flags during exec() (ppc32 and s390 have been fixed recently
> > by commits f9783ec86 and 59e4c3a2f in a similar way already).
> >
> > Signed-off-by: Jiri Kosina <jkosina@xxxxxxx>
> > ---
> >
> > Untested, as I don't own the hardware.
>
> Ping, Acks, Nacks, anyone?

Silence means "I'll fix it if you broke it" ;)

> Andrew, if noone has any objections, I guess this should perhaps go
> through -mm.

Sure. But..


> > --- a/arch/blackfin/include/asm/elf.h
> > +++ b/arch/blackfin/include/asm/elf.h
> > @@ -132,6 +132,7 @@ do { \
> >
> > #define ELF_PLATFORM (NULL)
> >
> > -#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
> > +#define SET_PERSONALITY(ex) \
> > + set_personality(PER_LINUX | (current->personality & (~PER_MASK)))

This is repeated soooo many times. Could we not just delete it and, in
include/linux/elf.h, do:

#ifndef SET_PERSONALITY
<that stuff>
#endif

?

If any SET_PERSONALITY-using code is including asm/elf.h directly then
it will reliably break and will get fixed.

Extra marks will be awarded if you can work out whether to use
PER_LINUX_32BIT ;)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/