From patchwork Mon Apr 9 00:28:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 132952 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp648183ljb; Sun, 8 Apr 2018 17:36:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+U6JKFbzeVvWJlfSe+vLfmSrRebyqwljI9eSIQmOcmoWT6x6Occj0n+gDkG936sXEr6eiQ X-Received: by 10.98.62.71 with SMTP id l68mr26964190pfa.98.1523234213062; Sun, 08 Apr 2018 17:36:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523234213; cv=none; d=google.com; s=arc-20160816; b=bf4PCVxo8JLY7J/4tB429wEvPiGfupBKeSuQYr70QgItBNkUuObovnxpEYNiBitayt PxjzHMjDGu6KCg4uzjGlCpeuNzZi6631xRPZseN8IDk3PbgPfZ5finD735GC5BEX2Hgk WSZFx/gmUHGSz9PgJG6xbSIk5UYJyuHoHD8aIxdRoE7ilcxvj8OYxCXABcu0zAyONv9P VuJ8uLrMhuUADdw9RqRxEaYIIeX1D7zkwFQCOcUTHnd/WveUoDNC23VWY00wFsOJMLB4 16dvo64eBz47b7LjYINItZrQ0QQWmMkxbNfxG3nBOugHeSa1cPOXqItZCFHT7sWAVE45 9q1A== 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=ys872/B69uTbolxfIuU4mmtiX5KsHZJsyIs9I3ggGCw=; b=NKdMydjQqHhl+HlDcSFgzN7qryQMSyiAB31rck9y3/Cx1q+Nso5ceVkqt2WRztUHlr 1cCaSgmRa2tI/K+cppEFhNTSC8T1sJpW3xk6BSDhkp4VmLMj/9aUV++YMMMKfNxaFMtP J7MirJF5I9sA3km60XXSz7pTMg/s0+YNgu2NIVkw+ZaMlObkP1K4DY6Md/WRKqU0jDGN FMO7FES1oXP0PNaAPuLHfJ1IaKsuLvbTPxHP5k+cIIGMof111GuylM1ihtkPoaYbl01T Cr7B70xkYqZERoOWR9OS9UCP322AxfiXeb4AJDnE4IdW3JjEZq4OXyfDv5vfDftZ+VTy SfTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=h16zL0Rl; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 g1si10024742pgq.743.2018.04.08.17.36.52; Sun, 08 Apr 2018 17:36:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=h16zL0Rl; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 S932676AbeDIAgv (ORCPT + 11 others); Sun, 8 Apr 2018 20:36:51 -0400 Received: from mail-sn1nam02on0127.outbound.protection.outlook.com ([104.47.36.127]:39469 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932665AbeDIAgt (ORCPT ); Sun, 8 Apr 2018 20:36:49 -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=ys872/B69uTbolxfIuU4mmtiX5KsHZJsyIs9I3ggGCw=; b=h16zL0RlPJEZogsVW8ypv+piRP3j02+7pQJSExl/wL4tBQTB+44oK+kG0Ux0gR47dG7RlYkrbvvvJziMXO8w1GjEMNqBmSkY235PT4hIkMwUcKDhUuBugEoAGkpqk+IL17ymRerVqnhAfL259NiMH9XaFY8qIjvIVozVDg2dzd8= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0885.namprd21.prod.outlook.com (52.132.132.154) 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:36:46 +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:36:46 +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.4 064/162] arm64: ptrace: Fix VFP register dumping in compat coredumps Thread-Topic: [PATCH AUTOSEL for 4.4 064/162] arm64: ptrace: Fix VFP register dumping in compat coredumps Thread-Index: AQHTz5muW+y4xslqkke6D4XIhA6m+w== Date: Mon, 9 Apr 2018 00:28:28 +0000 Message-ID: <20180409002738.163941-64-alexander.levin@microsoft.com> References: <20180409002738.163941-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002738.163941-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; DM5PR2101MB0885; 7:5hYA6rL4zuHrPKnYQ9F+yfEzOStqofsGAql8cfwBOsvXqvhisEgmnEQofcBATitLO1V0uu4RBqsiXJb1ux6M6gymAFcXYtSNLXKeP/MyXyDd1AeCSgc6Ldt6GYja7mxG+QCm9BO4MxIN8TeCalNAmJmBaV2QJEeKRysUUUeht0coN+azbwX+HYVxnWnVd5NXdiAbx4ShJyhyLgLB29hIqvKSatgjHHIXBVI+HX2jCdyeSWuM9TCzNqLmB5cKNO2K; 20:AoNzqhKj3FiSe3RCymiL3lpZOEDWX3XiBHY2mNYkHfJSFM1ysMt0VQ1R5uuGSZp2FzKnAvuRe+QClTYMQch2fk8LOfvz6SG8tlRF/uFhiNlx8OBs5872m+2HsMTU4+ceZE62uogpaQpuGAcuyOlYkOis9CYDTnmyndxIMzSmW5k= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: acdb73aa-38e6-401d-8cfa-08d59db1f99e x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:DM5PR2101MB0885; x-ms-traffictypediagnostic: DM5PR2101MB0885: 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:DM5PR2101MB0885; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB0885; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39380400002)(396003)(376002)(39860400002)(366004)(346002)(199004)(189003)(66066001)(3846002)(6116002)(86362001)(305945005)(10290500003)(6436002)(5250100002)(3280700002)(10090500001)(3660700001)(6506007)(2501003)(107886003)(446003)(53936002)(11346002)(2616005)(26005)(76176011)(7736002)(478600001)(476003)(81156014)(25786009)(8676002)(81166006)(186003)(8936002)(4326008)(97736004)(102836004)(99286004)(14454004)(36756003)(6512007)(316002)(2906002)(22452003)(68736007)(54906003)(110136005)(486006)(6486002)(6666003)(5660300001)(2900100001)(1076002)(72206003)(86612001)(105586002)(106356001)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB0885; 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: sLfM48Ndq1Km1LYT+tiATOzNPluRwGa1Dc+PSuTKWvLY8GOg28MV6JHxcFuE0sm0D/3hGDv1gAuOXXXJIdMHwvVI/keUQaeiM3kfD9vUGPKPeQGjgx47ArU6QlmxJEylVXp9/BWZWfGtAmw2BO9Udw0KRUvptcUZOiohkS9CU2XK5MH1ihaVru5VOkP/clW/vYtWdDBy57IMVNJgQ5Bnxmj2O+BjzQal1KP+/1DPZJCPNr5XdDepS+rKy+AVLryoVWj6W2rb5DCT+lgHrx9SAazXgIRru/fjyqEopB5X09vS/2YSekoUHmlAu7NUTyp/8sMZ5NAKzVnO9PtU1ahL/+6/4PeJMzvG7UuxzFYrTofYXXMjLzShsMQTVvdYwd9khmycKclqDPO5Shrn9hLhunumtbNMwBhgp2tiUlm4FX4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: acdb73aa-38e6-401d-8cfa-08d59db1f99e X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:28:28.9582 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0885 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 55909b2208cc..183f39384e4c 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -792,7 +792,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; @@ -800,13 +800,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;