[PATCH] i386 - sys_clone from vsyscall

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <[email protected]>

--- /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;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux