diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2020-06-06 21:19:58 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2020-06-26 01:02:35 -0400 |
commit | d547175b54fa8104b0e2e5fd4b372cf04fa031ab (patch) | |
tree | 27da8da95b8c3320a8eb78654cda12528ff87307 /arch/arm64/kernel | |
parent | b44f384074d09d406b9223d60905e4badadc4741 (diff) | |
download | linux-d547175b54fa8104b0e2e5fd4b372cf04fa031ab.tar.gz linux-d547175b54fa8104b0e2e5fd4b372cf04fa031ab.tar.bz2 linux-d547175b54fa8104b0e2e5fd4b372cf04fa031ab.zip |
arm64: sanitize compat_ptrace_write_user()
don't bother with copy_regset_from_user() (not to mention
set_fs())
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/arm64/kernel')
-rw-r--r-- | arch/arm64/kernel/ptrace.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index d5f3da5197a1..9f769e862f68 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -1553,8 +1553,8 @@ static int compat_ptrace_read_user(struct task_struct *tsk, compat_ulong_t off, static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off, compat_ulong_t val) { - int ret; - mm_segment_t old_fs = get_fs(); + struct pt_regs newregs = *task_pt_regs(tsk); + unsigned int idx = off / 4; if (off & 3 || off >= COMPAT_USER_SZ) return -EIO; @@ -1562,14 +1562,25 @@ static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off, if (off >= sizeof(compat_elf_gregset_t)) return 0; - set_fs(KERNEL_DS); - ret = copy_regset_from_user(tsk, &user_aarch32_view, - REGSET_COMPAT_GPR, off, - sizeof(compat_ulong_t), - &val); - set_fs(old_fs); + switch (idx) { + case 15: + newregs.pc = val; + break; + case 16: + newregs.pstate = compat_psr_to_pstate(val); + break; + case 17: + newregs.orig_x0 = val; + break; + default: + newregs.regs[idx] = val; + } + + if (!valid_user_regs(&newregs.user_regs, tsk)) + return -EINVAL; - return ret; + *task_pt_regs(tsk) = newregs; + return 0; } #ifdef CONFIG_HAVE_HW_BREAKPOINT |