Loading arch/powerpc/kernel/ptrace32.c +25 −71 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <linux/smp_lock.h> #include <linux/smp_lock.h> #include <linux/errno.h> #include <linux/errno.h> #include <linux/ptrace.h> #include <linux/ptrace.h> #include <linux/regset.h> #include <linux/user.h> #include <linux/user.h> #include <linux/security.h> #include <linux/security.h> #include <linux/signal.h> #include <linux/signal.h> Loading @@ -46,43 +47,21 @@ static long compat_ptrace_old(struct task_struct *child, long request, static long compat_ptrace_old(struct task_struct *child, long request, long addr, long data) long addr, long data) { { int ret = -EPERM; switch (request) { switch (request) { case PPC_PTRACE_GETREGS: { /* Get GPRs 0 - 31. */ case PPC_PTRACE_GETREGS: /* Get GPRs 0 - 31. */ int i; return copy_regset_to_user(child, unsigned long *reg = &((unsigned long *)child->thread.regs)[0]; task_user_regset_view(current), 0, unsigned int __user *tmp = (unsigned int __user *)addr; 0, 32 * sizeof(compat_long_t), compat_ptr(data)); CHECK_FULL_REGS(child->thread.regs); for (i = 0; i < 32; i++) { ret = put_user(*reg, tmp); if (ret) break; reg++; tmp++; } break; } case PPC_PTRACE_SETREGS: { /* Set GPRs 0 - 31. */ int i; unsigned long *reg = &((unsigned long *)child->thread.regs)[0]; unsigned int __user *tmp = (unsigned int __user *)addr; CHECK_FULL_REGS(child->thread.regs); case PPC_PTRACE_SETREGS: /* Set GPRs 0 - 31. */ for (i = 0; i < 32; i++) { return copy_regset_from_user(child, ret = get_user(*reg, tmp); task_user_regset_view(current), 0, if (ret) 0, 32 * sizeof(compat_long_t), break; compat_ptr(data)); reg++; tmp++; } break; } } } return -EPERM; return ret; } } long compat_arch_ptrace(struct task_struct *child, compat_long_t request, long compat_arch_ptrace(struct task_struct *child, compat_long_t request, Loading Loading @@ -291,42 +270,17 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, break; break; } } case PTRACE_GETREGS: { /* Get all pt_regs from the child. */ case PTRACE_GETREGS: /* Get all pt_regs from the child. */ int ui; return copy_regset_to_user( if (!access_ok(VERIFY_WRITE, (void __user *)data, child, task_user_regset_view(current), 0, PT_REGS_COUNT * sizeof(int))) { 0, PT_REGS_COUNT * sizeof(compat_long_t), ret = -EIO; compat_ptr(data)); break; } case PTRACE_SETREGS: /* Set all gp regs in the child. */ CHECK_FULL_REGS(child->thread.regs); return copy_regset_from_user( ret = 0; child, task_user_regset_view(current), 0, for (ui = 0; ui < PT_REGS_COUNT; ui ++) { 0, PT_REGS_COUNT * sizeof(compat_long_t), ret |= __put_user(ptrace_get_reg(child, ui), compat_ptr(data)); (unsigned int __user *) data); data += sizeof(int); } break; } case PTRACE_SETREGS: { /* Set all gp regs in the child. */ unsigned long tmp; int ui; if (!access_ok(VERIFY_READ, (void __user *)data, PT_REGS_COUNT * sizeof(int))) { ret = -EIO; break; } CHECK_FULL_REGS(child->thread.regs); ret = 0; for (ui = 0; ui < PT_REGS_COUNT; ui ++) { ret = __get_user(tmp, (unsigned int __user *) data); if (ret) break; ptrace_put_reg(child, ui, tmp); data += sizeof(int); } break; } case PTRACE_GETFPREGS: case PTRACE_GETFPREGS: case PTRACE_SETFPREGS: case PTRACE_SETFPREGS: Loading Loading
arch/powerpc/kernel/ptrace32.c +25 −71 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <linux/smp_lock.h> #include <linux/smp_lock.h> #include <linux/errno.h> #include <linux/errno.h> #include <linux/ptrace.h> #include <linux/ptrace.h> #include <linux/regset.h> #include <linux/user.h> #include <linux/user.h> #include <linux/security.h> #include <linux/security.h> #include <linux/signal.h> #include <linux/signal.h> Loading @@ -46,43 +47,21 @@ static long compat_ptrace_old(struct task_struct *child, long request, static long compat_ptrace_old(struct task_struct *child, long request, long addr, long data) long addr, long data) { { int ret = -EPERM; switch (request) { switch (request) { case PPC_PTRACE_GETREGS: { /* Get GPRs 0 - 31. */ case PPC_PTRACE_GETREGS: /* Get GPRs 0 - 31. */ int i; return copy_regset_to_user(child, unsigned long *reg = &((unsigned long *)child->thread.regs)[0]; task_user_regset_view(current), 0, unsigned int __user *tmp = (unsigned int __user *)addr; 0, 32 * sizeof(compat_long_t), compat_ptr(data)); CHECK_FULL_REGS(child->thread.regs); for (i = 0; i < 32; i++) { ret = put_user(*reg, tmp); if (ret) break; reg++; tmp++; } break; } case PPC_PTRACE_SETREGS: { /* Set GPRs 0 - 31. */ int i; unsigned long *reg = &((unsigned long *)child->thread.regs)[0]; unsigned int __user *tmp = (unsigned int __user *)addr; CHECK_FULL_REGS(child->thread.regs); case PPC_PTRACE_SETREGS: /* Set GPRs 0 - 31. */ for (i = 0; i < 32; i++) { return copy_regset_from_user(child, ret = get_user(*reg, tmp); task_user_regset_view(current), 0, if (ret) 0, 32 * sizeof(compat_long_t), break; compat_ptr(data)); reg++; tmp++; } break; } } } return -EPERM; return ret; } } long compat_arch_ptrace(struct task_struct *child, compat_long_t request, long compat_arch_ptrace(struct task_struct *child, compat_long_t request, Loading Loading @@ -291,42 +270,17 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, break; break; } } case PTRACE_GETREGS: { /* Get all pt_regs from the child. */ case PTRACE_GETREGS: /* Get all pt_regs from the child. */ int ui; return copy_regset_to_user( if (!access_ok(VERIFY_WRITE, (void __user *)data, child, task_user_regset_view(current), 0, PT_REGS_COUNT * sizeof(int))) { 0, PT_REGS_COUNT * sizeof(compat_long_t), ret = -EIO; compat_ptr(data)); break; } case PTRACE_SETREGS: /* Set all gp regs in the child. */ CHECK_FULL_REGS(child->thread.regs); return copy_regset_from_user( ret = 0; child, task_user_regset_view(current), 0, for (ui = 0; ui < PT_REGS_COUNT; ui ++) { 0, PT_REGS_COUNT * sizeof(compat_long_t), ret |= __put_user(ptrace_get_reg(child, ui), compat_ptr(data)); (unsigned int __user *) data); data += sizeof(int); } break; } case PTRACE_SETREGS: { /* Set all gp regs in the child. */ unsigned long tmp; int ui; if (!access_ok(VERIFY_READ, (void __user *)data, PT_REGS_COUNT * sizeof(int))) { ret = -EIO; break; } CHECK_FULL_REGS(child->thread.regs); ret = 0; for (ui = 0; ui < PT_REGS_COUNT; ui ++) { ret = __get_user(tmp, (unsigned int __user *) data); if (ret) break; ptrace_put_reg(child, ui, tmp); data += sizeof(int); } break; } case PTRACE_GETFPREGS: case PTRACE_GETFPREGS: case PTRACE_SETFPREGS: case PTRACE_SETFPREGS: Loading