On Wed 05-07-17 20:53:02, Michal Hocko wrote: > On Wed 05-07-17 11:35:51, Linus Torvalds wrote: > > On Wed, Jul 5, 2017 at 11:28 AM, Michal Hocko <mhocko@xxxxxxxxxx> wrote: > > > > > > Dohh, that was on mmotm which has a clean up by Oleg which reorganizes > > > the code a bit. This is on top of the current master > > > > Oh, ok. I think I know which patch from Oleg you're talking about. > > > > Since I do want that patch too, and since I'd hate to cause > > unnecessary merge conflicts in this area, how about we just plan on > > letting your original patch (on top of Oleg's) go through Andrew and > > the -mm tree? I'll get it that way, and it's not like this is > > timing-critical. > > That would lead to conflicts when backporting to stable trees though > which is quite annoying as well and arguably slightly more annoying than > resolving this in mmotm. I can help to rebase Oleg's patch on top of > mine which is not a stable material. Here is the rebase of Oleg's patch. --- >From 61ff0cd972dac218390a5859b89ce386db731d1d Mon Sep 17 00:00:00 2001 From: Oleg Nesterov <oleg@xxxxxxxxxx> Date: Fri, 30 Jun 2017 10:19:00 +0200 Subject: [PATCH] mm/mmap.c: expand_downwards: don't require the gap if !vm_prev expand_stack(vma) fails if address < stack_guard_gap even if there is no vma->vm_prev. I don't think this makes sense, and we didn't do this before the recent commit 1be7107fbe18 ("mm: larger stack guard gap, between vmas"). We do not need a gap in this case, any address is fine as long as security_mmap_addr() doesn't object. This also simplifies the code, we know that address >= prev->vm_end and thus underflow is not possible. Link: http://lkml.kernel.org/r/20170628175258.GA24881@xxxxxxxxxx Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: Larry Woodman <lwoodman@xxxxxxxxxx> Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Acked-by: Michal Hocko <mhocko@xxxxxxxx> Signed-off-by: Michal Hocko <mhocko@xxxxxxxx> --- mm/mmap.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index ece0f6d3a1b5..f30847405cab 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2316,7 +2316,6 @@ int expand_downwards(struct vm_area_struct *vma, { struct mm_struct *mm = vma->vm_mm; struct vm_area_struct *prev; - unsigned long gap_addr; int error; address &= PAGE_MASK; @@ -2325,15 +2324,12 @@ int expand_downwards(struct vm_area_struct *vma, return error; /* Enforce stack_guard_gap */ - gap_addr = address - stack_guard_gap; - if (gap_addr > address) - return -ENOMEM; prev = vma->vm_prev; - if (prev && prev->vm_end > gap_addr && + /* Check that both stack segments have the same anon_vma? */ + if (prev && !(prev->vm_flags & VM_GROWSDOWN) && (prev->vm_flags & (VM_WRITE|VM_READ|VM_EXEC))) { - if (!(prev->vm_flags & VM_GROWSDOWN)) + if (address - prev->vm_end < stack_guard_gap) return -ENOMEM; - /* Check that both stack segments have the same anon_vma? */ } /* We must make sure the anon_vma is allocated. */ -- 2.11.0 -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>