public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: blaisorblade@yahoo.it
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, jdike@addtoit.com,
	user-mode-linux-devel@lists.sourceforge.net,
	blaisorblade@yahoo.it, bstroesser@fujitsu-siemens.com
Subject: [patch 4/8] uml: disallow stack access below $esp like i386 / x86_64 [before 2.6.11]
Date: Fri, 04 Feb 2005 19:35:48 +0100	[thread overview]
Message-ID: <20050204183548.B9723310BD@zion> (raw)


From: Bodo Stroesser <bstroesser@fujitsu-siemens.com>

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 <bstroesser@fujitsu-siemens.com>
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 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(+)

diff -puN arch/um/kernel/trap_kern.c~uml-stack-expansion arch/um/kernel/trap_kern.c
--- linux-2.6.11/arch/um/kernel/trap_kern.c~uml-stack-expansion	2005-02-04 06:18:18.689557088 +0100
+++ linux-2.6.11-paolo/arch/um/kernel/trap_kern.c	2005-02-04 06:18:18.739549488 +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;
 
diff -puN include/asm-um/processor-i386.h~uml-stack-expansion include/asm-um/processor-i386.h
--- linux-2.6.11/include/asm-um/processor-i386.h~uml-stack-expansion	2005-02-04 06:18:18.726551464 +0100
+++ linux-2.6.11-paolo/include/asm-um/processor-i386.h	2005-02-04 06:18:18.739549488 +0100
@@ -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
diff -puN include/asm-um/processor-x86_64.h~uml-stack-expansion include/asm-um/processor-x86_64.h
--- linux-2.6.11/include/asm-um/processor-x86_64.h~uml-stack-expansion	2005-02-04 06:18:18.736549944 +0100
+++ linux-2.6.11-paolo/include/asm-um/processor-x86_64.h	2005-02-04 06:18:18.740549336 +0100
@@ -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
_

                 reply	other threads:[~2005-02-04 20:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050204183548.B9723310BD@zion \
    --to=blaisorblade@yahoo.it \
    --cc=akpm@osdl.org \
    --cc=bstroesser@fujitsu-siemens.com \
    --cc=jdike@addtoit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox