Commit 435b380d authored by Bodo Stroesser's avatar Bodo Stroesser Committed by Linus Torvalds

[PATCH] uml: disallow stack access below $esp like i386 / x86_64

When a page fault occurs on an address below the stack-vma, UML tries to
expand the stack.

On i386 and x86_64, the failing address is compared to the current userspace
stack pointer.  If the failing address is below "esp-32" resp.  "rsp-128",
stack expansion is not allowed, and a SIGSEGV is given to the user.

This patch makes UML behave like i386/x86_64.
Signed-off-by: default avatarBodo Stroesser <bstroesser@fujitsu-siemens.com>
Signed-off-by: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 3e80a943
......@@ -48,6 +48,8 @@ int handle_page_fault(unsigned long address, unsigned long ip,
goto good_area;
else if(!(vma->vm_flags & VM_GROWSDOWN))
goto out;
else if(!ARCH_IS_STACKGROW(address))
goto out;
else if(expand_stack(vma, address))
goto out;
......
......@@ -27,6 +27,9 @@ struct arch_thread {
#define current_text_addr() \
({ void *pc; __asm__("movl $1f,%0\n1:":"=g" (pc)); pc; })
#define ARCH_IS_STACKGROW(address) \
(address + 32 >= UPT_SP(&current->thread.regs.regs))
#include "asm/processor-generic.h"
#endif
......
......@@ -17,6 +17,9 @@ struct arch_thread {
#define current_text_addr() \
({ void *pc; __asm__("movq $1f,%0\n1:":"=g" (pc)); pc; })
#define ARCH_IS_STACKGROW(address) \
(address + 128 >= UPT_SP(&current->thread.regs.regs))
#include "asm/processor-generic.h"
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment