Re: [PATCH 3.18 32/32] mm: larger stack guard gap, between vmas

From: Hugh Dickins
Date: Wed Jun 21 2017 - 01:49:30 EST


On Mon, 19 Jun 2017, Greg Kroah-Hartman wrote:

> 3.18-stable review patch. If anyone has any objections, please let me know.
>
> ------------------
>
> From: Hugh Dickins <hughd@xxxxxxxxxx>
>
> commit 1be7107fbe18eed3e319a6c3e83c78254b693acb upstream.

Here's a few adjustments to the 3.18 patch: no doubt you'll have
already sorted out any build errors (and I have to confess that
I haven't even tried to build this); and the VM_WARN_ON line (as
in 4.4) only fixes a highly unlikely error; but those FOLL_MLOCK
lines in mm/gup.c were mistaken, and do need to be deleted.

Hugh

diff -purN 318n/include/linux/mm.h 318h/include/linux/mm.h
--- 318n/include/linux/mm.h 2017-06-20 16:48:54.050429965 -0700
+++ 318h/include/linux/mm.h 2017-06-20 19:13:05.842191061 -0700
@@ -1242,6 +1242,9 @@ int set_page_dirty_lock(struct page *pag
int clear_page_dirty_for_io(struct page *page);
int get_cmdline(struct task_struct *task, char *buffer, int buflen);

+extern struct task_struct *task_of_stack(struct task_struct *task,
+ struct vm_area_struct *vma, bool in_group);
+
extern unsigned long move_page_tables(struct vm_area_struct *vma,
unsigned long old_addr, struct vm_area_struct *new_vma,
unsigned long new_addr, unsigned long len,
@@ -1897,8 +1900,9 @@ void page_cache_async_readahead(struct a
pgoff_t offset,
unsigned long size);

-extern unsigned long stack_guard_gap;
+unsigned long max_sane_readahead(unsigned long nr);

+extern unsigned long stack_guard_gap;
/* Generic expand stack which grows the stack according to GROWS{UP,DOWN} */
extern int expand_stack(struct vm_area_struct *vma, unsigned long address);

diff -purN 318n/mm/gup.c 318h/mm/gup.c
--- 318n/mm/gup.c 2017-06-20 16:48:54.054429927 -0700
+++ 318h/mm/gup.c 2017-06-20 19:18:19.579275331 -0700
@@ -275,9 +275,6 @@ static int faultin_page(struct task_stru
unsigned int fault_flags = 0;
int ret;

- /* mlock all present pages, but do not fault in new pages */
- if (*flags & FOLL_MLOCK)
- return -ENOENT;
if (*flags & FOLL_WRITE)
fault_flags |= FAULT_FLAG_WRITE;
if (nonblocking)
diff -purN 318n/mm/mmap.c 318h/mm/mmap.c
--- 318n/mm/mmap.c 2017-06-20 16:48:54.054429927 -0700
+++ 318h/mm/mmap.c 2017-06-20 19:43:16.945345744 -0700
@@ -931,7 +931,7 @@ again: remove_next = 1 + (end > next->
else if (next)
vma_gap_update(next);
else
- mm->highest_vm_end = end;
+ VM_WARN_ON(mm->highest_vm_end != vm_end_gap(vma));
}
if (insert && file)
uprobe_mmap(insert);