Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755599AbcJUUvB (ORCPT ); Fri, 21 Oct 2016 16:51:01 -0400 Received: from mail-by2nam01on0089.outbound.protection.outlook.com ([104.47.34.89]:31117 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933111AbcJUUug (ORCPT ); Fri, 21 Oct 2016 16:50:36 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; From: Yury Norov To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH 14/18] arm64: signal32: move ilp32 and aarch32 common code to separated file Date: Fri, 21 Oct 2016 23:33:13 +0300 Message-ID: <1477081997-4770-15-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477081997-4770-1-git-send-email-ynorov@caviumnetworks.com> References: <1477081997-4770-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: AMSPR04CA0047.eurprd04.prod.outlook.com (10.242.87.165) To BN4PR07MB2241.namprd07.prod.outlook.com (10.164.63.147) X-MS-Office365-Filtering-Correlation-Id: 5307cb77-f272-48e1-f1b1-08d3f9f1dccd X-Microsoft-Exchange-Diagnostics: 1;BN4PR07MB2241;2:OlMijnRz40PsoMvzCJhk0hmqC6zmpRU5lRLVYRd4oMu75n6/fMTigY4XKL3DBeu8AbYCTvf9BTlTKfhOQ4JKLlnYr8UwIZwOkYR9nexBkHJg2huYZRHP1VBAFu3Rvdsut08F3eNli3sE3OkhrIbSKicRlR8fBkbIzWT9Q1eg8PPreaUgSDndrx0s4G0GK2isJgxI/TFPNsE4QYIi03VhSA==;3:OeoVVvDPtgMmve1iS52Dpzv8+OtgQqAlg6rPdyAsUJc9sE8G6yY80kQ/E7Dr1JGTb2SVgY/a1PE25xbc7TvLsJbfyGqBB1U+EqUtYWbsaJPsX0B548BsQOCLiZmES12uV/htk4GRLv7f/32EuqWDsA==;25:P/s8vch8Hp4yIvOfzxjdaP0hv5LoCIi9QpSjmVQt/+NTAq3SaPJH3+X9qW3Nj3v6cN3OEtlOOOcOHN/V7VFwFLZ5A/NaObzaLXaUVu4WwjSb0Yo9SDF7EbP2fkQ18daZGSYbXSF6K8j7OMFJOE6IwowBuXMot7F1UETthS2i799dJMVV2pM6rckBB9owCfC/pYKe6ZI4OLjtK8G9CoizeNwraMZd59g7c47MTmELBL1CZArFG1lCwAgs+7OisVGgEBAMU8ILM1RWTPMh5czufSzXkp336TCYwopDkTd3IqGEy6I9xsb5Q6y2GmY27MC5WY+C3Bbp4wR8tVIUffmoYOzWLDHsmjoaj1Zjgm7ZSTTQbbSaCDTANFN14oHkOgo3Lt5bHV0I7d4hKKy9sqm4vSL4xoJTGlpYkASZSxAdYbEWmXdlZPwGl8A9cHlruR3f X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN4PR07MB2241; X-Microsoft-Exchange-Diagnostics: 1;BN4PR07MB2241;31:Cv4V7qQATQETQuqozRqAdzx0Dv9vw0Y/D43//LHVVssUU8BdnlVjLlSgsjjQ/dbwLpTGVzdcaQNkObbPcnRM4sx/RJX1bUTagqsAntJjHoqDVR/RvMGI/trN0kjHq0Hx/Bpdi/bHty7cin/DModTdvdVAaDax0nzH/9uaZifyj04gQ/iKMi6KiEvFzDMmu/ZiDrWrE1Bi5LjWLB05CcIvTrh/Kbu92RnS/q6oiQhCp48omXiw2Fue0NuU2CKk4lGxuYRBVExHO5ZX2AIGe03wQ==;20:oTEBm9YH2IFpNyRngfDdqADMdTVqp8kyNmxVskyO2LKYrK2UWmxJIlPry5Kknh9P/58TEtX04Mk8twM0LKcyt+C3I63BTjnQe3B+1tqdOqmXX3vXmMLM3n9zqpcP+bPETcDDg5tBKb9XQFgBae2Ak6DJDOcnfr+5z1+5OG7QKrWRyjStuekJQdM+l3DXjiLodWn+zl6bR7MOSjd1DMN160NV7Z7XIFGtWl0RWzc9e1LPKguKJr6zrVMxw3SIeOR+2jxymAq5i+HL6jTtAr4I94Bz3jsAjgt5Xivpj15h3DXrExWSKFbZ7F6A1oEKWzayxdFAPwKkO1hyOlkJ0FlXaLgJPvOfE7javY8zHVUbyopbLXGG4IshAIneskJotcH6f4yZ/iwCgb6DX8nwHXP0fsyJSizs9+OvfqazuqK4SMrIrpohoET2S2WYwF0EXasipH06QUzzY4vwEg6h6MYUc6fHm5EoesZWVSWIKOl19Yszd4/8+rysTUOXGG0i1WTK3oKtirpNixa4ixt140ab3uBvQrESRygPEdR/eMC9DV1r0Tc4+ztLV46sAdSkuG67q85Gt9wB03kT6e1SSEv7BidCb/NHbd+LmPhmwjwiY/I= 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:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046);SRVR:BN4PR07MB2241;BCL:0;PCL:0;RULEID:;SRVR:BN4PR07MB2241; X-Microsoft-Exchange-Diagnostics: 1;BN4PR07MB2241;4:tJoJpd0agCtZHcde7At6QCWPGHDXmliurUfodVquepfrvIgiqsvtsm6RZXynKcwrhy+VYfV/uE/2tVTY8o0IJwGlEDxXv6uxXiOBceZ7KRn5Wa9JXkL1916FHigPqF20siFIxo5kUdWGlBQiEtsNOCyFeLKVUfvGk61SG208r/1JfaiG7a6jq6Wfjacyvbjy536vkTAPSAWMMM4n0G0I4SPj5iAea7MvQDY+QBOI/TzqjNRIiSXmvOsWzAuoRfvFdeMfnjViD3s8p7d5dbBfuINblZuFoxeP3lTVWkn7Sq2j46ChHupZQRVBjEs5PgM4PStREaC7sivFT0sRK6cOjppVq8ukTXTB/Y1uhhSyOJz0twTo99C41ioVJTrInqCe/yERZF2NhyUeD4qAFYGcN76m+zkjc5zbm6PhtURBmy2vkSpyVXUfjNZHnhENfREG/N0Hv1Yis8GDEZmco8e6A+2YOlPD/e7PlUMIFooCw9E7vxZcSNlSLVnGrJq+y0yKica4/bvlwfSg/fjDnQmThD2u+JBCDpBuEL4NQN9MCbU= X-Forefront-PRVS: 01026E1310 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6069001)(7916002)(189002)(199003)(2201001)(7846002)(81156014)(189998001)(4326007)(5003940100001)(76506005)(81166006)(15975445007)(5001770100001)(101416001)(105586002)(77096005)(97736004)(6116002)(305945005)(8676002)(6666003)(7736002)(42186005)(3846002)(106356001)(229853001)(2950100002)(586003)(2906002)(5660300001)(19580395003)(66066001)(7416002)(48376002)(19580405001)(33646002)(47776003)(50986999)(68736007)(50226002)(92566002)(36756003)(50466002)(76176999)(2004002)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN4PR07MB2241;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN4PR07MB2241;23:v4jfqbWVR4XblCHVkoWUPdgzGWTZFlOeccc8dk9Im?= =?us-ascii?Q?MMglbUhW+VOizDU7qRG+N7ZeYSud3hNijoMeSyJpwGpxJpLsuFWu3qZK55T1?= =?us-ascii?Q?TvIzrWkUjo6lJGOyrKyrjW8KZCxwoW3t9C4KTYh7lRgEayjgvHDsobavCpmZ?= =?us-ascii?Q?sB/GNde2wG2LNvSLi2ixFHbStgBm5jqZ4BbKqcQUvjirX3t3IFO+u7tOVrSk?= =?us-ascii?Q?q8HFP8ztLYIUNJ7BTahEOUs2sXvXvpZUKC5wnX4i0mOAMjNEoga7kraL3AmG?= =?us-ascii?Q?xysJHfJX/lSLMSvsR8NgIeD1ov7njesRopRP5ChCiwsmvNI1iBao+XKdUaiT?= =?us-ascii?Q?jaxpnkajnlBIiOPd8gmiJ3IFUnaPQ/Z5rsqS7Rm4FtcPpU42C/w7JwxEbbKb?= =?us-ascii?Q?67IOEPuh3Xmg9SpZZ2xrcaG6YUadGZ0+LvICzyliciSGIk31GmG5KUOp3WLB?= =?us-ascii?Q?sdweeP5foEWOvJLcPDCJQpoUioBMCZTSr34beuKKrC7T1DC4xuZ7rpAaRacc?= =?us-ascii?Q?VV6tS+4AlqBRNPuN1Z9PxClyUvsn5PsloXabz9i2gAt3Dcpzacr7I0gtlb+c?= =?us-ascii?Q?Y2C5R3NjzalkgptL5XkYrf+4X7Xt/3zygewGhK11aiYR0VOzE6Z96PjGju1l?= =?us-ascii?Q?kExm0oyAuADhpbD8u2KOYHhfja+pzc3cyN846juINnIqOomR2y0JhxgUJDKN?= =?us-ascii?Q?/Toq77KASnscZPc34S7sXDpskMw0uAdSToV1aC4+6RAiHa2RHdgQcrHpagvQ?= =?us-ascii?Q?5cldbvQKooyW+td/3iCQmsT8N+ZhdD4gi3nD5dNs6bx0sdQMyLq/Q724lgX+?= =?us-ascii?Q?Rzvp6//VRs7fDHV+StGUpnDrQV0NsdgfJ2ICejGkdgvM07sdZ05JZzhpaK0F?= =?us-ascii?Q?Jym89OEfReKkLxHrzvq59WgWYu1DpjqPdDxQiMTJSwYkNKD8DKhefrW6vHgi?= =?us-ascii?Q?9bvcm12wP1WjuDUAq2bvpgpY/QLmNEcsgbbt11QHLg/P6O658gYAKeWojhJB?= =?us-ascii?Q?mQwZ4kg1b1Wj823x+wHGC6PftG2yA/N3lwLqAJ6BKlML3K5XGNKcQ9Jz0CRH?= =?us-ascii?Q?jPwnEFGaCG3Rumw3CNjv9DDDc4zTUDd15Fps0Asw+9ghNvI2ljcKORLRCAMu?= =?us-ascii?Q?r4nWlDf+b3FKHVIlUmPS8OAMJF/oWu0XonSLanvqiNGP4EIykjuEHgYTgTWF?= =?us-ascii?Q?PVITk9OQO3bEi7MaMEbcZeyf1XkfHPVtG6YlhCovPnJ4BdKgfpPYdjLVA=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1;BN4PR07MB2241;6:zTyr2dno7Nc9LGa2XY3t48n1+teEI8Qxpt4lTIxlj8XdfsNEbTLkUTgBjQJGECr5/M0fvTT36pX16S+5t9QZbYTWcixzxwAydNucgz0zKUOZADGZlFGbVMKuCQj+dRw6U405XmMSXPjx2rOxBeKpNFRc9Z+2mi3G+/An+iMUw1jGG09RSlf6QuJd8vz10dsMrrW168bUM6PfYeYrbxZpmbbQA+gUHEpDEBa/rxwAZ079H1E8dLIf0mdYBnuZWPdaCSh968oKYcqW81EEv8gNTNEqpye7h15l2pH8GryCeLKvW9brqjSaTh3lNh8Sm0As;5:P9JXfhozYllWoxuwBP4dhVApn7yQRaoAbpNac6YsvNMNvXHLY7zqzqVf9WEJkLTIpPHfW6w7X+rtV8BYl8L8hnpE4RBGvMR5fNThhbbDJk8062RpV0qkkDegAOOYn4wF/5mD2/GDrsBYj+n65ghtOhczO2lqiwvow6jSuyMWjNE=;24:0PdGXvNk7HQkUZoL4iEC9gs30h9TJxc+MNQm6DwMHM21heTiKOvsWn4cJ8QWZ9MwXlxpwA/Wlf1Sr5Hwm1mzgvS5hGuJxHmZ0Tp8slf0HZQ=;7:cp9Wss/pr1vpB1MXgbFghM2nsrTbQ9fwD/e07C5cOasX8vdRcGSAooLsenulItyOTpyjfePIV9dmYCArroqDIYMBjSuDDKrWUwCuyhhHCUnty4OkJhbvwvfh6VmRDNjKLGifGhveXevDHjFnk2uZbUL5IYWZLCG+4OnFr7f3WQP7osXnTNy2i+SbxfWz2WI1OEc+eZYoaS7ONZxbtqu6RHxOci+bIh+HC6JEP3lAFR+dgxjvna50RAhhhgKP1CxVO5qtooSRJVwHhnf+WBUx54teOAl4FBlXsCeQQFqNvcLUMs1hAKrYlEw3L7B650T4rSQ1TJ44ovb5q08ILYElF7qGvdNWOMnIqvvAv6eFflE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2016 20:35:57.3708 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN4PR07MB2241 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 11343 Lines: 332 Signed-off-by: Yury Norov --- arch/arm64/include/asm/signal32.h | 3 + arch/arm64/include/asm/signal32_common.h | 27 +++++++ arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/signal32.c | 107 ------------------------ arch/arm64/kernel/signal32_common.c | 135 +++++++++++++++++++++++++++++++ 5 files changed, 166 insertions(+), 108 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.h b/arch/arm64/include/asm/signal32.h index e68fcce..1c4ede7 100644 --- a/arch/arm64/include/asm/signal32.h +++ b/arch/arm64/include/asm/signal32.h @@ -13,6 +13,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + +#include + #ifndef __ASM_SIGNAL32_H #define __ASM_SIGNAL32_H diff --git a/arch/arm64/include/asm/signal32_common.h b/arch/arm64/include/asm/signal32_common.h new file mode 100644 index 0000000..36c1ebc --- /dev/null +++ b/arch/arm64/include/asm/signal32_common.h @@ -0,0 +1,27 @@ +/* + * 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); + +int put_sigset_t(compat_sigset_t __user *uset, sigset_t *set); +int get_sigset_t(sigset_t *set, const compat_sigset_t __user *uset); + +#endif /* CONFIG_COMPAT*/ + +#endif /* __ASM_SIGNAL32_COMMON_H */ diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 06070f5..fdc0052 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -30,7 +30,7 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE arm64-obj-$(CONFIG_AARCH32_EL0) += sys32.o kuser32.o signal32.o \ sys_compat.o entry32.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..f2c1a38 100644 --- a/arch/arm64/kernel/signal32.c +++ b/arch/arm64/kernel/signal32.c @@ -103,113 +103,6 @@ struct compat_rt_sigframe { #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) -static inline int put_sigset_t(compat_sigset_t __user *uset, sigset_t *set) -{ - compat_sigset_t cset; - - cset.sig[0] = set->sig[0] & 0xffffffffull; - cset.sig[1] = set->sig[0] >> 32; - - return copy_to_user(uset, &cset, sizeof(*uset)); -} - -static inline int get_sigset_t(sigset_t *set, - const compat_sigset_t __user *uset) -{ - compat_sigset_t s32; - - if (copy_from_user(&s32, uset, sizeof(*uset))) - return -EFAULT; - - set->sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32); - 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..c8cba96 --- /dev/null +++ b/arch/arm64/kernel/signal32_common.c @@ -0,0 +1,135 @@ +/* + * 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 put_sigset_t(compat_sigset_t __user *uset, sigset_t *set) +{ + compat_sigset_t cset; + + cset.sig[0] = set->sig[0] & 0xffffffffull; + cset.sig[1] = set->sig[0] >> 32; + + return copy_to_user(uset, &cset, sizeof(*uset)); +} + +int get_sigset_t(sigset_t *set, const compat_sigset_t __user *uset) +{ + compat_sigset_t s32; + + if (copy_from_user(&s32, uset, sizeof(*uset))) + return -EFAULT; + + set->sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32); + 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; +} -- 2.7.4