From: Roland McGrath Date: Thu, 13 Mar 2008 08:25:35 +0000 (+1100) Subject: [POWERPC] user_regset PTRACE_SETREGS regression fix X-Git-Tag: v2.6.25-rc7~64^2~5 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2372eb9bcafdd149b26987a8c25bbed92fd2775;p=linux-2.6 [POWERPC] user_regset PTRACE_SETREGS regression fix The PTRACE_SETREGS request was only recently added on powerpc, and gdb does not use it. So it slipped through without getting all the testing it should have had. The user_regset changes had a simple bug in storing to all of the 32-bit general registers block on 64-bit kernels. This bug only comes up with PTRACE_SETREGS, not PPC_PTRACE_SETREGS. It causes a BUG_ON to hit, so this fix needs to go in ASAP. Signed-off-by: Roland McGrath Signed-off-by: Paul Mackerras --- diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index 7673e98657..2a9fe97e45 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -530,15 +530,21 @@ static int gpr32_set(struct task_struct *target, --count; } - if (kbuf) + if (kbuf) { for (; count > 0 && pos <= PT_MAX_PUT_REG; --count) regs[pos++] = *k++; - else + for (; count > 0 && pos < PT_TRAP; --count, ++pos) + ++k; + } else { for (; count > 0 && pos <= PT_MAX_PUT_REG; --count) { if (__get_user(reg, u++)) return -EFAULT; regs[pos++] = reg; } + for (; count > 0 && pos < PT_TRAP; --count, ++pos) + if (__get_user(reg, u++)) + return -EFAULT; + } if (count > 0 && pos == PT_TRAP) { if (kbuf)