1 From cd20f002742028366c33b38b3ca613eaee4582c9 Mon Sep 17 00:00:00 2001
2 From: Helge Deller <deller@gmx.de>
3 Date: Mon, 19 Jun 2017 17:34:05 +0200
4 Subject: [PATCH 2/3] Allow stack to grow up to address space limit
6 commit bd726c90b6b8ce87602208701b208a208e6d5600 upstream.
8 Fix expand_upwards() on architectures with an upward-growing stack (parisc,
9 metag and partly IA-64) to allow the stack to reliably grow exactly up to
10 the address space limit given by TASK_SIZE.
12 Signed-off-by: Helge Deller <deller@gmx.de>
13 Acked-by: Hugh Dickins <hughd@google.com>
14 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17 mm/mmap.c | 13 ++++++++-----
18 1 file changed, 8 insertions(+), 5 deletions(-)
20 diff --git a/mm/mmap.c b/mm/mmap.c
21 index 5e043dd..fcf4c88 100644
24 @@ -2172,16 +2172,19 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
25 if (!(vma->vm_flags & VM_GROWSUP))
28 - /* Guard against wrapping around to address 0. */
29 + /* Guard against exceeding limits of the address space. */
31 - address += PAGE_SIZE;
33 + if (address >= TASK_SIZE)
35 + address += PAGE_SIZE;
37 /* Enforce stack_guard_gap */
38 gap_addr = address + stack_guard_gap;
39 - if (gap_addr < address)
42 + /* Guard against overflow */
43 + if (gap_addr < address || gap_addr > TASK_SIZE)
44 + gap_addr = TASK_SIZE;
47 if (next && next->vm_start < gap_addr) {
48 if (!(next->vm_flags & VM_GROWSUP))