All of lore.kernel.org
 help / color / mirror / Atom feed
diff for duplicates of <20170705191007.GA26635@dhcp22.suse.cz>

diff --git a/a/1.txt b/N1/1.txt
index cb38561..ee4f6d9 100644
--- a/a/1.txt
+++ b/N1/1.txt
@@ -20,3 +20,66 @@ On Wed 05-07-17 20:53:02, Michal Hocko wrote:
 
 Here is the rebase of Oleg's patch.
 ---
+>From 61ff0cd972dac218390a5859b89ce386db731d1d Mon Sep 17 00:00:00 2001
+From: Oleg Nesterov <oleg@redhat.com>
+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@redhat.com
+Signed-off-by: Oleg Nesterov <oleg@redhat.com>
+Cc: Hugh Dickins <hughd@google.com>
+Cc: Larry Woodman <lwoodman@redhat.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Acked-by: Michal Hocko <mhocko@suse.com>
+Signed-off-by: Michal Hocko <mhocko@suse.com>
+---
+ 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
diff --git a/a/content_digest b/N1/content_digest
index 48606f5..d9bada1 100644
--- a/a/content_digest
+++ b/N1/content_digest
@@ -38,6 +38,69 @@
  "> mine which is not a stable material.\n"
  "\n"
  "Here is the rebase of Oleg's patch.\n"
- ---
+ "---\n"
+ ">From 61ff0cd972dac218390a5859b89ce386db731d1d Mon Sep 17 00:00:00 2001\n"
+ "From: Oleg Nesterov <oleg@redhat.com>\n"
+ "Date: Fri, 30 Jun 2017 10:19:00 +0200\n"
+ "Subject: [PATCH] mm/mmap.c: expand_downwards: don't require the gap if\n"
+ " !vm_prev\n"
+ "\n"
+ "expand_stack(vma) fails if address < stack_guard_gap even if there is no\n"
+ "vma->vm_prev.  I don't think this makes sense, and we didn't do this\n"
+ "before the recent commit 1be7107fbe18 (\"mm: larger stack guard gap,\n"
+ "between vmas\").  We do not need a gap in this case, any address is fine as\n"
+ "long as security_mmap_addr() doesn't object.\n"
+ "\n"
+ "This also simplifies the code, we know that address >= prev->vm_end and\n"
+ "thus underflow is not possible.\n"
+ "\n"
+ "Link: http://lkml.kernel.org/r/20170628175258.GA24881@redhat.com\n"
+ "Signed-off-by: Oleg Nesterov <oleg@redhat.com>\n"
+ "Cc: Hugh Dickins <hughd@google.com>\n"
+ "Cc: Larry Woodman <lwoodman@redhat.com>\n"
+ "Cc: Linus Torvalds <torvalds@linux-foundation.org>\n"
+ "Acked-by: Michal Hocko <mhocko@suse.com>\n"
+ "Signed-off-by: Michal Hocko <mhocko@suse.com>\n"
+ "---\n"
+ " mm/mmap.c | 10 +++-------\n"
+ " 1 file changed, 3 insertions(+), 7 deletions(-)\n"
+ "\n"
+ "diff --git a/mm/mmap.c b/mm/mmap.c\n"
+ "index ece0f6d3a1b5..f30847405cab 100644\n"
+ "--- a/mm/mmap.c\n"
+ "+++ b/mm/mmap.c\n"
+ "@@ -2316,7 +2316,6 @@ int expand_downwards(struct vm_area_struct *vma,\n"
+ " {\n"
+ " \tstruct mm_struct *mm = vma->vm_mm;\n"
+ " \tstruct vm_area_struct *prev;\n"
+ "-\tunsigned long gap_addr;\n"
+ " \tint error;\n"
+ " \n"
+ " \taddress &= PAGE_MASK;\n"
+ "@@ -2325,15 +2324,12 @@ int expand_downwards(struct vm_area_struct *vma,\n"
+ " \t\treturn error;\n"
+ " \n"
+ " \t/* Enforce stack_guard_gap */\n"
+ "-\tgap_addr = address - stack_guard_gap;\n"
+ "-\tif (gap_addr > address)\n"
+ "-\t\treturn -ENOMEM;\n"
+ " \tprev = vma->vm_prev;\n"
+ "-\tif (prev && prev->vm_end > gap_addr &&\n"
+ "+\t/* Check that both stack segments have the same anon_vma? */\n"
+ "+\tif (prev && !(prev->vm_flags & VM_GROWSDOWN) &&\n"
+ " \t\t\t(prev->vm_flags & (VM_WRITE|VM_READ|VM_EXEC))) {\n"
+ "-\t\tif (!(prev->vm_flags & VM_GROWSDOWN))\n"
+ "+\t\tif (address - prev->vm_end < stack_guard_gap)\n"
+ " \t\t\treturn -ENOMEM;\n"
+ "-\t\t/* Check that both stack segments have the same anon_vma? */\n"
+ " \t}\n"
+ " \n"
+ " \t/* We must make sure the anon_vma is allocated. */\n"
+ "-- \n"
+ "2.11.0\n"
+ "\n"
+ "-- \n"
+ "Michal Hocko\n"
+ SUSE Labs
 
-00a1eaf4198f77a7824ccf6dba0bafca03f5581a1ce0b9b810e3c5227ebb75f6
+6c3a4f4e59c45a13563a4cb965f60497d4d404087b35810bbb6108cbb5589d2a

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.