summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2020-05-22 12:51:42 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2020-06-26 01:02:14 -0400
commit030754c99538ef83ba6aaf1cdfe33ec4fbbc0c0f (patch)
tree532405a8fe327893778f6e7112c0bd7468b5d92e
parentb3a9e3b9622ae10064826dccb4f7a52bd88c7407 (diff)
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 <viro@zeniv.linux.org.uk>
-rw-r--r--arch/sparc/kernel/ptrace_64.c59
1 files changed, 16 insertions, 43 deletions
diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
index 7122efb4b1cc..f7b2ddfc81d6 100644
--- a/arch/sparc/kernel/ptrace_64.c
+++ b/arch/sparc/kernel/ptrace_64.c
@@ -518,10 +518,10 @@ static int genregs32_get(struct task_struct *target,
void *kbuf, void __user *ubuf)
{
const struct pt_regs *regs = task_pt_regs(target);
- compat_ulong_t __user *reg_window;
compat_ulong_t *k = kbuf;
compat_ulong_t __user *u = ubuf;
- compat_ulong_t reg;
+ u32 uregs[16];
+ u32 reg;
if (target == current)
flushw_user();
@@ -533,52 +533,25 @@ static int genregs32_get(struct task_struct *target,
for (; count > 0 && pos < 16; count--)
*k++ = regs->u_regs[pos++];
- reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6];
- reg_window -= 16;
- if (target == current) {
- for (; count > 0 && pos < 32; count--) {
- if (get_user(*k++, &reg_window[pos++]))
- return -EFAULT;
- }
- } else {
- for (; count > 0 && pos < 32; count--) {
- if (access_process_vm(target,
- (unsigned long)
- &reg_window[pos],
- k, sizeof(*k),
- FOLL_FORCE)
- != sizeof(*k))
- return -EFAULT;
- k++;
- pos++;
- }
+ if (count && pos < 32) {
+ if (get_from_target(target, regs->u_regs[UREG_I6],
+ uregs, sizeof(uregs)))
+ return -EFAULT;
+ for (; count > 0 && pos < 32; count--)
+ *k++ = uregs[pos++ - 16];
+
}
} else {
- for (; count > 0 && pos < 16; count--) {
+ for (; count > 0 && pos < 16; count--)
if (put_user((compat_ulong_t) regs->u_regs[pos++], u++))
return -EFAULT;
- }
-
- reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6];
- reg_window -= 16;
- if (target == current) {
- for (; count > 0 && pos < 32; count--) {
- if (get_user(reg, &reg_window[pos++]) ||
- put_user(reg, u++))
- return -EFAULT;
- }
- } else {
- for (; count > 0 && pos < 32; count--) {
- if (access_process_vm(target,
- (unsigned long)
- &reg_window[pos++],
- &reg, sizeof(reg),
- FOLL_FORCE)
- != sizeof(reg))
- return -EFAULT;
- if (put_user(reg, u++))
+ if (count && pos < 32) {
+ if (get_from_target(target, regs->u_regs[UREG_I6],
+ uregs, sizeof(uregs)))
+ return -EFAULT;
+ for (; count > 0 && pos < 32; count--)
+ if (put_user(uregs[pos++ - 16], u++))
return -EFAULT;
- }
}
}
while (count > 0) {