Patch "mm: Don't count the stack guard page towards RLIMIT_STACK" has been added to the 3.14-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    mm: Don't count the stack guard page towards RLIMIT_STACK

to the 3.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     mm-don-t-count-the-stack-guard-page-towards-rlimit_stack.patch
and it can be found in the queue-3.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From 690eac53daff34169a4d74fc7bfbd388c4896abb Mon Sep 17 00:00:00 2001
From: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 11 Jan 2015 11:33:57 -0800
Subject: mm: Don't count the stack guard page towards RLIMIT_STACK

From: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

commit 690eac53daff34169a4d74fc7bfbd388c4896abb upstream.

Commit fee7e49d4514 ("mm: propagate error from stack expansion even for
guard page") made sure that we return the error properly for stack
growth conditions.  It also theorized that counting the guard page
towards the stack limit might break something, but also said "Let's see
if anybody notices".

Somebody did notice.  Apparently android-x86 sets the stack limit very
close to the limit indeed, and including the guard page in the rlimit
check causes the android 'zygote' process problems.

So this adds the (fairly trivial) code to make the stack rlimit check be
against the actual real stack size, rather than the size of the vma that
includes the guard page.

Reported-and-tested-by: Chih-Wei Huang <cwhuang@xxxxxxxxxxxxxxx>
Cc: Jay Foad <jay.foad@xxxxxxxxx>
Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
 mm/mmap.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2058,14 +2058,17 @@ static int acct_stack_growth(struct vm_a
 {
 	struct mm_struct *mm = vma->vm_mm;
 	struct rlimit *rlim = current->signal->rlim;
-	unsigned long new_start;
+	unsigned long new_start, actual_size;
 
 	/* address space limit tests */
 	if (!may_expand_vm(mm, grow))
 		return -ENOMEM;
 
 	/* Stack limit test */
-	if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
+	actual_size = size;
+	if (size && (vma->vm_flags & (VM_GROWSUP | VM_GROWSDOWN)))
+		actual_size -= PAGE_SIZE;
+	if (actual_size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
 		return -ENOMEM;
 
 	/* mlock limit tests */


Patches currently in stable-queue which might be from torvalds@xxxxxxxxxxxxxxxxxxxx are

queue-3.14/perf-x86-intel-uncore-make-sure-only-uncore-events-are-collected.patch
queue-3.14/drivers-rtc-rtc-sirfsoc.c-move-hardware-initilization-earlier-in-probe.patch
queue-3.14/nilfs2-fix-the-nilfs_iget-vs.-nilfs_new_inode-races.patch
queue-3.14/mm-vmscan-prevent-kswapd-livelock-due-to-pfmemalloc-throttled-process-being-killed.patch
queue-3.14/sched-deadline-avoid-double-accounting-in-case-of-missed-deadlines.patch
queue-3.14/revert-arm-7830-1-delay-don-t-bother-reporting-bogomips-in-proc-cpuinfo.patch
queue-3.14/ocfs2-fix-the-wrong-directory-passed-to-ocfs2_lookup_ino_from_name-when-link-file.patch
queue-3.14/sched-deadline-fix-migration-of-sched_deadline-tasks.patch
queue-3.14/drivers-rtc-rtc-isl12057.c-fix-masking-of-register-values.patch
queue-3.14/ocfs2-fix-journal-commit-deadlock.patch
queue-3.14/scripts-kernel-doc-don-t-eat-struct-members-with-__aligned.patch
queue-3.14/mm-don-t-count-the-stack-guard-page-towards-rlimit_stack.patch
queue-3.14/perf-fix-events-installation-during-moving-group.patch
queue-3.14/mm-propagate-error-from-stack-expansion-even-for-guard-page.patch
queue-3.14/perf-session-do-not-fail-on-processing-out-of-order-event.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]