mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: erg0t <ergot86@gmail.com>
To: mingo@elte.hu
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] i386 - sys_clone from vsyscall
Date: Wed, 11 Jan 2006 17:53:10 +0000	[thread overview]
Message-ID: <401b11ae0601110953h2389f118t3d4d11c33eece4f8@mail.gmail.com> (raw)

This patch fixes a little problem when sys_clone is called from a
vsyscall and a new stack
for the child is specifed.
Some regs, and return address are pushed in the stack before sysenter,
so when the syscall returns, pop the regs and return, if we made a new
stack for the thread
we need to copy that to the new stack or the thread will segfault.
Sorry for use the 0xffffe410 constant I didn't find another way to reference it.
And sorry for my english :S
	Signed-off-by: Daniel F <ergot86@gmail.com>

--- /usr/src/linux-2.6.14/arch/i386/kernel/process.c.orig    
2005-12-13 17:06:46.000000000 +0000
+++ /usr/src/linux-2.6.14/arch/i386/kernel/process.c  2006-01-11
15:19:01.000000000 +0000
@@ -446,6 +446,7 @@ int copy_thread(int nr, unsigned long cl
 {
        struct pt_regs * childregs;
        struct task_struct *tsk;
+       unsigned long vsyscall_stack[4] ;
        int err;

        childregs = ((struct pt_regs *) (THREAD_SIZE + (unsigned long)
p->thread_info)) - 1;
@@ -462,6 +463,17 @@ int copy_thread(int nr, unsigned long cl
        childregs = (struct pt_regs *) ((unsigned long) childregs - 8);
        *childregs = *regs;
        childregs->eax = 0;
+       /*
+        * When we were called from a vsyscall some thigs are pushed
on the stack,
+        * we need to copy the stuff to the new stack.
+        */
+       if ((regs->esp != esp) && (regs->eip == 0xffffe410)) {
+               if (copy_from_user(vsyscall_stack,(void
*)regs->esp,sizeof(vsyscall_stack)))
+                       return -EFAULT ;
+               if (copy_to_user((void
*)esp-sizeof(vsyscall_stack),vsyscall_stack,sizeof(vsyscall_stack)))
+                       return -EFAULT ;
+               esp -= sizeof(vsyscall_stack) ;
+       }
        childregs->esp = esp;

        p->thread.esp = (unsigned long) childregs;

             reply	other threads:[~2006-01-11 17:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-11 17:53 erg0t [this message]
2006-01-26  3:43 Chuck Ebbert
2006-01-26 15:12 ` Daniel fernandez
2006-01-26 16:41 Chuck Ebbert

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=401b11ae0601110953h2389f118t3d4d11c33eece4f8@mail.gmail.com \
    --to=ergot86@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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

all inboxes | Powered by JetHome®