From patchwork Fri Jun 17 23:54:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 9185237 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 844DC601C0 for ; Sat, 18 Jun 2016 00:01:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CDF227EE2 for ; Sat, 18 Jun 2016 00:01:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E2632833B; Sat, 18 Jun 2016 00:01:11 +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=unavailable version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 616BC27EE2 for ; Sat, 18 Jun 2016 00:01:10 +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 1bE3fY-0006S9-5z; Fri, 17 Jun 2016 23:59:24 +0000 Received: from mail-bl2on0065.outbound.protection.outlook.com ([65.55.169.65] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bE3cQ-0001tZ-81 for linux-arm-kernel@lists.infradead.org; Fri, 17 Jun 2016 23:56:15 +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=LvURsJBzkuLutoGX6OIdjfZOvY30bLNH31W6iYsfcPI=; b=FOt187Tov92sXBe74ZBv/gnFXp7HU5/XTrjBTtJ0XMYCSlMN0lrvOnYH7CV/qsTTbeMeD8Nlih5KUHW5b3WQIHrtBXVy2JZwcJra0X4YC5YYclnfokpTuHEdQ0Fo0ddyvIGJZGkaOWktMdoiWfPAx8k//1RSXMvLzU9Mg7lFtes= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (50.233.148.158) by SN1PR07MB2253.namprd07.prod.outlook.com (10.164.47.147) with Microsoft SMTP Server (TLS) id 15.1.517.8; Fri, 17 Jun 2016 23:55:47 +0000 From: Yury Norov To: , , , , , , Subject: [PATCH 16/19] arm64: signal32: move ilp32 and aarch32 common code to separated file Date: Sat, 18 Jun 2016 02:54:25 +0300 Message-ID: <1466207668-10549-17-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1466207668-10549-1-git-send-email-ynorov@caviumnetworks.com> References: <1466207668-10549-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [50.233.148.158] X-ClientProxiedBy: SN1PR0701CA0045.namprd07.prod.outlook.com (10.163.126.13) To SN1PR07MB2253.namprd07.prod.outlook.com (10.164.47.147) X-MS-Office365-Filtering-Correlation-Id: 2289eee9-bf5c-4e55-5f7f-08d3970ae734 X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2253; 2:kcXnzgCOSa5tgiair6C97fWuH9uTzY7eF4zQWfYxku2MayFiLLQW6GpJiVfe28EbPWo6WGkGMbThU8fE2m9QOmtiiwbb0kyTFBZZbVxjcuoCYxMAteHZbPqIJQro0wdT1Ce3HfL2QSHdmVRerlL94xTPTXfUg+X/NBDIW0AwSXn11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g3ZFvUdY5t9u/533z1D+3zLMxuNeYHyGpsekS6NZkUfuX1LV7nBELkWpDRpZKT6Uh X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2253; 20:YeHZizGNbL22YA5Rah4VxhVFe/+NiPXujVdfTFLbifwc4ugD91PUn4sR/Qc4nKb9qANEg6aT4rXmoM6UN0BUpjfKk3DshQU22bRcVZ9WpsXxyDLIHcsdSzB3e7YQYp8Et48RZWcn4RQfxVyNYdr2Da9y2G983qbjXFvwuWXesJWtqljYddWcCj4JgFMUkdWwlYgHh/M2g9MYkQI1QPWQJ/6sI/MvqMWwY2vso5nM6UWonXsSdsvW7+Wjzpqfe7u730NfRfmTAnaO3bMdRIVsZv2SiSx9H0E+5FH0SmbIBgihkRrL6k1h+472IGrsGuEyCTTNfXs9kKkO7N8cPEZif/2oquKQxdajwW0jknIUD+JlfhXDKjFwxSVbW/j77l9TUqbZDFxvuFipPYF2rRTAWf9qjBplL5yIUgF5c/SXI9YWTkcvsS6GmKiGCj7e+7qi69dYrOnPCQCwBt+/x83NUaqu8aDUVYQEIEMdQAarHPze5AwQ0YC9bacsajv4d2Fen7xefnqxvBhSIuBf5jdaPZFj9CCmymU6OwAlE38mZ/n/khjN4q1cMyVP9olZTmQCUIJAhHDshauifjxZo6CUI/5nUSmXzATS23t0eF4aoQM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(180628864354917)(22074186197030)(192374486261705); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:SN1PR07MB2253; BCL:0; PCL:0; RULEID:; SRVR:SN1PR07MB2253; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2253; 4:BlNWCXqFq0HxJGkdKhWBUVf8YFQZFqRo4G4yjAyC89vyWNkMDCOXuCbd7bNtM2MSoAGzJu92CT5TgASzb0n6vHdCtVFe72u+e55QGFLDmK5vQ0DkUXUTvxDdNL9C/gsfOIlCj1QpnMXTmvrtbdqmfldvvPYLxVDTivdMA0LjNUbRsRkjDKqmGKunEv9F2aHOX+yYApkQuZetjgqa3TPdZXPIEoqQA6cEOLjkyrNYFinl9oHLODTghgMxUIvSkdz0sm618vGe758+LIKSG0jNJBTVsmeG0C/UlnxMtGQiWc3i+xEhhdilzGZLD7Cy928gOj3jbVO8UaWdpklQrV5X/QrFJaMA9JKoYGiCxWpSCmYHBzn1Yw7b18ZQp1oxcpAWpSehQUcf3216a5UOIsno+ZPK7PMMi3JNhwLNXyz5GHADLItuMWTNrmrvSOYAIK5V3+mk4Fo68Ur4GlJHyakQrOwI94S1O2URmmBbmeip8dEo+nY8YtlNot1KlR50dyF1SlhQ2K1mGo6n0ssNV6u9Kg== X-Forefront-PRVS: 09760A0505 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(199003)(189002)(586003)(6116002)(3846002)(50226002)(48376002)(50466002)(36756003)(76506005)(2201001)(19580405001)(92566002)(19580395003)(33646002)(15975445007)(77096005)(81166006)(2950100001)(68736007)(42186005)(8676002)(229853001)(4326007)(2906002)(50986999)(76176999)(81156014)(106356001)(7846002)(105586002)(101416001)(66066001)(5003940100001)(47776003)(189998001)(5001770100001)(97736004)(5004730100002)(2004002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR07MB2253; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; CAT:NONE; LANG:en; CAT:NONE; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR07MB2253; 23:nqS9/jeq3lVB/qKb64dGe6/HT8//7a+Tz1cG/SQh1?= =?us-ascii?Q?qhH0ZTHaKKbWqDlKIhDJinjW26TRKtaR5eSE971xJ7dFeyqCkQ8Qrh/TXyw0?= =?us-ascii?Q?cHT6gdBowIRKJuSzB5M2V8Rf+u2xZgfQxja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change-CrossTenant-OriginalArrivalTime: 17 Jun 2016 23:55:47.1620 (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-20160617_165610_974189_B18FAAAA X-CRM114-Status: GOOD ( 15.87 ) 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: kilobyte@angband.pl, manuel.montezelo@gmail.com, pinskia@gmail.com, szabolcs.nagy@arm.com, Nathan_Lynch@mentor.com, heiko.carstens@de.ibm.com, agraf@suse.de, geert@linux-m68k.org, Prasun.Kapoor@caviumnetworks.com, klimov.linux@gmail.com, broonie@kernel.org, ynorov@caviumnetworks.com, maxim.kuvyrkov@linaro.org, schwidefsky@de.ibm.com, bamvor.zhangjian@huawei.com, philipp.tomsich@theobroma-systems.com, linyongting@huawei.com, davem@davemloft.net, joseph@codesourcery.com, 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 Signed-off-by: Yury Norov --- arch/arm64/include/asm/signal32_common.h | 25 +++++++ arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/signal32.c | 85 ----------------------- arch/arm64/kernel/signal32_common.c | 115 +++++++++++++++++++++++++++++++ 4 files changed, 141 insertions(+), 86 deletions(-) create mode 100644 arch/arm64/include/asm/signal32_common.h create mode 100644 arch/arm64/kernel/signal32_common.c diff --git a/arch/arm64/include/asm/signal32_common.h b/arch/arm64/include/asm/signal32_common.h new file mode 100644 index 0000000..b4f2099 --- /dev/null +++ b/arch/arm64/include/asm/signal32_common.h @@ -0,0 +1,25 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef __ASM_SIGNAL32_COMMON_H +#define __ASM_SIGNAL32_COMMON_H + +#ifdef CONFIG_COMPAT + +int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from); +int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from); + +#endif /* CONFIG_COMPAT*/ + +#endif /* __ASM_SIGNAL32_COMMON_H */ + diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 205bc03..d69bd40 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -29,7 +29,7 @@ arm64-obj-$(CONFIG_AARCH32_EL0) += sys32.o kuser32.o signal32.o \ sys_compat.o entry32.o \ ../../arm/kernel/opcodes.o binfmt_elf32.o arm64-obj-$(CONFIG_ARM64_ILP32) += binfmt_ilp32.o sys_ilp32.o -arm64-obj-$(CONFIG_COMPAT) += entry32_common.o +arm64-obj-$(CONFIG_COMPAT) += entry32_common.o signal32_common.o arm64-obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o arm64-obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c index b7063de..b103af3 100644 --- a/arch/arm64/kernel/signal32.c +++ b/arch/arm64/kernel/signal32.c @@ -125,91 +125,6 @@ static inline int get_sigset_t(sigset_t *set, return 0; } -int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from) -{ - int err; - - if (!access_ok(VERIFY_WRITE, to, sizeof(*to))) - return -EFAULT; - - /* If you change siginfo_t structure, please be sure - * this code is fixed accordingly. - * It should never copy any pad contained in the structure - * to avoid security leaks, but must copy the generic - * 3 ints plus the relevant union member. - * This routine must convert siginfo from 64bit to 32bit as well - * at the same time. - */ - err = __put_user(from->si_signo, &to->si_signo); - err |= __put_user(from->si_errno, &to->si_errno); - err |= __put_user((short)from->si_code, &to->si_code); - if (from->si_code < 0) - err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, - SI_PAD_SIZE); - else switch (from->si_code & __SI_MASK) { - case __SI_KILL: - err |= __put_user(from->si_pid, &to->si_pid); - err |= __put_user(from->si_uid, &to->si_uid); - break; - case __SI_TIMER: - err |= __put_user(from->si_tid, &to->si_tid); - err |= __put_user(from->si_overrun, &to->si_overrun); - err |= __put_user(from->si_int, &to->si_int); - break; - case __SI_POLL: - err |= __put_user(from->si_band, &to->si_band); - err |= __put_user(from->si_fd, &to->si_fd); - break; - case __SI_FAULT: - err |= __put_user((compat_uptr_t)(unsigned long)from->si_addr, - &to->si_addr); -#ifdef BUS_MCEERR_AO - /* - * Other callers might not initialize the si_lsb field, - * so check explicitly for the right codes here. - */ - if (from->si_signo == SIGBUS && - (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO)) - err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb); -#endif - break; - case __SI_CHLD: - err |= __put_user(from->si_pid, &to->si_pid); - err |= __put_user(from->si_uid, &to->si_uid); - err |= __put_user(from->si_status, &to->si_status); - err |= __put_user(from->si_utime, &to->si_utime); - err |= __put_user(from->si_stime, &to->si_stime); - break; - case __SI_RT: /* This is not generated by the kernel as of now. */ - case __SI_MESGQ: /* But this is */ - err |= __put_user(from->si_pid, &to->si_pid); - err |= __put_user(from->si_uid, &to->si_uid); - err |= __put_user(from->si_int, &to->si_int); - break; - case __SI_SYS: - err |= __put_user((compat_uptr_t)(unsigned long) - from->si_call_addr, &to->si_call_addr); - err |= __put_user(from->si_syscall, &to->si_syscall); - err |= __put_user(from->si_arch, &to->si_arch); - break; - default: /* this is just in case for now ... */ - err |= __put_user(from->si_pid, &to->si_pid); - err |= __put_user(from->si_uid, &to->si_uid); - break; - } - return err; -} - -int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from) -{ - if (copy_from_user(to, from, __ARCH_SI_PREAMBLE_SIZE) || - copy_from_user(to->_sifields._pad, - from->_sifields._pad, SI_PAD_SIZE)) - return -EFAULT; - - return 0; -} - /* * VFP save/restore code. * diff --git a/arch/arm64/kernel/signal32_common.c b/arch/arm64/kernel/signal32_common.c new file mode 100644 index 0000000..8fbb609 --- /dev/null +++ b/arch/arm64/kernel/signal32_common.c @@ -0,0 +1,115 @@ +/* + * Based on arch/arm/kernel/signal.c + * + * Copyright (C) 1995-2009 Russell King + * Copyright (C) 2012 ARM Ltd. + * Modified by Will Deacon + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from) +{ + int err; + + if (!access_ok(VERIFY_WRITE, to, sizeof(*to))) + return -EFAULT; + + /* If you change siginfo_t structure, please be sure + * this code is fixed accordingly. + * It should never copy any pad contained in the structure + * to avoid security leaks, but must copy the generic + * 3 ints plus the relevant union member. + * This routine must convert siginfo from 64bit to 32bit as well + * at the same time. + */ + err = __put_user(from->si_signo, &to->si_signo); + err |= __put_user(from->si_errno, &to->si_errno); + err |= __put_user((short)from->si_code, &to->si_code); + if (from->si_code < 0) + err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, + SI_PAD_SIZE); + else switch (from->si_code & __SI_MASK) { + case __SI_KILL: + err |= __put_user(from->si_pid, &to->si_pid); + err |= __put_user(from->si_uid, &to->si_uid); + break; + case __SI_TIMER: + err |= __put_user(from->si_tid, &to->si_tid); + err |= __put_user(from->si_overrun, &to->si_overrun); + err |= __put_user(from->si_int, &to->si_int); + break; + case __SI_POLL: + err |= __put_user(from->si_band, &to->si_band); + err |= __put_user(from->si_fd, &to->si_fd); + break; + case __SI_FAULT: + err |= __put_user((compat_uptr_t)(unsigned long)from->si_addr, + &to->si_addr); +#ifdef BUS_MCEERR_AO + /* + * Other callers might not initialize the si_lsb field, + * so check explicitly for the right codes here. + */ + if (from->si_signo == SIGBUS && + (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO)) + err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb); +#endif + break; + case __SI_CHLD: + err |= __put_user(from->si_pid, &to->si_pid); + err |= __put_user(from->si_uid, &to->si_uid); + err |= __put_user(from->si_status, &to->si_status); + err |= __put_user(from->si_utime, &to->si_utime); + err |= __put_user(from->si_stime, &to->si_stime); + break; + case __SI_RT: /* This is not generated by the kernel as of now. */ + case __SI_MESGQ: /* But this is */ + err |= __put_user(from->si_pid, &to->si_pid); + err |= __put_user(from->si_uid, &to->si_uid); + err |= __put_user(from->si_int, &to->si_int); + break; + case __SI_SYS: + err |= __put_user((compat_uptr_t)(unsigned long) + from->si_call_addr, &to->si_call_addr); + err |= __put_user(from->si_syscall, &to->si_syscall); + err |= __put_user(from->si_arch, &to->si_arch); + break; + default: /* this is just in case for now ... */ + err |= __put_user(from->si_pid, &to->si_pid); + err |= __put_user(from->si_uid, &to->si_uid); + break; + } + return err; +} + +int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from) +{ + if (copy_from_user(to, from, __ARCH_SI_PREAMBLE_SIZE) || + copy_from_user(to->_sifields._pad, + from->_sifields._pad, SI_PAD_SIZE)) + return -EFAULT; + + return 0; +} +