From patchwork Mon Jan 9 11:29:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 9504461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0DAF36071A for ; Mon, 9 Jan 2017 11:35:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 069C328406 for ; Mon, 9 Jan 2017 11:35:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF67E2849A; Mon, 9 Jan 2017 11:35:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5DE1728406 for ; Mon, 9 Jan 2017 11:35:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cQYEo-0000wn-9E; Mon, 09 Jan 2017 11:35:42 +0000 Received: from mail-co1nam03on0087.outbound.protection.outlook.com ([104.47.40.87] helo=NAM03-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cQYE3-0006EI-Q0 for linux-arm-kernel@lists.infradead.org; Mon, 09 Jan 2017 11:35:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-caviumnetworks-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=+Fswmj5RtGXw7PBpnuZT+WZhSS4qBmfEvajHrI2RIeI=; b=wB9sLE8THhp9RGY7WbPf5VUKI9Yiiju8Dy6xG+vAkl4N3wVhNd4Z/ipriiKnbERoNOG1ANqjsE8UQHd+rC/7Ui+qYZvzjUI7qIbP2reAqHTtqs31C2unYswm5I2wsrVipZK3yIAgDvxv+nsT2AjMX0ZrUyMBjUiYM0wrUjF/moc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (103.78.20.242) by SN1PR07MB2253.namprd07.prod.outlook.com (10.164.47.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.829.7; Mon, 9 Jan 2017 11:34:33 +0000 From: Yury Norov To: , , , "linux-arch @ vger . kernel . org Arnd Bergmann" , Catalin Marinas Subject: [PATCH 18/20] arm64: ptrace: handle ptrace_request differently for aarch32 and ilp32 Date: Mon, 9 Jan 2017 16:59:55 +0530 Message-ID: <1483961397-8599-19-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483961397-8599-1-git-send-email-ynorov@caviumnetworks.com> References: <1483961397-8599-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [103.78.20.242] X-ClientProxiedBy: HE1PR0802CA0008.eurprd08.prod.outlook.com (10.172.123.146) To SN1PR07MB2253.namprd07.prod.outlook.com (10.164.47.147) X-MS-Office365-Filtering-Correlation-Id: adcf3b07-6736-411f-816b-08d438837c0e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:SN1PR07MB2253; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2253; 3:ZeNO3evxR1urjia7Le72tpg6tMFLB4gFIaUNX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AeI4x7HrvbESB+RKJ/donc3svc6 X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2253; 31:OIA/x/vbzTDD+BJ/F2/JdnoojhCiOhfDkWrDgZYOGQkVjeIpi2vMEWf9lSmHma0DXTfsXQX3D8b1uKuzCgXCZAslmvA6zfTRspR1JJBYexCuB4/jcbVWocL07Fik9Aho54cvQMN3MdFTdn9xxQt+7+iqrz+a65QyJLPTA2zIa0nQPN6k2Xq3C2O8KZ3jj48kmMROVHfuc/M7EaMpNmAMShZCcaWjECKaBfnEb+np6WKX+tZxlvCm+LAPNfbYiYKjysfPdj+jJS9i6Xp9SbRVb0ADkXIv5tIX8M01zgxsYnk=; 20:MKkd7azZt1LCM3mAHeExtEmaqkCZzULeKVCXENN392sIL2WaXqihaN+RcXscb+i6nInjw9aRxETgx88/ZykfQRaXfVQ40VHWdn93fFdo5s8U88pXLJg63tuM5HcJl2f7urYjnEbCqP+FXok1nAaqItKsQrbRO8lKBzvKgq5vdAo7sg/RbarY62MCbK8g7E3JE0Nl7zgvqPsGRsxwb0Yacc5PKqvVrWF6xGHauLGmtMcR5g70kvVyTcqqj2iC8MJSbiIjTvg7l6PRyHQ1r38Whi/TZmiAMI+1NUT61xgEYjU8ZXJBEtuJeURxwFDSV+MgoA1SWcH7sps8faFXwuPZhijCDs9Tc2HGK1YpTppB2yNUONBLV7XZ9oCZPXwmxTOGRHp1qoT0oKOdDio+TE56OlUDllxilpAy3Dd0l2IrcPy2t2iGYJ824JrzaYyRfLjFJwPh+vatOIYtnrEOUFMoOuJBei4k0axMmVkGPo3tMPigT6+qu0NRkEiZ35tcPNZwDIOEwwvdDayPTTnUTCmFBvR2UJHfd+VYqt+cxF/qwy+P1CWmB7BHk0YuN6EA9rCVtEfBNlDcS+k4xYWRT75VJK7e1zTWAvDIB5CipzPBAF4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148); SRVR:SN1PR07MB2253; BCL:0; PCL:0; RULEID:; SRVR:SN1PR07MB2253; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2253; 4:rLXI1C8h9I46e0gb4sa0nnI3YcG0kG7dnyLbAxPJL2R1w8p6hT715Uh8oJSkN5Kt3mGi544K7VMEfpzj1wWDZ3oQ0Ur70s3RCDV5JRT+O7fgTKFdOoubwbdbMI2gr86vcWmHQn5/e66BaC7XMpY+C3GTiN8g/R+i4OhSYd/pz3lsMSLwkud24932tbu5SpYnhGq5hNWXYa+hpXZQG1SbyLrfqtPkWNJpBR0N6TacT6PC99SMVfC2CreDiB9TXuQ1AL1kTzu+OT3v8WLxFKw5chkLPObh1ldmVcyVWr1PFwkW7VWPJGyf3CKooDga5STCB+f35qDMi6+cTuXbPXdAi0VZjIyA8RDGhshHdDfBUdmcwlhDRf7DGjbMhqpjmRiZ0draFYSb/Jp+8JfKaOxvOElUgFVxDMzgt8djvQBadNdZZEkENRk2pcqM8y4wPqEnhlQpj/y3JEcRrQJY/YUxjjVp+IFSuIRU6BIZDu6uEaBZFinH/yCxdLYU4PwFLXatJ/f9CKBLiso2H9KEnLmwGdXrI0oCUsD2A2O1UuJyBXz1T5wbO/+HLyBU43TlzwXeIrDG533f6c+bgKQ3QM1NaQ== X-Forefront-PRVS: 0182DBBB05 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(7916002)(39450400003)(199003)(189002)(189998001)(42186005)(92566002)(76506005)(7416002)(47776003)(7736002)(2201001)(305945005)(66066001)(6116002)(3846002)(105586002)(50466002)(50226002)(106356001)(81166006)(81156014)(5003940100001)(2950100002)(6666003)(5660300001)(54906002)(33646002)(48376002)(25786008)(68736007)(8676002)(101416001)(76176999)(2906002)(5001770100001)(6486002)(6496003)(38730400001)(4326007)(97736004)(36756003)(39060400001)(50986999)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR07MB2253; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR07MB2253; 23:61BQ7TajFfa5Lrx83srg0bEswkS+aviO8LtSCy0yS?= =?us-ascii?Q?nV9c3SoLYOTZc9EmMpWsKcF9Y4tnzK02+RwK4Md9991LBKRAQZgBgU6PK6lv?= =?us-ascii?Q?xCMkTnNYiIhK27f/CRyQInR9GSKgMNsay9YEICGwZ/nJc26O/szSfcjj+I5h?= =?us-ascii?Q?5o7xc81NbTKWEDPIl07yQR9wD5fZvJ79UUSVWdS031Ke1Rw8I4FO+3aPiUmU?= =?us-ascii?Q?gkRROjfTzrdRUzYryAsQzHw+RI4arPvPK5+4qy53tUagJ3mnJJzF2+zZQ5zV?= =?us-ascii?Q?V4GB+t5/SlVRCl+43zA8ucULsUcEdIuxNhqeX35S+/aHMMJ1tlw8/LpFMETQ?= =?us-ascii?Q?j1AnS55a1DEdwNjy7NCNQFg3xqr7pYA1nLM5bRbPa/r4tBz22QgDmS9e5CMC?= =?us-ascii?Q?sPRGVCj6HPMIruA77KFav5uzOY3u20IM+BE6qvpZwX6E5AMVsMI0ck5AjzUx?= =?us-ascii?Q?br5H1H8m2NtjE0DSJF7XtavMmzzj8VAGOTCA06ESgBKXXeBq/D0ep72rqNrT?= =?us-ascii?Q?pM7Fj+nIX2e5SguMjguErh66w540VWrj49IoijV+LoWmN1QnglUM22F233sS?= =?us-ascii?Q?B+R2KdlIldrXmCE7uhyINNaVDK2PEz/WnAGVzyeiVER0Gd338wE2MVCjwlvc?= =?us-ascii?Q?SPNbEl2oYaJqNk1CvgPi5uCOey/zo8zXnZH2Qn/46PLyYkBMfRouXlminFDX?= =?us-ascii?Q?Ng6QJgGAbSESQbXNWXJCpqIn0o5qPE6XZ7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QCm75P54U8QX2Rhyqp4A/XkXEvQAkdEmTTvGPXZXIfqec5/wqVK1v8GJgfWbHT+FHTDeQ5C1Sk7lzLTQ==; 24:yRox+ZVtbf8GFJ429DP7FxCwWJtiANo+/ErKVquzSQ5NzzK+NEGyJJxghDDT7D2exiTfqhM1by2WOSxOk8wmG9YWdf39EPRX9qXshZBB92c= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2253; 7:T+B2Xh3x3Easrd4CZvz1cEcHP93Ea/sOxmpaMypiCV0gMCDD5s19zgJv6FqAle27oI9Jeya3KxHP00vwo0ep3imK2EJXa4t04Mnqd2Zw5Me/8hrQGcsNjDrXGqJg2C/l0xZ1xTQ9WAIxP7TOKqXYIHpnK7ZtfgZ0DsacCLw6xBDOV/eYgaNBMB06pjaDkC1sQQdpNYZnXJ/9cS81BpJjly1Grh35mpIuMpTbqYV3pghzfNeUORWyVaLrRjvF5D6+cy9ooDgu0x7yn7c+m3C1BWmNXif534P1WRtQWmQnQzzfQsXjg9WX8bjxgDisaZb3sE2OnXKA1aT3FwX1aPElFUXUq9utX4wkiM+NBgcVqn9D6XwQylUEMDUjUM7dvrIfEYa/vpAZsJ6jcdVVOKnPM0dhmcDGjs8o9ipR4HbC02AbWB1OV6TGtD/ODqDkj4WFvTwuOujMcW4Br+teunEC3A== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2017 11:34:33.0121 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2253 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170109_033456_326578_5228DC8C X-CRM114-Status: GOOD ( 10.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Pinski , Heiko Carstens , Chris Metcalf , Yury Norov , philipp.tomsich@theobroma-systems.com, Joseph Myers , zhouchengming1@huawei.com, Steve Ellcey , Prasun.Kapoor@caviumnetworks.com, Andreas Schwab , agraf@suse.de, szabolcs.nagy@arm.com, geert@linux-m68k.org, Adam Borowski , manuel.montezelo@gmail.com, Chris Metcalf , Andrew Pinski , linyongting@huawei.com, klimov.linux@gmail.com, broonie@kernel.org, Bamvor Zhangjian , Maxim Kuvyrkov , Florian Weimer , Nathan_Lynch@mentor.com, Ramana Radhakrishnan , schwidefsky@de.ibm.com, davem@davemloft.net, christoph.muellner@theobroma-systems.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP ILP32 has context-related structures different from both aarch32 and aarch64/lp64. In this patch compat_arch_ptrace() renamed to compat_a32_ptrace(), and compat_arch_ptrace() only makes choice between compat_a32_ptrace() and new compat_ilp32_ptrace() handler. compat_ilp32_ptrace() calls generic compat_ptrace_request() for all requests except PTRACE_GETSIGMASK and PTRACE_SETSIGMASK, which need special handling. Signed-off-by: Yury Norov --- arch/arm64/kernel/ptrace.c | 65 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index ab7937c..d936048 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -758,9 +758,11 @@ static const struct user_regset_view user_aarch64_view = { .regsets = aarch64_regsets, .n = ARRAY_SIZE(aarch64_regsets) }; -#ifdef CONFIG_AARCH32_EL0 +#ifdef CONFIG_COMPAT #include +#endif +#ifdef CONFIG_AARCH32_EL0 enum compat_regset { REGSET_COMPAT_GPR, REGSET_COMPAT_VFP, @@ -1216,7 +1218,7 @@ static int compat_ptrace_sethbpregs(struct task_struct *tsk, compat_long_t num, } #endif /* CONFIG_HAVE_HW_BREAKPOINT */ -long compat_arch_ptrace(struct task_struct *child, compat_long_t request, +static long compat_a32_ptrace(struct task_struct *child, compat_long_t request, compat_ulong_t caddr, compat_ulong_t cdata) { unsigned long addr = caddr; @@ -1293,8 +1295,67 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, return ret; } + +#else +#define compat_a32_ptrace(child, request, caddr, cdata) (0) #endif /* CONFIG_AARCH32_EL0 */ +#ifdef CONFIG_ARM64_ILP32 +#include + +static long compat_ilp32_ptrace(struct task_struct *child, compat_long_t request, + compat_ulong_t caddr, compat_ulong_t cdata) +{ + sigset_t new_set; + + switch (request) { + case PTRACE_GETSIGMASK: + if (caddr != sizeof(compat_sigset_t)) + return -EINVAL; + + return put_sigset_t((compat_sigset_t __user *) (u64) cdata, + &child->blocked); + + case PTRACE_SETSIGMASK: + if (caddr != sizeof(compat_sigset_t)) + return -EINVAL; + + if (get_sigset_t(&new_set, (compat_sigset_t __user *) (u64) cdata)) + return -EFAULT; + + sigdelsetmask(&new_set, sigmask(SIGKILL)|sigmask(SIGSTOP)); + + /* + * Every thread does recalc_sigpending() after resume, so + * retarget_shared_pending() and recalc_sigpending() are not + * called here. + */ + spin_lock_irq(&child->sighand->siglock); + child->blocked = new_set; + spin_unlock_irq(&child->sighand->siglock); + + return 0; + + default: + return compat_ptrace_request(child, request, caddr, cdata); + } +} + +#else +#define compat_ilp32_ptrace(child, request, caddr, cdata) (0) +#endif + +#ifdef CONFIG_COMPAT +long compat_arch_ptrace(struct task_struct *child, compat_long_t request, + compat_ulong_t caddr, compat_ulong_t cdata) +{ + if (is_a32_compat_task()) + return compat_a32_ptrace(child, request, caddr, cdata); + + return compat_ilp32_ptrace(child, request, caddr, cdata); +} +#endif + const struct user_regset_view *task_user_regset_view(struct task_struct *task) { #ifdef CONFIG_AARCH32_EL0