diff options
| author | Christoph Hellwig <hch@lst.de> | 2005-11-07 03:59:47 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-07 10:53:42 -0500 |
| commit | 481bed454247538e9f57d4ea37b153ccba24ba7b (patch) | |
| tree | bb4198296962c08dbf52e8f377dc27206f621640 /arch/x86_64 | |
| parent | db73e9aa99bf093427b79877f9475392724fd5e5 (diff) | |
[PATCH] consolidate sys_ptrace()
The sys_ptrace boilerplate code (everything outside the big switch
statement for the arch-specific requests) is shared by most architectures.
This patch moves it to kernel/ptrace.c and leaves the arch-specific code as
arch_ptrace.
Some architectures have a too different ptrace so we have to exclude them.
They continue to keep their implementations. For sh64 I had to add a
sh64_ptrace wrapper because it does some initialization on the first call.
For um I removed an ifdefed SUBARCH_PTRACE_SPECIAL block, but
SUBARCH_PTRACE_SPECIAL isn't defined anywhere in the tree.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Paul Mackerras <paulus@samba.org>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Acked-By: David Howells <dhowells@redhat.com>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/x86_64')
| -rw-r--r-- | arch/x86_64/kernel/ptrace.c | 43 |
1 files changed, 1 insertions, 42 deletions
diff --git a/arch/x86_64/kernel/ptrace.c b/arch/x86_64/kernel/ptrace.c index bbf64b59a21e..a87b6cebe80f 100644 --- a/arch/x86_64/kernel/ptrace.c +++ b/arch/x86_64/kernel/ptrace.c | |||
| @@ -313,48 +313,11 @@ static unsigned long getreg(struct task_struct *child, unsigned long regno) | |||
| 313 | 313 | ||
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data) | 316 | long arch_ptrace(struct task_struct *child, long request, long addr, long data) |
| 317 | { | 317 | { |
| 318 | struct task_struct *child; | ||
| 319 | long i, ret; | 318 | long i, ret; |
| 320 | unsigned ui; | 319 | unsigned ui; |
| 321 | 320 | ||
| 322 | /* This lock_kernel fixes a subtle race with suid exec */ | ||
| 323 | lock_kernel(); | ||
| 324 | ret = -EPERM; | ||
| 325 | if (request == PTRACE_TRACEME) { | ||
| 326 | /* are we already being traced? */ | ||
| 327 | if (current->ptrace & PT_PTRACED) | ||
| 328 | goto out; | ||
| 329 | ret = security_ptrace(current->parent, current); | ||
| 330 | if (ret) | ||
| 331 | goto out; | ||
| 332 | /* set the ptrace bit in the process flags. */ | ||
| 333 | current->ptrace |= PT_PTRACED; | ||
| 334 | ret = 0; | ||
| 335 | goto out; | ||
| 336 | } | ||
| 337 | ret = -ESRCH; | ||
| 338 | read_lock(&tasklist_lock); | ||
| 339 | child = find_task_by_pid(pid); | ||
| 340 | if (child) | ||
| 341 | get_task_struct(child); | ||
| 342 | read_unlock(&tasklist_lock); | ||
| 343 | if (!child) | ||
| 344 | goto out; | ||
| 345 | |||
| 346 | ret = -EPERM; | ||
| 347 | if (pid == 1) /* you may not mess with init */ | ||
| 348 | goto out_tsk; | ||
| 349 | |||
| 350 | if (request == PTRACE_ATTACH) { | ||
| 351 | ret = ptrace_attach(child); | ||
| 352 | goto out_tsk; | ||
| 353 | } | ||
| 354 | ret = ptrace_check_attach(child, request == PTRACE_KILL); | ||
| 355 | if (ret < 0) | ||
| 356 | goto out_tsk; | ||
| 357 | |||
| 358 | switch (request) { | 321 | switch (request) { |
| 359 | /* when I and D space are separate, these will need to be fixed. */ | 322 | /* when I and D space are separate, these will need to be fixed. */ |
| 360 | case PTRACE_PEEKTEXT: /* read word at location addr. */ | 323 | case PTRACE_PEEKTEXT: /* read word at location addr. */ |
| @@ -608,10 +571,6 @@ asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data | |||
| 608 | ret = ptrace_request(child, request, addr, data); | 571 | ret = ptrace_request(child, request, addr, data); |
| 609 | break; | 572 | break; |
| 610 | } | 573 | } |
| 611 | out_tsk: | ||
| 612 | put_task_struct(child); | ||
| 613 | out: | ||
| 614 | unlock_kernel(); | ||
| 615 | return ret; | 574 | return ret; |
| 616 | } | 575 | } |
| 617 | 576 | ||
