]> git.baikalelectronics.ru Git - kernel.git/commit
mm: propagate error from stack expansion even for guard page
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 6 Jan 2015 21:00:05 +0000 (13:00 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 6 Jan 2015 21:00:05 +0000 (13:00 -0800)
commitc84dee83c742b67848e7162cd112ecfdabe3c303
tree002f1613fbaec50a2637abb0777128c3830fced7
parent016bd972173dd45f89745d2c8412fb2b4c30d084
mm: propagate error from stack expansion even for guard page

Jay Foad reports that the address sanitizer test (asan) sometimes gets
confused by a stack pointer that ends up being outside the stack vma
that is reported by /proc/maps.

This happens due to an interaction between RLIMIT_STACK and the guard
page: when we do the guard page check, we ignore the potential error
from the stack expansion, which effectively results in a missing guard
page, since the expected stack expansion won't have been done.

And since /proc/maps explicitly ignores the guard page (commit
e1ecaf04c1f8: "mm: fix up some user-visible effects of the stack guard
page"), the stack pointer ends up being outside the reported stack area.

This is the minimal patch: it just propagates the error.  It also
effectively makes the guard page part of the stack limit, which in turn
measn that the actual real stack is one page less than the stack limit.

Let's see if anybody notices.  We could teach acct_stack_growth() to
allow an extra page for a grow-up/grow-down stack in the rlimit test,
but I don't want to add more complexity if it isn't needed.

Reported-and-tested-by: Jay Foad <jay.foad@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/mm.h
mm/memory.c