diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2007-07-17 13:03:44 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-17 19:23:03 +0200 |
commit | f284ce7269031947326bac6bb19a977705276222 (patch) | |
tree | 8b145d42d4da182fb185dacc53b24ca7a2546114 /arch | |
parent | PTRACE_PEEKDATA consolidation (diff) | |
download | linux-f284ce7269031947326bac6bb19a977705276222.tar.xz linux-f284ce7269031947326bac6bb19a977705276222.zip |
PTRACE_POKEDATA consolidation
Identical implementations of PTRACE_POKEDATA go into generic_ptrace_pokedata()
function.
AFAICS, fix bug on xtensa where successful PTRACE_POKEDATA will nevertheless
return EPERM.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/alpha/kernel/ptrace.c | 4 | ||||
-rw-r--r-- | arch/arm/kernel/ptrace.c | 7 | ||||
-rw-r--r-- | arch/arm26/kernel/ptrace.c | 7 | ||||
-rw-r--r-- | arch/avr32/kernel/ptrace.c | 6 | ||||
-rw-r--r-- | arch/cris/arch-v10/kernel/ptrace.c | 7 | ||||
-rw-r--r-- | arch/cris/arch-v32/kernel/ptrace.c | 7 | ||||
-rw-r--r-- | arch/frv/kernel/ptrace.c | 4 | ||||
-rw-r--r-- | arch/h8300/kernel/ptrace.c | 5 | ||||
-rw-r--r-- | arch/i386/kernel/ptrace.c | 5 | ||||
-rw-r--r-- | arch/m32r/kernel/ptrace.c | 12 | ||||
-rw-r--r-- | arch/m68k/kernel/ptrace.c | 3 | ||||
-rw-r--r-- | arch/m68knommu/kernel/ptrace.c | 5 | ||||
-rw-r--r-- | arch/mips/kernel/ptrace.c | 6 | ||||
-rw-r--r-- | arch/powerpc/kernel/ptrace.c | 6 | ||||
-rw-r--r-- | arch/s390/kernel/ptrace.c | 5 | ||||
-rw-r--r-- | arch/sh/kernel/ptrace.c | 5 | ||||
-rw-r--r-- | arch/sh64/kernel/ptrace.c | 5 | ||||
-rw-r--r-- | arch/um/kernel/ptrace.c | 6 | ||||
-rw-r--r-- | arch/v850/kernel/ptrace.c | 6 | ||||
-rw-r--r-- | arch/x86_64/kernel/ptrace.c | 5 | ||||
-rw-r--r-- | arch/xtensa/kernel/ptrace.c | 5 |
21 files changed, 23 insertions, 98 deletions
diff --git a/arch/alpha/kernel/ptrace.c b/arch/alpha/kernel/ptrace.c index 0cd060598f9a..83a781842266 100644 --- a/arch/alpha/kernel/ptrace.c +++ b/arch/alpha/kernel/ptrace.c @@ -315,9 +315,7 @@ do_sys_ptrace(long request, long pid, long addr, long data, /* When I and D space are separate, this will have to be fixed. */ case PTRACE_POKETEXT: /* write the word at location addr. */ case PTRACE_POKEDATA: - tmp = data; - copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 1); - ret = (copied == sizeof(tmp)) ? 0 : -EIO; + ret = generic_ptrace_pokedata(child, addr, data); break; case PTRACE_POKEUSR: /* write the specified register */ diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c index 9a5d9754c2a2..78c9f1a3d41f 100644 --- a/arch/arm/kernel/ptrace.c +++ b/arch/arm/kernel/ptrace.c @@ -677,12 +677,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) */ case PTRACE_POKETEXT: case PTRACE_POKEDATA: - ret = access_process_vm(child, addr, &data, - sizeof(unsigned long), 1); - if (ret == sizeof(unsigned long)) - ret = 0; - else - ret = -EIO; + ret = generic_ptrace_pokedata(child, addr, data); break; case PTRACE_POKEUSR: diff --git a/arch/arm26/kernel/ptrace.c b/arch/arm26/kernel/ptrace.c index 0d0ead0e0a74..0fefb86970c6 100644 --- a/arch/arm26/kernel/ptrace.c +++ b/arch/arm26/kernel/ptrace.c @@ -551,12 +551,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) */ case PTRACE_POKETEXT: case PTRACE_POKEDATA: - ret = access_process_vm(child, addr, &data, - sizeof(unsigned long), 1); - if (ret == sizeof(unsigned long)) - ret = 0; - else - ret = -EIO; + ret = generic_ptrace_pokedata(child, addr, data); break; case PTRACE_POKEUSR: diff --git a/arch/avr32/kernel/ptrace.c b/arch/avr32/kernel/ptrace.c index 1043fdc2df7f..39060cbeb2a3 100644 --- a/arch/avr32/kernel/ptrace.c +++ b/arch/avr32/kernel/ptrace.c @@ -176,11 +176,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) /* Write the word in data at location addr */ case PTRACE_POKETEXT: case PTRACE_POKEDATA: - ret = access_process_vm(child, addr, &data, sizeof(data), 1); - if (ret == sizeof(data)) - ret = 0; - else - ret = -EIO; + ret = generic_ptrace_pokedata(child, addr, data); break; case PTRACE_POKEUSR: diff --git a/arch/cris/arch-v10/kernel/ptrace.c b/arch/cris/arch-v10/kernel/ptrace.c index 74b1b4dc8225..f4f9db698b44 100644 --- a/arch/cris/arch-v10/kernel/ptrace.c +++ b/arch/cris/arch-v10/kernel/ptrace.c @@ -103,12 +103,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) /* Write the word at location address. */ case PTRACE_POKETEXT: case PTRACE_POKEDATA: - ret = 0; - - if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data)) - break; - - ret = -EIO; + ret = generic_ptrace_pokedata(child, addr, data); break; /* Write the word at location address in the USER area. */ diff --git a/arch/cris/arch-v32/kernel/ptrace.c b/arch/cris/arch-v32/kernel/ptrace.c index d4d57b741334..38ece0cd47cb 100644 --- a/arch/cris/arch-v32/kernel/ptrace.c +++ b/arch/cris/arch-v32/kernel/ptrace.c @@ -146,12 +146,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) /* Write the word at location address. */ case PTRACE_POKETEXT: case PTRACE_POKEDATA: - ret = 0; - - if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data)) - break; - - ret = -EIO; + ret = generic_ptrace_pokedata(child, addr, data); break; /* Write the word at location address in the USER area. */ diff --git a/arch/frv/kernel/ptrace.c b/arch/frv/kernel/ptrace.c index a10f3092fad4..709e9bdc6126 100644 --- a/arch/frv/kernel/ptrace.c +++ b/arch/frv/kernel/ptrace.c @@ -168,9 +168,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ret = -EIO; if (is_user_addr_valid(child, addr, sizeof(tmp)) < 0) break; - if (access_process_vm(child, addr, &data, sizeof(data), 1) != sizeof(data)) - break; - ret = 0; + ret = generic_ptrace_pokedata(child, addr, data); break; case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ diff --git a/arch/h8300/kernel/ptrace.c b/arch/h8300/kernel/ptrace.c index 8a7a991b8f76..d32bbf02fc48 100644 --- a/arch/h8300/kernel/ptrace.c +++ b/arch/h8300/kernel/ptrace.c @@ -111,10 +111,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) /* when I and D space are separate, this will have to be fixed. */ case PTRACE_POKETEXT: /* write the word at location addr. */ case PTRACE_POKEDATA: - ret = 0; - if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data)) - break; - ret = -EIO; + ret = generic_ptrace_pokedata(child, addr, data); break; case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ diff --git a/arch/i386/kernel/ptrace.c b/arch/i386/kernel/ptrace.c index f4bcf1da662a..1c075f58d1f9 100644 --- a/arch/i386/kernel/ptrace.c +++ b/arch/i386/kernel/ptrace.c @@ -387,10 +387,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) /* when I and D space are separate, this will have to be fixed. */ case PTRACE_POKETEXT: /* write the word at location addr. */ case PTRACE_POKEDATA: - ret = 0; - if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data)) - break; - ret = -EIO; + ret = generic_ptrace_pokedata(child, addr, data); break; case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ diff --git a/arch/m32r/kernel/ptrace.c b/arch/m32r/kernel/ptrace.c index 01a1c9ac8458..57a92ef31a90 100644 --- a/arch/m32r/kernel/ptrace.c +++ b/arch/m32r/kernel/ptrace.c @@ -619,15 +619,9 @@ do_ptrace(long request, struct task_struct *child, long addr, long data) */ case PTRACE_POKETEXT: case PTRACE_POKEDATA: - ret = access_process_vm(child, addr, &data, sizeof(data), 1); - if (ret == sizeof(data)) { - ret = 0; - if (request == PTRACE_POKETEXT) { - invalidate_cache(); - } - } else { - ret = -EIO; - } + ret = generic_ptrace_pokedata(child, addr, data); + if (ret == 0 && request == PTRACE_POKETEXT) + invalidate_cache(); break; /* diff --git a/arch/m68k/kernel/ptrace.c b/arch/m68k/kernel/ptrace.c index 01a3a09c53d9..2cf0690b7882 100644 --- a/arch/m68k/kernel/ptrace.c +++ b/arch/m68k/kernel/ptrace.c @@ -157,8 +157,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) /* when I and D space are separate, this will have to be fixed. */ case PTRACE_POKETEXT: /* write the word at location addr. */ case PTRACE_POKEDATA: - if (access_process_vm(child, addr, &data, sizeof(data), 1) != sizeof(data)) - goto out_eio; + ret = generic_ptrace_pokedata(child, addr, data); break; case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ diff --git a/arch/m68knommu/kernel/ptrace.c b/arch/m68knommu/kernel/ptrace.c index f550e614aa78..ef70ca070ce2 100644 --- a/arch/m68knommu/kernel/ptrace.c +++ b/arch/m68knommu/kernel/ptrace.c @@ -151,10 +151,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) /* when I and D space are separate, this will have to be fixed. */ case PTRACE_POKETEXT: /* write the word at location addr. */ case PTRACE_POKEDATA: - ret = 0; - if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data)) - break; - ret = -EIO; + ret = generic_ptrace_pokedata(child, addr, data); break; case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c index af9d0bec8731..893e7bccf226 100644 --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c @@ -305,11 +305,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) /* when I and D space are separate, this will have to be fixed. */ case PTRACE_POKETEXT: /* write the word at location addr. */ case PTRACE_POKEDATA: - ret = 0; - if (access_process_vm(child, addr, &data, sizeof(data), 1) - == sizeof(data)) - break; - ret = -EIO; + ret = generic_ptrace_pokedata(child, addr, data); break; case PTRACE_POKEUSR: { diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index 581d427148e7..8a177bd9eab4 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -413,11 +413,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) /* If I and D space are separate, this will have to be fixed. */ case PTRACE_POKETEXT: /* write the word at location addr. */ case PTRACE_POKEDATA: - ret = 0; - if (access_process_vm(child, addr, &data, sizeof(data), 1) - == sizeof(data)) - break; - ret = -EIO; + ret = generic_ptrace_pokedata(child, addr, data); break; /* write the word at location addr in the USER area */ diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c index 28afff4e5d1b..f4503ca27630 100644 --- a/arch/s390/kernel/ptrace.c +++ b/arch/s390/kernel/ptrace.c @@ -314,10 +314,7 @@ do_ptrace_normal(struct task_struct *child, long request, long addr, long data) /* Remove high order bit from address (only for 31 bit). */ addr &= PSW_ADDR_INSN; /* write the word at location addr. */ - copied = access_process_vm(child, addr, &data, sizeof(data),1); - if (copied != sizeof(data)) - return -EIO; - return 0; + return generic_ptrace_pokedata(child, addr, data); case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ diff --git a/arch/sh/kernel/ptrace.c b/arch/sh/kernel/ptrace.c index f23f949576a5..891d1d46c902 100644 --- a/arch/sh/kernel/ptrace.c +++ b/arch/sh/kernel/ptrace.c @@ -126,10 +126,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) /* when I and D space are separate, this will have to be fixed. */ case PTRACE_POKETEXT: /* write the word at location addr. */ case PTRACE_POKEDATA: - ret = 0; - if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data)) - break; - ret = -EIO; + ret = generic_ptrace_pokedata(child, addr, data); break; case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ diff --git a/arch/sh64/kernel/ptrace.c b/arch/sh64/kernel/ptrace.c index 12340e499bfb..df06c6477468 100644 --- a/arch/sh64/kernel/ptrace.c +++ b/arch/sh64/kernel/ptrace.c @@ -158,10 +158,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) /* when I and D space are separate, this will have to be fixed. */ case PTRACE_POKETEXT: /* write the word at location addr. */ case PTRACE_POKEDATA: - ret = 0; - if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data)) - break; - ret = -EIO; + ret = generic_ptrace_pokedata(child, addr, data); break; case PTRACE_POKEUSR: diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c index 1966da6eb363..6916c8888dba 100644 --- a/arch/um/kernel/ptrace.c +++ b/arch/um/kernel/ptrace.c @@ -64,11 +64,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) /* when I and D space are separate, this will have to be fixed. */ case PTRACE_POKETEXT: /* write the word at location addr. */ case PTRACE_POKEDATA: - ret = -EIO; - if (access_process_vm(child, addr, &data, sizeof(data), - 1) != sizeof(data)) - break; - ret = 0; + ret = generic_ptrace_pokedata(child, addr, data); break; case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ diff --git a/arch/v850/kernel/ptrace.c b/arch/v850/kernel/ptrace.c index 3bedd144e52d..a458ac941b25 100644 --- a/arch/v850/kernel/ptrace.c +++ b/arch/v850/kernel/ptrace.c @@ -126,11 +126,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) case PTRACE_POKETEXT: /* write the word at location addr. */ case PTRACE_POKEDATA: - rval = 0; - if (access_process_vm(child, addr, &data, sizeof(data), 1) - == sizeof(data)) - break; - rval = -EIO; + rval = generic_ptrace_pokedata(child, addr, data); goto out; /* Read/write the word at location ADDR in the registers. */ diff --git a/arch/x86_64/kernel/ptrace.c b/arch/x86_64/kernel/ptrace.c index 327ff93a38b6..fa6775ef729f 100644 --- a/arch/x86_64/kernel/ptrace.c +++ b/arch/x86_64/kernel/ptrace.c @@ -359,10 +359,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) /* when I and D space are separate, this will have to be fixed. */ case PTRACE_POKETEXT: /* write the word at location addr. */ case PTRACE_POKEDATA: - ret = 0; - if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data)) - break; - ret = -EIO; + ret = generic_ptrace_pokedata(child, addr, data); break; case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ diff --git a/arch/xtensa/kernel/ptrace.c b/arch/xtensa/kernel/ptrace.c index af182d3a7000..06a13d9b69db 100644 --- a/arch/xtensa/kernel/ptrace.c +++ b/arch/xtensa/kernel/ptrace.c @@ -128,10 +128,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) case PTRACE_POKETEXT: /* write the word at location addr. */ case PTRACE_POKEDATA: - if (access_process_vm(child, addr, &data, sizeof(data), 1) - == sizeof(data)) - break; - ret = -EIO; + ret = generic_ptrace_pokedata(child, addr, data); goto out; case PTRACE_POKEUSR: |