Received: by 10.213.65.68 with SMTP id h4csp2113764imn; Sun, 8 Apr 2018 20:03:50 -0700 (PDT) X-Google-Smtp-Source: AIpwx49YZUOGSJ/VSb6R3cQgYqGyU1TCqdB44SIqSvLDKnlY3Wl8qh45dDwBYfpMHuJxIBHgYBrK X-Received: by 10.98.7.83 with SMTP id b80mr27863089pfd.133.1523243030116; Sun, 08 Apr 2018 20:03:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243030; cv=none; d=google.com; s=arc-20160816; b=QZI0w93nUYsQLqTWuVyE0+PRws5UWGNfncVMqszgVVTzIBLapKqorzv85vcU6XkrSA cSVnFORSYBxpZH06JYdDOdezKzUmcSsvqI7AvPcg/p2xQ0m94lpUhVc0adT4ipCYtWP3 X/3YlLc1P+b6vVLAg7W/D33AS0ERpyxQt+pX3TiWTUSaQsYlkZdSExktRmvRfx2DwR/O EyqE8bdY4gZXO5720JAUrt5CQ66zgLa6OHpJQT4P7xXzKrb1PcSbzjtE2pGNz5yp2Rwf 45dATDOH2/p5Tt0GvYNb/qceehavM0PPXPmaMYwR2j80QA0T2S9OT3Fy2S0wLx1WOq7/ rcBQ== 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=2EGIMksSo+7vcZSA5cIcSDECJNIfWsRxKy3I4+8n9Ks=; b=DlG6RAtwNrtwlarcjmquyO4oDkdavY/maY51oEm6vfbgVJLh9MoA51AprOZ5lltC61 QZl/cKX+5EkgdQTKWlt5k23cUMwQcQJ+yDOfS2t99D13q3UK3YIZPdbQNg/jWIxlpgq2 87HWpQZFIQNwB+hB/QpQJ/7HffSHHabip1blv/Yf03t7p84/zJmA4JZ+b3WQPra/xpSE U+iUcEldHRDKjEeChp3PTYgbCL9vvkgUxyanSnEed98h8N7u/6NWEZvHjSnuS+5lGN/Y 5FN6xXpNnUdTnhuXzYYWX7SV3iPxYIOJB0foFt+VNZN02p1Z+vH+S9j0+zr9Wp23yAkI bYKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=WyTt+Z1W; 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 91-v6si16115961ply.33.2018.04.08.20.03.13; Sun, 08 Apr 2018 20:03:50 -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=WyTt+Z1W; 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 S1755756AbeDIAaT (ORCPT + 99 others); Sun, 8 Apr 2018 20:30:19 -0400 Received: from mail-sn1nam02on0125.outbound.protection.outlook.com ([104.47.36.125]:10314 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753157AbeDIAaQ (ORCPT ); Sun, 8 Apr 2018 20:30:16 -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=2EGIMksSo+7vcZSA5cIcSDECJNIfWsRxKy3I4+8n9Ks=; b=WyTt+Z1WqkKFXuHs4THFDGwWzYYn7o9ZlTV9LCHfrk2x1NO4r5zLvn0Dm9cNcz+fwA7yUBH8YkvxH3AjuOeIo+vQTOc89YOjndV3j3QrZYfGc2FMXnq/eunyAgEi43LQIUZraion7UdPpcHJkF1Q0VdupaQjpz7tS5o+m2WaXIY= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) 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:30:14 +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:30:13 +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 121/293] arm64: ptrace: Fix VFP register dumping in compat coredumps Thread-Topic: [PATCH AUTOSEL for 4.9 121/293] arm64: ptrace: Fix VFP register dumping in compat coredumps Thread-Index: AQHTz5kekh3e+yDfDUiAdhGxujLg3Q== Date: Mon, 9 Apr 2018 00:24:27 +0000 Message-ID: <20180409002239.163177-121-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;DM5PR2101MB1032;7:+cMFxhihnrSPpcWG6TIHCCsC0S8VLcPq0GppIuiPukgJp3V2DHrhbTOrjHBXb4HpULpU8oCTC6gJYSS81B1I3hWqw+V4O3RyoVirM5B/IN01jkCdeJcNDt4hkin0lGYdtuTHi9QlGTWqkhswuocQNd8PjU4UP1dcMBnLBP4+5RVy/HtAuvIDudt9DSxfZMGZmZgWZO+wREq5Xgwp/yl2K+ab0JWWjqRRsNJtST2GvmZXYGHsymMPULc0pGPc3H6g;20:ezUVueUuh1x8grdHfTVD/v1y6AlMHvUbiLnb4W0xKQ5BMjp9NI/BChfgKa0Gy3iAwUXZm/mGYG+9/ckAMVFMlMTgk+KGCuUYRNZ1t8oH2WrYw8qpNTbM4gfB7u2u5MUUKQ3tgC/5NiuvGgvqtEoB7O6nsPls8dABaxX4ulMtbr8= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 69e26b49-fbae-4c22-0fec-08d59db10f97 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1032; x-ms-traffictypediagnostic: DM5PR2101MB1032: 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)(3231221)(944501327)(52105095)(10201501046)(93006095)(93001095)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB1032;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1032; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(396003)(39860400002)(376002)(366004)(189003)(199004)(5660300001)(76176011)(99286004)(10090500001)(2900100001)(105586002)(305945005)(7736002)(107886003)(2501003)(5250100002)(14454004)(53936002)(4326008)(8936002)(68736007)(25786009)(86612001)(3846002)(66066001)(1076002)(486006)(316002)(72206003)(22452003)(106356001)(186003)(97736004)(6436002)(6116002)(476003)(2616005)(478600001)(6486002)(10290500003)(2906002)(110136005)(54906003)(6512007)(81156014)(81166006)(8676002)(36756003)(11346002)(3660700001)(446003)(6666003)(86362001)(26005)(102836004)(3280700002)(6506007)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1032;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: kADEPeQYF3xCrXDacJkGaoXvo5yLyhClXdis4JPuWrrN1GdRrch90VDSgZlzobxpzemfPjvFRTSKK/Y2oI9hIIWhLPcD6MowcsQuvlFb8at/PtjkVk70D9Wl7rnD7DXV8TgkRbfoglkKSa7aBDH6PfBka0BlmclQbv6ucrs+EsFDWwvXMiXAfKQUFVXOZvxb8VHkYQl+zb0eTsK9Zow4rot0FZ/JLNcJiMiiANX0k05EBr+WWI/SxH03JM/vu+TA4a/dmCTrkcALNBw9+25YctSI8c9a81NeQRzSRwbiqpApG1w5xcVZtlKe037pgrpqM0l6Vfg8aUYDcNw96m/UqMGCvjAALrMZnvyKb8Vtm0dVWYVmI1xxi5R3wakyqt53ttVia4SF/XbxxwYYEMlsKvcDTbyms/0WhMc+av7uDSI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69e26b49-fbae-4c22-0fec-08d59db10f97 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:24:27.4406 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1032 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(-) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index d1fd560b3a2a..5c78b64369cf 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -896,7 +896,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; =20 uregs =3D &target->thread.fpsimd_state.user_fpsimd; =20 @@ -904,13 +904,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 =3D user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0, - VFP_STATE_SIZE - sizeof(compat_ulong_t)); + vregs_end_pos =3D VFP_STATE_SIZE - sizeof(compat_ulong_t); + ret =3D user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, + 0, vregs_end_pos); =20 if (count && !ret) { fpscr =3D (uregs->fpsr & VFP_FPSCR_STAT_MASK) | (uregs->fpcr & VFP_FPSCR_CTRL_MASK); - ret =3D put_user(fpscr, (compat_ulong_t *)ubuf); + + ret =3D user_regset_copyout(&pos, &count, &kbuf, &ubuf, &fpscr, + vregs_end_pos, VFP_STATE_SIZE); } =20 return ret; --=20 2.15.1