From patchwork Mon Nov 2 23:30:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 7538871 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 16AD0BEEA4 for ; Mon, 2 Nov 2015 23:38:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8AF12205E3 for ; Mon, 2 Nov 2015 23:38:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 13E732057F for ; Mon, 2 Nov 2015 23:38:16 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZtOeM-0001SR-Jn; Mon, 02 Nov 2015 23:36:30 +0000 Received: from mail-bl2on0092.outbound.protection.outlook.com ([65.55.169.92] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZtObx-0006A2-An for linux-arm-kernel@lists.infradead.org; Mon, 02 Nov 2015 23:34:25 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (109.252.143.100) by CO2PR07MB620.namprd07.prod.outlook.com (10.141.228.156) with Microsoft SMTP Server (TLS) id 15.1.312.18; Mon, 2 Nov 2015 23:33:37 +0000 From: Yury Norov To: , , , Subject: [PATCH v6 11/17] ptrace: Allow compat to use the native siginfo Date: Tue, 3 Nov 2015 02:30:40 +0300 Message-ID: <1446507046-24604-12-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1446507046-24604-1-git-send-email-ynorov@caviumnetworks.com> References: <1446507046-24604-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [109.252.143.100] X-ClientProxiedBy: VI1PR05CA0004.eurprd05.prod.outlook.com (25.162.33.142) To CO2PR07MB620.namprd07.prod.outlook.com (10.141.228.156) X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB620; 2:4ct96bdrb+AOB1OiXh05QNVHM53JZLS79iI4iYWu/TaJcq1/zwPAg8lxVBCDRZTjyM5BBVHAEWVy60si3zTxaR9OWRrMcwVe0vtuvd7FinHaOcAlOimaPQRqN6dmHReLuPZAm28Qhd4BVvHlowjKuE0gp5nialj2E2lDf5UzGik=; 3:BCfF3STVNLEHwqhmuFN90IotnIL8FoWz28hWOZCK1c+bphS5dETMF2N7drHeupRTLUK5ewGfrrh6gvMX2HBHExMgPJy3ElvHyP4FaO7q4DMRCyKBHrhXbFFa1MWC7BjW1MgGei4BH1L2QnLfEEnmvg==; 25:JW2c4alMefEJQJhA0y+6wfsEZ8W8zJYcxlDr7T3gJZT6wCmgYthc+SVbGuNhCaraBJ1DuCeqWymQp3PqYGV4mlj/dQDQnYj9c3SaBgKLdNHNF+qi0vi0hsYFEbImm+TlvtDLInZT72CRbHytGM9WSaY6nbDedxoYjPvdDOIDqmRGdzkYxJ+3Y/4q+Sg4p0xSDrWCMNuRnqGp3pqTFrSCOnI73oPmhkLrPtJxnRUwVtCDVQ5S4mIquB+E17l65YDoBwDbTfmWB+jImVFFFGuI3Q== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR07MB620; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB620; 20:VfYF12ltJsPn7I1iSN97Hgmd2QMjx+UY0m02bMa3vFb1fkPUfj9u5ApFOwsK5mGak5pvjB0xpkw8XtuNyNc9AYOqSIhTjksr3r/5tAi3wFPherxe/MzH3VcE7xqxKAspLkeEw5cx2A9yjUtnVUCn6So42C9TEdaaw8h/JDo4HKAOI/vtp9ZcIRlivXbI1HbRip1tnqgNnb1tprFvbYJt/XplWs7j3Jn2tqCFYIgOjhJRywrhObhkGiiKfYKDty6rA4dAGFKCjFQe3YdHcqK6g91xVOYRHf4zImOFVm2gKugfJ5+txf00uY5qyrNkU6vjNwyoTNt3trA8BRTwG0ZW9WUzX+C3sxzcg9yd/O7MbSkH9ExXj5/6BCNdDd9CXpRHVxHUTZTgYvLzdZ57BVD0EzKxLig0/u9/8p5NuOB4WmqyRE2/RMnBmyEItkLdr32xCWZVrrO5quKcBAQid8S4PaRQ8UeTxCd1YYAuhqSdsvaAgPjF6Y77nMTMyuiUUnL9uI9CNA0K2vR/aKK5zAx6o/C20eUUFanALgHCZPsY++/xGtM/c5wxXTtPR8Lo2U67uGELqPbiivAUZsNn6R+fyDL7yZW34jYzCZYLXXP+4kA= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(10201501046); SRVR:CO2PR07MB620; BCL:0; PCL:0; RULEID:; SRVR:CO2PR07MB620; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB620; 4:ri12cMTgE5GOn4K0zvPqB2HF7eP2n3PhDKqTzoRNgOziFBZ/kgTVP+eCHf33lYMk/mBkPstQ0JgIOim2fB02R+Wlljqt35siNlE+JRQvYIz6WUTOMPyiJPbrq1o8yW4synFTkxbreOhIv0cvRCRrUoHZHj1KpTNiSoT5BBc7uCjldmth3KMwfpkWmK416P0O9HalYXFHdE1uQVAh2Mvz8z1DKdFu0RKTvckMn9+TQyqUQWcSAE4BuLwCPHQV/QnBjizYQqIdyHXmesdEadBWJreJZGz0i5NJcbttQ+apZ0rUk5sjrHUj8KfkxeS8wus2mDkNbyBOGJNWFmsGX74dy4rHIyCgmDwevGfxCjyFlosVT3f0KGgRwNLJkrd/5y8f X-Forefront-PRVS: 0748FF9A04 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(189002)(199003)(66066001)(48376002)(50986999)(47776003)(5007970100001)(5004730100002)(5003940100001)(4001430100002)(40100003)(42186005)(101416001)(50466002)(76506005)(19580395003)(19580405001)(33646002)(76176999)(50226001)(105586002)(107886002)(106356001)(189998001)(5008740100001)(229853001)(122386002)(5001960100002)(2201001)(2950100001)(36756003)(87976001)(5001770100001)(81156007)(77096005)(92566002)(97736004)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR07MB620; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; CO2PR07MB620; 23:9YV5xmZcpOqi5+VvNnNjItF85eqsLloSWAPq+N2R9j?= =?us-ascii?Q?Sj3Rvy08UPfM8eqAAPMzQ2Tc2RDXg+v3/OOWkWz9+AWs1vHej2RvpCKV4iyv?= =?us-ascii?Q?fDh6NN4wiaFyKb96qjtBQtSFfSTQNr9yfevRn3tHYMij4fIzBtTddtRLaT+H?= =?us-ascii?Q?Bx7m5UgxQWiQ1MAOT05DEvfyO4ymeRhitDj2WAl85mrc6F1VV1FB+Y1fkqwv?= =?us-ascii?Q?yvZz1odBYjrDduJ3Ri2SOFJaZv+UoOSNmkWQuKvxhxMUzKjCaRosfaaP7CLM?= =?us-ascii?Q?jlstMVZ8eHB0VIZsDqyfo6ggIA1dP8bvt1m9+MuQMsO3e7IDnTVKAMeY9IRx?= =?us-ascii?Q?mgYU/QeHUUYA3UqbbEl/fPW8yOSYd98iSa7rSpZU3iEmwJgkGnVQSgL7C9D/?= =?us-ascii?Q?1lwF1UoQ43TYIihYOXnMQDOfw2OGJWLYB8PvCaS4evP/u5FkPzrDqvKjmmI9?= =?us-ascii?Q?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87BkDr3UrB59qxzSuGpN6GWk4o=; 20:4Ulyfs/0y8V74lzb7dWy7hrRcV1OiykB8BXQ25j/swYkfHxVzpSK3AgmYSKoscSCch4TtRJ1Wrw0gYHPWdd8Ow== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2015 23:33:37.7135 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB620 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151102_153402_432390_401C3BDD X-CRM114-Status: GOOD ( 11.75 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pinskia@gmail.com, Prasun.Kapoor@caviumnetworks.com, Nathan_Lynch@mentor.com, agraf@suse.de, klimov.linux@gmail.com, Andrew Pinski , broonie@kernel.org, jan.dakinevich@gmail.com, Andrew Pinski , ddaney.cavm@gmail.com, bamvor.zhangjian@huawei.com, Yury Norov , philipp.tomsich@theobroma-systems.com, andrey.konovalov@linaro.org, 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andrew Pinski Set COMPAT_USE_NATIVE_SIGINFO to be true for non AARCH32 tasks. With ARM64 ILP32 ABI, we want to use the non-compat siginfo as we want to simplify signal handling for this new ABI. This patch just adds a new define COMPAT_USE_NATIVE_SIGINFO and if it is true then read/write in the compat case as it was the non-compat case. Signed-off-by: Christoph Muellner Signed-off-by: Philipp Tomsich Signed-off-by: Yury Norov Signed-off-by: Andrew Pinski Reviewed-by: David Daney --- include/linux/compat.h | 4 ++++ kernel/ptrace.c | 24 +++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/include/linux/compat.h b/include/linux/compat.h index a76c917..0a25d90 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -24,6 +24,10 @@ #define COMPAT_USE_64BIT_TIME 0 #endif +#ifndef COMPAT_USE_NATIVE_SIGINFO +#define COMPAT_USE_NATIVE_SIGINFO 0 +#endif + #ifndef __SC_DELOUSE #define __SC_DELOUSE(t,v) ((t)(unsigned long)(v)) #endif diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 787320d..04799aa 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -652,7 +652,7 @@ static int ptrace_peek_siginfo(struct task_struct *child, break; #ifdef CONFIG_COMPAT - if (unlikely(is_compat_task())) { + if (unlikely(is_compat_task() && !COMPAT_USE_NATIVE_SIGINFO)) { compat_siginfo_t __user *uinfo = compat_ptr(data); if (copy_siginfo_to_user32(uinfo, &info) || @@ -1140,16 +1140,26 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request, case PTRACE_GETSIGINFO: ret = ptrace_getsiginfo(child, &siginfo); - if (!ret) - ret = copy_siginfo_to_user32( - (struct compat_siginfo __user *) datap, - &siginfo); + if (!ret) { + if (COMPAT_USE_NATIVE_SIGINFO) + ret = copy_siginfo_to_user( + (struct siginfo __user *) datap, + &siginfo); + else + ret = copy_siginfo_to_user32( + (struct compat_siginfo __user *) datap, + &siginfo); + } break; case PTRACE_SETSIGINFO: memset(&siginfo, 0, sizeof siginfo); - if (copy_siginfo_from_user32( - &siginfo, (struct compat_siginfo __user *) datap)) + if (COMPAT_USE_NATIVE_SIGINFO) + ret = copy_from_user(&siginfo, datap, sizeof(siginfo)); + else + ret = copy_siginfo_from_user32( + &siginfo, (struct compat_siginfo __user *) datap); + if (ret) ret = -EFAULT; else ret = ptrace_setsiginfo(child, &siginfo);