From: Jeff Dike <jdike@addtoit.com>
To: Andrew Morton <akpm@osdl.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
uml-devel <user-mode-linux-devel@lists.sourceforge.net>
Subject: [PATCH 4/6] UML - Stop specially protecting kernel stacks
Date: Thu, 2 Aug 2007 17:04:38 -0400 [thread overview]
Message-ID: <20070802210438.GA11184@c2.user-mode-linux.org> (raw)
Map all of physical memory as executable to avoid having to change
stack protections during fork and exit.
unprotect_stack is now called only from MODE_TT code, so it is marked
as such.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
--
arch/um/include/kern_util.h | 2 ++
arch/um/kernel/init_task.c | 2 ++
arch/um/kernel/physmem.c | 2 +-
arch/um/kernel/process.c | 5 ++---
4 files changed, 7 insertions(+), 4 deletions(-)
Index: linux-2.6.21-mm/arch/um/kernel/physmem.c
===================================================================
--- linux-2.6.21-mm.orig/arch/um/kernel/physmem.c 2007-08-02 16:43:17.000000000 -0400
+++ linux-2.6.21-mm/arch/um/kernel/physmem.c 2007-08-02 16:43:25.000000000 -0400
@@ -105,7 +105,7 @@ void __init setup_physmem(unsigned long
offset = uml_reserved - uml_physmem;
err = os_map_memory((void *) uml_reserved, physmem_fd, offset,
- len - offset, 1, 1, 0);
+ len - offset, 1, 1, 1);
if(err < 0){
os_print_error(err, "Mapping memory");
exit(1);
Index: linux-2.6.21-mm/arch/um/kernel/process.c
===================================================================
--- linux-2.6.21-mm.orig/arch/um/kernel/process.c 2007-08-02 16:43:17.000000000 -0400
+++ linux-2.6.21-mm/arch/um/kernel/process.c 2007-08-02 16:43:25.000000000 -0400
@@ -82,9 +82,9 @@ unsigned long alloc_stack(int order, int
if (atomic)
flags = GFP_ATOMIC;
page = __get_free_pages(flags, order);
- if(page == 0)
+ if (page == 0)
return 0;
- stack_protections(page);
+
return page;
}
@@ -141,7 +141,6 @@ void release_thread(struct task_struct *
void exit_thread(void)
{
- unprotect_stack((unsigned long) current_thread);
}
void *get_current(void)
Index: linux-2.6.21-mm/arch/um/include/kern_util.h
===================================================================
--- linux-2.6.21-mm.orig/arch/um/include/kern_util.h 2007-08-02 16:43:17.000000000 -0400
+++ linux-2.6.21-mm/arch/um/include/kern_util.h 2007-08-02 16:43:25.000000000 -0400
@@ -82,7 +82,9 @@ extern void check_stack_overflow(void *p
extern void relay_signal(int sig, union uml_pt_regs *regs);
extern int user_context(unsigned long sp);
extern void timer_irq(union uml_pt_regs *regs);
+#ifdef CONFIG_MODE_TT
extern void unprotect_stack(unsigned long stack);
+#endif
extern void do_uml_exitcalls(void);
extern int attach_debugger(int idle_pid, int pid, int stop);
extern int config_gdb(char *str);
Index: linux-2.6.21-mm/arch/um/kernel/init_task.c
===================================================================
--- linux-2.6.21-mm.orig/arch/um/kernel/init_task.c 2007-08-02 16:43:17.000000000 -0400
+++ linux-2.6.21-mm/arch/um/kernel/init_task.c 2007-08-02 16:43:25.000000000 -0400
@@ -47,7 +47,9 @@ union thread_union cpu0_irqstack
__attribute__((__section__(".data.init_irqstack"))) =
{ INIT_THREAD_INFO(init_task) };
+#ifdef CONFIG_MODE_TT
void unprotect_stack(unsigned long stack)
{
os_protect_memory((void *) stack, THREAD_SIZE, 1, 1, 0);
}
+#endif
reply other threads:[~2007-08-02 21:05 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=20070802210438.GA11184@c2.user-mode-linux.org \
--to=jdike@addtoit.com \
--cc=akpm@osdl.org \
--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