ptrace: unify FDPIC implementations
authorMike Frysinger <vapier@gentoo.org>
Wed, 26 May 2010 21:42:52 +0000 (14:42 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 27 May 2010 16:12:44 +0000 (09:12 -0700)
The Blackfin/FRV/SuperH guys all have the same exact FDPIC ptrace code in
their arch handlers (since they were probably copied & pasted).  Since
these ptrace interfaces are an arch independent aspect of the FDPIC code,
unify them in the common ptrace code so new FDPIC ports don't need to copy
and paste this fundamental stuff yet again.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Acked-by: Roland McGrath <roland@redhat.com>
Acked-by: David Howells <dhowells@redhat.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/blackfin/kernel/ptrace.c
arch/frv/kernel/ptrace.c
arch/sh/kernel/ptrace_32.c
kernel/ptrace.c

index 43eb969405d1657bd0aba85b2528e9d28296bd55..6ec77685df526899c6998fe3030513714d42d5a8 100644 (file)
@@ -292,28 +292,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                        break;
                }
 
-#ifdef CONFIG_BINFMT_ELF_FDPIC
-       case PTRACE_GETFDPIC: {
-               unsigned long tmp = 0;
-
-               switch (addr) {
-               case_PTRACE_GETFDPIC_EXEC:
-               case PTRACE_GETFDPIC_EXEC:
-                       tmp = child->mm->context.exec_fdpic_loadmap;
-                       break;
-               case_PTRACE_GETFDPIC_INTERP:
-               case PTRACE_GETFDPIC_INTERP:
-                       tmp = child->mm->context.interp_fdpic_loadmap;
-                       break;
-               default:
-                       break;
-               }
-
-               ret = put_user(tmp, datap);
-               break;
-       }
-#endif
-
                /* when I and D space are separate, this will have to be fixed. */
        case PTRACE_POKEDATA:
                pr_debug("ptrace: PTRACE_PEEKDATA\n");
@@ -357,8 +335,14 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
        case PTRACE_PEEKUSR:
                switch (addr) {
 #ifdef CONFIG_BINFMT_ELF_FDPIC /* backwards compat */
-               case PT_FDPIC_EXEC:   goto case_PTRACE_GETFDPIC_EXEC;
-               case PT_FDPIC_INTERP: goto case_PTRACE_GETFDPIC_INTERP;
+               case PT_FDPIC_EXEC:
+                       request = PTRACE_GETFDPIC;
+                       addr = PTRACE_GETFDPIC_EXEC;
+                       goto case_default;
+               case PT_FDPIC_INTERP:
+                       request = PTRACE_GETFDPIC;
+                       addr = PTRACE_GETFDPIC_INTERP;
+                       goto case_default;
 #endif
                default:
                        ret = get_reg(child, addr, datap);
@@ -385,6 +369,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                                             0, sizeof(struct pt_regs),
                                             (const void __user *)data);
 
+       case_default:
        default:
                ret = ptrace_request(child, request, addr, data);
                break;
index 60eeed3694c0764d2d0b9d7d3a0c2cffe14b9a89..fac028936a041aab80f80506901e643787caaf3b 100644 (file)
@@ -344,26 +344,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                                             0, sizeof(child->thread.user->f),
                                             (const void __user *)data);
 
-       case PTRACE_GETFDPIC:
-               tmp = 0;
-               switch (addr) {
-               case PTRACE_GETFDPIC_EXEC:
-                       tmp = child->mm->context.exec_fdpic_loadmap;
-                       break;
-               case PTRACE_GETFDPIC_INTERP:
-                       tmp = child->mm->context.interp_fdpic_loadmap;
-                       break;
-               default:
-                       break;
-               }
-
-               ret = 0;
-               if (put_user(tmp, (unsigned long *) data)) {
-                       ret = -EFAULT;
-                       break;
-               }
-               break;
-
        default:
                ret = ptrace_request(child, request, addr, data);
                break;
index d4104ce9fe53c8a01fc354c41e0d57c5359a1d68..6c4bbba2a67573e2d1a72d2362bc28b4af4e2428 100644 (file)
@@ -435,29 +435,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                                             REGSET_DSP,
                                             0, sizeof(struct pt_dspregs),
                                             (const void __user *)data);
-#endif
-#ifdef CONFIG_BINFMT_ELF_FDPIC
-       case PTRACE_GETFDPIC: {
-               unsigned long tmp = 0;
-
-               switch (addr) {
-               case PTRACE_GETFDPIC_EXEC:
-                       tmp = child->mm->context.exec_fdpic_loadmap;
-                       break;
-               case PTRACE_GETFDPIC_INTERP:
-                       tmp = child->mm->context.interp_fdpic_loadmap;
-                       break;
-               default:
-                       break;
-               }
-
-               ret = 0;
-               if (put_user(tmp, datap)) {
-                       ret = -EFAULT;
-                       break;
-               }
-               break;
-       }
 #endif
        default:
                ret = ptrace_request(child, request, addr, data);
index 6af9cdd558b7b28b5d7e44cc78e3e7cced8582d5..4b4f72084d1ba21b79ef01a41f0c50439840a6dc 100644 (file)
@@ -594,6 +594,26 @@ int ptrace_request(struct task_struct *child, long request,
                ret = ptrace_detach(child, data);
                break;
 
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+       case PTRACE_GETFDPIC: {
+               unsigned long tmp = 0;
+
+               switch (addr) {
+               case PTRACE_GETFDPIC_EXEC:
+                       tmp = child->mm->context.exec_fdpic_loadmap;
+                       break;
+               case PTRACE_GETFDPIC_INTERP:
+                       tmp = child->mm->context.interp_fdpic_loadmap;
+                       break;
+               default:
+                       break;
+               }
+
+               ret = put_user(tmp, (unsigned long __user *) data);
+               break;
+       }
+#endif
+
 #ifdef PTRACE_SINGLESTEP
        case PTRACE_SINGLESTEP:
 #endif