Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753022AbdCAT0I (ORCPT ); Wed, 1 Mar 2017 14:26:08 -0500 Received: from mail-dm3nam03on0045.outbound.protection.outlook.com ([104.47.41.45]:62642 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752492AbdCATZz (ORCPT ); Wed, 1 Mar 2017 14:25:55 -0500 Authentication-Results: lists.infradead.org; dkim=none (message not signed) header.d=none;lists.infradead.org; dmarc=none action=none header.from=caviumnetworks.com; From: Yury Norov To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arnd Bergmann , Catalin Marinas Cc: Yury Norov , Andrew Pinski , Andrew Pinski , Adam Borowski , Chris Metcalf , Steve Ellcey , Maxim Kuvyrkov , Ramana Radhakrishnan , Florian Weimer , Bamvor Zhangjian , Andreas Schwab , Chris Metcalf , Heiko Carstens , schwidefsky@de.ibm.com, broonie@kernel.org, Joseph Myers , christoph.muellner@theobroma-systems.com, szabolcs.nagy@arm.com, klimov.linux@gmail.com, Nathan_Lynch@mentor.com, agraf@suse.de, Prasun.Kapoor@caviumnetworks.com, geert@linux-m68k.org, philipp.tomsich@theobroma-systems.com, manuel.montezelo@gmail.com, linyongting@huawei.com, davem@davemloft.net, zhouchengming1@huawei.com, Bamvor Jian Zhang Subject: [PATCH 18/20] arm64: ptrace: handle ptrace_request differently for aarch32 and ilp32 Date: Thu, 2 Mar 2017 00:49:26 +0530 Message-Id: <1488395968-14313-19-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488395968-14313-1-git-send-email-ynorov@caviumnetworks.com> References: <1488395968-14313-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [27.97.135.110] X-ClientProxiedBy: HE1PR0802CA0015.eurprd08.prod.outlook.com (10.172.123.153) To DM3PR07MB2249.namprd07.prod.outlook.com (10.164.33.147) X-MS-Office365-Filtering-Correlation-Id: a43768ce-0e4e-4ded-7f82-08d460d867be X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DM3PR07MB2249; X-Microsoft-Exchange-Diagnostics: 1;DM3PR07MB2249;3:k0jU9qPAJnRV6zWsNbAmchnZmgxn5H8dRUoZ8ZfJRXSafnIpDt6Nbijwgn6BYJjPjJTvIQsyUMtrbb7rg5VL+zxJOJ8ygcVg4+cqtDkgNgSYyCy3yWFnLl5ZgPO96+5cub3v+U+wWdIrX1bzsubZIS6jOeGtChPtGT56bohfgwTcK66RWlJd0izmHKvX7QuXJxxnMokV8UaEoajhTmr2xkyyapiBq2t6s6YMcLxOOorjOT2bYbq1UbOBUG2cwRD5Aww1+Gyx8ZJ72thybEzm+Q==;25:sPXMD417gkopBDTPj5sS/epz7bma0o3yxB1enbeyxUUqS6ryGOtmas4F+4eTmnwxx4TB2gEZzW9/yG4ER7VuRcTRvXDzYwVsqmGNPNstIRHFzqXjWtZrDFHRqqkmRXlLgVU5b77GQNAwf2gyFwVdUSOOrUdleyO9q11vmWpTOwmtlfbeZHcNWGHKns9dujMNjFaa3q+0eSQsWBkj9OTTch223j4HhEH7cbDkYkl7/EbY+oxxj6J9kDn94UpusmRJJX4cKGVy44ola/6ZfB8nhSHpcWJl7N1g+5nG9c/RLvuh7d/kEvy/+M1E+PaRw0T1EaOX0r5lKVFC9SDHKkhKB/zwraL+fAkOysdbjOCGUVtJoDPdgvW6ek3XKM5ucxzY/NlQhtew4sJY7EVOBTkNlspteSSV/r0To8K9tEv4bfx+f24cVj/CIWlBdOg/AESn85hFc4SZ97+RldA6r1/vog== X-Microsoft-Exchange-Diagnostics: 1;DM3PR07MB2249;31:3EV3XIjB7PP/ETvbwgGVdfYsoP0toZNOEmP9H4SToB77El5XzEQZ/PXBcHCOZOOIAI3ChMoBTbmsMk+0S1t31Z645lIDJPP5Rh8exHEtdsI4WxKhxHrH3f/q2X3M9wgdK4YTa4ItDJbp1fyfYNx52e/mQ7ANPzAaGHpmGppthC6GoLrjZ2j0t1DJL0I3Jz1z0d7jZDNyuQKs7jLoO86U7KVM1PRyf38eRmix/+P2/9g=;20:z2ECsiCpGERoVbSO+Zc7vLCe3VfVdy6q+BaF1Msz944xqEBXdPhqwvwiIywks9LGPtqrZf7pyAbBG+yxtt44xlJf59Ee6GgyxCg+7krNSjvkYvPky9i5LnyScbUlBi/4TkFETShyzvOQWXE4ShFGA9Q+26xwO4FbOlo9tsVs/D43Yl57aveE/nNRI/b/bz/9Z9U+krYAjlrPUoqrRDNqI1+LFjhKgnnfaYN/4iU+etbCDtS2AVtccznwNnvzDfaciDKXOWMjZ/bEDs2HIzNQ7W+myNoOG8QxrkcDgacZb0uxOG0NwoDFOcAm8FIUxMZ/FGMl/Lr948tfxsS4HMbkEyRprMH7Ad4aCODlrhKHK2heWmqmvTGfj6gWD9Qqi5i14FunZtho5vHPdeiBSFEk+Fuw2Y8mcTLtVT3Tx5RCTTAw14Fzhqn/0aN9yLv7nucvJIQShTOFKDpLD3xus2CWc7VymXOza7QJz8U5tlMTgs9brjdqObBcrqu8aCw6DKRJuL6GA5GJcqZjIvsgAxI6JF5u95Mr9LXuf8Va7F4Gk6wvkhvbo1j+1HfJXFpLOZ2YvLteSRXhuGxdMCPBX0VAxqb7fUwZf2UqJGXjEf7OogQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(50582790962513); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123555025)(20161123564025)(20161123558025)(20161123562025)(20161123560025)(6072148);SRVR:DM3PR07MB2249;BCL:0;PCL:0;RULEID:;SRVR:DM3PR07MB2249; X-Microsoft-Exchange-Diagnostics: 1;DM3PR07MB2249;4:2lwPxgP1FDhGT1pZ15+AxKELahsxk6D0D6usVakTSlIfJ+OFWpehpxiE6G8ahQ41jrgdmyoyVcE0PubWfqzLSqT3grA7OeD9nZFFrICxWlXVN6Vw6jVnQdFgQp16blr+Ds1Ox5oBYEi5BCApdiWDhRgnp5b2GIdkcFJpHmOHNC5wTNHuSroWREfJ83CNBfxkV/FH/Bt/TmnLo9KmHR7YoHU0TWdT6nkNpx86iM41vGOK5LoEeckFb2uPcw8urkoYvI+9nkyMtssngPt5CDN7VLiNZ/sMCyqQi6/KJfqznrPpcw0lkgp1+Jg7LdS1mCwXeDlT0sEmGkJF9EjeuL945tT3qKsaUohhEeW56t1Q7s9mtgHoawVpc/o9hpiC3nhoHNADwJAGi4TdX3pomKoOYtM2iO3EFSpszfTO4JfSowpY4pfext3XOja54QaUuCcB2t7TFNPM4BhKVS1Hk8jGHrXrBSferBsbTEIyvLNDPicBRuDQioRsXfCeYqfopz2cxH/EMCJncL3pJTR3sgC8hkj+3r0AbESwnFtqx43eltyoob34Bhkist8uZ8mfQIM29bEJTYFWgw0sClzpcd5ptaB673pKlAyIOnKL4b5kcaQUyqVAmF4J23l/nC+jKdk+j1A2Mx7yz2jB62bN4wVWwQ== X-Forefront-PRVS: 0233768B38 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(39450400003)(76506005)(92566002)(50226002)(6496005)(7416002)(54906002)(5660300001)(8676002)(5009440100003)(7736002)(4326008)(81166006)(305945005)(6486002)(66066001)(189998001)(76176999)(48376002)(5003940100001)(42186005)(2906002)(6666003)(2950100002)(6116002)(50466002)(50986999)(36756003)(47776003)(3846002)(33646002)(53936002)(25786008)(38730400002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM3PR07MB2249;H:localhost;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM3PR07MB2249;23:WbTOF9wwctcMLtDrhI/CeTEvaeyKaIhCEtrwJ8YtK?= =?us-ascii?Q?O4aoMtMAtE9cg4R76aIJ9HU0rhivqQ6AP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x0xqf3cbFa6kj5nUvsH1o4F9xINt31OF8lCzDZsnA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;DM3PR07MB2249;6:TfrHZJf9FM9NeJ8n+61shhH0tT6gEHNyRRMYsjsj6l7ask1ORT1TL7An778HU5Gr38B/0MSErWfV0SbcD+O2WPKdaGY3qwqI9MRzgSyOsxPyR8zsRYNyjwF4PkHCPTqLnD4iwnnw2wmg9MtMpjkeOh+rhAIb5YqAKH9ynd0Y1HcbLzUBgq4/LoEEXN6nQzN4tBuH8R8jCLTZ/+rCKKyfBA3WhfRNuSq0fy+/ljb8tFrlcyaCQaaRZquCIJP5Uyx0xf3+9GgmQVDZT6GSBUrZhUJqw269lfCNrdrerqIlfwWyTOaxO+SAz4DJ+9Dt4RPCyOIQ1ohVxTsYyQJe8Z0+v7p13Dx0I04rUk58R2HFB8E/E6gUf207ts1ldoeI7Ufacmej4E0/1Nx3XhEzHa81zw==;5:vq6XM+kMoaFHmTuVUAyuybiro5/LqGfAwpwcrYO7gXSWvzt3uoFo6aK+JRHplsLfkqin2gH8w2rT/20CGHb698cw5cbfD1h57SvydUPjQC6urL0oNsk8yyE1bXaJUtdF1HBojyErn8ZvtutoTKpE6JakkBd491Orha00siEliKM=;24:1QaK32uGAE87HVvfi4wryR1hrH22WJySTftLWStcMiO94OiTcnCItS4K8G36xDttoY8yVTPxQWI7CXDtKmS69NDJ6E0jPxM+U2xCbLZk/wA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM3PR07MB2249;7:wtYhXKQVNXLLWxkFqdUfWex7OYVWyhY0U7uKGCBK8XSTckqZTz32aRz1SgONSZe8AZ2mmi+iRy7qRvM44m+4VIrMm5891kIEI9XdpK9CbNtmZoYc9ga0fpPSGxfnkBC3YjaI93YKX07m3zLqgc765G5B+o1ktEMgvCtsUKjycJatOvyAJdK7qpLKFnkXYljAESOHHwCs7trkxO1qF/uu1MIuMrA9nkDvAOY5nBasDtOxMExBX9AlpJifDPVhWXGfGjHQTkXnJvjqCbnyAXhd8kYQ0GManr/3aU3gjh5GZwKC5ySChMwe50Z31Ha3UaIk6ukaSrDtCfhEeWIHbFZAZg== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2017 19:23:10.3176 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR07MB2249 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3374 Lines: 112 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 Signed-off-by: Bamvor Jian Zhang Signed-off-by: Chengming Zhou --- 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 09e30a9..81d23ed 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -764,9 +764,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, @@ -1222,7 +1224,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; @@ -1299,8 +1301,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 -- 2.7.4