History

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 d7824370e263: "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.

Linus Torvalds committed 11 years ago

Commit fee7e491 parent b1940cd2 files · +3 −3Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/mm.h+1−1
@@ -1952,7 +1952,7 @@ extern int expand_downwards(struct vm_area_struct *vma, · 1951 unmodified lines
1952#if VM_GROWSUP1952#if VM_GROWSUP
1953extern int expand_upwards(struct vm_area_struct *vma, unsigned long address);1953extern int expand_upwards(struct vm_area_struct *vma, unsigned long address);
1954#else1954#else
1955 #define expand_upwards(vma, address) do { } while (0)1955 #define expand_upwards(vma, address) (0)
1956#endif1956#endif
1957 1957
1958/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */1958/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t