[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
Sat Dec 9 18:35:45 UTC 2017


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

benh pushed a commit to branch wheezy-security
in repository linux.

commit ed695767bec662e0c97c767a6140dd93480a931f
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 271e8ef..69da2c8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -214,6 +214,7 @@ linux (3.2.96-1) UNRELEASED; urgency=medium
   * mlx4*: Ignore ABI change
   * [rt] Update to 3.2.95-rt133
   * dm: Avoid ABI change in 3.2.95
+  * mm/mmap.c: expand_downwards: don't require the gap if !vm_prev
 
  -- Ben Hutchings <ben at decadent.org.uk>  Sun, 26 Nov 2017 20:43:54 +0000
 
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..4cbae1e
--- /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
+@@ -1776,7 +1776,6 @@ int expand_downwards(struct vm_area_stru
+ 				   unsigned long address)
+ {
+ 	struct vm_area_struct *prev;
+-	unsigned long gap_addr;
+ 	int error;
+ 
+ 	address &= PAGE_MASK;
+@@ -1785,15 +1784,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 fe9ac19..8166a39 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -106,6 +106,7 @@ bugfix/all/udf-Fix-handling-of-i_blocks.patch
 bugfix/all/kbuild-Fix-missing-n-for-NEW-symbols-in-yes-make-old.patch
 bugfix/all/netfilter-ipv4-defrag-set-local_df-flag-on-defragmen.patch
 bugfix/all/mm-add-pte_present-check-on-existing-hugetlb_entry-c.patch
+bugfix/all/mm-mmap.c-expand_downwards-don-t-require-the-gap-if-.patch
 
 # Miscellaneous features
 features/all/hwmon-it87-Add-IT8728F-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