From patchwork Mon Apr 9 00:25:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 132976 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp702635ljb; Sun, 8 Apr 2018 19:03:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+5DixmmD4sGwiJWxs6miuYEOI6iTk8X/QeD3akF6wmduKa7uDatZvull4zzOuzt9WTUVZX X-Received: by 2002:a17:902:5a3:: with SMTP id f32-v6mr23132056plf.287.1523239401231; Sun, 08 Apr 2018 19:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523239401; cv=none; d=google.com; s=arc-20160816; b=vmbQyxFbEbTKm8YPoI74U2lZpMDmbSCRCL+L7STujsFraU4M0dPopEMEbjztbu0no0 +n2g2xycinaioJ0ew/NzYCcCnmobTUowhBOCr8BWKDQI4F7xuUZ01AEOY7Sskr2pXF7j XY7vqMy4cWKIlukh617/PB6VpQMAYK15ZTXFvsxUHuM4TjvPdC7CVYRM2vFbiHyFACda N8hcnGGYaWivgjVRlLQXkt8ZkQwd5madR/2BO+1Km24Lu4DnFdXNRRBl7sdiqwJKop3+ O4A8GubjeXuXeGlhEHK4gps+XSw3nhf8DNP1B5/QNHKFnBKt03RVtFhBk1YgRBpWCQwj vTdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=iQBo9/vsT4aZyQUNnFacVw/d1auuVqzWtzB1jcIxMdw=; b=kU9HVqt1KVW/ro0ADOCqngkKiH6PLa0NTUNMPhP8ArVtl/w2Icw+ghNbG+Hdbzx11A pE7+S3AjIZCREeAIpqWE8ApqQas4dRoFgXhFN0UYSERAEdazZzkeNbcIzu3O9kejMS9i U4bka+pYY2335FYOPQlw+THRlk/jLVDAAKeBcCB7KItDR+mFPlPIpVjj2QLuL+2AHKjm 54+eGwrTMJpGbxP5Cg+CYVfKe18Ib1oyCHzLjk2G+R4+FE20+abcIm2PpwBeGiwbY5P+ +ME2S0ovHMcwN17X33oc1uTnsNHdZcavdyh/hGd1VdMeuyo2BZJbdIXp1zQUnuqujDly 8ssA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=OoRori0Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d185si10483510pgc.746.2018.04.08.19.03.20; Sun, 08 Apr 2018 19:03:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=OoRori0Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756395AbeDIAcD (ORCPT + 29 others); Sun, 8 Apr 2018 20:32:03 -0400 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=iQBo9/vsT4aZyQUNnFacVw/d1auuVqzWtzB1jcIxMdw=; b=OoRori0Qz+PTOvesMJCNgMdbXQsM33m3+EiEU3KBc4PTPGjizLRUNM9eJ8SfDs/R96Bh/2QEBlHVm1xUDxOeoRrQRUxq23tw/HtLP3KriYK5G68vAUlTO1eVADrEgV/e6cTdH0L78d4MTsJ+qYAi+QDGmcVbFbO1n2Z7roYtN50= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1126.namprd21.prod.outlook.com (52.132.132.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:31:54 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:31:54 +0000 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() Thread-Topic: [PATCH AUTOSEL for 4.9 181/293] arm64: ptrace: Fix incorrect get_user() use in compat_vfp_set() Thread-Index: AQHTz5k7Z0BmFY1nCkq/ubGLmB0ZXg== 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> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM5PR2101MB1126; 7:egZn9GEsHFoCYijPM+/T1gHJDzJJLuO53BARHXunUvrHMjsMrNSrcX3hb7lXeVbKoz4zv8q6PQojR0/uq7foaU+8TdpZKE7vjmVGnHq7IaK212uQilzAZfMZtLNpSiKDrkGjAjZyTdNp77xVnQC3bgpoupXzFnHl1EiFBHHqnpB+9JwS4of0Qhvqo5N/nrwcGhT8fTpvsPjdgkufZm84YZVAfVcARLe6sXXlkOUXcFcTBD5awuj9OYB4CLAme4fO; 20:QI7Ye1NX23+qM6vSBOJajoTtCi4Vv6ik0xn6ASRqchKRzY6s5t+8PzQe5t1r1q3v3boVjnRf3lVIIehqjZ9bzFqdvUw8Ut6aaF1eThTai6fZ0jd/fSmafcAwOWmmYw+QOVZgG5wUXzp1sT8O7mk+pCLLyvlgSnoAbXaYW3VvAyQ= X-MS-Office365-Filtering-Correlation-Id: b3069525-2f30-40ad-ab9a-08d59db14b9f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603328)(7193020); SRVR:DM5PR2101MB1126; x-ms-traffictypediagnostic: DM5PR2101MB1126: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(180628864354917)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:DM5PR2101MB1126; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB1126; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(39380400002)(396003)(39860400002)(346002)(376002)(189003)(199004)(2616005)(476003)(81156014)(8676002)(81166006)(3846002)(486006)(2900100001)(6436002)(186003)(478600001)(72206003)(110136005)(54906003)(2906002)(86612001)(6666003)(2501003)(26005)(10090500001)(102836004)(6512007)(6116002)(14454004)(5250100002)(10290500003)(1076002)(446003)(3280700002)(3660700001)(11346002)(8936002)(25786009)(59450400001)(6506007)(106356001)(4326008)(107886003)(36756003)(105586002)(53936002)(86362001)(66066001)(6486002)(99286004)(5660300001)(316002)(22452003)(305945005)(76176011)(97736004)(68736007)(7736002)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB1126; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 4e1SRd7zI+O08P/9pHEU+NCJSjdBlJ8V6wPXeii50EESGjuudTdMr7GvgTZMzchYRhWFA2p4qmaFWU1nxQ3ib8b/0J8o2fqviMktiAuNxE0VXTWF13+RGpAVy2s8RxFYBvoWg0rpEXEqsqiKIJqZ/d6eTwqm2Iy0zdhXnoqCZycxv5lprcqNR45H4JlC4C7whZmts3wnDhY2qCNlHnHw0RAGl5twkaOG1KSuJVhI0qscr1jyTsdYGSVkKbQx5eMW87gzhs3kYHS1VAunGNyMJwRsER3mjXv348KEmnGZoCn7f6ZqerAZSg8hCdZ2KcVII5Pp7PzZiCqGe/33gOR1Qtv9+qyg+DEDivG+PN/+C5tvQaLLGfhhXe2vUwpsYl4hSpT0CC4GmwL22MGVE1OlepesNyN4Eo9lxTgp2hUTSlY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: b3069525-2f30-40ad-ab9a-08d59db14b9f X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:25:16.0189 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1126 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 != 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 Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/kernel/ptrace.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.15.1 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;