[linux] 02/03: mm/mmap.c: expand_downwards: don't require the gap if !vm_prev

debian-kernel at lists.debian.org debian-kernel at lists.debian.org
Thu Nov 30 19:31:09 UTC 2017


This is an automated email from the git hooks/post-receive script.

benh pushed a commit to branch stretch
in repository linux.

commit cc24606df4be2b0beee6a26a7dbdf1d8ee28dbe5
Author: Ben Hutchings <ben at decadent.org.uk>
Date:   Thu Nov 30 01:06:17 2017 +0000

    mm/mmap.c: expand_downwards: don't require the gap if !vm_prev
---
 debian/changelog                                   |  1 +
 ...xpand_downwards-don-t-require-the-gap-if-.patch | 56 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 3 files changed, 58 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 3c53c8e..24b5e68 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -728,6 +728,7 @@ linux (4.9.65-1) UNRELEASED; urgency=medium
     - md/raid5: do not disable interrupts
   * mm/mmap.c: do not blow on PROT_NONE MAP_FIXED holes in the stack
     (Closes: #865416)
+  * mm/mmap.c: expand_downwards: don't require the gap if !vm_prev
 
  -- Ben Hutchings <ben at decadent.org.uk>  Sun, 01 Oct 2017 16:14:43 +0100
 
diff --git a/debian/patches/bugfix/all/mm-mmap.c-expand_downwards-don-t-require-the-gap-if-.patch b/debian/patches/bugfix/all/mm-mmap.c-expand_downwards-don-t-require-the-gap-if-.patch
new file mode 100644
index 0000000..611a484
--- /dev/null
+++ b/debian/patches/bugfix/all/mm-mmap.c-expand_downwards-don-t-require-the-gap-if-.patch
@@ -0,0 +1,56 @@
+From: Oleg Nesterov <oleg at redhat.com>
+Date: Mon, 10 Jul 2017 15:49:54 -0700
+Subject: mm/mmap.c: expand_downwards: don't require the gap if !vm_prev
+Origin: https://git.kernel.org/linus/32e4e6d5cbb0c0e427391635991fe65e17797af8
+
+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 at redhat.com>
+Acked-by: Michal Hocko <mhocko at suse.com>
+Cc: Hugh Dickins <hughd at google.com>
+Cc: Larry Woodman <lwoodman at redhat.com>
+Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
+---
+ mm/mmap.c | 10 +++-------
+ 1 file changed, 3 insertions(+), 7 deletions(-)
+
+--- a/mm/mmap.c
++++ b/mm/mmap.c
+@@ -2312,7 +2312,6 @@ int expand_downwards(struct vm_area_stru
+ {
+ 	struct mm_struct *mm = vma->vm_mm;
+ 	struct vm_area_struct *prev;
+-	unsigned long gap_addr;
+ 	int error;
+ 
+ 	address &= PAGE_MASK;
+@@ -2321,15 +2320,12 @@ int expand_downwards(struct vm_area_stru
+ 		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. */
diff --git a/debian/patches/series b/debian/patches/series
index fd9d7f3..f82487a 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -99,6 +99,7 @@ bugfix/all/kbuild-do-not-use-hyphen-in-exported-variable-name.patch
 bugfix/all/partially-revert-usb-kconfig-using-select-for-usb_co.patch
 bugfix/all/kbuild-include-addtree-remove-quotes-before-matching-path.patch
 bugfix/all/mm-mmap.c-do-not-blow-on-prot_none-map_fixed-holes-i.patch
+bugfix/all/mm-mmap.c-expand_downwards-don-t-require-the-gap-if-.patch
 
 # Miscellaneous features
 features/all/netfilter-nft_ct-add-notrack-support.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/linux.git



More information about the Kernel-svn-changes mailing list