]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
c6x: sanitize copy_thread(), get rid of clone(2) wrapper, switch to generic clone()
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 21 Oct 2012 20:37:49 +0000 (16:37 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 29 Nov 2012 04:43:39 +0000 (23:43 -0500)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/c6x/include/asm/syscalls.h
arch/c6x/include/uapi/asm/unistd.h
arch/c6x/kernel/entry.S
arch/c6x/kernel/process.c

index e7b8991dc07c69c25425fce66c16306dcede12d1..df3d05feb153af684c7405913740b549c752baee 100644 (file)
@@ -41,10 +41,6 @@ extern long sys_fallocate_c6x(int fd, int mode,
                              u32 len_lo, u32 len_hi);
 extern int sys_cache_sync(unsigned long s, unsigned long e);
 
-struct pt_regs;
-
-extern asmlinkage long sys_c6x_clone(struct pt_regs *regs);
-
 #include <asm-generic/syscalls.h>
 
 #endif /* __ASM_C6X_SYSCALLS_H */
index 625beafb9cd152f1d0489beaa1edf57464b1887a..f3987a8703d92ba18be7cbe949b155985ee59aa3 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #define __ARCH_WANT_SYS_EXECVE
+#define __ARCH_WANT_SYS_CLONE
 
 /* Use the standard ABI for syscalls. */
 #include <asm-generic/unistd.h>
index 75f6f36472cfa8cd5bdb29057d0d2b1b904ef70f..1037b98953ca437009770e193ed34bcace91c737 100644 (file)
@@ -613,18 +613,6 @@ ENDPROC(sys_sigaltstack)
        ;; Special system calls
        ;; return address is in B3
        ;;
-ENTRY(sys_clone)
-       ADD     .D1X    SP,8,A4
-#ifdef CONFIG_C6X_BIG_KERNEL
- ||    MVKL    .S1     sys_c6x_clone,A0
-       MVKH    .S1     sys_c6x_clone,A0
-       BNOP    .S2X    A0,5
-#else
- ||    B       .S2     sys_c6x_clone
-       NOP     5
-#endif
-ENDPROC(sys_clone)
-
 ENTRY(sys_rt_sigreturn)
        ADD     .D1X    SP,8,A4
 #ifdef CONFIG_C6X_BIG_KERNEL
index 2770d9a9a84edbc4d66b9cbae3e39aff8f001d38..a3f91895e8b48567d5ab68d6faa503884f7e487e 100644 (file)
@@ -112,22 +112,6 @@ void exit_thread(void)
 {
 }
 
-SYSCALL_DEFINE1(c6x_clone, struct pt_regs *, regs)
-{
-       unsigned long clone_flags;
-       unsigned long newsp;
-
-       /* syscall puts clone_flags in A4 and usp in B4 */
-       clone_flags = regs->orig_a4;
-       if (regs->b4)
-               newsp = regs->b4;
-       else
-               newsp = regs->sp;
-
-       return do_fork(clone_flags, newsp, regs, 0, (int __user *)regs->a6,
-                      (int __user *)regs->b6);
-}
-
 /*
  * Do necessary setup to start up a newly executed thread.
  */
@@ -155,13 +139,13 @@ void start_thread(struct pt_regs *regs, unsigned int pc, unsigned long usp)
  */
 int copy_thread(unsigned long clone_flags, unsigned long usp,
                unsigned long ustk_size,
-               struct task_struct *p, struct pt_regs *regs)
+               struct task_struct *p, struct pt_regs *unused)
 {
        struct pt_regs *childregs;
 
        childregs = task_pt_regs(p);
 
-       if (!regs) {
+       if (unlikely(p->flags & PF_KTHREAD)) {
                /* case of  __kernel_thread: we return to supervisor space */
                memset(childregs, 0, sizeof(struct pt_regs));
                childregs->sp = (unsigned long)(childregs + 1);
@@ -170,8 +154,9 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
                childregs->a1 = ustk_size;      /* argument */
        } else {
                /* Otherwise use the given stack */
-               *childregs = *regs;
-               childregs->sp = usp;
+               *childregs = *current_pt_regs();
+               if (usp)
+                       childregs->sp = usp;
                p->thread.pc = (unsigned long) ret_from_fork;
        }