Skip to content

Commit 030754c

Browse files
author
Al Viro
committed
sparc64: switch genregs32_get() to use of get_from_target()
... for fetching the register window from target's stack, rather than open-coding it. Signed-off-by: Al Viro <[email protected]>
1 parent b3a9e3b commit 030754c

File tree

1 file changed

+16
-43
lines changed

1 file changed

+16
-43
lines changed

arch/sparc/kernel/ptrace_64.c

Lines changed: 16 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,10 @@ static int genregs32_get(struct task_struct *target,
518518
void *kbuf, void __user *ubuf)
519519
{
520520
const struct pt_regs *regs = task_pt_regs(target);
521-
compat_ulong_t __user *reg_window;
522521
compat_ulong_t *k = kbuf;
523522
compat_ulong_t __user *u = ubuf;
524-
compat_ulong_t reg;
523+
u32 uregs[16];
524+
u32 reg;
525525

526526
if (target == current)
527527
flushw_user();
@@ -533,52 +533,25 @@ static int genregs32_get(struct task_struct *target,
533533
for (; count > 0 && pos < 16; count--)
534534
*k++ = regs->u_regs[pos++];
535535

536-
reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6];
537-
reg_window -= 16;
538-
if (target == current) {
539-
for (; count > 0 && pos < 32; count--) {
540-
if (get_user(*k++, &reg_window[pos++]))
541-
return -EFAULT;
542-
}
543-
} else {
544-
for (; count > 0 && pos < 32; count--) {
545-
if (access_process_vm(target,
546-
(unsigned long)
547-
&reg_window[pos],
548-
k, sizeof(*k),
549-
FOLL_FORCE)
550-
!= sizeof(*k))
551-
return -EFAULT;
552-
k++;
553-
pos++;
554-
}
536+
if (count && pos < 32) {
537+
if (get_from_target(target, regs->u_regs[UREG_I6],
538+
uregs, sizeof(uregs)))
539+
return -EFAULT;
540+
for (; count > 0 && pos < 32; count--)
541+
*k++ = uregs[pos++ - 16];
542+
555543
}
556544
} else {
557-
for (; count > 0 && pos < 16; count--) {
545+
for (; count > 0 && pos < 16; count--)
558546
if (put_user((compat_ulong_t) regs->u_regs[pos++], u++))
559547
return -EFAULT;
560-
}
561-
562-
reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6];
563-
reg_window -= 16;
564-
if (target == current) {
565-
for (; count > 0 && pos < 32; count--) {
566-
if (get_user(reg, &reg_window[pos++]) ||
567-
put_user(reg, u++))
568-
return -EFAULT;
569-
}
570-
} else {
571-
for (; count > 0 && pos < 32; count--) {
572-
if (access_process_vm(target,
573-
(unsigned long)
574-
&reg_window[pos++],
575-
&reg, sizeof(reg),
576-
FOLL_FORCE)
577-
!= sizeof(reg))
578-
return -EFAULT;
579-
if (put_user(reg, u++))
548+
if (count && pos < 32) {
549+
if (get_from_target(target, regs->u_regs[UREG_I6],
550+
uregs, sizeof(uregs)))
551+
return -EFAULT;
552+
for (; count > 0 && pos < 32; count--)
553+
if (put_user(uregs[pos++ - 16], u++))
580554
return -EFAULT;
581-
}
582555
}
583556
}
584557
while (count > 0) {

0 commit comments

Comments
 (0)