From patchwork Mon Apr 9 00:35:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 132954 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp650257ljb; Sun, 8 Apr 2018 17:40:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx48bdY2lrmFRYe8b70xmGeIFfw3GwEJsNHzb4VyIbZhkd9O5+hqyLrWmJBc+kvMhS698q7I5 X-Received: by 2002:a17:902:2803:: with SMTP id e3-v6mr35695989plb.156.1523234436763; Sun, 08 Apr 2018 17:40:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523234436; cv=none; d=google.com; s=arc-20160816; b=rS94Yq8Nnj9oamebU1r4LNuQLQfPVRqgdgH8zPY4toX4Dz6RFzM+1vZrjfHUd5PU3P sRrxLAroG75UVOwP2I2pCe7fQwqGQOxpGtMboK2WBQRaXNEVjWmm2s/ug4GbVfSij6cj bGu9Tt/ULXnDLvOZ6iap9H+2TL3zY3PtcnwgnRls+45YtEZlxTQUqmiU44/PG/XAtIsg Rgamc9fV5MKljd3EAEX8+AYAYOHUgn2H+hKUHz4cD0m0n716QQf7v3pplkP5wCUu7yo6 wUe125pUwW4djb3962OuHmGM88RdOxzy+EINbN2Q3Cg4fbU6TJOYWIS4CeyUgHG8gihm CvYg== 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=4Ne8w0HRkxCrw/E0Gr3V4zpFdUfGCZ3W0mP1640jD0k=; b=XhBF5JSExxv6A0TA2ttzfjsxPFQhEbz12ikYQcPMst+WqHeQCkSF4z5ClXVANbPZgY nXiDZnndllZ+xy48uFSZU3pNoPR9kpQRyi+etgLLPtld5jUqgli658uZbgzjgX37LAK4 nSmomm3bTowTrMd3WVA/fps9LSUJEJX61i15q5QEC2a2vwa+LYiG5tERmRc/GQwF/Hfc XfDfMRNj09E0txAprNVzmTJ5dHRIRPk5qzytPqyWyRgLriu8LmVNIoCxsxeOoq4YzQve TonIAthojKUY+c7ad0xqI1/j5ebrqlWHnJG1eT2VayENIhNMO3Hc4Tp/WPNfevnqyZ4v GdYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=E8BSGSoQ; 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 s9-v6si14520306plk.490.2018.04.08.17.40.36; Sun, 08 Apr 2018 17:40:36 -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=E8BSGSoQ; 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 S933352AbeDIAkc (ORCPT + 29 others); Sun, 8 Apr 2018 20:40:32 -0400 Received: from mail-sn1nam01on0097.outbound.protection.outlook.com ([104.47.32.97]:64040 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932553AbeDIAkY (ORCPT ); Sun, 8 Apr 2018 20:40:24 -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=4Ne8w0HRkxCrw/E0Gr3V4zpFdUfGCZ3W0mP1640jD0k=; b=E8BSGSoQK/nKtlxkgHgxi1h/kwNrSRYCm+rdzc6+GMrgEjGQot2L3tX8UciRnCB9Hyk1r4GsH8NBtngNRaDqjk4jCX97pTnag0F3nUQI8ByKhZNn+aF3HnqAPNJrGgMvNnfQcWHvjK0oP9ngAscFtBHK1Tx3UZVpPQ/u0tVFMJk= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0870.namprd21.prod.outlook.com (10.167.110.165) 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:40:21 +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:40:21 +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 043/101] arm64: ptrace: Fix VFP register dumping in compat coredumps Thread-Topic: [PATCH AUTOSEL for 3.18 043/101] arm64: ptrace: Fix VFP register dumping in compat coredumps Thread-Index: AQHTz5q3zd9FJXLC+0+g/ZQSfV0hyQ== Date: Mon, 9 Apr 2018 00:35:53 +0000 Message-ID: <20180409003505.164715-43-alexander.levin@microsoft.com> References: <20180409003505.164715-1-alexander.levin@microsoft.com> In-Reply-To: <20180409003505.164715-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; DM5PR2101MB0870; 7:Q7OIQOQK4EJ1uwvU5VSR9qCjG5vsI6yYWoRa6o9qvgGNOW3dLLTLI0CaNCLtv43rFcmIiKkeAyNVsj6nLSlMGJ30JnnhGetHPzn4Pf1Q2KFnzOxYkQXq0ax0c++ZRSxvrHhvlFw5KhjJfNIAPeUaMpSwo2TsWTCuzmTk6znueb+He8KXpPkej/pLCHcavCWESA1Soc1E2I9QMs7yvzHnEcmRw/mpHAHiPIE20JK55GWiqPuBzZ4GhXRFe9jUnTOi; 20:wWuUNdx0BmiuVpTAUEb6MWsPclt3NJ/3A8TIVtVaduS8sDYxGUGZVf53Jyfw2t4JyRFgYpFF7x0X1GMLpnzyvMvt72ISze/hnQPwKtH8UB7iayebC7k44sbjbrjDL97H/a9h4tZPwd6NqwXKiJnsfWSRXDKmKVph3PHHhEOWe6w= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 13f97a45-3757-466e-e08b-08d59db279dc x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:DM5PR2101MB0870; x-ms-traffictypediagnostic: DM5PR2101MB0870: 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)(3002001)(10201501046)(3231221)(944501327)(52105095)(93006095)(93001095)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:DM5PR2101MB0870; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB0870; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39380400002)(396003)(366004)(376002)(39860400002)(346002)(199004)(189003)(5250100002)(5660300001)(26005)(10290500003)(2501003)(478600001)(68736007)(8676002)(8936002)(81156014)(81166006)(22452003)(3846002)(86362001)(36756003)(1076002)(305945005)(54906003)(72206003)(186003)(316002)(4326008)(25786009)(6486002)(110136005)(7736002)(446003)(10090500001)(76176011)(14454004)(11346002)(476003)(2900100001)(97736004)(107886003)(486006)(2906002)(6512007)(53936002)(102836004)(2616005)(86612001)(6116002)(3280700002)(6666003)(6506007)(66066001)(6436002)(3660700001)(105586002)(99286004)(106356001)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB0870; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: zNZeEzhxdMEKEWH4JPoLhArxQxA4vP0BMBYkavwR9GPD7c1nlsdYefu+CPo+04ijl5uuLW2C7L8qlznf+QnIwFueMxcfmzZfHhCU/1cj/U+A6nT43kvHYxHbY/zyzDU/5qVdQu5/1zFR6Slt2HaE0U5HX/09dLSK8LLW9/718DxUTh9YtQX8g3r+Dj0YTyDM9ZsfTz/n1EzOI6c2L90mSIGZVNu+NWo2jRzhe/7RKQ5gKXqL1vO48zW3eGcJngZ3sORXUWniSXb7upWHYoWgk9u7XskonA/82hW+IND13Dcy30Kli4c0Cro0Mg0cS4oLPA6vVyPxQRyhdPUeCf5MJPBt9I++jQRbWnjGxmpe7aeB25wdHpasKwXZjPuSAGWlryhyogaRr8hicwC87pdO/1sD8UYw6Pi8uOsjc31UwFs= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13f97a45-3757-466e-e08b-08d59db279dc X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:35:53.5172 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0870 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Martin [ Upstream commit af66b2d88a76574d55e81d712292abd34beb6178 ] Currently, VFP registers are omitted from coredumps for compat processes, due to a bug in the REGSET_COMPAT_VFP regset implementation. compat_vfp_get() needs to transfer non-contiguous data from thread_struct.fpsimd_state, and uses put_user() to handle the offending trailing word (FPSCR). This fails when copying to a kernel address (i.e., kbuf && !ubuf), which is what happens when dumping core. As a result, the ELF coredump core code silently omits the NT_ARM_VFP note from the dump. It would be possible to work around this with additional special case code for the put_user(), but since user_regset_copyout() is explicitly designed to handle this scenario it is cleaner to port the put_user() to a user_regset_copyout() call, which this patch does. Signed-off-by: Dave Martin Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/kernel/ptrace.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) -- 2.15.1 diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 8a4ae8e73213..2e845f5c8ab2 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -743,7 +743,7 @@ static int compat_vfp_get(struct task_struct *target, { struct user_fpsimd_state *uregs; compat_ulong_t fpscr; - int ret; + int ret, vregs_end_pos; uregs = &target->thread.fpsimd_state.user_fpsimd; @@ -751,13 +751,16 @@ static int compat_vfp_get(struct task_struct *target, * The VFP registers are packed into the fpsimd_state, so they all sit * nicely together for us. We just need to create the fpscr separately. */ - ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0, - VFP_STATE_SIZE - sizeof(compat_ulong_t)); + vregs_end_pos = VFP_STATE_SIZE - sizeof(compat_ulong_t); + ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, + 0, vregs_end_pos); if (count && !ret) { fpscr = (uregs->fpsr & VFP_FPSCR_STAT_MASK) | (uregs->fpcr & VFP_FPSCR_CTRL_MASK); - ret = put_user(fpscr, (compat_ulong_t *)ubuf); + + ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &fpscr, + vregs_end_pos, VFP_STATE_SIZE); } return ret;