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.

Signed-off-by: Bodo Stroesser <[EMAIL PROTECTED]>
---


diff -puN include/asm-um/processor-i386.h~stack_grow_check_SP 
include/asm-um/processor-i386.h
--- linux-2.6.10-mm3/include/asm-um/processor-i386.h~stack_grow_check_SP        
2005-01-17 14:39:32.349020626 +0100
+++ linux-2.6.10-mm3-root/include/asm-um/processor-i386.h       2005-01-17 
15:13:54.030087304 +0100
@@ -32,6 +32,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
diff -puN include/asm-um/processor-x86_64.h~stack_grow_check_SP 
include/asm-um/processor-x86_64.h
--- linux-2.6.10-mm3/include/asm-um/processor-x86_64.h~stack_grow_check_SP      
2005-01-17 14:39:51.373082903 +0100
+++ linux-2.6.10-mm3-root/include/asm-um/processor-x86_64.h     2005-01-17 
15:13:41.320365765 +0100
@@ -25,6 +25,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
diff -puN arch/um/kernel/trap_kern.c~stack_grow_check_SP 
arch/um/kernel/trap_kern.c
--- linux-2.6.10-mm3/arch/um/kernel/trap_kern.c~stack_grow_check_SP     
2005-01-17 14:45:34.450017573 +0100
+++ linux-2.6.10-mm3-root/arch/um/kernel/trap_kern.c    2005-01-17 
14:53:23.114777237 +0100
@@ -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;
 
_


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

Reply via email to