]> git.proxmox.com Git - pve-kernel.git/blame - CVE-2017-1000364-mm-mmap.c-do-not-blow-on-PROT_NONE-MAP_FIXED-holes-i.patch
add CVE fixes
[pve-kernel.git] / CVE-2017-1000364-mm-mmap.c-do-not-blow-on-PROT_NONE-MAP_FIXED-holes-i.patch
CommitLineData
4c390211
TL
1From 3e4f09eef73ad12d4876e24daf52a0dc0891d7da Mon Sep 17 00:00:00 2001
2From: Michal Hocko <mhocko@suse.com>
3Date: Mon, 17 Jul 2017 14:53:28 +0200
4Subject: [PATCH 1/2] mm/mmap.c: do not blow on PROT_NONE MAP_FIXED holes in
5 the stack
6
7Commit 1be7107fbe18 ("mm: larger stack guard gap, between vmas") has
8introduced a regression in some rust and Java environments which are
9trying to implement their own stack guard page. They are punching a new
10MAP_FIXED mapping inside the existing stack Vma.
11
12This will confuse expand_{downwards,upwards} into thinking that the
13stack expansion would in fact get us too close to an existing non-stack
14vma which is a correct behavior wrt safety. It is a real regression on
15the other hand.
16
17Let's work around the problem by considering PROT_NONE mapping as a part
18of the stack. This is a gros hack but overflowing to such a mapping
19would trap anyway an we only can hope that usespace knows what it is
20doing and handle it propely.
21
22Fixes: 1be7107fbe18 ("mm: larger stack guard gap, between vmas")
23Link: http://lkml.kernel.org/r/20170705182849.GA18027@dhcp22.suse.cz
24Signed-off-by: Michal Hocko <mhocko@suse.com>
25Debugged-by: Vlastimil Babka <vbabka@suse.cz>
26Cc: Ben Hutchings <ben@decadent.org.uk>
27Cc: Willy Tarreau <w@1wt.eu>
28Cc: Oleg Nesterov <oleg@redhat.com>
29Cc: Rik van Riel <riel@redhat.com>
30Cc: Hugh Dickins <hughd@google.com>
31Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
32Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
33
34CVE-2017-1000364
35
36(cherry picked from commit 561b5e0709e4a248c67d024d4d94b6e31e3edf2f)
37Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
38Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
39Acked-by: Kamal Mostafa <kamal@canonical.com>
40Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
41Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
42---
43 mm/mmap.c | 6 ++++--
44 1 file changed, 4 insertions(+), 2 deletions(-)
45
46diff --git a/mm/mmap.c b/mm/mmap.c
47index ef78a5ca5599..9fabd8c82f38 100644
48--- a/mm/mmap.c
49+++ b/mm/mmap.c
50@@ -2240,7 +2240,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
51 gap_addr = TASK_SIZE;
52
53 next = vma->vm_next;
54- if (next && next->vm_start < gap_addr) {
55+ if (next && next->vm_start < gap_addr &&
56+ (next->vm_flags & (VM_WRITE|VM_READ|VM_EXEC))) {
57 if (!(next->vm_flags & VM_GROWSUP))
58 return -ENOMEM;
59 /* Check that both stack segments have the same anon_vma? */
60@@ -2324,7 +2325,8 @@ int expand_downwards(struct vm_area_struct *vma,
61 if (gap_addr > address)
62 return -ENOMEM;
63 prev = vma->vm_prev;
64- if (prev && prev->vm_end > gap_addr) {
65+ if (prev && prev->vm_end > gap_addr &&
66+ (prev->vm_flags & (VM_WRITE|VM_READ|VM_EXEC))) {
67 if (!(prev->vm_flags & VM_GROWSDOWN))
68 return -ENOMEM;
69 /* Check that both stack segments have the same anon_vma? */
70--
712.11.0
72