aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2012-10-04 20:12:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-05 14:04:47 -0400
commit16f3e95b3209c4d9080e3a3c6bb9955a0e7cfa95 (patch)
tree3ea326a41bd3709d4cb23bdf89ea4084e41dc6f5
parent0d118d7f49c8aa0b74be83bc2ad134b71106cab4 (diff)
cross-arch: don't corrupt personality flags upon exec()
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 f9783ec862ea ("[S390] Do not clobber personality flags on exec") and 59e4c3a2fe9c ("powerpc/32: Don't clobber personality flags on exec") in a similar way already). Signed-off-by: Jiri Kosina <jkosina@suse.cz> Cc: Haavard Skinnemoen <hskinnemoen@gmail.com> Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no> Cc: Mike Frysinger <vapier@gentoo.org> Cc: Mark Salter <msalter@redhat.com> Cc: Mikael Starvik <starvik@axis.com> Cc: Jesper Nilsson <jesper.nilsson@axis.com> Cc: David Howells <dhowells@redhat.com> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Cc: Richard Kuo <rkuo@codeaurora.org> Cc: Hirokazu Takata <takata@linux-m32r.org> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Michal Simek <monstr@monstr.eu> Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com> Cc: Jonas Bonn <jonas@southpole.se> Cc: Chen Liqin <liqin.chen@sunplusct.com> Cc: Lennox Wu <lennox.wu@gmail.com> Cc: Paul Mundt <lethal@linux-sh.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Chris Zankel <chris@zankel.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/avr32/include/asm/elf.h3
-rw-r--r--arch/blackfin/include/asm/elf.h3
-rw-r--r--arch/c6x/include/asm/elf.h3
-rw-r--r--arch/cris/include/asm/elf.h3
-rw-r--r--arch/frv/include/asm/elf.h3
-rw-r--r--arch/h8300/include/asm/elf.h3
-rw-r--r--arch/hexagon/include/asm/elf.h3
-rw-r--r--arch/m32r/include/asm/elf.h3
-rw-r--r--arch/m68k/include/asm/elf.h3
-rw-r--r--arch/microblaze/include/asm/elf.h3
-rw-r--r--arch/mn10300/include/asm/elf.h3
-rw-r--r--arch/openrisc/include/asm/elf.h3
-rw-r--r--arch/score/include/asm/elf.h2
-rw-r--r--arch/sh/include/asm/elf.h3
-rw-r--r--arch/sparc/include/asm/elf_32.h3
-rw-r--r--arch/xtensa/include/asm/elf.h3
16 files changed, 31 insertions, 16 deletions
diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
index 3b3159b710d4..e2c328739808 100644
--- a/arch/avr32/include/asm/elf.h
+++ b/arch/avr32/include/asm/elf.h
@@ -102,6 +102,7 @@ typedef struct user_fpu_struct elf_fpregset_t;
102 102
103#define ELF_PLATFORM (NULL) 103#define ELF_PLATFORM (NULL)
104 104
105#define SET_PERSONALITY(ex) set_personality(PER_LINUX_32BIT) 105#define SET_PERSONALITY(ex) \
106 set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK)))
106 107
107#endif /* __ASM_AVR32_ELF_H */ 108#endif /* __ASM_AVR32_ELF_H */
diff --git a/arch/blackfin/include/asm/elf.h b/arch/blackfin/include/asm/elf.h
index e6c6812a9abd..14bc98ff668f 100644
--- a/arch/blackfin/include/asm/elf.h
+++ b/arch/blackfin/include/asm/elf.h
@@ -132,6 +132,7 @@ do { \
132 132
133#define ELF_PLATFORM (NULL) 133#define ELF_PLATFORM (NULL)
134 134
135#define SET_PERSONALITY(ex) set_personality(PER_LINUX) 135#define SET_PERSONALITY(ex) \
136 set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
136 137
137#endif 138#endif
diff --git a/arch/c6x/include/asm/elf.h b/arch/c6x/include/asm/elf.h
index f4552db20b4a..32b997126adf 100644
--- a/arch/c6x/include/asm/elf.h
+++ b/arch/c6x/include/asm/elf.h
@@ -77,7 +77,8 @@ do { \
77 77
78#define ELF_PLATFORM (NULL) 78#define ELF_PLATFORM (NULL)
79 79
80#define SET_PERSONALITY(ex) set_personality(PER_LINUX) 80#define SET_PERSONALITY(ex) \
81 set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
81 82
82/* C6X specific section types */ 83/* C6X specific section types */
83#define SHT_C6000_UNWIND 0x70000001 84#define SHT_C6000_UNWIND 0x70000001
diff --git a/arch/cris/include/asm/elf.h b/arch/cris/include/asm/elf.h
index 8a3d8e2b33c1..8182f2dc89d0 100644
--- a/arch/cris/include/asm/elf.h
+++ b/arch/cris/include/asm/elf.h
@@ -86,6 +86,7 @@ typedef unsigned long elf_fpregset_t;
86 86
87#define ELF_PLATFORM (NULL) 87#define ELF_PLATFORM (NULL)
88 88
89#define SET_PERSONALITY(ex) set_personality(PER_LINUX) 89#define SET_PERSONALITY(ex) \
90 set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
90 91
91#endif 92#endif
diff --git a/arch/frv/include/asm/elf.h b/arch/frv/include/asm/elf.h
index c3819804a74b..9ccbc80f0b11 100644
--- a/arch/frv/include/asm/elf.h
+++ b/arch/frv/include/asm/elf.h
@@ -137,6 +137,7 @@ do { \
137 137
138#define ELF_PLATFORM (NULL) 138#define ELF_PLATFORM (NULL)
139 139
140#define SET_PERSONALITY(ex) set_personality(PER_LINUX) 140#define SET_PERSONALITY(ex) \
141 set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
141 142
142#endif 143#endif
diff --git a/arch/h8300/include/asm/elf.h b/arch/h8300/include/asm/elf.h
index c24fa250d653..41193c396bff 100644
--- a/arch/h8300/include/asm/elf.h
+++ b/arch/h8300/include/asm/elf.h
@@ -54,7 +54,8 @@ typedef unsigned long elf_fpregset_t;
54 54
55#define ELF_PLATFORM (NULL) 55#define ELF_PLATFORM (NULL)
56 56
57#define SET_PERSONALITY(ex) set_personality(PER_LINUX) 57#define SET_PERSONALITY(ex) \
58 set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
58 59
59#define R_H8_NONE 0 60#define R_H8_NONE 0
60#define R_H8_DIR32 1 61#define R_H8_DIR32 1
diff --git a/arch/hexagon/include/asm/elf.h b/arch/hexagon/include/asm/elf.h
index 37976a0d3650..82b499621e05 100644
--- a/arch/hexagon/include/asm/elf.h
+++ b/arch/hexagon/include/asm/elf.h
@@ -217,7 +217,8 @@ do { \
217#define ELF_PLATFORM (NULL) 217#define ELF_PLATFORM (NULL)
218 218
219#ifdef __KERNEL__ 219#ifdef __KERNEL__
220#define SET_PERSONALITY(ex) set_personality(PER_LINUX) 220#define SET_PERSONALITY(ex) \
221 set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
221#endif 222#endif
222 223
223#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 224#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
diff --git a/arch/m32r/include/asm/elf.h b/arch/m32r/include/asm/elf.h
index b8da7d0574d2..70896161c636 100644
--- a/arch/m32r/include/asm/elf.h
+++ b/arch/m32r/include/asm/elf.h
@@ -128,6 +128,7 @@ typedef elf_fpreg_t elf_fpregset_t;
128 intent than poking at uname or /proc/cpuinfo. */ 128 intent than poking at uname or /proc/cpuinfo. */
129#define ELF_PLATFORM (NULL) 129#define ELF_PLATFORM (NULL)
130 130
131#define SET_PERSONALITY(ex) set_personality(PER_LINUX) 131#define SET_PERSONALITY(ex) \
132 set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
132 133
133#endif /* _ASM_M32R__ELF_H */ 134#endif /* _ASM_M32R__ELF_H */
diff --git a/arch/m68k/include/asm/elf.h b/arch/m68k/include/asm/elf.h
index e9b7cda59744..f83c1d0a87cf 100644
--- a/arch/m68k/include/asm/elf.h
+++ b/arch/m68k/include/asm/elf.h
@@ -113,6 +113,7 @@ typedef struct user_m68kfp_struct elf_fpregset_t;
113 113
114#define ELF_PLATFORM (NULL) 114#define ELF_PLATFORM (NULL)
115 115
116#define SET_PERSONALITY(ex) set_personality(PER_LINUX) 116#define SET_PERSONALITY(ex) \
117 set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
117 118
118#endif 119#endif
diff --git a/arch/microblaze/include/asm/elf.h b/arch/microblaze/include/asm/elf.h
index 834849f59ae8..640ddd4b6a9b 100644
--- a/arch/microblaze/include/asm/elf.h
+++ b/arch/microblaze/include/asm/elf.h
@@ -116,7 +116,8 @@ do { \
116} while (0) 116} while (0)
117 117
118#ifdef __KERNEL__ 118#ifdef __KERNEL__
119#define SET_PERSONALITY(ex) set_personality(PER_LINUX_32BIT) 119#define SET_PERSONALITY(ex) \
120 set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK)))
120#endif 121#endif
121 122
122#endif /* __uClinux__ */ 123#endif /* __uClinux__ */
diff --git a/arch/mn10300/include/asm/elf.h b/arch/mn10300/include/asm/elf.h
index 8157c9267f42..4ebd6b3a0a1e 100644
--- a/arch/mn10300/include/asm/elf.h
+++ b/arch/mn10300/include/asm/elf.h
@@ -151,7 +151,8 @@ do { \
151#define ELF_PLATFORM (NULL) 151#define ELF_PLATFORM (NULL)
152 152
153#ifdef __KERNEL__ 153#ifdef __KERNEL__
154#define SET_PERSONALITY(ex) set_personality(PER_LINUX) 154#define SET_PERSONALITY(ex) \
155 set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
155#endif 156#endif
156 157
157#endif /* _ASM_ELF_H */ 158#endif /* _ASM_ELF_H */
diff --git a/arch/openrisc/include/asm/elf.h b/arch/openrisc/include/asm/elf.h
index a8fe2c513070..225a7ff320ad 100644
--- a/arch/openrisc/include/asm/elf.h
+++ b/arch/openrisc/include/asm/elf.h
@@ -110,7 +110,8 @@ extern void dump_elf_thread(elf_greg_t *dest, struct pt_regs *pt);
110 110
111#define ELF_PLATFORM (NULL) 111#define ELF_PLATFORM (NULL)
112 112
113#define SET_PERSONALITY(ex) set_personality(PER_LINUX) 113#define SET_PERSONALITY(ex) \
114 set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
114 115
115#endif /* __KERNEL__ */ 116#endif /* __KERNEL__ */
116#endif 117#endif
diff --git a/arch/score/include/asm/elf.h b/arch/score/include/asm/elf.h
index f478ce94181f..5d566c7a0af2 100644
--- a/arch/score/include/asm/elf.h
+++ b/arch/score/include/asm/elf.h
@@ -54,7 +54,7 @@ typedef elf_fpreg_t elf_fpregset_t;
54 54
55#define SET_PERSONALITY(ex) \ 55#define SET_PERSONALITY(ex) \
56do { \ 56do { \
57 set_personality(PER_LINUX); \ 57 set_personality(PER_LINUX | (current->personality & (~PER_MASK))); \
58} while (0) 58} while (0)
59 59
60struct task_struct; 60struct task_struct;
diff --git a/arch/sh/include/asm/elf.h b/arch/sh/include/asm/elf.h
index f38112be67d2..37924afa8d8a 100644
--- a/arch/sh/include/asm/elf.h
+++ b/arch/sh/include/asm/elf.h
@@ -183,7 +183,8 @@ do { \
183} while (0) 183} while (0)
184#endif 184#endif
185 185
186#define SET_PERSONALITY(ex) set_personality(PER_LINUX_32BIT) 186#define SET_PERSONALITY(ex) \
187 set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK)))
187 188
188#ifdef CONFIG_VSYSCALL 189#ifdef CONFIG_VSYSCALL
189/* vDSO has arch_setup_additional_pages */ 190/* vDSO has arch_setup_additional_pages */
diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
index 2d4d755cba9e..ac74a2c98e6d 100644
--- a/arch/sparc/include/asm/elf_32.h
+++ b/arch/sparc/include/asm/elf_32.h
@@ -128,6 +128,7 @@ typedef struct {
128 128
129#define ELF_PLATFORM (NULL) 129#define ELF_PLATFORM (NULL)
130 130
131#define SET_PERSONALITY(ex) set_personality(PER_LINUX) 131#define SET_PERSONALITY(ex) \
132 set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
132 133
133#endif /* !(__ASMSPARC_ELF_H) */ 134#endif /* !(__ASMSPARC_ELF_H) */
diff --git a/arch/xtensa/include/asm/elf.h b/arch/xtensa/include/asm/elf.h
index 6e65eadaae14..5293312bc6a4 100644
--- a/arch/xtensa/include/asm/elf.h
+++ b/arch/xtensa/include/asm/elf.h
@@ -189,7 +189,8 @@ typedef struct {
189#endif 189#endif
190} elf_xtregs_t; 190} elf_xtregs_t;
191 191
192#define SET_PERSONALITY(ex) set_personality(PER_LINUX_32BIT) 192#define SET_PERSONALITY(ex) \
193 set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK)))
193 194
194struct task_struct; 195struct task_struct;
195 196