Skip to content

Commit

Permalink
cross-arch: don't corrupt personality flags upon exec()
Browse files Browse the repository at this point in the history
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 f9783ec ("[S390] Do not clobber personality flags on
exec") and 59e4c3a ("powerpc/32: Don't clobber personality flags on
exec") in a similar way already).

Signed-off-by: Jiri Kosina <[email protected]>
Cc: Haavard Skinnemoen <[email protected]>
Cc: Hans-Christian Egtvedt <[email protected]>
Cc: Mike Frysinger <[email protected]>
Cc: Mark Salter <[email protected]>
Cc: Mikael Starvik <[email protected]>
Cc: Jesper Nilsson <[email protected]>
Cc: David Howells <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Cc: Richard Kuo <[email protected]>
Cc: Hirokazu Takata <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Koichi Yasutake <[email protected]>
Cc: Jonas Bonn <[email protected]>
Cc: Chen Liqin <[email protected]>
Cc: Lennox Wu <[email protected]>
Cc: Paul Mundt <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Chris Zankel <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Jiri Kosina authored and torvalds committed Oct 5, 2012
1 parent 0d118d7 commit 16f3e95
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 16 deletions.
3 changes: 2 additions & 1 deletion arch/avr32/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ typedef struct user_fpu_struct elf_fpregset_t;

#define ELF_PLATFORM (NULL)

#define SET_PERSONALITY(ex) set_personality(PER_LINUX_32BIT)
#define SET_PERSONALITY(ex) \
set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK)))

#endif /* __ASM_AVR32_ELF_H */
3 changes: 2 additions & 1 deletion arch/blackfin/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

#endif
3 changes: 2 additions & 1 deletion arch/c6x/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ 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)))

/* C6X specific section types */
#define SHT_C6000_UNWIND 0x70000001
Expand Down
3 changes: 2 additions & 1 deletion arch/cris/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ typedef unsigned long elf_fpregset_t;

#define ELF_PLATFORM (NULL)

#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
#define SET_PERSONALITY(ex) \
set_personality(PER_LINUX | (current->personality & (~PER_MASK)))

#endif
3 changes: 2 additions & 1 deletion arch/frv/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,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)))

#endif
3 changes: 2 additions & 1 deletion arch/h8300/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ typedef unsigned long elf_fpregset_t;

#define ELF_PLATFORM (NULL)

#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
#define SET_PERSONALITY(ex) \
set_personality(PER_LINUX | (current->personality & (~PER_MASK)))

#define R_H8_NONE 0
#define R_H8_DIR32 1
Expand Down
3 changes: 2 additions & 1 deletion arch/hexagon/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ do { \
#define ELF_PLATFORM (NULL)

#ifdef __KERNEL__
#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
#define SET_PERSONALITY(ex) \
set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
#endif

#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
Expand Down
3 changes: 2 additions & 1 deletion arch/m32r/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ typedef elf_fpreg_t elf_fpregset_t;
intent than poking at uname or /proc/cpuinfo. */
#define ELF_PLATFORM (NULL)

#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
#define SET_PERSONALITY(ex) \
set_personality(PER_LINUX | (current->personality & (~PER_MASK)))

#endif /* _ASM_M32R__ELF_H */
3 changes: 2 additions & 1 deletion arch/m68k/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ typedef struct user_m68kfp_struct elf_fpregset_t;

#define ELF_PLATFORM (NULL)

#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
#define SET_PERSONALITY(ex) \
set_personality(PER_LINUX | (current->personality & (~PER_MASK)))

#endif
3 changes: 2 additions & 1 deletion arch/microblaze/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ do { \
} while (0)

#ifdef __KERNEL__
#define SET_PERSONALITY(ex) set_personality(PER_LINUX_32BIT)
#define SET_PERSONALITY(ex) \
set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK)))
#endif

#endif /* __uClinux__ */
Expand Down
3 changes: 2 additions & 1 deletion arch/mn10300/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ do { \
#define ELF_PLATFORM (NULL)

#ifdef __KERNEL__
#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
#define SET_PERSONALITY(ex) \
set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
#endif

#endif /* _ASM_ELF_H */
3 changes: 2 additions & 1 deletion arch/openrisc/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ extern void dump_elf_thread(elf_greg_t *dest, struct pt_regs *pt);

#define ELF_PLATFORM (NULL)

#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
#define SET_PERSONALITY(ex) \
set_personality(PER_LINUX | (current->personality & (~PER_MASK)))

#endif /* __KERNEL__ */
#endif
2 changes: 1 addition & 1 deletion arch/score/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ typedef elf_fpreg_t elf_fpregset_t;

#define SET_PERSONALITY(ex) \
do { \
set_personality(PER_LINUX); \
set_personality(PER_LINUX | (current->personality & (~PER_MASK))); \
} while (0)

struct task_struct;
Expand Down
3 changes: 2 additions & 1 deletion arch/sh/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ do { \
} while (0)
#endif

#define SET_PERSONALITY(ex) set_personality(PER_LINUX_32BIT)
#define SET_PERSONALITY(ex) \
set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK)))

#ifdef CONFIG_VSYSCALL
/* vDSO has arch_setup_additional_pages */
Expand Down
3 changes: 2 additions & 1 deletion arch/sparc/include/asm/elf_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ typedef struct {

#define ELF_PLATFORM (NULL)

#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
#define SET_PERSONALITY(ex) \
set_personality(PER_LINUX | (current->personality & (~PER_MASK)))

#endif /* !(__ASMSPARC_ELF_H) */
3 changes: 2 additions & 1 deletion arch/xtensa/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ typedef struct {
#endif
} elf_xtregs_t;

#define SET_PERSONALITY(ex) set_personality(PER_LINUX_32BIT)
#define SET_PERSONALITY(ex) \
set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK)))

struct task_struct;

Expand Down

0 comments on commit 16f3e95

Please sign in to comment.