Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933760AbbLOVvG (ORCPT ); Tue, 15 Dec 2015 16:51:06 -0500 Received: from mail-by2on0096.outbound.protection.outlook.com ([207.46.100.96]:52373 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932469AbbLOVvE (ORCPT ); Tue, 15 Dec 2015 16:51:04 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; From: Yury Norov To: , , , CC: , , , , , , , , , , , , , Subject: [PATCH v6 16/20] arm64: signal32: move ilp32 and aarch32 common code to separated file Date: Wed, 16 Dec 2015 00:42:42 +0300 Message-ID: <1450215766-14765-17-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1450215766-14765-1-git-send-email-ynorov@caviumnetworks.com> References: <1450215766-14765-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: AM3PR01CA028.eurprd01.prod.exchangelabs.com (10.141.191.18) To BLUPR07MB611.namprd07.prod.outlook.com (10.141.207.16) X-Microsoft-Exchange-Diagnostics: 1;BLUPR07MB611;2:V6u1zllZS0b7h2fUHr55uiFpZ9Vm6KWsCMAIuTGGFVWYoMJhFnylyXrLA60eLOKe+n0t/Rqqc+L117dj0JiGR32bxW37jxyKLHNrtJJMjfBrInnIaosK7KvA7JUl6O+hhcfR5xNyupP3mybtyqMrqQ==;3:fve4uDjqh3zLOVb9aBGOw9aIfmhz0KtOcjFp2RXQ/ljnkZwQp0YwwHlRVYx/Yyu5z0puJz2LReyoms1xVT34LlLxdE/4ChJBjmWUak/pIRTdl2bPwzD63dd0hdR6KpqF;25:HiVdcn6WRXYIsz6MpXC3pbAO3VfZO5WkQtro4Zfbua4iGlTMkPYd8CYOpjinFx6JUiDx/JEmOfLPGLsesOZ1jNsN6x53bwwDJsikK7DydLlclU4k9CwunAuLgSglSkQbX0NoUgmvkvF5Ixh8+3l8Wrm2C4RwbqnfwVXqOoAvyzQaOCs9cBw9tgYk7ZNR7PQSgkq5lXrDekdrydwDIVuC1jFISZOB0BfGnDpdwGK/UTYWQuBQL8SAyNdRnov5RMOHw2bbph8U13i8Zg9iL7/dDg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR07MB611; X-Microsoft-Exchange-Diagnostics: 1;BLUPR07MB611;20:iwgI9pmbcCwgnuynOra1f2t7MExquX9WPqzLdB0Ni2daEJ4ZTWrXSXi7+6sq93uOtFttWiDPetiPeXSx6IJBisvmYJLjvl0oYDyBDm/Ts5cwddwrCeIFC9/aH9ofjs4WiSZKDaiNMYBvF8l7PiVprc9X6Nc+Pk9I8RgQgQYCgVQTvwHW/odpWPKY9dsElQ9FAQe3titGz23fYeRUv82Bxqybf0oOk0KMNxLsZrejZuh7vGgqTLbBR0j+dAcjvLRs+BZjKECK6S0rfyTANADTm61KLoPI3jamer+e5uwziBOwmvpvurH+tPrM5el59kWS5369ONs1d61iKe1O+hoZs/fIWiC/Z+tY/sF3JP74+tXdx0q8HOVxU6idQ8y+/1bU/duqbM+x/zt36iqF3XuUSDoNZJfQZjjA2wtcP8US7WtRODjoyMmeY4xa7jFja4gtg5q8paYgDbQB0v5SoepfV3NwnlZqvgyP2eNVHogKs3r/rviDqmhvm1zmE+8FtgUT23w6DLMQrekvH3iBZOfijdzL/eQn72B1GJ7cWk4ACT6hE3eTvRDfW8m0CIO6bipJqmD1KPC2nmq20w1jcwEejW8N8Iczsi+FVCcyHvIBXxE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187)(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001)(10201501046);SRVR:BLUPR07MB611;BCL:0;PCL:0;RULEID:;SRVR:BLUPR07MB611; X-Microsoft-Exchange-Diagnostics: 1;BLUPR07MB611;4:rKpdaFCj2qoDUtPKLVD9l9unXSn+R7+VqqOtqzKtUsYRyQ4smi4RcSimz/eyhVdQOHI+RTLmqffc0ee017IyrLhiIDMsQTcjXdAFEtNAUyAukQjtnd/lxgbcBUAzffhk0OksuMRJc5NNKjiOFKxbXVp8ZmDPU/DwOHbfZ/p8fYEVPJNzdSlBNQHDjEONK7IL8ps9uMirlE25Fz6ryjmVd/QnP/9jrZy/t3bFw8L+Mxr+aqIVx2pwxYs3i7RzQb5XtfiUMPZra4Wr4iMnOEWcL7c6/WLiFKVL2tAoh7p9lIU2+LRSxinjMRLlCQS0GFlyr4/gBidfiWBF8j8KVi7p4HbOR6hSnmP/YNoY2MJRa8PI72iHfqWxTK7LtzQ1t+aR9FjYTwt2QLy2Gcgjxm/RcNjLLTL6Ob7XirTX5Nd1a83bHv6u26+c13ZguJQ4zrjYP8JWOUayLhiNSpadPwJ26Q== X-Forefront-PRVS: 07915F544A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(6069001)(189002)(199003)(106356001)(76176999)(47776003)(3846002)(5008740100001)(5001960100002)(5001770100001)(66066001)(229853001)(81156007)(87976001)(122386002)(97736004)(92566002)(19580395003)(1096002)(33646002)(6116002)(40100003)(586003)(5003940100001)(189998001)(36756003)(105586002)(2950100001)(76506005)(48376002)(50986999)(50466002)(77096005)(42186005)(101416001)(2201001)(19580405001)(15975445007)(50226001)(5004730100002)(2004002)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR07MB611;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR07MB611;23:WSwLGAn5t7JmQymMPMjCPegWMfn5pgAN5TGDIBVGEp?= =?us-ascii?Q?aegk2fLquymsDMwL7eWHcJKEHIlt1LjocwW+Z3Cbfo9/3xM+cFgkjDrq9Dip?= =?us-ascii?Q?V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IPdNHxOrvoU?= =?us-ascii?Q?GlQVW07NOgaWtEB8AwIlvn1ojBC8ptjCgA1fIf7wEkZZr4Sn4DMuDvGcPGn0?= =?us-ascii?Q?WsBkYaZi8fD8qoz+jcyOv5p0BLDJtqlsbxUB916HjpfzcUr4A6PCr4jQq+IA?= =?us-ascii?Q?lyZcy0tDKSag6LEl2mHfw5bXQadfYu?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR07MB611;5:EJC8RqTip7YytnLTe9swWwCd2qkb/Y3nmQ4AVM7TvC0M4IO9ktKaNBZfhT35dS5qYmC+2miNhKCdlEaVNEpGZfiv6MTaALJPT4aHLH76jojPf/ojgPIj8aPEvEsvVU4obQMmU8l1GlhocvBZklIlnw==;24:XsXpKbXE9Zip2XkOfDh+jpJZHIdsDMOzBBy5cZ7vmcEieuLzwVYxtnCQJxNdiBFd2pcifB4n0ILC6Irz+c4PQ0e8Iwl5VNuLwn2tCbO1KVI= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2015 21:50:58.9171 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR07MB611 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 10077 Lines: 285 Signed-off-by: Yury Norov --- arch/arm64/include/asm/signal32_common.h | 30 ++++++++ arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/signal32.c | 85 ---------------------- arch/arm64/kernel/signal32_common.c | 116 +++++++++++++++++++++++++++++++ 4 files changed, 147 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..37a3a3c --- /dev/null +++ b/arch/arm64/include/asm/signal32_common.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2015 Cavium Networks. + * + * 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 __KERNEL__ + +#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 /* __KERNEL__ */ +#endif /* __ASM_SIGNAL32_COMMON_H */ + diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 94b8b84..f90fb08 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -25,7 +25,7 @@ arm64-obj-$(CONFIG_AARCH32_EL0) += sys32.o kuser32.o signal32.o \ ../../arm/kernel/opcodes.o arm64-obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o arm64-obj-$(CONFIG_ARM64_ILP32) += sys_ilp32.o -arm64-obj-$(CONFIG_COMPAT) += entry32-common.o +arm64-obj-$(CONFIG_COMPAT) += entry32-common.o signal32_common.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o arm64-obj-$(CONFIG_PERF_EVENTS) += perf_regs.o perf_callchain.o arm64-obj-$(CONFIG_HW_PERF_EVENTS) += perf_event.o diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c index 71ef6dc..2a69815 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 explicitely 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..446c7c0 --- /dev/null +++ b/arch/arm64/kernel/signal32_common.c @@ -0,0 +1,116 @@ +/* + * Based on arch/arm/kernel/signal.c + * + * Copyright (C) 1995-2009 Russell King + * Copyright (C) 2012 ARM Ltd. + * Copyright (C) 2015 Cavium Metworks. + * 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 explicitely 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; +} + -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/