]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
MIPS: Use compat_sys_ptrace
authorThomas Bogendoerfer <tsbogend@alpha.franken.de>
Sun, 17 Aug 2008 14:49:25 +0000 (16:49 +0200)
committerRalf Baechle <ralf@linux-mips.org>
Sat, 11 Oct 2008 15:18:41 +0000 (16:18 +0100)
This replaces mips's sys_ptrace32 with a compat_arch_ptrace and
enables the new generic definition of compat_sys_ptrace instead.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/kernel/ptrace32.c
arch/mips/kernel/scall64-n32.S
arch/mips/kernel/scall64-o32.S
arch/mips/kernel/signal32.c
include/asm-mips/ptrace.h

index 76818be6ba7ce1511b37061c5cf4c9649d9397c7..cac56a8c8679a28183a3a4be42f86891116dd9b6 100644 (file)
@@ -15,6 +15,7 @@
  * binaries.
  */
 #include <linux/compiler.h>
+#include <linux/compat.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
@@ -46,37 +47,13 @@ int ptrace_setfpregs(struct task_struct *child, __u32 __user *data);
  * Tracing a 32-bit process with a 64-bit strace and vice versa will not
  * work.  I don't know how to fix this.
  */
-asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
+long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
+                       compat_ulong_t caddr, compat_ulong_t cdata)
 {
-       struct task_struct *child;
+       int addr = caddr;
+       int data = cdata;
        int ret;
 
-#if 0
-       printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",
-              (int) request, (int) pid, (unsigned long) addr,
-              (unsigned long) data);
-#endif
-       lock_kernel();
-       if (request == PTRACE_TRACEME) {
-               ret = ptrace_traceme();
-               goto out;
-       }
-
-       child = ptrace_get_task_struct(pid);
-       if (IS_ERR(child)) {
-               ret = PTR_ERR(child);
-               goto out;
-       }
-
-       if (request == PTRACE_ATTACH) {
-               ret = ptrace_attach(child);
-               goto out_tsk;
-       }
-
-       ret = ptrace_check_attach(child, request == PTRACE_KILL);
-       if (ret < 0)
-               goto out_tsk;
-
        switch (request) {
        /* when I and D space are separate, these will need to be fixed. */
        case PTRACE_PEEKTEXT: /* read word at location addr. */
@@ -214,7 +191,7 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
                        if (!cpu_has_dsp) {
                                tmp = 0;
                                ret = -EIO;
-                               goto out_tsk;
+                               goto out;
                        }
                        dregs = __get_dsp_regs(child);
                        tmp = (unsigned long) (dregs[addr - DSP_BASE]);
@@ -224,14 +201,14 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
                        if (!cpu_has_dsp) {
                                tmp = 0;
                                ret = -EIO;
-                               goto out_tsk;
+                               goto out;
                        }
                        tmp = child->thread.dsp.dspcontrol;
                        break;
                default:
                        tmp = 0;
                        ret = -EIO;
-                       goto out_tsk;
+                       goto out;
                }
                ret = put_user(tmp, (unsigned __user *) (unsigned long) data);
                break;
@@ -414,10 +391,6 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
                ret = ptrace_request(child, request, addr, data);
                break;
        }
-
-out_tsk:
-       put_task_struct(child);
 out:
-       unlock_kernel();
        return ret;
 }
index da7f1b6ea0fb128344cf1da80f32593c1967f050..324c5499dec28c4b29cb529a9bc5032c71ba9aa1 100644 (file)
@@ -219,7 +219,7 @@ EXPORT(sysn32_call_table)
        PTR     compat_sys_getrusage
        PTR     compat_sys_sysinfo
        PTR     compat_sys_times
-       PTR     sys32_ptrace
+       PTR     compat_sys_ptrace
        PTR     sys_getuid                      /* 6100 */
        PTR     sys_syslog
        PTR     sys_getgid
index d7cd1aac9ada9a646d49189a35179a2815460897..85fedac99a578eb67e732b8762856eda3ca766c1 100644 (file)
@@ -231,7 +231,7 @@ sys_call_table:
        PTR     sys_setuid
        PTR     sys_getuid
        PTR     compat_sys_stime                /* 4025 */
-       PTR     sys32_ptrace
+       PTR     compat_sys_ptrace
        PTR     sys_alarm
        PTR     sys_ni_syscall                  /* was sys_fstat */
        PTR     sys_pause
index 572c610db1b11c4fe2b31da5150abaa431936be1..652709b353adf045be0a1e526910844f467dff0b 100644 (file)
@@ -482,6 +482,18 @@ int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from)
        return err;
 }
 
+int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
+{
+       memset(to, 0, sizeof *to);
+
+       if (copy_from_user(to, from, 3*sizeof(int)) ||
+           copy_from_user(to->_sifields._pad,
+                          from->_sifields._pad, SI_PAD_SIZE32))
+               return -EFAULT;
+
+       return 0;
+}
+
 asmlinkage void sys32_sigreturn(nabi_no_regargs struct pt_regs regs)
 {
        struct sigframe32 __user *frame;
index 786f7e3c99bcfe591422c4c2ceec98ab0f97c6ec..c00cca24dae0427544520a156c186e57f9877a1f 100644 (file)
@@ -9,6 +9,9 @@
 #ifndef _ASM_PTRACE_H
 #define _ASM_PTRACE_H
 
+#ifdef CONFIG_64BIT
+#define __ARCH_WANT_COMPAT_SYS_PTRACE
+#endif
 
 /* 0 - 31 are integer registers, 32 - 63 are fp registers.  */
 #define FPR_BASE       32