]> git.proxmox.com Git - pve-kernel.git/blame - CVE-2017-1000364-mm-mmap.c-expand_downwards-don-t-require-the-gap-if-.patch
drop patches applied upstream
[pve-kernel.git] / CVE-2017-1000364-mm-mmap.c-expand_downwards-don-t-require-the-gap-if-.patch
CommitLineData
4c390211
TL
1From aea792ba99ba73a6b0c4e5aea3b4b6b3f9d821f6 Mon Sep 17 00:00:00 2001
2From: Oleg Nesterov <oleg@redhat.com>
3Date: Mon, 17 Jul 2017 14:53:29 +0200
4Subject: [PATCH 2/2] mm/mmap.c: expand_downwards: don't require the gap if
5 !vm_prev
6
7expand_stack(vma) fails if address < stack_guard_gap even if there is no
8vma->vm_prev. I don't think this makes sense, and we didn't do this
9before the recent commit 1be7107fbe18 ("mm: larger stack guard gap,
10between vmas").
11
12We do not need a gap in this case, any address is fine as long as
13security_mmap_addr() doesn't object.
14
15This also simplifies the code, we know that address >= prev->vm_end and
16thus underflow is not possible.
17
18Link: http://lkml.kernel.org/r/20170628175258.GA24881@redhat.com
19Signed-off-by: Oleg Nesterov <oleg@redhat.com>
20Acked-by: Michal Hocko <mhocko@suse.com>
21Cc: Hugh Dickins <hughd@google.com>
22Cc: Larry Woodman <lwoodman@redhat.com>
23Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
24Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
25
26CVE-2017-1000364
27
28(cherry picked from commit 32e4e6d5cbb0c0e427391635991fe65e17797af8)
29Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
30Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
31Acked-by: Kamal Mostafa <kamal@canonical.com>
32Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
33Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
34---
35 mm/mmap.c | 10 +++-------
36 1 file changed, 3 insertions(+), 7 deletions(-)
37
38diff --git a/mm/mmap.c b/mm/mmap.c
39index 9fabd8c82f38..09c728a1eeee 100644
40--- a/mm/mmap.c
41+++ b/mm/mmap.c
42@@ -2312,7 +2312,6 @@ int expand_downwards(struct vm_area_struct *vma,
43 {
44 struct mm_struct *mm = vma->vm_mm;
45 struct vm_area_struct *prev;
46- unsigned long gap_addr;
47 int error;
48
49 address &= PAGE_MASK;
50@@ -2321,15 +2320,12 @@ int expand_downwards(struct vm_area_struct *vma,
51 return error;
52
53 /* Enforce stack_guard_gap */
54- gap_addr = address - stack_guard_gap;
55- if (gap_addr > address)
56- return -ENOMEM;
57 prev = vma->vm_prev;
58- if (prev && prev->vm_end > gap_addr &&
59+ /* Check that both stack segments have the same anon_vma? */
60+ if (prev && !(prev->vm_flags & VM_GROWSDOWN) &&
61 (prev->vm_flags & (VM_WRITE|VM_READ|VM_EXEC))) {
62- if (!(prev->vm_flags & VM_GROWSDOWN))
63+ if (address - prev->vm_end < stack_guard_gap)
64 return -ENOMEM;
65- /* Check that both stack segments have the same anon_vma? */
66 }
67
68 /* We must make sure the anon_vma is allocated. */
69--
702.11.0
71