Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751447AbdFDMEV (ORCPT ); Sun, 4 Jun 2017 08:04:21 -0400 Received: from mail-cys01nam02on0041.outbound.protection.outlook.com ([104.47.37.41]:52159 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751416AbdFDMDz (ORCPT ); Sun, 4 Jun 2017 08:03:55 -0400 Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=caviumnetworks.com; From: Yury Norov To: Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arnd Bergmann 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: Sun, 4 Jun 2017 15:00:07 +0300 Message-Id: <20170604120009.342-19-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170604120009.342-1-ynorov@caviumnetworks.com> References: <20170604120009.342-1-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [176.59.55.28] X-ClientProxiedBy: VI1P190CA0017.EURP190.PROD.OUTLOOK.COM (10.165.188.158) To BY1PR0701MB1271.namprd07.prod.outlook.com (10.160.108.17) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PR0701MB1271: X-MS-Office365-Filtering-Correlation-Id: 6ffb4ab9-5ec1-4ac8-44d5-08d4ab41c1a4 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BY1PR0701MB1271; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1271;3:g7qqeSXdY8DR3k3SBOSpJYywe9befiP6OjKW14zfp5R57GY3Sd8DFVHAICaq09wS6z4dj0ueCP7wKcd64X0fYaTjqAA3bEFMncxzBNo7gHZAeGa7pw7KA6m2lD0I9uXK/K5yKZgTJXJLN8RrcI8t33X+L3QqWjWzvPF7RHBV2HHWThtcxgrU0WCZMbVDM5+XMKEYjKZRlFUVQitoCJNtMuwMaMkypI7H8xqcPS6SR0S3Wm88fJAFxI+eBP5UNDWY61fKmNce7AYrWNRxCTtul+qZ+grQq4hPk9aXJLk9F5gGJHuxLShakPf9dyTNOrCoDzo6repIEm0aBdlvue9Xtw==;25:+vbHXpIzkQ6JXdjts5MlvFWeY0QSLbwI1oK7XL0j3/Jq4VyE7zXD7mI3D3bNauHzRugPk2f31f7i/u8THTfQ+BqGzm99svNXiHtZ3tzmB7UukjlkZ+bDxW/FjM/m2GTnpIU7UhMPJDUUH+yo/axCBYAZVaTFxCZfK1szzN5GTrlvZG3k/zcOPgER4KDcNxJFbisJmA0crLMYTgDCFFFGXEW0OyUdm9ffYNqwb7A7YdoRbqq8y2PN4Wq/TtjuHdMy34XmPk+YQLEAL2Dfe/xfrNuVKYZdT2+67M1lIdm5IT6MEDHTUudnukIifQnnc+5nyEW81P1IAPq5d7z7s5NuSCFiwv4q+EraPz8ggpSbHvqEfnxDtA8m5ScK9KRUZTF4YoEYjykTexdiiqrii5mw83HNh4Rvn+zPVwzmVvHmlEKaxe6PDaO4CMbX3cuDXAGpcnJAM3YJ/LgDDaBSdNy8KK41smbJmtHLig1ziFlU7+E= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1271;31:qcwSURZ6f8s9UUcep1m+wV/CSr4JiVDounEfeslajOvZZ76Uh+huLzXX7B0aJCpwx4/3pTVLe4vFQGMFm2OuQQJ3+zlspweqooulZRz7ZxVGvYtnaWUvjAdTfaJPr2JE848xUqNCGjpWvGvlWxO8Erosme90jA5LmZcoWjun7kYplyBi6AxVDxAMIQkgBVcDe0tHRQdbdKVmGO79Y/HC+T3TEV1zljd2VP4r3v6q63Q=;20:JXlI7WbpmS2U+1KkzqBQtIM/IeGNuP/aGaUQzf/52+bXUJf65FR2okrvEl5n6PpSg79Znq3fkvD4BBMe3M03QzA9NZ4AuXjR98w5LzWB5KuKRq7RrR5QxFoeM1tCNjiwrwYK6pk9H0WS3qDEN2R9d+8WZsSW+a5X43Pqi3Ib/TbRA+qviGuVUtMAILlcB1WMNdKadXfrJOv+s5zSkmXi7pwrS8OxD9mnUdqCTpZi0Nav/YzJyb9hiFanbzR57mPAfiXXrbEYUYV5XLf9RpzSlXv2lxDEu8rsuVB4UI69uSB8+AN5ZVWeUCNf0mMv2t5Y91G3KOvsLJHd0XqQvAiCIRQr8YW7pm4tGqOlPVSWqGE2A+ou+C3b8mraWUVnvHaux8dS3XfzbFnGgdPeJLH0Z2MAMbXKH7x5OQt0QjxJUZe/Fb1/0QBXMwY4iClnG3EvfGl98CzSNdGKRwehDdlqHsAC5HLy6xed2R937SEtIofwWl1LFcxiTDdqY6dYmuXHzNEJqhJM5Nb72q5tL/wohSX3HyKMsg2Ht4dvyAkpBrcmNqA3IgO3pHWCwiW8zL13yV5/BD4Z8sd2icTMAMmHAfEezS1o1L2caUN1k4L2GU8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(50582790962513); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(100000703101)(100105400095)(93006095)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123560025)(20161123555025)(20161123562025)(20161123558100)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BY1PR0701MB1271;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BY1PR0701MB1271; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0701MB1271;4:nPPvnLgv0cXyzoWdVRatpM7b9OQP4LTxZ4kD4F0P?= =?us-ascii?Q?IA2esNxLl3IuUPVxQuYhaloP0YQpsJ5ENCp4ZYgLg56kxXmUTi2oSffO1Os1?= =?us-ascii?Q?fZxa4YtHD7xOvzgwzPrb93rZdiuchZtq+sPI0SeosXHzNyajBPhOybRLFZ1g?= =?us-ascii?Q?YU6PZVU10T/8G8fMrdpw7QiifpStesCHIYRWI01whOfM8GsAoOE4opw4i3+b?= =?us-ascii?Q?s51tfSoHmy6Gpi50MQdX8Zray8GiBNIbPSiQpz5c1Gblve0G5jI7fSjbmTNm?= =?us-ascii?Q?oggvRGxjW1bjTMchP6W5T+f3JMMtxf7BAiLLHqoPBkWhu2sHqjjlS0CSADMa?= =?us-ascii?Q?NmU4kHYuKdwdXlt/7OTrb4LeHvhN5/p/FaB+UvcCAITB3vNB8mKZv+5CKIRx?= =?us-ascii?Q?KCAj0j1cGTYNWxTXh4csJ39d2DkqpGc5DXAtSei8Z4iBW0BIFkhdbQ/bYKos?= =?us-ascii?Q?PPNmrUxcdaqmnCAqJNPynH5qszDo9vA45g2joaXVf6snT3hycV/SABeg0UAL?= =?us-ascii?Q?2zvO3a6sEA9385ExTWoht/ADYacybgAiGAMWSGqFggvweRRu+1oj/Z0jv7B7?= =?us-ascii?Q?IFAEzR7v4Hq085jZJl46TusP7XT3uZ8qzp+5TQ7ryRyo4aiu17TRiLM6cT1R?= =?us-ascii?Q?JJhn1ndQyvgswA5pBZuoBJ+NXK8boHifBsAhrOfyM4vg+ejzzaz7PGPALT4s?= =?us-ascii?Q?W6D9cmFxstQopOp/snDfy5yN37oHutc5agcwbncyS1yAYgxQVzpm4aG0s+qx?= =?us-ascii?Q?7iK8qlmMmCSYZygxyQw+EgmxPnIq1HFGW5febSYt8HuesafrG+En887wI85s?= =?us-ascii?Q?5+E23tSSB8fUjIsrN5XltOmUq6W+atQyaZ04bOgVQqcuLLvALtefA4TjvsOD?= =?us-ascii?Q?KzBm1qw5/ekGAalyxJ1AGl6BhsovXnqRCoSMkmnqtJ7sYyxCQtF/kx1vuw+Y?= =?us-ascii?Q?Ecquovk6nwE2s3Dyu6zcrcQdLKQnhZuZKxLEq0GAGBpa4mVHfvCPHB5XLgm0?= =?us-ascii?Q?HldqR0TyC2ZP2jl74o7yhd4ArfvC6yXmehgMgVJVlAUq5mPl+2ZHxrZ3Ocx2?= =?us-ascii?Q?bcihsBUgFqyoYNfN1nOFDP5BU7YrWWBNqLu4KtqEzVEf0b7LZphKecrfnSyb?= =?us-ascii?Q?tyorNph4yB45Ob1qwYbcaiI+BgZ6GvRhBDVhqpXrgME1MRdp0SzPyA=3D=3D?= X-Forefront-PRVS: 03283976A6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6069001)(39410400002)(39400400002)(39850400002)(81166006)(8676002)(76176999)(50226002)(42882006)(2950100002)(48376002)(50466002)(6666003)(50986999)(33646002)(47776003)(5660300001)(189998001)(305945005)(7406005)(53936002)(7416002)(36756003)(76506005)(66066001)(42186005)(54906002)(5003940100001)(25786009)(2906002)(1076002)(6116002)(3846002)(6496005)(72206003)(6486002)(38730400002)(478600001)(4326008);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1271;H:localhost;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0701MB1271;23:8cOQ9PnjPbt/yVY+N7XQm/5e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xVr9s596FikgnvZBnBHjzUOIOhsNn2f5jrwi6eANGlN2lgZ1LkwKoHHfmaQz4BUuUu2rpcYHP/gut9ZNU3oC+ZcI2m1Y2ro+IlACtagWEQV0CrDVLkdAZk0HKyJg7KQgyQ/kSUyKJ11v8W/AhXEE4d/2lV98+FRi7rxu61noTA/5nJ5L8RfsXPpfUgnvTi1CZGkW0p1uqg5W8oRZYS7LnpwKv3keHpnR;24:W3kNswOGWrn3oZMHeak91ags1LYrV5z01D38lfekA+pPvSgcfQVfu6rqGqhcQpwAXienaLVDHRxNndGAIb+rBPW7YH0LLg4ZieF/0A390l0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1271;7:v+SF2yTHckiOkqomV8d4rOfbw7NMREMQsr6kgt899CvzfA5mvbcO93Ng4BQcMMB63/bfeNonbUw8HaA2JPtnApqOLBG+1MGeHvNBUygCmj5WugrOGb8cnaipJjmfZU+zc2T0OhK+xecPhWFU1SNv5pQEOcqVE7fiTRbXx1wkCzqcsoXLzWZcYoK/XajDlhRekeZaiyX6c2MT7IYPzJR+k9QoJiCFqlHTngIWicZa6H+KCdiZ8Kh6jEn/8fwGU9u8ZZvUOAYmbvnSqeENoaZIl4VKQDy/O38PKPnOONugBKve61/UlElMORTUZ4mKdYsDSlJQMvYeTtjyOwsZQHENEA== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2017 12:03:47.0449 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1271 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3385 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 e2b7c040bf84..28f96765e8cc 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -765,9 +765,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, @@ -1223,7 +1225,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; @@ -1300,8 +1302,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.11.0