Skip to content

Commit 3eeacd9

Browse files
committed
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>
1 parent 002af93 commit 3eeacd9

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎arch/powerpc/kernel/ptrace.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ int ptrace_get_reg(struct task_struct *task, int regno, unsigned long *data)
297297
}
298298
#endif
299299

300-
if (regno < (sizeof(struct pt_regs) / sizeof(unsigned long))) {
300+
if (regno < (sizeof(struct user_pt_regs) / sizeof(unsigned long))) {
301301
*data = ((unsigned long *)task->thread.regs)[regno];
302302
return 0;
303303
}
@@ -360,10 +360,10 @@ static int gpr_get(struct task_struct *target, const struct user_regset *regset,
360360
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
361361
&target->thread.regs->orig_gpr3,
362362
offsetof(struct pt_regs, orig_gpr3),
363-
sizeof(struct pt_regs));
363+
sizeof(struct user_pt_regs));
364364
if (!ret)
365365
ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
366-
sizeof(struct pt_regs), -1);
366+
sizeof(struct user_pt_regs), -1);
367367

368368
return ret;
369369
}
@@ -853,10 +853,10 @@ static int tm_cgpr_get(struct task_struct *target,
853853
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
854854
&target->thread.ckpt_regs.orig_gpr3,
855855
offsetof(struct pt_regs, orig_gpr3),
856-
sizeof(struct pt_regs));
856+
sizeof(struct user_pt_regs));
857857
if (!ret)
858858
ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
859-
sizeof(struct pt_regs), -1);
859+
sizeof(struct user_pt_regs), -1);
860860

861861
return ret;
862862
}
@@ -3131,7 +3131,7 @@ long arch_ptrace(struct task_struct *child, long request,
31313131
case PTRACE_GETREGS: /* Get all pt_regs from the child. */
31323132
return copy_regset_to_user(child, &user_ppc_native_view,
31333133
REGSET_GPR,
3134-
0, sizeof(struct pt_regs),
3134+
0, sizeof(struct user_pt_regs),
31353135
datavp);
31363136

31373137
#ifdef CONFIG_PPC64
@@ -3140,7 +3140,7 @@ long arch_ptrace(struct task_struct *child, long request,
31403140
case PTRACE_SETREGS: /* Set all gp regs in the child. */
31413141
return copy_regset_from_user(child, &user_ppc_native_view,
31423142
REGSET_GPR,
3143-
0, sizeof(struct pt_regs),
3143+
0, sizeof(struct user_pt_regs),
31443144
datavp);
31453145

31463146
case PTRACE_GETFPREGS: /* Get the child FPU state (FPR0...31 + FPSCR) */

0 commit comments

Comments
 (0)