lkml.org 
[lkml]   [2018]   [Apr]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL for 4.9 181/293] arm64: ptrace: Fix incorrect get_user() use in compat_vfp_set()
    Date
    From: Dave Martin <Dave.Martin@arm.com>

    [ Upstream commit 5fbd5fc49fc39ac8433da62d16682a1d0217ea4f ]

    Now that compat_vfp_get() uses the regset API to copy the FPSCR
    value out to userspace, compat_vfp_set() looks inconsistent. In
    particular, compat_vfp_set() will fail if called with kbuf != NULL
    && ubuf == NULL (which is valid usage according to the regset API).

    This patch fixes compat_vfp_set() to use user_regset_copyin(),
    similarly to compat_vfp_get().

    This also squashes a sparse warning triggered by the cast that
    drops __user when calling get_user().

    Signed-off-by: Dave Martin <Dave.Martin@arm.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
    ---
    arch/arm64/kernel/ptrace.c | 8 +++++---
    1 file changed, 5 insertions(+), 3 deletions(-)

    diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
    index cca95e75aaeb..df1addf104f5 100644
    --- a/arch/arm64/kernel/ptrace.c
    +++ b/arch/arm64/kernel/ptrace.c
    @@ -926,18 +926,20 @@ static int compat_vfp_set(struct task_struct *target,
    {
    struct user_fpsimd_state *uregs;
    compat_ulong_t fpscr;
    - int ret;
    + int ret, vregs_end_pos;

    if (pos + count > VFP_STATE_SIZE)
    return -EIO;

    uregs = &target->thread.fpsimd_state.user_fpsimd;

    + vregs_end_pos = VFP_STATE_SIZE - sizeof(compat_ulong_t);
    ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, uregs, 0,
    - VFP_STATE_SIZE - sizeof(compat_ulong_t));
    + vregs_end_pos);

    if (count && !ret) {
    - ret = get_user(fpscr, (compat_ulong_t *)ubuf);
    + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &fpscr,
    + vregs_end_pos, VFP_STATE_SIZE);
    if (!ret) {
    uregs->fpsr = fpscr & VFP_FPSCR_STAT_MASK;
    uregs->fpcr = fpscr & VFP_FPSCR_CTRL_MASK;
    --
    2.15.1
    \
     
     \ /
      Last update: 2018-04-09 04:05    [W:4.133 / U:0.236 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site