ptrace cleanups
Subsystems (16)
PATCH v2 3/24 ptrace: change signature of arch_ptrace()
In reply to Namhyung KimFix up the arguments to arch_ptrace() to take account of the fact that @addr and @data are now unsigned long rather than long as of a preceding patch in this series.
--- arch/alpha/kernel/ptrace.c | 7 ++++--- arch/arm/kernel/ptrace.c | 3 ++- arch/avr32/kernel/ptrace.c | 3 ++- arch/blackfin/kernel/ptrace.c | 3 ++- arch/cris/arch-v10/kernel/ptrace.c | 7 ++++--- arch/cris/arch-v32/kernel/ptrace.c | 3 ++- arch/frv/kernel/ptrace.c | 3 ++- arch/h8300/kernel/ptrace.c | 7 ++++--- arch/ia64/kernel/ptrace.c | 3 ++- arch/m32r/kernel/ptrace.c | 3 ++- arch/m68k/kernel/ptrace.c | 9 +++++---- arch/m68knommu/kernel/ptrace.c | 9 +++++---- arch/microblaze/kernel/ptrace.c | 3 ++- arch/mips/kernel/ptrace.c | 3 ++- arch/mn10300/kernel/ptrace.c | 3 ++- arch/parisc/kernel/ptrace.c | 11 ++++++----- arch/powerpc/kernel/ptrace.c | 15 ++++++++------- arch/s390/kernel/ptrace.c | 3 ++- arch/score/kernel/ptrace.c | 3 ++- arch/sh/kernel/ptrace_32.c | 25 +++++++++++++------------ arch/sh/kernel/ptrace_64.c | 6 ++++-- arch/sparc/kernel/ptrace_32.c | 3 ++- arch/sparc/kernel/ptrace_64.c | 7 ++++--- arch/tile/kernel/ptrace.c | 7 ++++--- arch/um/kernel/ptrace.c | 5 +++-- arch/um/sys-i386/ptrace.c | 4 ++-- arch/um/sys-x86_64/ptrace.c | 4 ++-- arch/x86/kernel/ptrace.c | 7 ++++--- arch/xtensa/kernel/ptrace.c | 3 ++- include/linux/ptrace.h | 3 ++- 30 files changed, 102 insertions(+), 73 deletions(-)
arch/alpha/kernel/ptrace.c +4 -3
@@ -269,7 +269,8 @@ void ptrace_disable(struct task_struct *child)user_disable_single_step (child); } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {unsigned long tmp;size_t copied;
@@ -292,7 +293,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)case PTRACE_PEEKUSR :force_successful_syscall_return (); ret =get_reg (child, addr); -DBG (DBG_MEM , ("peek $%ld->%#lx\n" , addr, ret)); +DBG (DBG_MEM , ("peek $%lu->%#lx\n" , addr, ret));break ;/* When I and D space are separate, this will have to be fixed. */
@@ -302,7 +303,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)break ;case PTRACE_POKEUSR :/* write the specified register */ -DBG (DBG_MEM , ("poke $%ld<-%#lx\n" , addr, data)); +DBG (DBG_MEM , ("poke $%lu<-%#lx\n" , addr, data)); ret =put_reg (child, addr, data);break ;default :
arch/arm/kernel/ptrace.c +2 -1
@@ -847,7 +847,8 @@ static int ptrace_setvfpregs(struct task_struct *tsk, void __user *data) }#endif -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int ret;
arch/avr32/kernel/ptrace.c +2 -1
@@ -146,7 +146,8 @@ static int ptrace_setregs(struct task_struct *tsk, const void __user *uregs)return ret; } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int ret;
arch/blackfin/kernel/ptrace.c +2 -1
@@ -232,7 +232,8 @@ void user_disable_single_step(struct task_struct *child)clear_tsk_thread_flag (child,TIF_SINGLESTEP ); } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int ret;unsigned long __user *datap = (unsigned long __user *)data;
arch/cris/arch-v10/kernel/ptrace.c +4 -3
@@ -76,7 +76,8 @@ ptrace_disable(struct task_struct *child)* (in user space) where the result of the ptrace call is written (instead of * being returned). */ -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int ret;unsigned long __user *datap = (unsigned long __user *)data;
@@ -141,7 +142,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)break ; } - data +=sizeof (long ); + data +=sizeof (unsigned long ); }break ;
@@ -165,7 +166,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) }put_reg (child, i, tmp); - data +=sizeof (long ); + data +=sizeof (unsigned long ); }break ;
arch/cris/arch-v32/kernel/ptrace.c +2 -1
@@ -126,7 +126,8 @@ ptrace_disable(struct task_struct *child) } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int ret;unsigned long __user *datap = (unsigned long __user *)data;
arch/frv/kernel/ptrace.c +2 -1
@@ -254,7 +254,8 @@ void ptrace_disable(struct task_struct *child)user_disable_single_step (child); } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {unsigned long tmp;int ret;
arch/h8300/kernel/ptrace.c +4 -3
@@ -50,7 +50,8 @@ void ptrace_disable(struct task_struct *child)user_disable_single_step (child); } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int ret;
@@ -120,7 +121,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ret = -EFAULT ;break ; } - data +=sizeof (long ); + data +=sizeof (unsigned long ); } ret =0 ;break ;
@@ -135,7 +136,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)break ; }h8300_put_reg (child, i, tmp); - data +=sizeof (long ); + data +=sizeof (unsigned long ); } ret =0 ;break ;
arch/ia64/kernel/ptrace.c +2 -1
@@ -1177,7 +1177,8 @@ ptrace_disable (struct task_struct *child) }long -arch_ptrace (struct task_struct *child,long request,long addr,long data) +arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {switch (request) {case PTRACE_PEEKTEXT :
arch/m32r/kernel/ptrace.c +2 -1
@@ -621,7 +621,8 @@ void ptrace_disable(struct task_struct *child) }long -arch_ptrace (struct task_struct *child,long request,long addr,long data) +arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int ret;
arch/m68k/kernel/ptrace.c +5 -4
@@ -156,7 +156,8 @@ void user_disable_single_step(struct task_struct *child)singlestep_disable (child); } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {unsigned long tmp;int i, ret =0 ;
@@ -200,7 +201,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)* into internal fpu reg representation */ if (FPU_IS_EMU && (addr <45 ) && !(addr %3 )) { - data = (unsigned long )data <<15 ; + data <<=15 ; data = (data &0xffff0000 ) | ((data &0x0000ffff ) >>1 ); }
@@ -215,7 +216,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ret =put_user (tmp, (unsigned long *)data);if (ret)break ; - data +=sizeof (long ); + data +=sizeof (unsigned long ); }break ;
@@ -229,7 +230,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) tmp |=get_reg (child,PT_SR ) & ~SR_MASK ; }put_reg (child, i, tmp); - data +=sizeof (long ); + data +=sizeof (unsigned long ); }break ;
arch/m68knommu/kernel/ptrace.c +5 -4
@@ -111,7 +111,8 @@ void ptrace_disable(struct task_struct *child)user_disable_single_step (child); } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int ret;
@@ -180,7 +181,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)* into internal fpu reg representation */ if (FPU_IS_EMU && (addr <45 ) && !(addr %3 )) { - data = (unsigned long )data <<15 ; + data <<=15 ; data = (data &0xffff0000 ) | ((data &0x0000ffff ) >>1 ); }
@@ -201,7 +202,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ret = -EFAULT ;break ; } - data +=sizeof (long ); + data +=sizeof (unsigned long ); } ret =0 ;break ;
@@ -221,7 +222,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) tmp |=get_reg (child,PT_SR ) & ~(SR_MASK <<16 ); }put_reg (child, i, tmp); - data +=sizeof (long ); + data +=sizeof (unsigned long ); } ret =0 ;break ;
arch/microblaze/kernel/ptrace.c +2 -1
@@ -73,7 +73,8 @@ static microblaze_reg_t *reg_save_addr(unsigned reg_offs,return (microblaze_reg_t *)((char *)regs + reg_offs); } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int rval;unsigned long val =0 ;
arch/mips/kernel/ptrace.c +2 -1
@@ -255,7 +255,8 @@ int ptrace_set_watch_regs(struct task_struct *child,return 0 ; } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int ret;
arch/mn10300/kernel/ptrace.c +2 -1
@@ -295,7 +295,8 @@ void ptrace_disable(struct task_struct *child)/* * handle the arch-specific side of process tracing */ -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {unsigned long tmp;int ret;
arch/parisc/kernel/ptrace.c +6 -5
@@ -110,7 +110,8 @@ void user_enable_block_step(struct task_struct *task)pa_psw (task)->l =0 ; } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {unsigned long tmp;long ret = -EIO ;
@@ -120,8 +121,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)/* Read the word at location addr in the USER area. For ptraced processes, the kernel saves all regs on a syscall. */ case PTRACE_PEEKUSR : -if ((addr & (sizeof (long )-1 )) || - (unsigned long ) addr >=sizeof (struct pt_regs )) +if ((addr & (sizeof (unsigned long )-1 )) || + addr >=sizeof (struct pt_regs ))break ; tmp = *(unsigned long *) ((char *)task_regs (child) + addr); ret =put_user (tmp, (unsigned long *) data);
@@ -151,8 +152,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)break ; } -if ((addr & (sizeof (long )-1 )) || - (unsigned long ) addr >=sizeof (struct pt_regs )) +if ((addr & (sizeof (unsigned long )-1 )) || + addr >=sizeof (struct pt_regs ))break ; if ((addr >= PT_GR1 && addr <= PT_GR31) || addr == PT_IAOQ0 || addr == PT_IAOQ1 ||
arch/powerpc/kernel/ptrace.c +8 -7
@@ -1406,8 +1406,8 @@ static long ppc_del_hwdebug(struct task_struct *child, long addr, long data)* Here are the old "legacy" powerpc specific getregs/setregs ptrace calls, * we mark them as obsolete now, they will be removed in a future version */ -static long arch_ptrace_old (struct task_struct *child,long request,long addr, -long data) +static long arch_ptrace_old (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {switch (request) {case PPC_PTRACE_GETREGS :/* Get GPRs 0 - 31. */
@@ -1434,7 +1434,8 @@ static long arch_ptrace_old(struct task_struct *child, long request, long addr,return -EPERM ; } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int ret = -EPERM ;
@@ -1446,11 +1447,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ret = -EIO ;/* convert to index and check */ #ifdef CONFIG_PPC32 - index = (unsigned long ) addr >>2 ; + index = addr >>2 ;if ((addr &3 ) || (index >PT_FPSCR ) || (child->thread.regs ==NULL )) #else - index = (unsigned long ) addr >>3 ; + index = addr >>3 ; if ((addr & 7) || (index > PT_FPSCR))#endif break ;
@@ -1474,11 +1475,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ret = -EIO ;/* convert to index and check */ #ifdef CONFIG_PPC32 - index = (unsigned long ) addr >>2 ; + index = addr >>2 ;if ((addr &3 ) || (index >PT_FPSCR ) || (child->thread.regs ==NULL )) #else - index = (unsigned long ) addr >>3 ; + index = addr >>3 ; if ((addr & 7) || (index > PT_FPSCR))#endif break ;
arch/s390/kernel/ptrace.c +2 -1
@@ -343,7 +343,8 @@ poke_user(struct task_struct *child, addr_t addr, addr_t data)return __poke_user (child, addr, data); } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {ptrace_area parea;int copied, ret;
arch/score/kernel/ptrace.c +2 -1
@@ -325,7 +325,8 @@ void ptrace_disable(struct task_struct *child) }long -arch_ptrace (struct task_struct *child,long request,long addr,long data) +arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int ret;unsigned long __user *datap = (void __user *)data;
arch/sh/kernel/ptrace_32.c +13 -12
@@ -338,7 +338,8 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)return &user_sh_native_view; } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {struct user * dummy =NULL ;unsigned long __user *datap = (unsigned long __user *)data;
@@ -356,17 +357,17 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)if (addr <sizeof (struct pt_regs )) tmp =get_stack_long (child, addr); -else if (addr >= (long ) &dummy->fpu && - addr < (long ) &dummy->u_fpvalid) { +else if (addr >= (unsigned long ) &dummy->fpu && + addr < (unsigned long ) &dummy->u_fpvalid) {if (!tsk_used_math (child)) { -if (addr == (long )&dummy->fpu.fpscr) +if (addr == (unsigned long )&dummy->fpu.fpscr) tmp =FPSCR_INIT ;else tmp =0 ; }else - tmp = ((long *)child->thread.xstate) - [(addr - (long )&dummy->fpu) >>2 ]; - }else if (addr == (long ) &dummy->u_fpvalid) + tmp = ((unsigned long *)child->thread.xstate) + [(addr - (unsigned long )&dummy->fpu) >>2 ]; + }else if (addr == (unsigned long ) &dummy->u_fpvalid) tmp = !!tsk_used_math (child);else if (addr ==PT_TEXT_ADDR ) tmp = child->mm->start_code;
@@ -390,13 +391,13 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)if (addr <sizeof (struct pt_regs )) ret =put_stack_long (child, addr, data); -else if (addr >= (long ) &dummy->fpu && - addr < (long ) &dummy->u_fpvalid) { +else if (addr >= (unsigned long ) &dummy->fpu && + addr < (unsigned long ) &dummy->u_fpvalid) {set_stopped_child_used_math (child); - ((long *)child->thread.xstate) - [(addr - (long )&dummy->fpu) >>2 ] = data; + ((unsigned long *)child->thread.xstate) + [(addr - (unsigned long )&dummy->fpu) >>2 ] = data; ret =0 ; - }else if (addr == (long ) &dummy->u_fpvalid) { + }else if (addr == (unsigned long ) &dummy->u_fpvalid) {conditional_stopped_child_used_math (data, child); ret =0 ; }
arch/sh/kernel/ptrace_64.c +4 -2
@@ -304,7 +304,8 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)return &user_sh64_native_view; } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int ret;
@@ -392,7 +393,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)return ret; } -asmlinkage int sh64_ptrace(long request, long pid, long addr, long data) +asmlinkage int sh64_ptrace(long request, long pid, +unsigned long addr,unsigned long data) {#define WPC_DBRMODE 0x0d104008static int first_call =1 ;
arch/sparc/kernel/ptrace_32.c +2 -1
@@ -323,7 +323,8 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)return &user_sparc32_view; } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {unsigned long addr2 = current->thread.kregs->u_regs[UREG_I4 ];const struct user_regset_view *view;
arch/sparc/kernel/ptrace_64.c +4 -3
@@ -969,7 +969,8 @@ struct fps {unsigned long fsr; }; -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {const struct user_regset_view *view =task_user_regset_view (current);unsigned long addr2 =task_pt_regs (current)->u_regs[UREG_I4 ];
@@ -977,8 +978,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)struct fps __user *fps;int ret; - pregs = (struct pt_regs __user *) (unsigned long ) addr; - fps = (struct fps __user *) (unsigned long ) addr; + pregs = (struct pt_regs __user *) addr; + fps = (struct fps __user *) addr;switch (request) {case PTRACE_PEEKUSR :
arch/tile/kernel/ptrace.c +4 -3
@@ -64,7 +64,8 @@ void ptrace_disable(struct task_struct *child)clear_tsk_thread_flag (child,TIF_SYSCALL_TRACE ); } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {unsigned long __user *datap;unsigned long tmp;
@@ -102,7 +103,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)case PTRACE_GETREGS :/* Get all registers from the child. */ if (!access_ok (VERIFY_WRITE , datap,PTREGS_SIZE ))break ; -for (i =0 ; i <PTREGS_SIZE ; i +=sizeof (long )) { +for (i =0 ; i <PTREGS_SIZE ; i +=sizeof (unsigned long )) { ret =__put_user (getreg (child, i), datap);if (ret !=0 )break ;
@@ -113,7 +114,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)case PTRACE_SETREGS :/* Set all registers in the child. */ if (!access_ok (VERIFY_READ , datap,PTREGS_SIZE ))break ; -for (i =0 ; i <PTREGS_SIZE ; i +=sizeof (long )) { +for (i =0 ; i <PTREGS_SIZE ; i +=sizeof (unsigned long )) { ret =__get_user (tmp, datap);if (ret !=0 )break ;
arch/um/kernel/ptrace.c +3 -2
@@ -42,10 +42,11 @@ void ptrace_disable(struct task_struct *child)extern int peek_user (struct task_struct * child,long addr,long data);extern int poke_user (struct task_struct * child,long addr,long data); -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int i, ret; -unsigned long __user *p = (void __user *)(unsigned long )data; +unsigned long __user *p = (void __user *)data;switch (request) {/* read word at location addr. */
arch/um/sys-i386/ptrace.c +2 -2
@@ -203,8 +203,8 @@ int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) (unsigned long *) &fpregs); } -long subarch_ptrace (struct task_struct *child,long request,long addr, -long data) +long subarch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {return -EIO ; }
arch/um/sys-x86_64/ptrace.c +2 -2
@@ -175,8 +175,8 @@ int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)return restore_fp_registers (userspace_pid[cpu], fpregs); } -long subarch_ptrace (struct task_struct *child,long request,long addr, -long data) +long subarch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int ret = -EIO ;
arch/x86/kernel/ptrace.c +4 -3
@@ -801,7 +801,8 @@ void ptrace_disable(struct task_struct *child)static const struct user_regset_view user_x86_32_view;/* Initialized below. */ #endif -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int ret;unsigned long __user *datap = (unsigned long __user *)data;
@@ -888,14 +889,14 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)#if definedCONFIG_X86_32 || definedCONFIG_IA32_EMULATION case PTRACE_GET_THREAD_AREA : -if (addr <0 ) +if ((int ) addr <0 )return -EIO ; ret =do_get_thread_area (child, addr, (struct user_desc __user *) data);break ;case PTRACE_SET_THREAD_AREA : -if (addr <0 ) +if ((int ) addr <0 )return -EIO ; ret =do_set_thread_area (child, addr, (struct user_desc __user *) data,0 );
arch/xtensa/kernel/ptrace.c +2 -1
@@ -256,7 +256,8 @@ int ptrace_pokeusr(struct task_struct *child, long regno, long val)return 0 ; } -long arch_ptrace (struct task_struct *child,long request,long addr,long data) +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) {int ret = -EPERM ;
include/linux/ptrace.h +2 -1
@@ -100,7 +100,8 @@#include <linux/sched.h> /* For struct task_struct. */ -extern long arch_ptrace (struct task_struct *child,long request,long addr,long data); +extern long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data);extern int ptrace_traceme (void );extern int ptrace_readdata (struct task_struct *tsk,unsigned long src,char __user *dst,int len);extern int ptrace_writedata (struct task_struct *tsk,char __user *src,unsigned long dst,int len);
Signature · 1 line
1.7.2.2
v2 cover ptrace cleanups
Hello,
This patchset tries to cleanup architecture independent/dependent part of ptrace syscall. Specifically it changes prototype of sys_ptrace() to have its arguments @addr and @data to be unsigned long. Since user space API of ptrace() declares them as void pointers, and most of archs consider them unsigned already in their arch_ptrace(), it would be no harmful to change them from (signed) long into unsigned long, IMHO.
ptrace() code accesses user area using above arguments frequently, changing them enables to drop unnecessary __force markup when casting them to __user pointers because sparse allows it only in case of unsigned long. And some duplicated/misused castings can be grouped into one place in favor of new variables to cleanup code further. This was suggested by Arnd Bergmann and comment from Christoph Hellwig was also helpful.
Although I couldn't test all archs, I hope it will not break anything.
Any comments would be appreciated.
Thanks.
* Changes from v1:
combine all arch signature changes into a single patch retain uses of get/put_user()
rebased on top of 2.6.36-rc3
---
Namhyung Kim (24):
ptrace: change signature of sys_ptrace() and friends
ptrace: cleanup ptrace_request()
ptrace: change signature of arch_ptrace()
ptrace: cleanup arch_ptrace() on x86
ptrace: cleanup arch_ptrace() on ARM
ptrace: cleanup arch_ptrace() on avr32
ptrace: cleanup arch_ptrace() and friends on Blackfin
ptrace: cleanup arch_ptrace() on cris
ptrace: cleanup arch_ptrace() on frv
ptrace: cleanup arch_ptrace() on h8300
ptrace: cleanup arch_ptrace() on m32r
ptrace: cleanup arch_ptrace() on m68k
ptrace: cleanup arch_ptrace() on m68knommu
ptrace: cleanup arch_ptrace() on microblaze
ptrace: cleanup arch_ptrace() on MIPS
ptrace: cleanup arch_ptrace() on mn10300
ptrace: cleanup arch_ptrace() on parisc
ptrace: cleanup arch_ptrace() on powerpc
ptrace: cleanup arch_ptrace() on score
ptrace: cleanup arch_ptrace() on sh
ptrace: cleanup arch_ptrace() on sparc
ptrace: cleanup arch_ptrace() on tile
ptrace: cleanup arch_ptrace() on um
ptrace: cleanup arch_ptrace() on xtensa
arch/alpha/kernel/ptrace.c | 7 ++-- arch/arm/kernel/ptrace.c | 28 ++++++++------- arch/avr32/kernel/ptrace.c | 11 +++--- arch/blackfin/kernel/ptrace.c | 16 +++++---- arch/cris/arch-v10/kernel/ptrace.c | 20 +++++----- arch/cris/arch-v32/kernel/ptrace.c | 16 ++++---- arch/frv/kernel/ptrace.c | 32 ++++++++--------- arch/h8300/kernel/ptrace.c | 33 +++++++++--------- arch/ia64/kernel/ptrace.c | 3 +- arch/m32r/kernel/ptrace.c | 11 +++--- arch/m68k/kernel/ptrace.c | 51 ++++++++++++++------------- arch/m68knommu/kernel/ptrace.c | 63 ++++++++++++++++------------------ arch/microblaze/kernel/ptrace.c | 5 ++- arch/mips/kernel/ptrace.c | 25 +++++++------ arch/mn10300/kernel/ptrace.c | 20 +++++----- arch/parisc/kernel/ptrace.c | 13 ++++--- arch/powerpc/kernel/ptrace.c | 66 ++++++++++++++++++----------------- arch/s390/kernel/ptrace.c | 3 +- arch/score/kernel/ptrace.c | 7 ++-- arch/sh/kernel/ptrace_32.c | 45 +++++++++++++----------- arch/sh/kernel/ptrace_64.c | 25 +++++++++----- arch/sparc/kernel/ptrace_32.c | 57 ++++++++++++------------------- arch/sparc/kernel/ptrace_64.c | 15 ++++---- arch/tile/kernel/ptrace.c | 11 +++--- arch/um/kernel/ptrace.c | 23 ++++++------ arch/um/sys-i386/ptrace.c | 4 +- arch/um/sys-x86_64/ptrace.c | 11 +++--- arch/x86/kernel/ptrace.c | 20 +++++------ arch/xtensa/kernel/ptrace.c | 14 ++++--- include/linux/ptrace.h | 12 ++++-- include/linux/syscalls.h | 3 +- kernel/ptrace.c | 29 +++++++++------ 32 files changed, 360 insertions(+), 339 deletions(-)
--
1.7.2.2
PATCH v2 1/24 ptrace: change signature of sys_ptrace() and friends
Since user space API of ptrace syscall defines @addr and @data as void pointers, it would be more appropriate to define them as unsigned long in kernel. Therefore related functions are changed also.
'unsigned long' is typically used in other places in kernel as an opaque data type and that using this helps cleaning up a lot of warnings from sparse.
--- include/linux/ptrace.h | 9 ++++++--- include/linux/syscalls.h | 3 ++- kernel/ptrace.c | 16 ++++++++++------ 3 files changed, 18 insertions(+), 10 deletions(-)
include/linux/ptrace.h +6 -3
@@ -108,7 +108,8 @@ extern int ptrace_attach(struct task_struct *tsk);extern int ptrace_detach (struct task_struct *,unsigned int );extern void ptrace_disable (struct task_struct *);extern int ptrace_check_attach (struct task_struct *task,int kill); -extern int ptrace_request (struct task_struct *child,long request,long addr,long data); +extern int ptrace_request (struct task_struct *child,long request, +unsigned long addr,unsigned long data);extern void ptrace_notify (int exit_code);extern void __ptrace_link (struct task_struct *child,struct task_struct *new_parent);
@@ -132,8 +133,10 @@ static inline void ptrace_unlink(struct task_struct *child)__ptrace_unlink (child); } -int generic_ptrace_peekdata (struct task_struct *tsk,long addr,long data); -int generic_ptrace_pokedata (struct task_struct *tsk,long addr,long data); +int generic_ptrace_peekdata (struct task_struct *tsk,unsigned long addr, +unsigned long data); +int generic_ptrace_pokedata (struct task_struct *tsk,unsigned long addr, +unsigned long data);/** * task_ptrace - return %PT_* flags that apply to a task
include/linux/syscalls.h +2 -1
@@ -701,7 +701,8 @@ asmlinkage long sys_nfsservctl(int cmd,asmlinkage long sys_syslog (int type,char __user *buf,int len);asmlinkage long sys_uselib (const char __user *library);asmlinkage long sys_ni_syscall (void ); -asmlinkage long sys_ptrace (long request,long pid,long addr,long data); +asmlinkage long sys_ptrace (long request,long pid,unsigned long addr, +unsigned long data); asmlinkage long sys_add_key(const char __user *_type, const char __user *_description,
kernel/ptrace.c +10 -6
@@ -402,7 +402,7 @@ int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long dsreturn copied; } -static int ptrace_setoptions (struct task_struct *child,long data) +static int ptrace_setoptions (struct task_struct *child,unsigned long data) { child->ptrace &= ~PT_TRACE_MASK ;
@@ -481,7 +481,8 @@ static int ptrace_setsiginfo(struct task_struct *child, const siginfo_t *info)#define is_sysemu_singlestep (request) 0#endif -static int ptrace_resume (struct task_struct *child,long request,long data) +static int ptrace_resume (struct task_struct *child,long request, +unsigned long data) {if (!valid_signal (data))return -EIO ;
@@ -558,7 +559,7 @@ static int ptrace_regset(struct task_struct *task, int req, unsigned int type,#endif int ptrace_request (struct task_struct *child,long request, -long addr,long data) +unsigned long addr,unsigned long data) {int ret = -EIO ;siginfo_t siginfo;
@@ -691,7 +692,8 @@ static struct task_struct *ptrace_get_task_struct(pid_t pid)#define arch_ptrace_attach (child) do { } while (0)#endif -SYSCALL_DEFINE4(ptrace, long, request, long, pid, long, addr, long, data) +SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr, + unsigned long, data) {struct task_struct *child;long ret;
@@ -732,7 +734,8 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, long, addr, long, data)return ret; } -int generic_ptrace_peekdata (struct task_struct *tsk,long addr,long data) +int generic_ptrace_peekdata (struct task_struct *tsk,unsigned long addr, +unsigned long data) {unsigned long tmp;int copied;
@@ -743,7 +746,8 @@ int generic_ptrace_peekdata(struct task_struct *tsk, long addr, long data)return put_user (tmp, (unsigned long __user *)data); } -int generic_ptrace_pokedata (struct task_struct *tsk,long addr,long data) +int generic_ptrace_pokedata (struct task_struct *tsk,unsigned long addr, +unsigned long data) {int copied;
Signature · 1 line
1.7.2.2
PATCH v2 2/24 ptrace: cleanup ptrace_request()
In reply to Namhyung Kimuse new local variable to remove unnecesary casting, but it requires put_user() to be changed to copy_to_user().
--- kernel/ptrace.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
kernel/ptrace.c +7 -6
@@ -563,6 +563,7 @@ int ptrace_request(struct task_struct *child, long request, {int ret = -EIO ;siginfo_t siginfo; +void __user *datap = (void __user *) data;switch (request) {case PTRACE_PEEKTEXT :
@@ -579,19 +580,19 @@ int ptrace_request(struct task_struct *child, long request, ret =ptrace_setoptions (child, data);break ;case PTRACE_GETEVENTMSG : - ret =put_user (child->ptrace_message, (unsigned long __user *) data); + ret =copy_to_user (datap, &child->ptrace_message, +sizeof (child->ptrace_message)) ? + -EFAULT :0 ;break ;case PTRACE_GETSIGINFO : ret =ptrace_getsiginfo (child, &siginfo);if (!ret) - ret =copy_siginfo_to_user ((siginfo_t __user *) data, - &siginfo); + ret =copy_siginfo_to_user (datap, &siginfo);break ;case PTRACE_SETSIGINFO : -if (copy_from_user (&siginfo, (siginfo_t __user *) data, -sizeof siginfo)) +if (copy_from_user (&siginfo, datap,sizeof siginfo)) ret = -EFAULT ;else ret =ptrace_setsiginfo (child, &siginfo);
@@ -622,7 +623,7 @@ int ptrace_request(struct task_struct *child, long request, }mmput (mm); - ret =put_user (tmp, (unsigned long __user *) data); + ret =copy_to_user (datap, &tmp,sizeof tmp) ? -EFAULT :0 ;break ; }#endif
Signature · 1 line
1.7.2.2
PATCH v2 4/24 ptrace: cleanup arch_ptrace() on x86
In reply to Namhyung KimRemove checking @addr less than 0 because @addr is now unsigned and use new udescp variable in order to remove unnecessary castings.
--- arch/x86/kernel/ptrace.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-)
arch/x86/kernel/ptrace.c +5 -8
@@ -806,6 +806,7 @@ long arch_ptrace(struct task_struct *child, long request, {int ret;unsigned long __user *datap = (unsigned long __user *)data; +struct user_desc __user *udescp = (struct user_desc __user *)data;switch (request) {/* read the word at location addr in the USER area. */
@@ -813,8 +814,7 @@ long arch_ptrace(struct task_struct *child, long request,unsigned long tmp; ret = -EIO ; -if ((addr & (sizeof (data) -1 )) || addr <0 || - addr >=sizeof (struct user )) +if ((addr & (sizeof (data) -1 )) || addr >=sizeof (struct user ))break ; tmp =0 ;/* Default return condition */
@@ -831,8 +831,7 @@ long arch_ptrace(struct task_struct *child, long request,case PTRACE_POKEUSR :/* write the word at location addr in the USER area */ ret = -EIO ; -if ((addr & (sizeof (data) -1 )) || addr <0 || - addr >=sizeof (struct user )) +if ((addr & (sizeof (data) -1 )) || addr >=sizeof (struct user ))break ;if (addr <sizeof (struct user_regs_struct ))
@@ -891,15 +890,13 @@ long arch_ptrace(struct task_struct *child, long request,case PTRACE_GET_THREAD_AREA :if ((int ) addr <0 )return -EIO ; - ret =do_get_thread_area (child, addr, - (struct user_desc __user *) data); + ret =do_get_thread_area (child, addr, udescp);break ;case PTRACE_SET_THREAD_AREA :if ((int ) addr <0 )return -EIO ; - ret =do_set_thread_area (child, addr, - (struct user_desc __user *) data,0 ); + ret =do_set_thread_area (child, addr, udescp,0 );break ;#endif
Signature · 1 line
1.7.2.2
PATCH v2 5/24 ptrace: cleanup arch_ptrace() on ARM
In reply to Namhyung Kimuse new 'datap' variable in order to remove unnecessary castings.
--- arch/arm/kernel/ptrace.c | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-)
arch/arm/kernel/ptrace.c +13 -12
@@ -851,10 +851,11 @@ long arch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { int ret; +unsigned long __user *datap = (unsigned long __user *) data;switch (request) {case PTRACE_PEEKUSR : - ret =ptrace_read_user (child, addr, (unsigned long __user *)data); + ret =ptrace_read_user (child, addr, datap);break ;case PTRACE_POKEUSR :
@@ -862,34 +863,34 @@ long arch_ptrace(struct task_struct *child, long request,break ;case PTRACE_GETREGS : - ret =ptrace_getregs (child, (void __user *)data); + ret =ptrace_getregs (child, datap);break ;case PTRACE_SETREGS : - ret =ptrace_setregs (child, (void __user *)data); + ret =ptrace_setregs (child, datap);break ;case PTRACE_GETFPREGS : - ret =ptrace_getfpregs (child, (void __user *)data); + ret =ptrace_getfpregs (child, datap);break ;case PTRACE_SETFPREGS : - ret =ptrace_setfpregs (child, (void __user *)data); + ret =ptrace_setfpregs (child, datap);break ;#ifdef CONFIG_IWMMXT case PTRACE_GETWMMXREGS : - ret =ptrace_getwmmxregs (child, (void __user *)data); + ret =ptrace_getwmmxregs (child, datap);break ;case PTRACE_SETWMMXREGS : - ret =ptrace_setwmmxregs (child, (void __user *)data); + ret =ptrace_setwmmxregs (child, datap);break ;#endif case PTRACE_GET_THREAD_AREA : ret =put_user (task_thread_info (child)->tp_value, - (unsigned long __user *) data); + datap);break ;case PTRACE_SET_SYSCALL :
@@ -899,21 +900,21 @@ long arch_ptrace(struct task_struct *child, long request,#ifdef CONFIG_CRUNCH case PTRACE_GETCRUNCHREGS : - ret =ptrace_getcrunchregs (child, (void __user *)data); + ret =ptrace_getcrunchregs (child, datap);break ;case PTRACE_SETCRUNCHREGS : - ret =ptrace_setcrunchregs (child, (void __user *)data); + ret =ptrace_setcrunchregs (child, datap);break ;#endif #ifdef CONFIG_VFP case PTRACE_GETVFPREGS : - ret =ptrace_getvfpregs (child, (void __user *)data); + ret =ptrace_getvfpregs (child, datap);break ;case PTRACE_SETVFPREGS : - ret =ptrace_setvfpregs (child, (void __user *)data); + ret =ptrace_setvfpregs (child, datap);break ;#endif
Signature · 1 line
1.7.2.2
PATCH v2 6/24 ptrace: cleanup arch_ptrace() on avr32
In reply to Namhyung Kimuse new 'datap' variable type of void pointer in order to remove unnecessary castings.
--- arch/avr32/kernel/ptrace.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
arch/avr32/kernel/ptrace.c +4 -4
@@ -150,6 +150,7 @@ long arch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { int ret; +void __user *datap = (void __user *) data;switch (request) {/* Read the word at location addr in the child process */
@@ -159,8 +160,7 @@ long arch_ptrace(struct task_struct *child, long request,break ;case PTRACE_PEEKUSR : - ret =ptrace_read_user (child, addr, - (unsigned long __user *)data); + ret =ptrace_read_user (child, addr, datap);break ;/* Write the word in data at location addr */
@@ -174,11 +174,11 @@ long arch_ptrace(struct task_struct *child, long request,break ;case PTRACE_GETREGS : - ret =ptrace_getregs (child, (void __user *)data); + ret =ptrace_getregs (child, datap);break ;case PTRACE_SETREGS : - ret =ptrace_setregs (child, (const void __user *)data); + ret =ptrace_setregs (child, datap);break ;default :
Signature · 1 line
1.7.2.2
PATCH v2 7/24 ptrace: cleanup arch_ptrace() and friends on Blackfin
In reply to Namhyung KimChange signature of get/put_reg() according to the change of arch_ptrace() and remove unnecessary castings.
--- arch/blackfin/kernel/ptrace.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
arch/blackfin/kernel/ptrace.c +7 -6
@@ -37,12 +37,13 @@* Get contents of register REGNO in task TASK. */ static inline long -get_reg (struct task_struct *task,long regno,unsigned long __user *datap) +get_reg (struct task_struct *task,unsigned long regno, +unsigned long __user *datap) {long tmp;struct pt_regs *regs =task_pt_regs (task); -if (regno &3 || regno >PT_LAST_PSEUDO || regno <0 ) +if (regno &3 || regno >PT_LAST_PSEUDO )return -EIO ;switch (regno) {
@@ -73,11 +74,11 @@ get_reg(struct task_struct *task, long regno, unsigned long __user *datap)* Write contents of register REGNO in task TASK. */ static inline int -put_reg (struct task_struct *task,long regno,unsigned long data) +put_reg (struct task_struct *task,unsigned long regno,unsigned long data) {struct pt_regs *regs =task_pt_regs (task); -if (regno &3 || regno >PT_LAST_PSEUDO || regno <0 ) +if (regno &3 || regno >PT_LAST_PSEUDO )return -EIO ;switch (regno) {
@@ -361,14 +362,14 @@ long arch_ptrace(struct task_struct *child, long request,return copy_regset_to_user (child, &user_bfin_native_view,REGSET_GENERAL ,0 ,sizeof (struct pt_regs ), - (void __user *)data); + datap);case PTRACE_SETREGS :pr_debug ("ptrace: PTRACE_SETREGS\n" );return copy_regset_from_user (child, &user_bfin_native_view,REGSET_GENERAL ,0 ,sizeof (struct pt_regs ), - (const void __user *)data); + datap); case_default:default :
Signature · 1 line
1.7.2.2
PATCH v2 8/24 ptrace: cleanup arch_ptrace() on cris
In reply to Namhyung KimUse new 'regno' variable in order to remove redandunt expression and remove checking @addr less than 0 because @addr is now unsigned. Also update 'datap' on PTRACE_GET/SETREGS to fix a bug on arch-v10.
--- arch/cris/arch-v10/kernel/ptrace.c | 17 ++++++++--------- arch/cris/arch-v32/kernel/ptrace.c | 13 ++++++------- 2 files changed, 14 insertions(+), 16 deletions(-)
arch/cris/arch-v10/kernel/ptrace.c +8 -9
@@ -80,6 +80,7 @@ long arch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { int ret; +unsigned int regno = addr >>2 ;unsigned long __user *datap = (unsigned long __user *)data;switch (request) {
@@ -94,10 +95,10 @@ long arch_ptrace(struct task_struct *child, long request,unsigned long tmp; ret = -EIO ; -if ((addr &3 ) || addr <0 || addr >PT_MAX <<2 ) +if ((addr &3 ) || regno >PT_MAX )break ; - tmp =get_reg (child, addr >>2 ); + tmp =get_reg (child, regno); ret =put_user (tmp, datap);break ; }
@@ -111,19 +112,17 @@ long arch_ptrace(struct task_struct *child, long request,/* Write the word at location address in the USER area. */ case PTRACE_POKEUSR : ret = -EIO ; -if ((addr &3 ) || addr <0 || addr >PT_MAX <<2 ) +if ((addr &3 ) || regno >PT_MAX )break ; - addr >>=2 ; - -if (addr ==PT_DCCR ) { +if (regno ==PT_DCCR ) {/* don't allow the tracing process to change stuff like * interrupt enable, kernel/user bit, dma enables etc. */ data &=DCCR_MASK ; data |=get_reg (child,PT_DCCR ) & ~DCCR_MASK ; } -if (put_reg (child, addr, data)) +if (put_reg (child, regno, data))break ; ret =0 ;break ;
@@ -142,7 +141,7 @@ long arch_ptrace(struct task_struct *child, long request,break ; } - data +=sizeof (unsigned long ); + datap++; }break ;
@@ -166,7 +165,7 @@ long arch_ptrace(struct task_struct *child, long request, }put_reg (child, i, tmp); - data +=sizeof (unsigned long ); + datap++; }break ;
arch/cris/arch-v32/kernel/ptrace.c +6 -7
@@ -130,6 +130,7 @@ long arch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { int ret; +unsigned int regno = addr >>2 ;unsigned long __user *datap = (unsigned long __user *)data;switch (request) {
@@ -164,10 +165,10 @@ long arch_ptrace(struct task_struct *child, long request,unsigned long tmp; ret = -EIO ; -if ((addr &3 ) || addr <0 || addr >PT_MAX <<2 ) +if ((addr &3 ) || regno >PT_MAX )break ; - tmp =get_reg (child, addr >>2 ); + tmp =get_reg (child, regno); ret =put_user (tmp, datap);break ; }
@@ -181,19 +182,17 @@ long arch_ptrace(struct task_struct *child, long request,/* Write the word at location address in the USER area. */ case PTRACE_POKEUSR : ret = -EIO ; -if ((addr &3 ) || addr <0 || addr >PT_MAX <<2 ) +if ((addr &3 ) || regno >PT_MAX )break ; - addr >>=2 ; - -if (addr ==PT_CCS ) { +if (regno ==PT_CCS ) {/* don't allow the tracing process to change stuff like * interrupt enable, kernel/user bit, dma enables etc. */ data &=CCS_MASK ; data |=get_reg (child,PT_CCS ) & ~CCS_MASK ; } -if (put_reg (child, addr, data)) +if (put_reg (child, regno, data))break ; ret =0 ;break ;
Signature · 1 line
1.7.2.2
PATCH v2 9/24 ptrace: cleanup arch_ptrace() on frv
In reply to Namhyung KimUse new 'regno', 'datap' variables in order to remove duplicated expressions and unnecessary castings. Alse remove checking @addr less than 0 because addr is now unsigned.
--- arch/frv/kernel/ptrace.c | 29 +++++++++++++---------------- 1 files changed, 13 insertions(+), 16 deletions(-)
arch/frv/kernel/ptrace.c +13 -16
@@ -259,19 +259,21 @@ long arch_ptrace(struct task_struct *child, long request, {unsigned long tmp;int ret; +int regno = addr >>2 ; +unsigned long __user *datap = (unsigned long __user *) data;switch (request) {/* read the word at location addr in the USER area. */ case PTRACE_PEEKUSR : { tmp =0 ; ret = -EIO ; -if ((addr &3 ) || addr <0 ) +if (addr &3 )break ; ret =0 ; -switch (addr >>2 ) { +switch (regno) { case 0 ... PT__END - 1: - tmp =get_reg (child, addr >>2 ); + tmp =get_reg (child, regno);break ;case PT__END +0 :
@@ -300,23 +302,18 @@ long arch_ptrace(struct task_struct *child, long request, }if (ret ==0 ) - ret =put_user (tmp, (unsigned long *) data); + ret =put_user (tmp, datap);break ; }case PTRACE_POKEUSR :/* write the word at location addr in the USER area */ ret = -EIO ; -if ((addr &3 ) || addr <0 ) +if (addr &3 )break ; - ret =0 ; -switch (addr >>2 ) { +switch (regno) { case 0 ... PT__END - 1: - ret =put_reg (child, addr >>2 , data); -break ; - -default : - ret = -EIO ; + ret =put_reg (child, regno, data);break ; }break ;
@@ -325,25 +322,25 @@ long arch_ptrace(struct task_struct *child, long request,return copy_regset_to_user (child, &user_frv_native_view,REGSET_GENERAL ,0 ,sizeof (child->thread.user->i), - (void __user *)data); + datap);case PTRACE_SETREGS :/* Set all integer regs in the child. */ return copy_regset_from_user (child, &user_frv_native_view,REGSET_GENERAL ,0 ,sizeof (child->thread.user->i), - (const void __user *)data); + datap);case PTRACE_GETFPREGS :/* Get the child FP/Media state. */ return copy_regset_to_user (child, &user_frv_native_view,REGSET_FPMEDIA ,0 ,sizeof (child->thread.user->f), - (void __user *)data); + datap);case PTRACE_SETFPREGS :/* Set the child FP/Media state. */ return copy_regset_from_user (child, &user_frv_native_view,REGSET_FPMEDIA ,0 ,sizeof (child->thread.user->f), - (const void __user *)data); + datap);default : ret =ptrace_request (child, request, addr, data);
Signature · 1 line
1.7.2.2
PATCH v2 10/24 ptrace: cleanup arch_ptrace() on h8300
In reply to Namhyung KimUse new 'regno', 'datap' variables in order to remove duplicated expressions and unnecessary castings. Alse remove checking @addr less than 0 because addr is now unsigned.
--- arch/h8300/kernel/ptrace.c | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-)
arch/h8300/kernel/ptrace.c +15 -15
@@ -54,24 +54,25 @@ long arch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { int ret; +int regno = addr >>2 ; +unsigned long __user *datap = (unsigned long __user *) data;switch (request) {/* read the word at location addr in the USER area. */ case PTRACE_PEEKUSR : {unsigned long tmp =0 ; -if ((addr &3 ) || addr <0 || addr >=sizeof (struct user )) { +if ((addr &3 ) || addr >=sizeof (struct user )) { ret = -EIO ;break ; } ret =0 ;/* Default return condition */ - addr = addr >>2 ;/* temporary hack. */ -if (addr <H8300_REGS_NO ) - tmp =h8300_get_reg (child, addr); +if (regno <H8300_REGS_NO ) + tmp =h8300_get_reg (child, regno);else { -switch (addr) { +switch (regno) {case 49 : tmp = child->mm->start_code;break ;
@@ -89,24 +90,23 @@ long arch_ptrace(struct task_struct *child, long request, } }if (!ret) - ret =put_user (tmp,(unsigned long *) data); + ret =put_user (tmp, datap);break ; }/* when I and D space are separate, this will have to be fixed. */ case PTRACE_POKEUSR :/* write the word at location addr in the USER area */ -if ((addr &3 ) || addr <0 || addr >=sizeof (struct user )) { +if ((addr &3 ) || addr >=sizeof (struct user )) { ret = -EIO ;break ; } - addr = addr >>2 ;/* temporary hack. */ -if (addr ==PT_ORIG_ER0 ) { +if (regno ==PT_ORIG_ER0 ) { ret = -EIO ;break ; } -if (addr <H8300_REGS_NO ) { - ret =h8300_put_reg (child, addr, data); +if (regno <H8300_REGS_NO ) { + ret =h8300_put_reg (child, regno, data);break ; } ret = -EIO ;
@@ -117,11 +117,11 @@ long arch_ptrace(struct task_struct *child, long request,unsigned long tmp;for (i =0 ; i <H8300_REGS_NO ; i++) { tmp =h8300_get_reg (child, i); -if (put_user (tmp, (unsigned long *) data)) { +if (put_user (tmp, datap)) { ret = -EFAULT ;break ; } - data +=sizeof (unsigned long ); + datap++; } ret =0 ;break ;
@@ -131,12 +131,12 @@ long arch_ptrace(struct task_struct *child, long request,int i;unsigned long tmp;for (i =0 ; i <H8300_REGS_NO ; i++) { -if (get_user (tmp, (unsigned long *) data)) { +if (get_user (tmp, datap)) { ret = -EFAULT ;break ; }h8300_put_reg (child, i, tmp); - data +=sizeof (unsigned long ); + datap++; } ret =0 ;break ;
Signature · 1 line
1.7.2.2
PATCH v2 11/24 ptrace: cleanup arch_ptrace() on m32r
In reply to Namhyung KimUse new 'datap' variable in order to remove duplicated castings.
--- arch/m32r/kernel/ptrace.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
arch/m32r/kernel/ptrace.c +4 -4
@@ -625,6 +625,7 @@ arch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { int ret; +unsigned long __user *datap = (unsigned long __user *) data;switch (request) {/*
@@ -639,8 +640,7 @@ arch_ptrace(struct task_struct *child, long request,* read the word at location addr in the USER area. */ case PTRACE_PEEKUSR : - ret =ptrace_read_user (child, addr, - (unsigned long __user *)data); + ret =ptrace_read_user (child, addr, datap);break ;/*
@@ -661,11 +661,11 @@ arch_ptrace(struct task_struct *child, long request,break ;case PTRACE_GETREGS : - ret =ptrace_getregs (child, (void __user *)data); + ret =ptrace_getregs (child, datap);break ;case PTRACE_SETREGS : - ret =ptrace_setregs (child, (void __user *)data); + ret =ptrace_setregs (child, datap);break ;default :
Signature · 1 line
1.7.2.2
PATCH v2 12/24 ptrace: cleanup arch_ptrace() on m68k
In reply to Namhyung KimUse new 'regno', 'datap' variables in order to remove duplicated expressions and unnecessary castings.
--- arch/m68k/kernel/ptrace.c | 46 ++++++++++++++++++++++---------------------- 1 files changed, 23 insertions(+), 23 deletions(-)
arch/m68k/kernel/ptrace.c +23 -23
@@ -161,51 +161,52 @@ long arch_ptrace(struct task_struct *child, long request, {unsigned long tmp;int i, ret =0 ; +int regno = addr >>2 ;/* temporary hack. */ +unsigned long __user *datap = (unsigned long __user *) data;switch (request) {/* read the word at location addr in the USER area. */ case PTRACE_PEEKUSR :if (addr &3 ) goto out_eio; - addr >>=2 ;/* temporary hack. */ -if (addr >=0 && addr <19 ) { - tmp =get_reg (child, addr); - }else if (addr >=21 && addr <49 ) { - tmp = child->thread.fp[addr -21 ]; +if (regno >=0 && regno <19 ) { + tmp =get_reg (child, regno); + }else if (regno >=21 && regno <49 ) { + tmp = child->thread.fp[regno -21 ];/* Convert internal fpu reg representation * into long double format */ -if (FPU_IS_EMU && (addr <45 ) && !(addr %3 )) +if (FPU_IS_EMU && (regno <45 ) && !(regno %3 )) tmp = ((tmp &0xffff0000 ) <<15 ) | ((tmp &0x0000ffff ) <<16 ); }else goto out_eio; - ret =put_user (tmp, (unsigned long *)data); + ret =put_user (tmp, datap);break ; -case PTRACE_POKEUSR :/* write the word at location addr in the USER area */ +case PTRACE_POKEUSR : +/* write the word at location addr in the USER area */ if (addr &3 ) goto out_eio; - addr >>=2 ;/* temporary hack. */ -if (addr ==PT_SR ) { +if (regno ==PT_SR ) { data &=SR_MASK ; data |=get_reg (child,PT_SR ) & ~SR_MASK ; } -if (addr >=0 && addr <19 ) { -if (put_reg (child, addr, data)) +if (regno >=0 && regno <19 ) { +if (put_reg (child, regno, data)) goto out_eio; - }else if (addr >=21 && addr <48 ) { + }else if (regno >=21 && regno <48 ) {/* Convert long double format * into internal fpu reg representation */ -if (FPU_IS_EMU && (addr <45 ) && !(addr %3 )) { +if (FPU_IS_EMU && (regno <45 ) && !(regno %3 )) { data <<=15 ; data = (data &0xffff0000 ) | ((data &0x0000ffff ) >>1 ); } - child->thread.fp[addr -21 ] = data; + child->thread.fp[regno -21 ] = data; }else goto out_eio;break ;
@@ -213,16 +214,16 @@ long arch_ptrace(struct task_struct *child, long request,case PTRACE_GETREGS :/* Get all gp regs from the child. */ for (i =0 ; i <19 ; i++) { tmp =get_reg (child, i); - ret =put_user (tmp, (unsigned long *)data); + ret =put_user (tmp, datap);if (ret)break ; - data +=sizeof (unsigned long ); + datap++; }break ;case PTRACE_SETREGS :/* Set all gp regs in the child. */ for (i =0 ; i <19 ; i++) { - ret =get_user (tmp, (unsigned long *)data); + ret =get_user (tmp, datap);if (ret)break ;if (i ==PT_SR ) {
@@ -230,25 +231,24 @@ long arch_ptrace(struct task_struct *child, long request, tmp |=get_reg (child,PT_SR ) & ~SR_MASK ; }put_reg (child, i, tmp); - data +=sizeof (unsigned long ); + datap++; }break ;case PTRACE_GETFPREGS :/* Get the child FPU state. */ -if (copy_to_user ((void *)data, &child->thread.fp, +if (copy_to_user (datap, &child->thread.fp,sizeof (struct user_m68kfp_struct ))) ret = -EFAULT ;break ;case PTRACE_SETFPREGS :/* Set the child FPU state. */ -if (copy_from_user (&child->thread.fp, (void *)data, +if (copy_from_user (&child->thread.fp, datap,sizeof (struct user_m68kfp_struct ))) ret = -EFAULT ;break ;case PTRACE_GET_THREAD_AREA : - ret =put_user (task_thread_info (child)->tp_value, - (unsigned long __user *)data); + ret =put_user (task_thread_info (child)->tp_value, datap);break ;default :
Signature · 1 line
1.7.2.2
PATCH v2 13/24 ptrace: cleanup arch_ptrace() on m68knommu
In reply to Namhyung KimUse new 'regno', 'datap' variables in order to remove duplicated expressions and unnecessary castings. Alse remove checking @addr less than 0 because addr is now unsigned.
--- arch/m68knommu/kernel/ptrace.c | 58 ++++++++++++++++++--------------------- 1 files changed, 27 insertions(+), 31 deletions(-)
arch/m68knommu/kernel/ptrace.c +27 -31
@@ -115,6 +115,8 @@ long arch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { int ret; +int regno = addr >>2 ; +unsigned long __user *datap = (unsigned long __user *) data;switch (request) {/* read the word at location addr in the USER area. */
@@ -122,71 +124,66 @@ long arch_ptrace(struct task_struct *child, long request,unsigned long tmp; ret = -EIO ; -if ((addr &3 ) || addr <0 || - addr >sizeof (struct user ) -3 ) +if ((addr &3 ) || addr >sizeof (struct user ) -3 )break ; tmp =0 ;/* Default return condition */ - addr = addr >>2 ;/* temporary hack. */ ret = -EIO ; -if (addr <19 ) { - tmp =get_reg (child, addr); -if (addr ==PT_SR ) +if (regno <19 ) { + tmp =get_reg (child, regno); +if (regno ==PT_SR ) tmp >>=16 ; - }else if (addr >=21 && addr <49 ) { - tmp = child->thread.fp[addr -21 ]; + }else if (regno >=21 && regno <49 ) { + tmp = child->thread.fp[regno -21 ];#ifdef CONFIG_M68KFPU_EMU /* Convert internal fpu reg representation * into long double format */ -if (FPU_IS_EMU && (addr <45 ) && !(addr %3 )) +if (FPU_IS_EMU && (regno <45 ) && !(regno %3 )) tmp = ((tmp &0xffff0000 ) <<15 ) | ((tmp &0x0000ffff ) <<16 );#endif - }else if (addr ==49 ) { + }else if (regno ==49 ) { tmp = child->mm->start_code; - }else if (addr ==50 ) { + }else if (regno ==50 ) { tmp = child->mm->start_data; - }else if (addr ==51 ) { + }else if (regno ==51 ) { tmp = child->mm->end_code; }else break ; - ret =put_user (tmp,(unsigned long *) data); + ret =put_user (tmp, datap);break ; }case PTRACE_POKEUSR :/* write the word at location addr in the USER area */ ret = -EIO ; -if ((addr &3 ) || addr <0 || - addr >sizeof (struct user ) -3 ) +if ((addr &3 ) || addr >sizeof (struct user ) -3 )break ; - addr = addr >>2 ;/* temporary hack. */ - -if (addr ==PT_SR ) { +if (regno ==PT_SR ) { data &=SR_MASK ; data <<=16 ; data |=get_reg (child,PT_SR ) & ~(SR_MASK <<16 ); } -if (addr <19 ) { -if (put_reg (child, addr, data)) +if (regno <19 ) { +if (put_reg (child, regno, data))break ; ret =0 ;break ; } -if (addr >=21 && addr <48 ) +if (regno >=21 && regno <48 ) {#ifdef CONFIG_M68KFPU_EMU /* Convert long double format * into internal fpu reg representation */ -if (FPU_IS_EMU && (addr <45 ) && !(addr %3 )) { +if (FPU_IS_EMU && (regno <45 ) && !(regno %3 )) { data <<=15 ; data = (data &0xffff0000 ) | ((data &0x0000ffff ) >>1 ); }#endif - child->thread.fp[addr -21 ] = data; + child->thread.fp[regno -21 ] = data; ret =0 ; }break ;
@@ -198,11 +195,11 @@ long arch_ptrace(struct task_struct *child, long request, tmp =get_reg (child, i);if (i ==PT_SR ) tmp >>=16 ; -if (put_user (tmp, (unsigned long *) data)) { +if (put_user (tmp, datap)) { ret = -EFAULT ;break ; } - data +=sizeof (unsigned long ); + datap++; } ret =0 ;break ;
@@ -212,7 +209,7 @@ long arch_ptrace(struct task_struct *child, long request,int i;unsigned long tmp;for (i =0 ; i <19 ; i++) { -if (get_user (tmp, (unsigned long *) data)) { +if (get_user (tmp, datap)) { ret = -EFAULT ;break ; }
@@ -222,7 +219,7 @@ long arch_ptrace(struct task_struct *child, long request, tmp |=get_reg (child,PT_SR ) & ~(SR_MASK <<16 ); }put_reg (child, i, tmp); - data +=sizeof (unsigned long ); + datap++; } ret =0 ;break ;
@@ -231,7 +228,7 @@ long arch_ptrace(struct task_struct *child, long request,#ifdef PTRACE_GETFPREGS case PTRACE_GETFPREGS : {/* Get the child FPU state. */ ret =0 ; -if (copy_to_user ((void *)data, &child->thread.fp, +if (copy_to_user (datap, &child->thread.fp,sizeof (struct user_m68kfp_struct ))) ret = -EFAULT ;break ;
@@ -241,7 +238,7 @@ long arch_ptrace(struct task_struct *child, long request,#ifdef PTRACE_SETFPREGS case PTRACE_SETFPREGS : {/* Set the child FPU state. */ ret =0 ; -if (copy_from_user (&child->thread.fp, (void *)data, +if (copy_from_user (&child->thread.fp, datap,sizeof (struct user_m68kfp_struct ))) ret = -EFAULT ;break ;
@@ -249,8 +246,7 @@ long arch_ptrace(struct task_struct *child, long request,#endif case PTRACE_GET_THREAD_AREA : - ret =put_user (task_thread_info (child)->tp_value, - (unsigned long __user *)data); + ret =put_user (task_thread_info (child)->tp_value, datap);break ;default :
Signature · 1 line
1.7.2.2
PATCH v2 14/24 ptrace: cleanup arch_ptrace() on microblaze
In reply to Namhyung KimRemove checking @addr greater than 0 because @addr is now unsigned.
--- arch/microblaze/kernel/ptrace.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/microblaze/kernel/ptrace.c +1 -1
@@ -100,7 +100,7 @@ long arch_ptrace(struct task_struct *child, long request, }else { rval = -EIO ; } - }else if (addr >=0 && addr <PT_SIZE && (addr &0x3 ) ==0 ) { + }else if (addr <PT_SIZE && (addr &0x3 ) ==0 ) {microblaze_reg_t *reg_addr =reg_save_addr (addr, child);if (request ==PTRACE_PEEKUSR ) val = *reg_addr;
Signature · 1 line
1.7.2.2
PATCH v2 16/24 ptrace: cleanup arch_ptrace() on mn10300
In reply to Namhyung KimUse new 'datap' variable in order to remove unnecessary castings. Also remove checking @addr less than 0 because @addr is now unsigned.
--- arch/mn10300/kernel/ptrace.c | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-)
arch/mn10300/kernel/ptrace.c +8 -9
@@ -300,27 +300,26 @@ long arch_ptrace(struct task_struct *child, long request, {unsigned long tmp;int ret; +unsigned long __user *datap = (unsigned long __user *) data;switch (request) {/* read the word at location addr in the USER area. */ case PTRACE_PEEKUSR : ret = -EIO ; -if ((addr &3 ) || addr <0 || - addr >sizeof (struct user ) -3 ) +if ((addr &3 ) || addr >sizeof (struct user ) -3 )break ; tmp =0 ;/* Default return condition */ if (addr <NR_PTREGS <<2 ) tmp =get_stack_long (child, ptrace_regid_to_frame[addr]); - ret =put_user (tmp, (unsigned long *) data); + ret =put_user (tmp, datap);break ;/* write the word at location addr in the USER area */ case PTRACE_POKEUSR : ret = -EIO ; -if ((addr &3 ) || addr <0 || - addr >sizeof (struct user ) -3 ) +if ((addr &3 ) || addr >sizeof (struct user ) -3 )break ; ret =0 ;
@@ -333,25 +332,25 @@ long arch_ptrace(struct task_struct *child, long request,return copy_regset_to_user (child, &user_mn10300_native_view,REGSET_GENERAL ,0 ,NR_PTREGS *sizeof (long ), - (void __user *)data); + datap);case PTRACE_SETREGS :/* Set all integer regs in the child. */ return copy_regset_from_user (child, &user_mn10300_native_view,REGSET_GENERAL ,0 ,NR_PTREGS *sizeof (long ), - (const void __user *)data); + datap);case PTRACE_GETFPREGS :/* Get the child FPU state. */ return copy_regset_to_user (child, &user_mn10300_native_view,REGSET_FPU ,0 ,sizeof (struct fpu_state_struct ), - (void __user *)data); + datap);case PTRACE_SETFPREGS :/* Set the child FPU state. */ return copy_regset_from_user (child, &user_mn10300_native_view,REGSET_FPU ,0 ,sizeof (struct fpu_state_struct ), - (const void __user *)data); + datap);default : ret =ptrace_request (child, request, addr, data);
Signature · 1 line
1.7.2.2
PATCH v2 17/24 ptrace: cleanup arch_ptrace() on parisc
In reply to Namhyung KimAdd missing __user markup on the argument of put_user().
--- arch/parisc/kernel/ptrace.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/parisc/kernel/ptrace.c +1 -1
@@ -125,7 +125,7 @@ long arch_ptrace(struct task_struct *child, long request, addr >= sizeof(struct pt_regs))break ; tmp = *(unsigned long *) ((char *)task_regs (child) + addr); - ret =put_user (tmp, (unsigned long *) data); + ret =put_user (tmp, (unsigned long __user *) data);break ;/* Write the word at location addr in the USER area. This will need
Signature · 1 line
1.7.2.2
PATCH v2 18/24 ptrace: cleanup arch_ptrace() on powerpc
In reply to Namhyung KimUse new 'datavp' and 'datalp' variables in order to remove unnecessary castings.
--- arch/powerpc/kernel/ptrace.c | 51 +++++++++++++++++++++-------------------- 1 files changed, 26 insertions(+), 25 deletions(-)
arch/powerpc/kernel/ptrace.c +26 -25
@@ -1409,26 +1409,28 @@ static long ppc_del_hwdebug(struct task_struct *child, long addr, long data)static long arch_ptrace_old (struct task_struct *child,long request,unsigned long addr,unsigned long data) { +void __user *datavp = (void __user *) data; +switch (request) {case PPC_PTRACE_GETREGS :/* Get GPRs 0 - 31. */ return copy_regset_to_user (child, &user_ppc_native_view,REGSET_GPR ,0 ,32 *sizeof (long ), - (void __user *) data); + datavp);case PPC_PTRACE_SETREGS :/* Set GPRs 0 - 31. */ return copy_regset_from_user (child, &user_ppc_native_view,REGSET_GPR ,0 ,32 *sizeof (long ), - (const void __user *) data); + datavp);case PPC_PTRACE_GETFPREGS :/* Get FPRs 0 - 31. */ return copy_regset_to_user (child, &user_ppc_native_view,REGSET_FPR ,0 ,32 *sizeof (double ), - (void __user *) data); + datavp);case PPC_PTRACE_SETFPREGS :/* Set FPRs 0 - 31. */ return copy_regset_from_user (child, &user_ppc_native_view,REGSET_FPR ,0 ,32 *sizeof (double ), - (const void __user *) data); + datavp); }return -EPERM ;
@@ -1438,6 +1440,8 @@ long arch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { int ret = -EPERM; +void __user *datavp = (void __user *) data; +unsigned long __user *datalp = datavp;switch (request) {/* read the word at location addr in the USER area. */
@@ -1464,7 +1468,7 @@ long arch_ptrace(struct task_struct *child, long request, tmp = ((unsigned long *)child->thread.fpr) [TS_FPRWIDTH * (index -PT_FPR0 )]; } - ret =put_user (tmp,(unsigned long __user *) data); + ret =put_user (tmp, datalp);break ; }
@@ -1526,11 +1530,11 @@ long arch_ptrace(struct task_struct *child, long request, dbginfo.features =0 ;#endif /* CONFIG_PPC_ADV_DEBUG_REGS */ -if (!access_ok (VERIFY_WRITE , data, +if (!access_ok (VERIFY_WRITE , datavp,sizeof (struct ppc_debug_info )))return -EFAULT ; - ret =__copy_to_user ((struct ppc_debug_info __user *)data, - &dbginfo,sizeof (struct ppc_debug_info )) ? + ret =__copy_to_user (datavp, &dbginfo, +sizeof (struct ppc_debug_info )) ? -EFAULT :0 ;break ; }
@@ -1538,11 +1542,10 @@ long arch_ptrace(struct task_struct *child, long request,case PPC_PTRACE_SETHWDEBUG : {struct ppc_hw_breakpoint bp_info; -if (!access_ok (VERIFY_READ , data, +if (!access_ok (VERIFY_READ , datavp,sizeof (struct ppc_hw_breakpoint )))return -EFAULT ; - ret =__copy_from_user (&bp_info, - (struct ppc_hw_breakpoint __user *)data, + ret =__copy_from_user (&bp_info, datavp,sizeof (struct ppc_hw_breakpoint )) ? -EFAULT :0 ;if (!ret)
@@ -1561,11 +1564,9 @@ long arch_ptrace(struct task_struct *child, long request,if (addr >0 )break ;#ifdef CONFIG_PPC_ADV_DEBUG_REGS - ret =put_user (child->thread.dac1, - (unsigned long __user *)data); + ret =put_user (child->thread.dac1, datalp);#else - ret =put_user (child->thread.dabr, - (unsigned long __user *)data); + ret =put_user (child->thread.dabr, datalp);#endif break ; }
@@ -1581,7 +1582,7 @@ long arch_ptrace(struct task_struct *child, long request,return copy_regset_to_user (child, &user_ppc_native_view,REGSET_GPR ,0 ,sizeof (struct pt_regs ), - (void __user *) data); + datavp);#ifdef CONFIG_PPC64 case PTRACE_SETREGS64 :
@@ -1590,19 +1591,19 @@ long arch_ptrace(struct task_struct *child, long request,return copy_regset_from_user (child, &user_ppc_native_view,REGSET_GPR ,0 ,sizeof (struct pt_regs ), - (const void __user *) data); + datavp);case PTRACE_GETFPREGS :/* Get the child FPU state (FPR0...31 + FPSCR) */ return copy_regset_to_user (child, &user_ppc_native_view,REGSET_FPR ,0 ,sizeof (elf_fpregset_t), - (void __user *) data); + datavp);case PTRACE_SETFPREGS :/* Set the child FPU state (FPR0...31 + FPSCR) */ return copy_regset_from_user (child, &user_ppc_native_view,REGSET_FPR ,0 ,sizeof (elf_fpregset_t), - (const void __user *) data); + datavp);#ifdef CONFIG_ALTIVEC case PTRACE_GETVRREGS :
@@ -1610,40 +1611,40 @@ long arch_ptrace(struct task_struct *child, long request,REGSET_VMX ,0 , (33 *sizeof (vector128) +sizeof (u32)), - (void __user *) data); + datavp);case PTRACE_SETVRREGS :return copy_regset_from_user (child, &user_ppc_native_view,REGSET_VMX ,0 , (33 *sizeof (vector128) +sizeof (u32)), - (const void __user *) data); + datavp);#endif #ifdef CONFIG_VSX case PTRACE_GETVSRREGS :return copy_regset_to_user (child, &user_ppc_native_view,REGSET_VSX ,0 ,32 *sizeof (double ), - (void __user *) data); + datavp);case PTRACE_SETVSRREGS :return copy_regset_from_user (child, &user_ppc_native_view,REGSET_VSX ,0 ,32 *sizeof (double ), - (const void __user *) data); + datavp);#endif #ifdef CONFIG_SPE case PTRACE_GETEVRREGS :/* Get the child spe register state. */ return copy_regset_to_user (child, &user_ppc_native_view,REGSET_SPE ,0 ,35 *sizeof (u32), - (void __user *) data); + datavp);case PTRACE_SETEVRREGS :/* Set the child spe register state. */ return copy_regset_from_user (child, &user_ppc_native_view,REGSET_SPE ,0 ,35 *sizeof (u32), - (const void __user *) data); + datavp);#endif /* Old reverse args ptrace callss */
Signature · 1 line
1.7.2.2
PATCH v2 19/24 ptrace: cleanup arch_ptrace() on score
In reply to Namhyung KimRemove unnecessary castings.
--- arch/score/kernel/ptrace.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/score/kernel/ptrace.c +2 -2
@@ -336,14 +336,14 @@ arch_ptrace(struct task_struct *child, long request, ret =copy_regset_to_user (child, &user_score_native_view,REGSET_GENERAL ,0 ,sizeof (struct pt_regs ), - (void __user *)datap); + datap);break ;case PTRACE_SETREGS : ret =copy_regset_from_user (child, &user_score_native_view,REGSET_GENERAL ,0 ,sizeof (struct pt_regs ), - (const void __user *)datap); + datap);break ;default :
Signature · 1 line
1.7.2.2
PATCH v2 20/24 ptrace: cleanup arch_ptrace() on sh
In reply to Namhyung KimRemove unnecessary castings and get rid of dummy pointer in favor of offsetof() macro in ptrace_32.c. Also use temporary variables and break long lines in order to improve readability.
--- arch/sh/kernel/ptrace_32.c | 38 +++++++++++++++++++++----------------- arch/sh/kernel/ptrace_64.c | 19 ++++++++++++------- 2 files changed, 33 insertions(+), 24 deletions(-)
arch/sh/kernel/ptrace_32.c +21 -17
@@ -341,7 +341,6 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)long arch_ptrace (struct task_struct *child,long request,unsigned long addr,unsigned long data) { -struct user * dummy =NULL ;unsigned long __user *datap = (unsigned long __user *)data;int ret;
@@ -357,17 +356,20 @@ long arch_ptrace(struct task_struct *child, long request,if (addr <sizeof (struct pt_regs )) tmp =get_stack_long (child, addr); -else if (addr >= (unsigned long ) &dummy->fpu && - addr < (unsigned long ) &dummy->u_fpvalid) { +else if (addr >= offsetof(struct user , fpu) && + addr < offsetof(struct user , u_fpvalid)) {if (!tsk_used_math (child)) { -if (addr == (unsigned long )&dummy->fpu.fpscr) + if (addr == offsetof(struct user, fpu.fpscr)) tmp =FPSCR_INIT ;else tmp =0 ; - }else + }else { +unsigned long index; + index = addr - offsetof(struct user , fpu); tmp = ((unsigned long *)child->thread.xstate) - [(addr - (unsigned long )&dummy->fpu) >>2 ]; - }else if (addr == (unsigned long ) &dummy->u_fpvalid) + [index >>2 ]; + } + }else if (addr == offsetof(struct user , u_fpvalid)) tmp = !!tsk_used_math (child);else if (addr ==PT_TEXT_ADDR ) tmp = child->mm->start_code;
@@ -391,13 +393,15 @@ long arch_ptrace(struct task_struct *child, long request,if (addr <sizeof (struct pt_regs )) ret =put_stack_long (child, addr, data); -else if (addr >= (unsigned long ) &dummy->fpu && - addr < (unsigned long ) &dummy->u_fpvalid) { +else if (addr >= offsetof(struct user , fpu) && + addr < offsetof(struct user , u_fpvalid)) { +unsigned long index; + index = addr - offsetof(struct user , fpu);set_stopped_child_used_math (child); ((unsigned long *)child->thread.xstate) - [(addr - (unsigned long )&dummy->fpu) >>2 ] = data; + [index >>2 ] = data; ret =0 ; - }else if (addr == (unsigned long ) &dummy->u_fpvalid) { + }else if (addr == offsetof(struct user , u_fpvalid)) {conditional_stopped_child_used_math (data, child); ret =0 ; }
@@ -407,35 +411,35 @@ long arch_ptrace(struct task_struct *child, long request,return copy_regset_to_user (child, &user_sh_native_view,REGSET_GENERAL ,0 ,sizeof (struct pt_regs ), - (void __user *)data); + datap);case PTRACE_SETREGS :return copy_regset_from_user (child, &user_sh_native_view,REGSET_GENERAL ,0 ,sizeof (struct pt_regs ), - (const void __user *)data); + datap);#ifdef CONFIG_SH_FPU case PTRACE_GETFPREGS :return copy_regset_to_user (child, &user_sh_native_view,REGSET_FPU ,0 ,sizeof (struct user_fpu_struct ), - (void __user *)data); + datap);case PTRACE_SETFPREGS :return copy_regset_from_user (child, &user_sh_native_view,REGSET_FPU ,0 ,sizeof (struct user_fpu_struct ), - (const void __user *)data); + datap);#endif #ifdef CONFIG_SH_DSP case PTRACE_GETDSPREGS :return copy_regset_to_user (child, &user_sh_native_view,REGSET_DSP ,0 ,sizeof (struct pt_dspregs ), - (void __user *)data); + datap);case PTRACE_SETDSPREGS :return copy_regset_from_user (child, &user_sh_native_view,REGSET_DSP ,0 ,sizeof (struct pt_dspregs ), - (const void __user *)data); + datap);#endif default : ret =ptrace_request (child, request, addr, data);
arch/sh/kernel/ptrace_64.c +12 -7
@@ -308,6 +308,7 @@ long arch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { int ret; +unsigned long __user *datap = (unsigned long __user *) data;switch (request) {/* read the word at location addr in the USER area. */
@@ -322,13 +323,15 @@ long arch_ptrace(struct task_struct *child, long request, tmp =get_stack_long (child, addr); else if ((addr >= offsetof(struct user, fpu)) && (addr < offsetof(struct user, u_fpvalid))) { - tmp =get_fpu_long (child, addr - offsetof(struct user , fpu)); +unsigned long index; + index = addr - offsetof(struct user , fpu); + tmp =get_fpu_long (child, index); } else if (addr == offsetof(struct user, u_fpvalid)) { tmp = !!tsk_used_math (child); } else {break ; } - ret =put_user (tmp, (unsigned long *)data); + ret =put_user (tmp, datap);break ; }
@@ -359,7 +362,9 @@ long arch_ptrace(struct task_struct *child, long request, }else if ((addr >= offsetof(struct user , fpu)) && (addr < offsetof(struct user , u_fpvalid))) { - ret =put_fpu_long (child, addr - offsetof(struct user , fpu), data); +unsigned long index; + index = addr - offsetof(struct user , fpu); + ret =put_fpu_long (child, index, data); }break ;
@@ -367,23 +372,23 @@ long arch_ptrace(struct task_struct *child, long request,return copy_regset_to_user (child, &user_sh64_native_view,REGSET_GENERAL ,0 ,sizeof (struct pt_regs ), - (void __user *)data); + datap);case PTRACE_SETREGS :return copy_regset_from_user (child, &user_sh64_native_view,REGSET_GENERAL ,0 ,sizeof (struct pt_regs ), - (const void __user *)data); + datap);#ifdef CONFIG_SH_FPU case PTRACE_GETFPREGS :return copy_regset_to_user (child, &user_sh64_native_view,REGSET_FPU ,0 ,sizeof (struct user_fpu_struct ), - (void __user *)data); + datap);case PTRACE_SETFPREGS :return copy_regset_from_user (child, &user_sh64_native_view,REGSET_FPU ,0 ,sizeof (struct user_fpu_struct ), - (const void __user *)data); + datap);#endif default : ret =ptrace_request (child, request, addr, data);
Signature · 1 line
1.7.2.2
PATCH v2 21/24 ptrace: cleanup arch_ptrace() on sparc
In reply to Namhyung KimFactor out struct fps and remove redundant castings.
--- arch/sparc/kernel/ptrace_32.c | 54 +++++++++++++++------------------------- arch/sparc/kernel/ptrace_64.c | 8 +++--- 2 files changed, 24 insertions(+), 38 deletions(-)
arch/sparc/kernel/ptrace_32.c +20 -34
@@ -323,19 +323,35 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)return &user_sparc32_view; } +struct fps { +unsigned long regs[32 ]; +unsigned long fsr; +unsigned long flags; +unsigned long extra; +unsigned long fpqd; +struct fq { +unsigned long *insnaddr; +unsigned long insn; + } fpq[16 ]; +}; +long arch_ptrace (struct task_struct *child,long request,unsigned long addr,unsigned long data) {unsigned long addr2 = current->thread.kregs->u_regs[UREG_I4 ]; +void __user *addr2p;const struct user_regset_view *view; +struct pt_regs __user *pregs; +struct fps __user *fps;int ret; view =task_user_regset_view (current); + addr2p = (void __user *) addr2; + pregs = (struct pt_regs __user *) addr; + fps = (struct fps __user *) addr;switch (request) {case PTRACE_GETREGS : { -struct pt_regs __user *pregs = (struct pt_regs __user *) addr; - ret = copy_regset_to_user(child, view, REGSET_GENERAL, 32 * sizeof(u32), 4 * sizeof(u32),
@@ -349,8 +365,6 @@ long arch_ptrace(struct task_struct *child, long request, }case PTRACE_SETREGS : { -struct pt_regs __user *pregs = (struct pt_regs __user *) addr; - ret = copy_regset_from_user(child, view, REGSET_GENERAL, 32 * sizeof(u32), 4 * sizeof(u32),
@@ -364,19 +378,6 @@ long arch_ptrace(struct task_struct *child, long request, }case PTRACE_GETFPREGS : { -struct fps { -unsigned long regs[32 ]; -unsigned long fsr; -unsigned long flags; -unsigned long extra; -unsigned long fpqd; -struct fq { -unsigned long *insnaddr; -unsigned long insn; - } fpq[16 ]; - }; -struct fps __user *fps = (struct fps __user *) addr; - ret = copy_regset_to_user(child, view, REGSET_FP, 0 * sizeof(u32), 32 * sizeof(u32),
@@ -398,19 +399,6 @@ long arch_ptrace(struct task_struct *child, long request, }case PTRACE_SETFPREGS : { -struct fps { -unsigned long regs[32 ]; -unsigned long fsr; -unsigned long flags; -unsigned long extra; -unsigned long fpqd; -struct fq { -unsigned long *insnaddr; -unsigned long insn; - } fpq[16 ]; - }; -struct fps __user *fps = (struct fps __user *) addr; - ret = copy_regset_from_user(child, view, REGSET_FP, 0 * sizeof(u32), 32 * sizeof(u32),
@@ -425,8 +413,7 @@ long arch_ptrace(struct task_struct *child, long request,case PTRACE_READTEXT :case PTRACE_READDATA : - ret =ptrace_readdata (child, addr, - (void __user *) addr2, data); + ret =ptrace_readdata (child, addr, addr2p, data);if (ret == data) ret =0 ;
@@ -436,8 +423,7 @@ long arch_ptrace(struct task_struct *child, long request,case PTRACE_WRITETEXT :case PTRACE_WRITEDATA : - ret =ptrace_writedata (child, (void __user *) addr2, - addr, data); + ret =ptrace_writedata (child, addr2p, addr, data);if (ret == data) ret =0 ;
arch/sparc/kernel/ptrace_64.c +4 -4
@@ -976,10 +976,12 @@ long arch_ptrace(struct task_struct *child, long request,unsigned long addr2 =task_pt_regs (current)->u_regs[UREG_I4 ];struct pt_regs __user *pregs;struct fps __user *fps; +void __user *addr2p;int ret; pregs = (struct pt_regs __user *) addr; fps = (struct fps __user *) addr; + addr2p = (void __user *) addr2;switch (request) {case PTRACE_PEEKUSR :
@@ -1030,8 +1032,7 @@ long arch_ptrace(struct task_struct *child, long request,case PTRACE_READTEXT :case PTRACE_READDATA : - ret =ptrace_readdata (child, addr, - (char __user *)addr2, data); + ret =ptrace_readdata (child, addr, addr2p, data);if (ret == data) ret =0 ;else if (ret >=0 )
@@ -1040,8 +1041,7 @@ long arch_ptrace(struct task_struct *child, long request,case PTRACE_WRITETEXT :case PTRACE_WRITEDATA : - ret =ptrace_writedata (child, (char __user *) addr2, - addr, data); + ret =ptrace_writedata (child, addr2p, addr, data);if (ret == data) ret =0 ;else if (ret >=0 )
Signature · 1 line
1.7.2.2
PATCH v2 22/24 ptrace: cleanup arch_ptrace() on tile
In reply to Namhyung KimRemove checking @addr less than 0 because @addr is now unsigned.
--- arch/tile/kernel/ptrace.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/tile/kernel/ptrace.c +2 -2
@@ -85,7 +85,7 @@ long arch_ptrace(struct task_struct *child, long request,case PTRACE_PEEKUSR :/* Read register from pt_regs. */ if (addr & (sizeof (data)-1 ))break ; -if (addr <0 || addr >=PTREGS_SIZE ) +if (addr >=PTREGS_SIZE )break ; tmp =getreg (child, addr);/* Read register */ ret =put_user (tmp, datap);
@@ -94,7 +94,7 @@ long arch_ptrace(struct task_struct *child, long request,case PTRACE_POKEUSR :/* Write register in pt_regs. */ if (addr & (sizeof (data)-1 ))break ; -if (addr <0 || addr >=PTREGS_SIZE ) +if (addr >=PTREGS_SIZE )break ;putreg (child, addr, data);/* Write register */ ret =0 ;
Signature · 1 line
1.7.2.2
PATCH v2 23/24 ptrace: cleanup arch_ptrace() on um
In reply to Namhyung KimRemove unnecessary castings using void pointer and fix copy_to_user() return value. Also add missing __user markup on the argument of arch_ptrctl().
--- arch/um/kernel/ptrace.c | 18 ++++++++---------- arch/um/sys-x86_64/ptrace.c | 7 +++---- 2 files changed, 11 insertions(+), 14 deletions(-)
arch/um/kernel/ptrace.c +8 -10
@@ -47,6 +47,7 @@ long arch_ptrace(struct task_struct *child, long request, {int i, ret;unsigned long __user *p = (void __user *)data; +void __user *vp = p;switch (request) {/* read word at location addr. */
@@ -108,24 +109,20 @@ long arch_ptrace(struct task_struct *child, long request,#endif #ifdef PTRACE_GETFPREGS case PTRACE_GETFPREGS :/* Get the child FPU state. */ - ret =get_fpregs ((struct user_i387_struct __user *) data, - child); + ret =get_fpregs (vp, child);break ;#endif #ifdef PTRACE_SETFPREGS case PTRACE_SETFPREGS :/* Set the child FPU state. */ - ret =set_fpregs ((struct user_i387_struct __user *) data, - child); + ret =set_fpregs (vp, child);break ;#endif case PTRACE_GET_THREAD_AREA : - ret =ptrace_get_thread_area (child, addr, - (struct user_desc __user *) data); + ret =ptrace_get_thread_area (child, addr, vp);break ;case PTRACE_SET_THREAD_AREA : - ret =ptrace_set_thread_area (child, addr, - (struct user_desc __user *) data); + ret =ptrace_set_thread_area (child, addr, datavp);break ;case PTRACE_FAULTINFO : {
@@ -135,7 +132,8 @@ long arch_ptrace(struct task_struct *child, long request,* On i386, ptrace_faultinfo is smaller! */ ret =copy_to_user (p, &child->thread.arch.faultinfo, -sizeof (struct ptrace_faultinfo )); +sizeof (struct ptrace_faultinfo )) ? + -EIO :0 ;break ; }
@@ -159,7 +157,7 @@ long arch_ptrace(struct task_struct *child, long request,#ifdef PTRACE_ARCH_PRCTL case PTRACE_ARCH_PRCTL :/* XXX Calls ptrace on the host - needs some SMP thinking */ - ret =arch_prctl (child, data, (void *) addr); + ret =arch_prctl (child, data, (void __user *) addr);break ;#endif default :
arch/um/sys-x86_64/ptrace.c +3 -4
@@ -179,15 +179,14 @@ long subarch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { int ret = -EIO; +void __user *datap = (void __user *) data;switch (request) {case PTRACE_GETFPXREGS :/* Get the child FPU state. */ - ret =get_fpregs ((struct user_i387_struct __user *) data, - child); + ret =get_fpregs (datap, child);break ;case PTRACE_SETFPXREGS :/* Set the child FPU state. */ - ret =set_fpregs ((struct user_i387_struct __user *) data, - child); + ret =set_fpregs (datap, child);break ; }
Signature · 1 line
1.7.2.2
PATCH v2 24/24 ptrace: cleanup arch_ptrace() on xtensa
In reply to Namhyung KimUse new 'datap' variable in order to remove unnecessary castings.
--- arch/xtensa/kernel/ptrace.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
arch/xtensa/kernel/ptrace.c +6 -5
@@ -260,6 +260,7 @@ long arch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { int ret = -EPERM; +void __user *datap = (void __user *) data;switch (request) {case PTRACE_PEEKTEXT :/* read word at location addr. */
@@ -268,7 +269,7 @@ long arch_ptrace(struct task_struct *child, long request,break ;case PTRACE_PEEKUSR :/* read register specified by addr. */ - ret =ptrace_peekusr (child, addr, (void __user *) data); + ret =ptrace_peekusr (child, addr, datap);break ;case PTRACE_POKETEXT :/* write the word at location addr. */
@@ -281,19 +282,19 @@ long arch_ptrace(struct task_struct *child, long request,break ;case PTRACE_GETREGS : - ret =ptrace_getregs (child, (void __user *) data); + ret =ptrace_getregs (child, datap);break ;case PTRACE_SETREGS : - ret =ptrace_setregs (child, (void __user *) data); + ret =ptrace_setregs (child, datap);break ;case PTRACE_GETXTREGS : - ret =ptrace_getxregs (child, (void __user *) data); + ret =ptrace_getxregs (child, datap);break ;case PTRACE_SETXTREGS : - ret =ptrace_setxregs (child, (void __user *) data); + ret =ptrace_setxregs (child, datap);break ;default :
Signature · 1 line
1.7.2.2
PATCH v2 15/24 ptrace: cleanup arch_ptrace() on MIPS
In reply to Namhyung KimUse new 'addrp', 'datavp' and 'datalp' variables in order to remove unnecessary castings.
--- arch/mips/kernel/ptrace.c | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-)
arch/mips/kernel/ptrace.c +11 -11
@@ -259,6 +259,9 @@ long arch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { int ret; +void __user *addrp = (void __user *) addr; +void __user *datavp = (void __user *) data; +unsigned long __user *datalp = (void __user *) data;switch (request) {/* when I and D space are separate, these will need to be fixed. */
@@ -387,7 +390,7 @@ long arch_ptrace(struct task_struct *child, long request, ret = -EIO ; goto out; } - ret =put_user (tmp, (unsigned long __user *) data); + ret =put_user (tmp, datalp);break ; }
@@ -479,34 +482,31 @@ long arch_ptrace(struct task_struct *child, long request, }case PTRACE_GETREGS : - ret =ptrace_getregs (child, (__s64 __user *) data); + ret =ptrace_getregs (child, datavp);break ;case PTRACE_SETREGS : - ret =ptrace_setregs (child, (__s64 __user *) data); + ret =ptrace_setregs (child, datavp);break ;case PTRACE_GETFPREGS : - ret =ptrace_getfpregs (child, (__u32 __user *) data); + ret =ptrace_getfpregs (child, datavp);break ;case PTRACE_SETFPREGS : - ret =ptrace_setfpregs (child, (__u32 __user *) data); + ret =ptrace_setfpregs (child, datavp);break ;case PTRACE_GET_THREAD_AREA : - ret =put_user (task_thread_info (child)->tp_value, - (unsigned long __user *) data); + ret =put_user (task_thread_info (child)->tp_value, datalp);break ;case PTRACE_GET_WATCH_REGS : - ret =ptrace_get_watch_regs (child, - (struct pt_watch_regs __user *) addr); + ret =ptrace_get_watch_regs (child, addrp);break ;case PTRACE_SET_WATCH_REGS : - ret =ptrace_set_watch_regs (child, - (struct pt_watch_regs __user *) addr); + ret =ptrace_set_watch_regs (child, addrp);break ;default :
Signature · 1 line
1.7.2.2
Re: [PATCH v2 22/24] ptrace: cleanup arch_ptrace() on tile
In reply to Namhyung KimQuoted 22 lines · Namhyung Kim
Remove checking @addr less than 0 because @addr is now unsigned.
Signed-off-by Namhyung Kim <[email protected]>Cc Chris Metcalf <[email protected]>--- arch/tile/kernel/ptrace.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)arch/tile/kernel/ptrace.c +1
-1@@ -85,7 +85,7 @@ long arch_ptrace(struct task_struct *child, long request,case PTRACE_PEEKUSR :/* Read register from pt_regs. */ if (addr & (sizeof (data)-1 ))break ; -if (addr <0 || addr >=PTREGS_SIZE ) +if (addr >=PTREGS_SIZE )break ; tmp =getreg (child, addr);/* Read register */ ret =put_user (tmp, datap);
arch/tile/kernel/ptrace.c long arch_ptrace(struct task_struct *child, long request, · line 100
Quoted 8 lines
arch/tile/kernel/ptrace.c +1
-1@@ -94,7 +94,7 @@ long arch_ptrace(struct task_struct *child, long request,case PTRACE_POKEUSR :/* Write register in pt_regs. */ if (addr & (sizeof (data)-1 ))break ; -if (addr <0 || addr >=PTREGS_SIZE ) +if (addr >=PTREGS_SIZE )break ;putreg (child, addr, data);/* Write register */ ret =0 ;
This omits the change to the actual function definition, which was present in the previous version of this patch.
On the up side, it also removes the change to the sizeof() values in GETREGS/SETREGS, which seemed unnecessary in the previous version.
Signature · 2 lines
Chris Metcalf, Tilera Corp. http://www.tilera.com
Re: [PATCH v2 22/24] ptrace: cleanup arch_ptrace() on tile
Hello,
Quoted 26 lines · Chris Metcalf
Quoted 25 lines · Namhyung Kim
Remove checking @addr less than 0 because @addr is now unsigned.
Signed-off-by Namhyung Kim <[email protected]>Cc Chris Metcalf <[email protected]>---
arch/tile/kernel/ptrace.c | 4 ++--1 files changed, 2 insertions(+), 2 deletions(-)arch/tile/kernel/ptrace.c +0
-0@@ -85,7 +85,7 @@ long arch_ptrace(struct task_struct *child, long request,case
PTRACE_PEEKUSR: /* Read register frompt_regs. */ if (addr & (sizeof(data)-1))
break;
- if (addr < 0 || addr >=PTREGS_SIZE)
+ if (addr >=PTREGS_SIZE)
break;
tmp =getreg(child, addr); /* Read register */ ret =put_user(tmp, datap);arch/tile/kernel/ptrace.c +0
-0@@ -94,7 +94,7 @@ long arch_ptrace(struct task_struct *child, long request,case
PTRACE_POKEUSR: /* Write register inpt_regs. */ if (addr & (sizeof(data)-1))
break;
Quoted 9 lines
Quoted 5 lines
- if (addr < 0 || addr >=
PTREGS_SIZE)
+ if (addr >=PTREGS_SIZE)
break;
putreg(child, addr, data); /* Write register */ ret = 0;This omits the change to the actual function definition, which was present in the previous version of this patch.
That change was moved/combined into previous patch in this series. Please check out 03/24 in this patchset also.
Quoted 3 lines
On the up side, it also removes the change to the
sizeof()values in GETREGS/SETREGS, which seemed unnecessary in the previous version.
Yes, it is unnecessary but little bit more accurate although there will be no machine that has diferent size of long and unsigned long. Anyway if you really hate it, I'll discard it. :-)
Signature · 2 lines
Regards, Namhyung Kim
Chris Metcalf
Acked-byRe: [PATCH v2 22/24] ptrace: cleanup arch_ptrace() on tile
Quoted 5 lines · Namhyung Kim
Quoted 2 lines · Chris Metcalf
This omits the change to the actual function definition, which was present in the previous version of this patch.
That change was moved/combined into previous patch in this series. Please check out 03/24 in this patchset also.
Sure, that looks fine. And sizeof(unsigned long) is OK; I don't have a real axe to grind there.
Signature · 2 lines
Chris Metcalf, Tilera Corp. http://www.tilera.com
Re: [PATCH v2 07/24] ptrace: cleanup arch_ptrace() and friends on Blackfin
In reply to Namhyung KimQuoted 2 lines · Namhyung Kim
Change signature of get/put_reg() according to the change of
arch_ptrace()and remove unnecessary castings.
thanks; Acked-by: Mike Frysinger <[email protected]> -mike
Re: [PATCH v2 02/24] ptrace: cleanup ptrace_request()
In reply to Namhyung KimYou've still changed put_user to copy_to_user here. I thought you'd agreed not to change that.
Thanks,
Roland
Re: [PATCH v2 02/24] ptrace: cleanup ptrace_request()
Quoted 3 lines · Roland McGrath
You've still changed
put_usertocopy_to_userhere. I thought you'd agreed not to change that.
My bad. I just sent v1, sorry. Here comes updated version.
Quoted 1 line
From
2e6543cdfb05c66dcb18ce5e8d941d835a4767afMon Sep 17 00:00:00 2001
From: Namhyung Kim <[email protected]>
Date: Thu, 26 Aug 2010 01:46:52 +0900
Subject: [PATCH v2 02/24 UPDATED] ptrace: cleanup ptrace_request()
Use new 'datavp' and 'datalp' variables to remove unnecesary castings.
--- kernel/ptrace.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)
kernel/ptrace.c +7 -7
@@ -563,6 +563,8 @@ int ptrace_request(struct task_struct *child, long request, {int ret = -EIO ;siginfo_t siginfo; +void __user *datavp = (void __user *) data; +unsigned long __user *datalp = datavp;switch (request) {case PTRACE_PEEKTEXT :
@@ -579,19 +581,17 @@ int ptrace_request(struct task_struct *child, long request, ret =ptrace_setoptions (child, data);break ;case PTRACE_GETEVENTMSG : - ret =put_user (child->ptrace_message, (unsigned long __user *) data); + ret =put_user (child->ptrace_message, datalp);break ;case PTRACE_GETSIGINFO : ret =ptrace_getsiginfo (child, &siginfo);if (!ret) - ret =copy_siginfo_to_user ((siginfo_t __user *) data, - &siginfo); + ret =copy_siginfo_to_user (datavp, &siginfo);break ;case PTRACE_SETSIGINFO : -if (copy_from_user (&siginfo, (siginfo_t __user *) data, -sizeof siginfo)) +if (copy_from_user (&siginfo, datavp,sizeof siginfo)) ret = -EFAULT ;else ret =ptrace_setsiginfo (child, &siginfo);
@@ -622,7 +622,7 @@ int ptrace_request(struct task_struct *child, long request, }mmput (mm); - ret =put_user (tmp, (unsigned long __user *) data); + ret =put_user (tmp, datalp);break ; }#endif
@@ -651,7 +651,7 @@ int ptrace_request(struct task_struct *child, long request,case PTRACE_SETREGSET : {struct iovec kiov; -struct iovec __user *uiov = (struct iovec __user *) data; +struct iovec __user *uiov = datavp;if (!access_ok (VERIFY_WRITE , uiov,sizeof (*uiov)))return -EFAULT ;
Signature · 1 line
1.7.2.2
Re: [PATCH v2 03/24] ptrace: change signature of arch_ptrace()
In reply to Namhyung KimQuoted 3 lines · Namhyung Kim
Fix up the arguments to
arch_ptrace()to take account of the fact that @addr and @data are now unsigned long rather than long as of a preceding patch in this series.
Re: [PATCH v2 13/24] ptrace: cleanup arch_ptrace() on m68knommu
In reply to Namhyung KimHi Namhyung,
Quoted 6 lines · Namhyung Kim
Use new 'regno', 'datap' variables in order to remove duplicated expressions and unnecessary castings. Alse remove checking @addr less than 0 because addr is now unsigned.
Signed-off-by Namhyung Kim <[email protected]>Cc Greg Ungerer <[email protected]>
Looks ok to me:
Quoted 167 lines
--- arch/m68knommu/kernel/ptrace.c | 58 ++++++++++++++++++--------------------- 1 files changed, 27 insertions(+), 31 deletions(-)arch/m68knommu/kernel/ptrace.c +27
-31@@ -115,6 +115,8 @@ long arch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { int ret; +int regno = addr >>2 ; +unsigned long __user *datap = (unsigned long __user *) data;switch (request) {/* read the word at location addr in the USER area. */ @@ -122,71 +124,66 @@ long arch_ptrace(struct task_struct *child, long request,unsigned long tmp; ret = -EIO ; -if ((addr &3 ) || addr <0 || - addr >sizeof (struct user ) -3 ) +if ((addr &3 ) || addr >sizeof (struct user ) -3 )break ; tmp =0 ;/* Default return condition */ - addr = addr >>2 ;/* temporary hack. */ ret = -EIO ; -if (addr <19 ) { - tmp =get_reg (child, addr); -if (addr ==PT_SR ) +if (regno <19 ) { + tmp =get_reg (child, regno); +if (regno ==PT_SR ) tmp >>=16 ; - }else if (addr >=21 && addr <49 ) { - tmp = child->thread.fp[addr -21 ]; + }else if (regno >=21 && regno <49 ) { + tmp = child->thread.fp[regno -21 ];#ifdef CONFIG_M68KFPU_EMU /* Convert internal fpu reg representation * into long double format */ -if (FPU_IS_EMU && (addr <45 ) && !(addr %3 )) +if (FPU_IS_EMU && (regno <45 ) && !(regno %3 )) tmp = ((tmp &0xffff0000 ) <<15 ) | ((tmp &0x0000ffff ) <<16 );#endif - }else if (addr ==49 ) { + }else if (regno ==49 ) { tmp = child->mm->start_code; - }else if (addr ==50 ) { + }else if (regno ==50 ) { tmp = child->mm->start_data; - }else if (addr ==51 ) { + }else if (regno ==51 ) { tmp = child->mm->end_code; }else break ; - ret =put_user (tmp,(unsigned long *) data); + ret =put_user (tmp, datap);break ; }case PTRACE_POKEUSR :/* write the word at location addr in the USER area */ ret = -EIO ; -if ((addr &3 ) || addr <0 || - addr >sizeof (struct user ) -3 ) +if ((addr &3 ) || addr >sizeof (struct user ) -3 )break ; - addr = addr >>2 ;/* temporary hack. */ - -if (addr ==PT_SR ) { +if (regno ==PT_SR ) { data &=SR_MASK ; data <<=16 ; data |=get_reg (child,PT_SR ) & ~(SR_MASK <<16 ); } -if (addr <19 ) { -if (put_reg (child, addr, data)) +if (regno <19 ) { +if (put_reg (child, regno, data))break ; ret =0 ;break ; } -if (addr >=21 && addr <48 ) +if (regno >=21 && regno <48 ) {#ifdef CONFIG_M68KFPU_EMU /* Convert long double format * into internal fpu reg representation */ -if (FPU_IS_EMU && (addr <45 ) && !(addr %3 )) { +if (FPU_IS_EMU && (regno <45 ) && !(regno %3 )) { data <<=15 ; data = (data &0xffff0000 ) | ((data &0x0000ffff ) >>1 ); }#endif - child->thread.fp[addr -21 ] = data; + child->thread.fp[regno -21 ] = data; ret =0 ; }break ;@@ -198,11 +195,11 @@ long arch_ptrace(struct task_struct *child, long request, tmp =get_reg (child, i);if (i ==PT_SR ) tmp >>=16 ; -if (put_user (tmp, (unsigned long *) data)) { +if (put_user (tmp, datap)) { ret = -EFAULT ;break ; } - data +=sizeof (unsigned long ); + datap++; } ret =0 ;break ;@@ -212,7 +209,7 @@ long arch_ptrace(struct task_struct *child, long request,int i;unsigned long tmp;for (i =0 ; i <19 ; i++) { -if (get_user (tmp, (unsigned long *) data)) { +if (get_user (tmp, datap)) { ret = -EFAULT ;break ; }@@ -222,7 +219,7 @@ long arch_ptrace(struct task_struct *child, long request, tmp |=get_reg (child,PT_SR ) & ~(SR_MASK <<16 ); }put_reg (child, i, tmp); - data +=sizeof (unsigned long ); + datap++; } ret =0 ;break ;@@ -231,7 +228,7 @@ long arch_ptrace(struct task_struct *child, long request,#ifdef PTRACE_GETFPREGS case PTRACE_GETFPREGS : {/* Get the child FPU state. */ ret =0 ; -if (copy_to_user ((void *)data, &child->thread.fp, +if (copy_to_user (datap, &child->thread.fp,sizeof (struct user_m68kfp_struct ))) ret = -EFAULT ;break ;@@ -241,7 +238,7 @@ long arch_ptrace(struct task_struct *child, long request,#ifdef PTRACE_SETFPREGS case PTRACE_SETFPREGS : {/* Set the child FPU state. */ ret =0 ; -if (copy_from_user (&child->thread.fp, (void *)data, +if (copy_from_user (&child->thread.fp, datap,sizeof (struct user_m68kfp_struct ))) ret = -EFAULT ;break ;@@ -249,8 +246,7 @@ long arch_ptrace(struct task_struct *child, long request,#endif case PTRACE_GET_THREAD_AREA : - ret =put_user (task_thread_info (child)->tp_value, - (unsigned long __user *)data); + ret =put_user (task_thread_info (child)->tp_value, datap);break ;default :
Signature · 5 lines
------------------------------------------------------------------------ Greg Ungerer -- Principal Engineer EMAIL: [email protected] SnapGear Group, McAfee PHONE: +61 7 3435 2888 8 Gardner Close FAX: +61 7 3217 5323 Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com
Re: [PATCH v2 14/24] ptrace: cleanup arch_ptrace() on microblaze
In reply to a message not in the archiveQuoted 5 lines · Michal Simek
Hi,
just for my info how does it look like this patch series? I mean who should added that patches to mainline?
Hello,
I am not sure but I hope Roland will take care of it.
Signature · 2 lines
Regards, Namhyung Kim
Re: [PATCH v2 14/24] ptrace: cleanup arch_ptrace() on microblaze
Quoted 10 lines · Michal Simek
Quoted 5 lines
Hi,
just for my info how does it look like this patch series? I mean who should added that patches to mainline?
Hello,
I am not sure but I hope Roland will take care of it.
Sorry, I didn't know you had any such expectation. Oleg and I do not autonomously maintain any ptrace tree that gets automatically merged or anything like that. Our Acked-by's are presumed to help your case and our objections to hurt it, but you just have to submit patches to linus, akpm, arch maintainers, or whatever other channels get merged regularly. We're not that kind of authoritative ourselves, though we are listed as the ptrace maintainers. We have to do the same with our own ptrace patches.
Thanks,
Roland
Re: [PATCH v2 14/24] ptrace: cleanup arch_ptrace() on microblaze
Quoted 8 lines · Roland McGrath
Sorry, I didn't know you had any such expectation. Oleg and I do not autonomously maintain any ptrace tree that gets automatically merged or anything like that. Our Acked-by's are presumed to help your case and our objections to hurt it, but you just have to submit patches to linus, akpm, arch maintainers, or whatever other channels get merged regularly. We're not that kind of authoritative ourselves, though we are listed as the ptrace maintainers. We have to do the same with our own ptrace patches.
Got it. Then I'll submit this to akpm but I think I don't have your Acked-by yet. :-)
Thanks for the information.
Signature · 2 lines
Regards, Namhyung Kim
Re: [PATCH v2 14/24] ptrace: cleanup arch_ptrace() on microblaze
Quoted 3 lines
Got it. Then I'll submit this to akpm but I think I don't have your Acked-by yet. :-)
Thanks for the information.
The cosmetic-only version of the generic patches was fine with me, i.e. where you don't replace put_user with copy_to_user et al. I don't have a particular say on the various arch code (a few of the arch maintainers tend to listen to me about this stuff, but it's up to them), so I didn't respond to those.
Thanks,
Roland
Re: [PATCH v2 14/24] ptrace: cleanup arch_ptrace() on microblaze
Quoted 6 lines · Roland McGrath
The cosmetic-only version of the generic patches was fine with me, i.e. where you don't replace
put_userwithcopy_to_useret al. I don't have a particular say on the various arch code (a few of the arch maintainers tend to listen to me about this stuff, but it's up to them), so I didn't respond to those.
OK. That means I can add your Acked-by's on architecture independent part in this series
which are 01, 03 and (resended) 02, right?
Signature · 2 lines
Regards, Namhyung Kim
Re: [PATCH v2 14/24] ptrace: cleanup arch_ptrace() on microblaze
Quoted 3 lines
OK. That means I can add your Acked-by's on architecture independent part in this series
which are 01, 03 and (resended) 02, right?
Yes, those alone should not change the compiled code at all. If that's so, then they are certainly fine with me.
Thanks,
Roland