]> git.proxmox.com Git - pve-kernel.git/blob - mm-fix-new-crash-in-unmapped_area_topdown.patch
bump version to 4.10.15-14
[pve-kernel.git] / mm-fix-new-crash-in-unmapped_area_topdown.patch
1 From f4cb767d76cf7ee72f97dd76f6cfa6c76a5edc89 Mon Sep 17 00:00:00 2001
2 From: Hugh Dickins <hughd@google.com>
3 Date: Tue, 20 Jun 2017 02:10:44 -0700
4 Subject: [PATCH] mm: fix new crash in unmapped_area_topdown()
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Trinity gets kernel BUG at mm/mmap.c:1963! in about 3 minutes of
10 mmap testing. That's the VM_BUG_ON(gap_end < gap_start) at the
11 end of unmapped_area_topdown(). Linus points out how MAP_FIXED
12 (which does not have to respect our stack guard gap intentions)
13 could result in gap_end below gap_start there. Fix that, and
14 the similar case in its alternative, unmapped_area().
15
16 Cc: stable@vger.kernel.org
17 Fixes: 1be7107fbe18 ("mm: larger stack guard gap, between vmas")
18 Reported-by: Dave Jones <davej@codemonkey.org.uk>
19 Debugged-by: Linus Torvalds <torvalds@linux-foundation.org>
20 Signed-off-by: Hugh Dickins <hughd@google.com>
21 Acked-by: Michal Hocko <mhocko@suse.com>
22 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
23 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
24 ---
25 mm/mmap.c | 6 ++++--
26 1 file changed, 4 insertions(+), 2 deletions(-)
27
28 diff --git a/mm/mmap.c b/mm/mmap.c
29 index 8e07976d5e47..290b77d9a01e 100644
30 --- a/mm/mmap.c
31 +++ b/mm/mmap.c
32 @@ -1817,7 +1817,8 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
33 /* Check if current node has a suitable gap */
34 if (gap_start > high_limit)
35 return -ENOMEM;
36 - if (gap_end >= low_limit && gap_end - gap_start >= length)
37 + if (gap_end >= low_limit &&
38 + gap_end > gap_start && gap_end - gap_start >= length)
39 goto found;
40
41 /* Visit right subtree if it looks promising */
42 @@ -1920,7 +1921,8 @@ unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
43 gap_end = vm_start_gap(vma);
44 if (gap_end < low_limit)
45 return -ENOMEM;
46 - if (gap_start <= high_limit && gap_end - gap_start >= length)
47 + if (gap_start <= high_limit &&
48 + gap_end > gap_start && gap_end - gap_start >= length)
49 goto found;
50
51 /* Visit left subtree if it looks promising */
52 --
53 2.11.0
54