From patchwork Mon Apr 9 00:41:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 132959 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp656554ljb; Sun, 8 Apr 2018 17:52:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/YezpEJwAwJM66Z7l1UkmotnDLBfIi34WJodamzoxTN8IehGxs9CzxsTxNHBL8uahIXPA9 X-Received: by 2002:a17:902:28e3:: with SMTP id f90-v6mr36573955plb.250.1523235122896; Sun, 08 Apr 2018 17:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523235122; cv=none; d=google.com; s=arc-20160816; b=sdqvPkXYb32a1GoKaiEnBToBULDh/6ikb15eqhiWytFGFyId4hOLvjcV/is9GwJI9b PCDMmvfibGaVqC6WOCeTzoovHsyRFM9EQMpC+Vo7AUl8hC+2gEtNAF0PzUNCsmVnBNvr kt4w+HemBo4HSkvOrPTl8Z11ilqEfI/6kHEj77dTjCZbhkEVE4GWpV9a5M5BlOor/omM i4UktikmajH7T6KkyTXreCmdK2LCwFQBVl1FOGas+w2/sjwBaBZUz6D7V64CD7I3fWC1 XJbAn+oybkJf51EYdfl7v6c0hWna5FzQbCCh20dS6DYYuQM/IvQt9U9BKlXBElB+lUOf fNyA== 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=BgwKqsIqJGecRKRGEBmF9M9WRCggHe6V7WuP2Q5IKeI=; b=DDxQ6O2La6h8+L1XlDiT+0o5MgTyGsOTFoHi4TbIarl57n6lUzStk62v+91Pyxp08g xV75pwFx0HNnJKarTd92ceqeUvGDJ+X4cThJOUyziYgc7sMWtaPLRKpV6KPNINnymv4G y/9Gb+4anWT+2J5g2DIMCQIP+tF3k7Fsdk/Ltg/g37G3xPWn6BH7eROpKtfFiAq+Mskp IKVG+FLM86FeQp4cN0SgUSbpPbnlA1uVCuTOvH3iBQ7TnHI1NaDMIaEM2IFepeRvvthk 5OqcQNhUIJ+Jvo29G7m8T9G4eHPlnR1s5wLYvAYnw+WzCiqqmniR8eaxlsAWVbS7r48e 0Wfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=cFICULwU; 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 j21si11863855pfe.132.2018.04.08.17.52.02; Sun, 08 Apr 2018 17:52:02 -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=cFICULwU; 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 S933484AbeDIAv7 (ORCPT + 29 others); Sun, 8 Apr 2018 20:51:59 -0400 Received: from mail-by2nam03on0126.outbound.protection.outlook.com ([104.47.42.126]:24363 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933422AbeDIAlZ (ORCPT ); Sun, 8 Apr 2018 20:41:25 -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=BgwKqsIqJGecRKRGEBmF9M9WRCggHe6V7WuP2Q5IKeI=; b=cFICULwUirQzDYVDCZvdqDJ4/TkBiY7J8vRfOa+KfZ3Bn+MYRf8MuIF64A5SzNP5kNm7Y5y2tsbaJzjnp/k7fvhPlIz8VPv/1Nr+0wmpX/3cBMuIdqn16L4JpHMIsaXHFKUCyqOq5YqXnpU8aV+mqRA3WkB64W0+uNvXs1TZr+k= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0901.namprd21.prod.outlook.com (52.132.132.158) 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:41:22 +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:41:22 +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 3.18 058/101] arm64: ptrace: Fix incorrect get_user() use in compat_vfp_set() Thread-Topic: [PATCH AUTOSEL for 3.18 058/101] arm64: ptrace: Fix incorrect get_user() use in compat_vfp_set() Thread-Index: AQHTz5t76SMipjwJD06/p8CgFw5LkQ== Date: Mon, 9 Apr 2018 00:41:21 +0000 Message-ID: <20180409004042.164920-8-alexander.levin@microsoft.com> References: <20180409004042.164920-1-alexander.levin@microsoft.com> In-Reply-To: <20180409004042.164920-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; DM5PR2101MB0901; 7:IJl0u/Uad2xt7YORKRidEez8XxADphwY0xOHqiQhNq9VROuxwAs9M/AvgOn1EEnUK7xy0AJevheJMaIQnk+0osWUv+NAyWpUZmEGV2edCMwubi0ucv+otKvZetZu9JxrJEcaYP4escLGCNmnKKKh360ofVM5xmMouv0FEWqs1VU2Q7tAw54PIipaIpsrmy/Z6et179j8DuAKCWZLNG5QNa2INSpr8azLRxLU4NJNlMDlIpXXD45eVsW6tHCEEY76; 20:iYbKYprTzNU1UjDMrjFGk9vttS3gmQKCpfJd3zrjMi8z2Bb58W5r98DdYwkd/OaDkJp9NctYfPQK5OISFq1Ml1sH1rDfE89WRBOVFcf7eUBiUnrQpuQGo0uG+eLooYEtqU5vLefjmK1XGH5a3QtURyvDZd2QuTfVC5HhL4PiKeM= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: dfc7e61a-cf02-402c-5fa2-08d59db29e55 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:DM5PR2101MB0901; x-ms-traffictypediagnostic: DM5PR2101MB0901: 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)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:DM5PR2101MB0901; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB0901; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(39380400002)(376002)(346002)(396003)(366004)(189003)(199004)(59450400001)(99286004)(68736007)(10290500003)(25786009)(86612001)(6116002)(66066001)(97736004)(3846002)(76176011)(6512007)(54906003)(6436002)(4326008)(53936002)(105586002)(110136005)(6486002)(3280700002)(1076002)(107886003)(8676002)(10090500001)(2501003)(81156014)(81166006)(5660300001)(14454004)(186003)(3660700001)(102836004)(7736002)(2906002)(26005)(5250100002)(36756003)(478600001)(446003)(316002)(6506007)(2616005)(106356001)(8936002)(11346002)(22452003)(2900100001)(86362001)(486006)(476003)(305945005)(72206003)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB0901; 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: 8lmh23VToYA7hEfRZntqjVA/dNV0QPVD5WT4JF71kYZwKA1aMWJZNliKyzY1iGt+CwuMutOMXs7kFNmwgz/tAp00wW20UiToNpbq3ROcMuGJWXN4cPSLcZuPRUYgl3zW4nefFHnajINi4quXxEfy9Af1KD72ud1hA+f3AbTZgNNXOpNQz+0oftetHUl+6NvSFxDZ7EISjplzFLO8pkftKaVRGQhSvH/E1Yiw99Zt5a+PuUyDvTcSIt5jLBe8MTW0B6Ifqxi4P/d5dtBDkr7rjdQuuIp5vqMMD4cUsl456OkCGPpu7zzIoBNmpYXUA9vc6kaMq9dG2P6Mk4o4FZi7DE/UWh0Eg7ryhPb1yaRhOxN1YOeAKPpMRYAyWZBQUpe3+s1wWCXRkYzdO6de+gsKYTCE79fi/glakwxmH81aIoI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: dfc7e61a-cf02-402c-5fa2-08d59db29e55 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:41:21.9552 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0901 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 a12eb17e7985..01defb4527f4 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -773,18 +773,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;