From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-co1nam03on0101.outbound.protection.outlook.com ([104.47.40.101]:32931 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755747AbeDIAb4 (ORCPT ); Sun, 8 Apr 2018 20:31:56 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Dave Martin , Will Deacon , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 181/293] arm64: ptrace: Fix incorrect get_user() use in compat_vfp_set() Date: Mon, 9 Apr 2018 00:25:16 +0000 Message-ID: <20180409002239.163177-181-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Dave Martin [ 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 !=3D NULL && ubuf =3D=3D 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 Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- 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; =20 if (pos + count > VFP_STATE_SIZE) return -EIO; =20 uregs =3D &target->thread.fpsimd_state.user_fpsimd; =20 + vregs_end_pos =3D VFP_STATE_SIZE - sizeof(compat_ulong_t); ret =3D user_regset_copyin(&pos, &count, &kbuf, &ubuf, uregs, 0, - VFP_STATE_SIZE - sizeof(compat_ulong_t)); + vregs_end_pos); =20 if (count && !ret) { - ret =3D get_user(fpscr, (compat_ulong_t *)ubuf); + ret =3D user_regset_copyin(&pos, &count, &kbuf, &ubuf, &fpscr, + vregs_end_pos, VFP_STATE_SIZE); if (!ret) { uregs->fpsr =3D fpscr & VFP_FPSCR_STAT_MASK; uregs->fpcr =3D fpscr & VFP_FPSCR_CTRL_MASK; --=20 2.15.1