diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-14 19:49:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-14 19:49:17 -0400 |
commit | 1dcf58d6e6e6eb7ec10e9abc56887b040205b06f (patch) | |
tree | c03e7a25ef13eea62f1547914a76e5c68f3f4c28 /arch/s390 | |
parent | 80dcc31fbe55932ac9204daee5f2ebc0c49b6da3 (diff) | |
parent | e4b0db72be2487bae0e3251c22f82c104f7c1cfd (diff) |
Merge branch 'akpm' (patches from Andrew)
Merge first patchbomb from Andrew Morton:
- arch/sh updates
- ocfs2 updates
- kernel/watchdog feature
- about half of mm/
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (122 commits)
Documentation: update arch list in the 'memtest' entry
Kconfig: memtest: update number of test patterns up to 17
arm: add support for memtest
arm64: add support for memtest
memtest: use phys_addr_t for physical addresses
mm: move memtest under mm
mm, hugetlb: abort __get_user_pages if current has been oom killed
mm, mempool: do not allow atomic resizing
memcg: print cgroup information when system panics due to panic_on_oom
mm: numa: remove migrate_ratelimited
mm: fold arch_randomize_brk into ARCH_HAS_ELF_RANDOMIZE
mm: split ET_DYN ASLR from mmap ASLR
s390: redefine randomize_et_dyn for ELF_ET_DYN_BASE
mm: expose arch_mmap_rnd when available
s390: standardize mmap_rnd() usage
powerpc: standardize mmap_rnd() usage
mips: extract logic for mmap_rnd()
arm64: standardize mmap_rnd() usage
x86: standardize mmap_rnd() usage
arm: factor out mmap ASLR into mmap_rnd
...
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/Kconfig | 6 | ||||
-rw-r--r-- | arch/s390/include/asm/elf.h | 12 | ||||
-rw-r--r-- | arch/s390/mm/mmap.c | 41 |
3 files changed, 30 insertions, 29 deletions
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index b2d7ec1669b4..6321fd8bf813 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig | |||
@@ -65,6 +65,7 @@ config S390 | |||
65 | def_bool y | 65 | def_bool y |
66 | select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE | 66 | select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE |
67 | select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS | 67 | select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS |
68 | select ARCH_HAS_ELF_RANDOMIZE | ||
68 | select ARCH_HAS_GCOV_PROFILE_ALL | 69 | select ARCH_HAS_GCOV_PROFILE_ALL |
69 | select ARCH_HAS_SG_CHAIN | 70 | select ARCH_HAS_SG_CHAIN |
70 | select ARCH_HAVE_NMI_SAFE_CMPXCHG | 71 | select ARCH_HAVE_NMI_SAFE_CMPXCHG |
@@ -156,6 +157,11 @@ config S390 | |||
156 | config SCHED_OMIT_FRAME_POINTER | 157 | config SCHED_OMIT_FRAME_POINTER |
157 | def_bool y | 158 | def_bool y |
158 | 159 | ||
160 | config PGTABLE_LEVELS | ||
161 | int | ||
162 | default 4 if 64BIT | ||
163 | default 2 | ||
164 | |||
159 | source "init/Kconfig" | 165 | source "init/Kconfig" |
160 | 166 | ||
161 | source "kernel/Kconfig.freezer" | 167 | source "kernel/Kconfig.freezer" |
diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h index c9c875d9ed31..a5c4978462c1 100644 --- a/arch/s390/include/asm/elf.h +++ b/arch/s390/include/asm/elf.h | |||
@@ -161,10 +161,11 @@ extern unsigned int vdso_enabled; | |||
161 | /* This is the location that an ET_DYN program is loaded if exec'ed. Typical | 161 | /* This is the location that an ET_DYN program is loaded if exec'ed. Typical |
162 | use of this is to invoke "./ld.so someprog" to test out a new version of | 162 | use of this is to invoke "./ld.so someprog" to test out a new version of |
163 | the loader. We need to make sure that it is out of the way of the program | 163 | the loader. We need to make sure that it is out of the way of the program |
164 | that it will "exec", and that there is sufficient room for the brk. */ | 164 | that it will "exec", and that there is sufficient room for the brk. 64-bit |
165 | 165 | tasks are aligned to 4GB. */ | |
166 | extern unsigned long randomize_et_dyn(void); | 166 | #define ELF_ET_DYN_BASE (is_32bit_task() ? \ |
167 | #define ELF_ET_DYN_BASE randomize_et_dyn() | 167 | (STACK_TOP / 3 * 2) : \ |
168 | (STACK_TOP / 3 * 2) & ~((1UL << 32) - 1)) | ||
168 | 169 | ||
169 | /* This yields a mask that user programs can use to figure out what | 170 | /* This yields a mask that user programs can use to figure out what |
170 | instruction set this CPU supports. */ | 171 | instruction set this CPU supports. */ |
@@ -225,9 +226,6 @@ struct linux_binprm; | |||
225 | #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 | 226 | #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 |
226 | int arch_setup_additional_pages(struct linux_binprm *, int); | 227 | int arch_setup_additional_pages(struct linux_binprm *, int); |
227 | 228 | ||
228 | extern unsigned long arch_randomize_brk(struct mm_struct *mm); | ||
229 | #define arch_randomize_brk arch_randomize_brk | ||
230 | |||
231 | void *fill_cpu_elf_notes(void *ptr, struct save_area *sa, __vector128 *vxrs); | 229 | void *fill_cpu_elf_notes(void *ptr, struct save_area *sa, __vector128 *vxrs); |
232 | 230 | ||
233 | #endif | 231 | #endif |
diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c index 179a2c20b01f..bb3367c5cb0b 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c | |||
@@ -60,22 +60,20 @@ static inline int mmap_is_legacy(void) | |||
60 | return sysctl_legacy_va_layout; | 60 | return sysctl_legacy_va_layout; |
61 | } | 61 | } |
62 | 62 | ||
63 | static unsigned long mmap_rnd(void) | 63 | unsigned long arch_mmap_rnd(void) |
64 | { | 64 | { |
65 | if (!(current->flags & PF_RANDOMIZE)) | ||
66 | return 0; | ||
67 | if (is_32bit_task()) | 65 | if (is_32bit_task()) |
68 | return (get_random_int() & 0x7ff) << PAGE_SHIFT; | 66 | return (get_random_int() & 0x7ff) << PAGE_SHIFT; |
69 | else | 67 | else |
70 | return (get_random_int() & mmap_rnd_mask) << PAGE_SHIFT; | 68 | return (get_random_int() & mmap_rnd_mask) << PAGE_SHIFT; |
71 | } | 69 | } |
72 | 70 | ||
73 | static unsigned long mmap_base_legacy(void) | 71 | static unsigned long mmap_base_legacy(unsigned long rnd) |
74 | { | 72 | { |
75 | return TASK_UNMAPPED_BASE + mmap_rnd(); | 73 | return TASK_UNMAPPED_BASE + rnd; |
76 | } | 74 | } |
77 | 75 | ||
78 | static inline unsigned long mmap_base(void) | 76 | static inline unsigned long mmap_base(unsigned long rnd) |
79 | { | 77 | { |
80 | unsigned long gap = rlimit(RLIMIT_STACK); | 78 | unsigned long gap = rlimit(RLIMIT_STACK); |
81 | 79 | ||
@@ -84,7 +82,7 @@ static inline unsigned long mmap_base(void) | |||
84 | else if (gap > MAX_GAP) | 82 | else if (gap > MAX_GAP) |
85 | gap = MAX_GAP; | 83 | gap = MAX_GAP; |
86 | gap &= PAGE_MASK; | 84 | gap &= PAGE_MASK; |
87 | return STACK_TOP - stack_maxrandom_size() - mmap_rnd() - gap; | 85 | return STACK_TOP - stack_maxrandom_size() - rnd - gap; |
88 | } | 86 | } |
89 | 87 | ||
90 | unsigned long | 88 | unsigned long |
@@ -179,17 +177,6 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, | |||
179 | return addr; | 177 | return addr; |
180 | } | 178 | } |
181 | 179 | ||
182 | unsigned long randomize_et_dyn(void) | ||
183 | { | ||
184 | unsigned long base; | ||
185 | |||
186 | base = STACK_TOP / 3 * 2; | ||
187 | if (!is_32bit_task()) | ||
188 | /* Align to 4GB */ | ||
189 | base &= ~((1UL << 32) - 1); | ||
190 | return base + mmap_rnd(); | ||
191 | } | ||
192 | |||
193 | #ifndef CONFIG_64BIT | 180 | #ifndef CONFIG_64BIT |
194 | 181 | ||
195 | /* | 182 | /* |
@@ -198,15 +185,20 @@ unsigned long randomize_et_dyn(void) | |||
198 | */ | 185 | */ |
199 | void arch_pick_mmap_layout(struct mm_struct *mm) | 186 | void arch_pick_mmap_layout(struct mm_struct *mm) |
200 | { | 187 | { |
188 | unsigned long random_factor = 0UL; | ||
189 | |||
190 | if (current->flags & PF_RANDOMIZE) | ||
191 | random_factor = arch_mmap_rnd(); | ||
192 | |||
201 | /* | 193 | /* |
202 | * Fall back to the standard layout if the personality | 194 | * Fall back to the standard layout if the personality |
203 | * bit is set, or if the expected stack growth is unlimited: | 195 | * bit is set, or if the expected stack growth is unlimited: |
204 | */ | 196 | */ |
205 | if (mmap_is_legacy()) { | 197 | if (mmap_is_legacy()) { |
206 | mm->mmap_base = mmap_base_legacy(); | 198 | mm->mmap_base = mmap_base_legacy(random_factor); |
207 | mm->get_unmapped_area = arch_get_unmapped_area; | 199 | mm->get_unmapped_area = arch_get_unmapped_area; |
208 | } else { | 200 | } else { |
209 | mm->mmap_base = mmap_base(); | 201 | mm->mmap_base = mmap_base(random_factor); |
210 | mm->get_unmapped_area = arch_get_unmapped_area_topdown; | 202 | mm->get_unmapped_area = arch_get_unmapped_area_topdown; |
211 | } | 203 | } |
212 | } | 204 | } |
@@ -273,15 +265,20 @@ s390_get_unmapped_area_topdown(struct file *filp, const unsigned long addr, | |||
273 | */ | 265 | */ |
274 | void arch_pick_mmap_layout(struct mm_struct *mm) | 266 | void arch_pick_mmap_layout(struct mm_struct *mm) |
275 | { | 267 | { |
268 | unsigned long random_factor = 0UL; | ||
269 | |||
270 | if (current->flags & PF_RANDOMIZE) | ||
271 | random_factor = arch_mmap_rnd(); | ||
272 | |||
276 | /* | 273 | /* |
277 | * Fall back to the standard layout if the personality | 274 | * Fall back to the standard layout if the personality |
278 | * bit is set, or if the expected stack growth is unlimited: | 275 | * bit is set, or if the expected stack growth is unlimited: |
279 | */ | 276 | */ |
280 | if (mmap_is_legacy()) { | 277 | if (mmap_is_legacy()) { |
281 | mm->mmap_base = mmap_base_legacy(); | 278 | mm->mmap_base = mmap_base_legacy(random_factor); |
282 | mm->get_unmapped_area = s390_get_unmapped_area; | 279 | mm->get_unmapped_area = s390_get_unmapped_area; |
283 | } else { | 280 | } else { |
284 | mm->mmap_base = mmap_base(); | 281 | mm->mmap_base = mmap_base(random_factor); |
285 | mm->get_unmapped_area = s390_get_unmapped_area_topdown; | 282 | mm->get_unmapped_area = s390_get_unmapped_area_topdown; |
286 | } | 283 | } |
287 | } | 284 | } |