Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/ptrace: Don't use sizeof(struct pt_regs) in ptrace code

Now that we've split the user & kernel versions of pt_regs we need to
be more careful in the ptrace code.

For now we've ensured the location of the fields in both structs is
the same, so most of the ptrace code doesn't need updating.

But there are a few places where we use sizeof(pt_regs), and these
will be wrong as soon as we increase the size of the kernel structure.

So flip them all to use sizeof(user_pt_regs).

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

+7 -7
+7 -7
arch/powerpc/kernel/ptrace.c
··· 297 297 } 298 298 #endif 299 299 300 - if (regno < (sizeof(struct pt_regs) / sizeof(unsigned long))) { 300 + if (regno < (sizeof(struct user_pt_regs) / sizeof(unsigned long))) { 301 301 *data = ((unsigned long *)task->thread.regs)[regno]; 302 302 return 0; 303 303 } ··· 360 360 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, 361 361 &target->thread.regs->orig_gpr3, 362 362 offsetof(struct pt_regs, orig_gpr3), 363 - sizeof(struct pt_regs)); 363 + sizeof(struct user_pt_regs)); 364 364 if (!ret) 365 365 ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, 366 - sizeof(struct pt_regs), -1); 366 + sizeof(struct user_pt_regs), -1); 367 367 368 368 return ret; 369 369 } ··· 853 853 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, 854 854 &target->thread.ckpt_regs.orig_gpr3, 855 855 offsetof(struct pt_regs, orig_gpr3), 856 - sizeof(struct pt_regs)); 856 + sizeof(struct user_pt_regs)); 857 857 if (!ret) 858 858 ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, 859 - sizeof(struct pt_regs), -1); 859 + sizeof(struct user_pt_regs), -1); 860 860 861 861 return ret; 862 862 } ··· 3131 3131 case PTRACE_GETREGS: /* Get all pt_regs from the child. */ 3132 3132 return copy_regset_to_user(child, &user_ppc_native_view, 3133 3133 REGSET_GPR, 3134 - 0, sizeof(struct pt_regs), 3134 + 0, sizeof(struct user_pt_regs), 3135 3135 datavp); 3136 3136 3137 3137 #ifdef CONFIG_PPC64 ··· 3140 3140 case PTRACE_SETREGS: /* Set all gp regs in the child. */ 3141 3141 return copy_regset_from_user(child, &user_ppc_native_view, 3142 3142 REGSET_GPR, 3143 - 0, sizeof(struct pt_regs), 3143 + 0, sizeof(struct user_pt_regs), 3144 3144 datavp); 3145 3145 3146 3146 case PTRACE_GETFPREGS: /* Get the child FPU state (FPR0...31 + FPSCR) */