From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sn1nam02on0135.outbound.protection.outlook.com ([104.47.36.135]:3040 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754315AbeDIAhk (ORCPT ); Sun, 8 Apr 2018 20:37:40 -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.4 091/162] arm64: ptrace: Fix incorrect get_user() use in compat_vfp_set() Date: Mon, 9 Apr 2018 00:28:50 +0000 Message-ID: <20180409002738.163941-91-alexander.levin@microsoft.com> References: <20180409002738.163941-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002738.163941-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 b81fa63bc834..f67bb64d2640 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -822,18 +822,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