aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-05-20 01:30:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-05-20 01:30:34 -0400
commit41abc90228f98774263572ec99e7ab820f091002 (patch)
treece41e35a000ae50780b3f09b5be5d46fe93bf2d2
parenta7b0806392b527e8a616e7ea6f17aafe33949a9f (diff)
parentffe6902b66aaa4ca6694bc19639259c16d84ddb1 (diff)
Merge tag 'metag-for-v3.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/metag
Pull Metag architecture and related fixes from James Hogan: "Mostly fixes for metag and parisc relating to upgrowing stacks. - Fix missing compiler barriers in metag memory barriers. - Fix BUG_ON on metag when RLIMIT_STACK hard limit is increased beyond safe value. - Make maximum stack size configurable. This reduces the default user stack size back to 80MB (especially on parisc after their removal of _STK_LIM_MAX override). This only affects metag and parisc. - Remove metag _STK_LIM_MAX override to match other arches and follow parisc, now that it is safe to do so (due to the BUG_ON fix mentioned above). - Finally now that both metag and parisc _STK_LIM_MAX overrides have been removed, it makes sense to remove _STK_LIM_MAX altogether" * tag 'metag-for-v3.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/metag: asm-generic: remove _STK_LIM_MAX metag: Remove _STK_LIM_MAX override parisc,metag: Do not hardcode maximum userspace stack size metag: Reduce maximum stack size to 256MB metag: fix memory barriers
-rw-r--r--arch/metag/include/asm/barrier.h3
-rw-r--r--arch/metag/include/asm/processor.h2
-rw-r--r--arch/metag/include/uapi/asm/Kbuild2
-rw-r--r--arch/metag/include/uapi/asm/resource.h7
-rw-r--r--arch/parisc/include/asm/processor.h5
-rw-r--r--arch/parisc/kernel/sys_parisc.c6
-rw-r--r--fs/exec.c6
-rw-r--r--include/asm-generic/resource.h2
-rw-r--r--include/uapi/asm-generic/resource.h7
-rw-r--r--mm/Kconfig15
10 files changed, 33 insertions, 22 deletions
diff --git a/arch/metag/include/asm/barrier.h b/arch/metag/include/asm/barrier.h
index 5d6b4b407dda..2d6f0de77325 100644
--- a/arch/metag/include/asm/barrier.h
+++ b/arch/metag/include/asm/barrier.h
@@ -15,6 +15,7 @@ static inline void wr_fence(void)
15 volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_FENCE; 15 volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_FENCE;
16 barrier(); 16 barrier();
17 *flushptr = 0; 17 *flushptr = 0;
18 barrier();
18} 19}
19 20
20#else /* CONFIG_METAG_META21 */ 21#else /* CONFIG_METAG_META21 */
@@ -35,6 +36,7 @@ static inline void wr_fence(void)
35 *flushptr = 0; 36 *flushptr = 0;
36 *flushptr = 0; 37 *flushptr = 0;
37 *flushptr = 0; 38 *flushptr = 0;
39 barrier();
38} 40}
39 41
40#endif /* !CONFIG_METAG_META21 */ 42#endif /* !CONFIG_METAG_META21 */
@@ -68,6 +70,7 @@ static inline void fence(void)
68 volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_ATOMIC_UNLOCK; 70 volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_ATOMIC_UNLOCK;
69 barrier(); 71 barrier();
70 *flushptr = 0; 72 *flushptr = 0;
73 barrier();
71} 74}
72#define smp_mb() fence() 75#define smp_mb() fence()
73#define smp_rmb() fence() 76#define smp_rmb() fence()
diff --git a/arch/metag/include/asm/processor.h b/arch/metag/include/asm/processor.h
index f16477d1f571..a8a37477c66e 100644
--- a/arch/metag/include/asm/processor.h
+++ b/arch/metag/include/asm/processor.h
@@ -22,6 +22,8 @@
22/* Add an extra page of padding at the top of the stack for the guard page. */ 22/* Add an extra page of padding at the top of the stack for the guard page. */
23#define STACK_TOP (TASK_SIZE - PAGE_SIZE) 23#define STACK_TOP (TASK_SIZE - PAGE_SIZE)
24#define STACK_TOP_MAX STACK_TOP 24#define STACK_TOP_MAX STACK_TOP
25/* Maximum virtual space for stack */
26#define STACK_SIZE_MAX (CONFIG_MAX_STACK_SIZE_MB*1024*1024)
25 27
26/* This decides where the kernel will search for a free chunk of vm 28/* This decides where the kernel will search for a free chunk of vm
27 * space during mmap's. 29 * space during mmap's.
diff --git a/arch/metag/include/uapi/asm/Kbuild b/arch/metag/include/uapi/asm/Kbuild
index 84e09feb4d54..ab78be2b6eb0 100644
--- a/arch/metag/include/uapi/asm/Kbuild
+++ b/arch/metag/include/uapi/asm/Kbuild
@@ -4,11 +4,11 @@ include include/uapi/asm-generic/Kbuild.asm
4header-y += byteorder.h 4header-y += byteorder.h
5header-y += ech.h 5header-y += ech.h
6header-y += ptrace.h 6header-y += ptrace.h
7header-y += resource.h
8header-y += sigcontext.h 7header-y += sigcontext.h
9header-y += siginfo.h 8header-y += siginfo.h
10header-y += swab.h 9header-y += swab.h
11header-y += unistd.h 10header-y += unistd.h
12 11
13generic-y += mman.h 12generic-y += mman.h
13generic-y += resource.h
14generic-y += setup.h 14generic-y += setup.h
diff --git a/arch/metag/include/uapi/asm/resource.h b/arch/metag/include/uapi/asm/resource.h
deleted file mode 100644
index 526d23cc3054..000000000000
--- a/arch/metag/include/uapi/asm/resource.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef _UAPI_METAG_RESOURCE_H
2#define _UAPI_METAG_RESOURCE_H
3
4#define _STK_LIM_MAX (1 << 28)
5#include <asm-generic/resource.h>
6
7#endif /* _UAPI_METAG_RESOURCE_H */
diff --git a/arch/parisc/include/asm/processor.h b/arch/parisc/include/asm/processor.h
index 198a86feb574..d951c9681ab3 100644
--- a/arch/parisc/include/asm/processor.h
+++ b/arch/parisc/include/asm/processor.h
@@ -55,6 +55,11 @@
55#define STACK_TOP TASK_SIZE 55#define STACK_TOP TASK_SIZE
56#define STACK_TOP_MAX DEFAULT_TASK_SIZE 56#define STACK_TOP_MAX DEFAULT_TASK_SIZE
57 57
58/* Allow bigger stacks for 64-bit processes */
59#define STACK_SIZE_MAX (USER_WIDE_MODE \
60 ? (1 << 30) /* 1 GB */ \
61 : (CONFIG_MAX_STACK_SIZE_MB*1024*1024))
62
58#endif 63#endif
59 64
60#ifndef __ASSEMBLY__ 65#ifndef __ASSEMBLY__
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index 31ffa9b55322..e1ffea2f9a0b 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -72,10 +72,10 @@ static unsigned long mmap_upper_limit(void)
72{ 72{
73 unsigned long stack_base; 73 unsigned long stack_base;
74 74
75 /* Limit stack size to 1GB - see setup_arg_pages() in fs/exec.c */ 75 /* Limit stack size - see setup_arg_pages() in fs/exec.c */
76 stack_base = rlimit_max(RLIMIT_STACK); 76 stack_base = rlimit_max(RLIMIT_STACK);
77 if (stack_base > (1 << 30)) 77 if (stack_base > STACK_SIZE_MAX)
78 stack_base = 1 << 30; 78 stack_base = STACK_SIZE_MAX;
79 79
80 return PAGE_ALIGN(STACK_TOP - stack_base); 80 return PAGE_ALIGN(STACK_TOP - stack_base);
81} 81}
diff --git a/fs/exec.c b/fs/exec.c
index 476f3ebf437e..238b7aa26f68 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -657,10 +657,10 @@ int setup_arg_pages(struct linux_binprm *bprm,
657 unsigned long rlim_stack; 657 unsigned long rlim_stack;
658 658
659#ifdef CONFIG_STACK_GROWSUP 659#ifdef CONFIG_STACK_GROWSUP
660 /* Limit stack size to 1GB */ 660 /* Limit stack size */
661 stack_base = rlimit_max(RLIMIT_STACK); 661 stack_base = rlimit_max(RLIMIT_STACK);
662 if (stack_base > (1 << 30)) 662 if (stack_base > STACK_SIZE_MAX)
663 stack_base = 1 << 30; 663 stack_base = STACK_SIZE_MAX;
664 664
665 /* Make sure we didn't let the argument array grow too large. */ 665 /* Make sure we didn't let the argument array grow too large. */
666 if (vma->vm_end - vma->vm_start > stack_base) 666 if (vma->vm_end - vma->vm_start > stack_base)
diff --git a/include/asm-generic/resource.h b/include/asm-generic/resource.h
index b4ea8f50fc65..5e752b959054 100644
--- a/include/asm-generic/resource.h
+++ b/include/asm-generic/resource.h
@@ -12,7 +12,7 @@
12 [RLIMIT_CPU] = { RLIM_INFINITY, RLIM_INFINITY }, \ 12 [RLIMIT_CPU] = { RLIM_INFINITY, RLIM_INFINITY }, \
13 [RLIMIT_FSIZE] = { RLIM_INFINITY, RLIM_INFINITY }, \ 13 [RLIMIT_FSIZE] = { RLIM_INFINITY, RLIM_INFINITY }, \
14 [RLIMIT_DATA] = { RLIM_INFINITY, RLIM_INFINITY }, \ 14 [RLIMIT_DATA] = { RLIM_INFINITY, RLIM_INFINITY }, \
15 [RLIMIT_STACK] = { _STK_LIM, _STK_LIM_MAX }, \ 15 [RLIMIT_STACK] = { _STK_LIM, RLIM_INFINITY }, \
16 [RLIMIT_CORE] = { 0, RLIM_INFINITY }, \ 16 [RLIMIT_CORE] = { 0, RLIM_INFINITY }, \
17 [RLIMIT_RSS] = { RLIM_INFINITY, RLIM_INFINITY }, \ 17 [RLIMIT_RSS] = { RLIM_INFINITY, RLIM_INFINITY }, \
18 [RLIMIT_NPROC] = { 0, 0 }, \ 18 [RLIMIT_NPROC] = { 0, 0 }, \
diff --git a/include/uapi/asm-generic/resource.h b/include/uapi/asm-generic/resource.h
index f863428796d5..c6d10af50123 100644
--- a/include/uapi/asm-generic/resource.h
+++ b/include/uapi/asm-generic/resource.h
@@ -57,12 +57,5 @@
57# define RLIM_INFINITY (~0UL) 57# define RLIM_INFINITY (~0UL)
58#endif 58#endif
59 59
60/*
61 * RLIMIT_STACK default maximum - some architectures override it:
62 */
63#ifndef _STK_LIM_MAX
64# define _STK_LIM_MAX RLIM_INFINITY
65#endif
66
67 60
68#endif /* _UAPI_ASM_GENERIC_RESOURCE_H */ 61#endif /* _UAPI_ASM_GENERIC_RESOURCE_H */
diff --git a/mm/Kconfig b/mm/Kconfig
index ebe5880c29d6..1b5a95f0fa01 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -581,3 +581,18 @@ config PGTABLE_MAPPING
581 581
582config GENERIC_EARLY_IOREMAP 582config GENERIC_EARLY_IOREMAP
583 bool 583 bool
584
585config MAX_STACK_SIZE_MB
586 int "Maximum user stack size for 32-bit processes (MB)"
587 default 80
588 range 8 256 if METAG
589 range 8 2048
590 depends on STACK_GROWSUP && (!64BIT || COMPAT)
591 help
592 This is the maximum stack size in Megabytes in the VM layout of 32-bit
593 user processes when the stack grows upwards (currently only on parisc
594 and metag arch). The stack will be located at the highest memory
595 address minus the given value, unless the RLIMIT_STACK hard limit is
596 changed to a smaller value in which case that is used.
597
598 A sane initial value is 80 MB.