uml: disallow stack access below $esp like i386 / x86_64 [before 2.6.11]
PATCH 4/8 uml: disallow stack access below $esp like i386 / x86_64 [before 2.6.11]
From: Bodo Stroesser <[email protected]>
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.
---
linux-2.6.11-paolo/arch/um/kernel/trap_kern.c | 2 ++ linux-2.6.11-paolo/include/asm-um/processor-i386.h | 3 +++ linux-2.6.11-paolo/include/asm-um/processor-x86_64.h | 3 +++ 3 files changed, 8 insertions(+)
arch/um/kernel/trap_kern.c renamed from arch/um/kernel/trap_kern.c~uml-stack-expansion +2 -0
@@ -48,6 +48,8 @@ int handle_page_fault(unsigned long addr 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;
include/asm-um/processor-i386.h renamed from include/asm-um/processor-i386.h~uml-stack-expansion +3 -0
@@ -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(¤t->thread.regs.regs)) +#include "asm/processor-generic.h" #endif
include/asm-um/processor-x86_64.h renamed from include/asm-um/processor-x86_64.h~uml-stack-expansion +3 -0
@@ -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(¤t->thread.regs.regs)) +#include "asm/processor-generic.h" #endif
_
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel