Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ptrace: use ptrace_request() in the remaining architectures

Use ptrace_request() in the three remaining architectures that didn't use it
(m68knommu, h8300, microblaze). This means:

- ptrace_request now handles PTRACE_{PEEK,POKE}{TEXT,DATA} and PTRACE_DETATCH
calls that were previously called directly, or in case of h8300 even open
coded.
- adds new support for PTRACE_SETOPTIONS/PTRACE_GETEVENTMSG/
PTRACE_GETSIGINFO/PTRACE_SETSIGINFO

Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Acked-by: Greg Ungerer <gerg@uclinux.org>
Acked-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Christoph Hellwig and committed by
Linus Torvalds
b3c1e01a 7baab93f

+3 -72
+1 -29
arch/h8300/kernel/ptrace.c
··· 42 42 * in exit.c or in signal.c. 43 43 */ 44 44 45 - inline 46 - static int read_long(struct task_struct * tsk, unsigned long addr, 47 - unsigned long * result) 48 - { 49 - *result = *(unsigned long *)addr; 50 - return 0; 51 - } 52 - 53 45 void ptrace_disable(struct task_struct *child) 54 46 { 55 47 h8300_disable_trace(child); ··· 52 60 int ret; 53 61 54 62 switch (request) { 55 - case PTRACE_PEEKTEXT: /* read word at location addr. */ 56 - case PTRACE_PEEKDATA: { 57 - unsigned long tmp; 58 - 59 - ret = read_long(child, addr, &tmp); 60 - if (ret < 0) 61 - break ; 62 - ret = put_user(tmp, (unsigned long *) data); 63 - break ; 64 - } 65 - 66 63 /* read the word at location addr in the USER area. */ 67 64 case PTRACE_PEEKUSR: { 68 65 unsigned long tmp = 0; ··· 90 109 } 91 110 92 111 /* when I and D space are separate, this will have to be fixed. */ 93 - case PTRACE_POKETEXT: /* write the word at location addr. */ 94 - case PTRACE_POKEDATA: 95 - ret = generic_ptrace_pokedata(child, addr, data); 96 - break; 97 - 98 112 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ 99 113 if ((addr & 3) || addr < 0 || addr >= sizeof(struct user)) { 100 114 ret = -EIO; ··· 151 175 break; 152 176 } 153 177 154 - case PTRACE_DETACH: /* detach a process that was attached. */ 155 - ret = ptrace_detach(child, data); 156 - break; 157 - 158 178 case PTRACE_GETREGS: { /* Get all gp regs from the child. */ 159 179 int i; 160 180 unsigned long tmp; ··· 182 210 } 183 211 184 212 default: 185 - ret = -EIO; 213 + ret = ptrace_request(child, request, addr, data); 186 214 break; 187 215 } 188 216 return ret;
+1 -17
arch/m68knommu/kernel/ptrace.c
··· 116 116 int ret; 117 117 118 118 switch (request) { 119 - /* when I and D space are separate, these will need to be fixed. */ 120 - case PTRACE_PEEKTEXT: /* read word at location addr. */ 121 - case PTRACE_PEEKDATA: 122 - ret = generic_ptrace_peekdata(child, addr, data); 123 - break; 124 - 125 119 /* read the word at location addr in the USER area. */ 126 120 case PTRACE_PEEKUSR: { 127 121 unsigned long tmp; ··· 153 159 ret = put_user(tmp,(unsigned long *) data); 154 160 break; 155 161 } 156 - 157 - /* when I and D space are separate, this will have to be fixed. */ 158 - case PTRACE_POKETEXT: /* write the word at location addr. */ 159 - case PTRACE_POKEDATA: 160 - ret = generic_ptrace_pokedata(child, addr, data); 161 - break; 162 162 163 163 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ 164 164 ret = -EIO; ··· 246 258 break; 247 259 } 248 260 249 - case PTRACE_DETACH: /* detach a process that was attached. */ 250 - ret = ptrace_detach(child, data); 251 - break; 252 - 253 261 case PTRACE_GETREGS: { /* Get all gp regs from the child. */ 254 262 int i; 255 263 unsigned long tmp; ··· 309 325 break; 310 326 311 327 default: 312 - ret = -EIO; 328 + ret = ptrace_request(child, request, addr, data); 313 329 break; 314 330 } 315 331 return ret;
+1 -26
arch/microblaze/kernel/ptrace.c
··· 78 78 unsigned long copied; 79 79 80 80 switch (request) { 81 - case PTRACE_PEEKTEXT: /* read word at location addr. */ 82 - case PTRACE_PEEKDATA: 83 - pr_debug("PEEKTEXT/PEEKDATA at %08lX\n", addr); 84 - copied = access_process_vm(child, addr, &val, sizeof(val), 0); 85 - rval = -EIO; 86 - if (copied != sizeof(val)) 87 - break; 88 - rval = put_user(val, (unsigned long *)data); 89 - break; 90 - 91 - case PTRACE_POKETEXT: /* write the word at location addr. */ 92 - case PTRACE_POKEDATA: 93 - pr_debug("POKETEXT/POKEDATA to %08lX\n", addr); 94 - rval = 0; 95 - if (access_process_vm(child, addr, &data, sizeof(data), 1) 96 - == sizeof(data)) 97 - break; 98 - rval = -EIO; 99 - break; 100 - 101 81 /* Read/write the word at location ADDR in the registers. */ 102 82 case PTRACE_PEEKUSR: 103 83 case PTRACE_POKEUSR: ··· 147 167 wake_up_process(child); 148 168 break; 149 169 150 - case PTRACE_DETACH: /* detach a process that was attached. */ 151 - pr_debug("PTRACE_DETACH\n"); 152 - rval = ptrace_detach(child, data); 153 - break; 154 170 default: 155 - /* rval = ptrace_request(child, request, addr, data); noMMU */ 156 - rval = -EIO; 171 + rval = ptrace_request(child, request, addr, data); 157 172 } 158 173 return rval; 159 174 }