From patchwork Wed Aug 17 11:46:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 9285693 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 DCE2660459 for ; Wed, 17 Aug 2016 11:55:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0A52290B7 for ; Wed, 17 Aug 2016 11:55:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5109290BC; Wed, 17 Aug 2016 11:55:58 +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 E7127290B7 for ; Wed, 17 Aug 2016 11:55:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZzQG-0006Ni-BO; Wed, 17 Aug 2016 11:54:16 +0000 Received: from mail-co1nam03on0083.outbound.protection.outlook.com ([104.47.40.83] helo=NAM03-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZzLW-0000s3-GJ for linux-arm-kernel@lists.infradead.org; Wed, 17 Aug 2016 11:49:38 +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=YEKp0ul/TiH4dd11f3n1r/FprCgvw3Igld5XjsktSr0=; b=C5pPxQUfDtn0e/eHekkT48sboD4/SXv4BeuYBoNgL9ubNUCyYFY6VyC78ZItTHRIwPFB1BkZ0dRpCOZP0HPmcIrsMBfGY7WhDvlVINhebwU0LtwPnvDzdFwHkf6p66kVVte+fR0WQE+eSjrutshApe3tn9WsriBX9dGqnGElYh4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (95.143.213.121) by CY1PR07MB2247.namprd07.prod.outlook.com (10.164.112.149) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.549.15; Wed, 17 Aug 2016 11:49:09 +0000 From: Yury Norov To: , , , , , , Subject: [PATCH 14/18] arm64: signal32: move ilp32 and aarch32 common code to separated file Date: Wed, 17 Aug 2016 14:46:39 +0300 Message-ID: <1471434403-25291-15-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471434403-25291-1-git-send-email-ynorov@caviumnetworks.com> References: <1471434403-25291-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: AM3PR03CA023.eurprd03.prod.outlook.com (10.141.191.151) To CY1PR07MB2247.namprd07.prod.outlook.com (10.164.112.149) X-MS-Office365-Filtering-Correlation-Id: 1aaa820f-c05f-4be1-979e-08d3c6948089 X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2247; 2:E0PNUXhub8Ml56qiuoGg4HAHBNcmW68e0x0PpnqPzVkNaADoE5sxRc+fjjXcckLzdcdxcSDEz4KvvwcSH2ISzFeeHAbyaAxzivKsBoQm8Vt0z2nC0kOsUN3TMSUNhRoMd7G3McT8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OGJntf7aQuOtQIAknLy+TDKjXYDosWN3Uj4UN7vp4LphjAOYIwjuypS7H7rFgMmWi0r7/2zF2MY8Vra/G6QKkCawa0NHYl/RVbu X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2247; 31:2nrZufcy4kRT19n5wBQGK/lymvYZHw3BjrO04Hp9ScsQEtZbGweufsl1l0kgnmtJJVv7euAMfoiG+LqyLS1z9eo/FnxkXxuvOmHx5CSozPO/K5IvrWnuq+E7D651QzrSTEUY7oT90RFWySFQTNKdvr/Ll0DUCrF6A3iF2xLwVqjLSKrfLZRNP4mdUe0X/rpdKF50hzUAPOSsUaA/E8hFaGBi0dkubRDQnyTva3CnH8o=; 20:cN148PcihzH46URzkUdFdU75bKoAtKqKBPaJ4FN1YOurUm0ZYC6AGzGQtWUa3hEqKGZzW5IAHteux4MXAyI5yijZHzbnW532Feh5fTB7ZJxBJVkLbCRlWNki3DQFg9V+9qiApvAZcXOecv5M9jjWlajpx7+q5/3wqCWootxoAqAymtz5hKRQ5mDblv41+/6KePJ/z62GJnIVf+Zj2G+WwkzIuM4/YY8cV38FHr8NNqBXttpW84inirhd9gMxbzidmlbq+a+PT3OI88c37pvuMh3qeB1yhwRX/dUizq82jXMyJoMGHC8NCl5nzthlF6CQtmXDgSuT60UQ6daJVFmo1UuvZM1jW+16SRIcK4l3tVHR5XUfThrRQdRw5JoU9ysllxeQ4jrQ8/FcH9jm5v19F+uWpefdTcGI2dWPOu7axRpEj16CiKAH6OhiZIJSxPLjjp8WWGcoPvSAGh+9ML40QZYS97OAmEiMOMnSxuyVT2efSuwx+q1C679kSWXvDOYYLnUIfrJ4FzkYjIsBSx0apEXfVixWlk42Pn9W0qzuPXHNqcPbMLsnAHJ8VMpAEuH6qBSH1l53u493SEmdItjZDWyVYc63iHFluImzuEsSzwA= 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:CY1PR07MB2247; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2247; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2247; 4:ZGJPOTydY54XlqIEt40KjIzDgyaQxgi9veTFni5eLeKoipfAEyGJTRIeP3Nii/UYNSkblPUI80G5z0H19igeVNYRbA8JC8YjQfJAspIG832y1eTL6InPKaVLh3ncJMi3hDamujIybbsXe9H7TXDnHFusIFtmth3FHghiOQrRkD5A6+8k8UpqW7gjMCh34L9XNj67S1vCo+uTPiM9Cu9508ZaJyWcZfaLobVzaVjral9SuWiOfrLGAPh0NDeyXC32jCyuXYDMc7EFY+2FoRLut0w0zqumJODW0wJItzRC2C2pb1fJuK1m6hhKCAw7raVrQpEKCxYLq+K9CczgbmlNeCCYsek0DZzhXB4rEu/26UizKy9Ea6PxJ0d5GZJb8Pw3VSPUdstNiTWNasCX8ITpoFyce3Kim0GZEmT8RM9WRRGjGvtQ179NRI0psBwa9Rj452H47D+Ef5q5MS3OYDg/elhn9i3uNoXi8+njlIYkXlqzHSMzNsIX8sCMcP0oc8cyZVAFC9YUrWcbES4rmxh6pwu10/eoYbiLwNBATSMHXrg= X-Forefront-PRVS: 0037FD6480 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(199003)(189002)(81156014)(50466002)(36756003)(50986999)(81166006)(586003)(76176999)(8676002)(47776003)(66066001)(7416002)(6116002)(3846002)(48376002)(50226002)(92566002)(2201001)(77096005)(229853001)(2950100001)(15975445007)(305945005)(42186005)(97736004)(105586002)(68736007)(5001770100001)(76506005)(33646002)(106356001)(7846002)(7736002)(2906002)(189998001)(101416001)(19580405001)(5003940100001)(19580395003)(4326007)(2004002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2247; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2247; 23:unhfSCCBVupEGFNVFtrVr+9S5OQeU6yOEmiy4asP8?= =?us-ascii?Q?IQy6UhFlp7lDI/uWlicObTCQ8ee4qyDkJYc+0sv4bdxdRrrD+gMy1Xv+imDz?= =?us-ascii?Q?8I8X7Z+lnRWdyVjLGBdY1MHefLrRyz7Cv7PVESob6h46/0eNgMcDoeWQI8Dg?= =?us-ascii?Q?EdXrKJU8tPFn0MjquuVAtV5izNuAIY9xLKXt+uEABcZhrFIX8Qp/fDAp9uoV?= =?us-ascii?Q?iaMn2/9WUd3oPpZNodaA9YS57yNTs5WQPmO2NU0f2jPss0JPJDsdbhv1JpTM?= =?us-ascii?Q?1/PHYWrH/O0GgxdvTFzr0bLcnLCfSRceQO+yxZnRKjKTGUTKCk93ViMagOsp?= =?us-ascii?Q?amHh2a90rNH+lK3z+YbTUiwSqbzAXXZfMUcwS80WZb/M2D92+/32w0dyjngu?= =?us-ascii?Q?MwAFKyc2qtYpK/zjv0sbot+QiZwGZIz3QhTGxiLri1jQXahCfefxkxDa5Kj6?= =?us-ascii?Q?OOWQtA4H7SQjRYWGsWwpEMiqdEFIKEOY4nTJgIcOB3pATCjDjCwmsmPen0kM?= =?us-ascii?Q?eITtZqTUQjipgXIqxfNq/1dBFiYGrlTIqdoRt81PdtRveV4o5DHoxxiRA5xW?= =?us-ascii?Q?RRR3+pBCDZY7+B59byyAzZwS5Cl3K9ICL8/1rzahH5yWtBVKdzIqdpAElDRR?= =?us-ascii?Q?AOtQ0/kvLjphnQHEoadDVUQ2fO/VjMZdo1YRu+jTEvw7lfwjQMPd+RDADnvq?= =?us-ascii?Q?NG8RKtfxCQNZnmnACtIeMYycRxsA1KTP/rZb0uz8mm+A9uGjUYEa+GC2xRJJ?= =?us-ascii?Q?zqo0tMbbYbGHaDXDMfEpir1mDosOWCliewWwlVY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BkfZlAdf11F3Xp4KsOo4=; 7:mWMD9Zq/4c/xLRSh3sXHW5ma6UTPWiOcrcRnXDOAyJxZyb/6Yj53OFr5fVQsnHr2Wrj7GBqANXXxUPkt9VY2YvoAQLeN33k+IL0cqQoL0ZOcxuixtSEdyv7DarpI+S2aY2l5aOCQIacIVAYLjsrI6Sz9EDtZybLAHE/T/JzCWdJjM9mV7YCvwSMw1NKjkXZoQXpFExffpz2XB/lkXSqMqwYcpbbkjWqyrtpZyHYgBDA9Q+uNXFWm2r3e0OgbiJJ9 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2016 11:49:09.8807 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2247 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160817_044923_510554_7DDA0FD1 X-CRM114-Status: GOOD ( 15.42 ) 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: szabolcs.nagy@arm.com, heiko.carstens@de.ibm.com, cmetcalf@ezchip.com, ynorov@caviumnetworks.com, philipp.tomsich@theobroma-systems.com, joseph@codesourcery.com, zhouchengming1@huawei.com, Prasun.Kapoor@caviumnetworks.com, agraf@suse.de, geert@linux-m68k.org, kilobyte@angband.pl, manuel.montezelo@gmail.com, pinskia@gmail.com, linyongting@huawei.com, klimov.linux@gmail.com, broonie@kernel.org, bamvor.zhangjian@huawei.com, maxim.kuvyrkov@linaro.org, Nathan_Lynch@mentor.com, schwidefsky@de.ibm.com, davem@davemloft.net, 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.h | 3 + arch/arm64/include/asm/signal32_common.h | 28 +++++++ arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/signal32.c | 107 ------------------------ arch/arm64/kernel/signal32_common.c | 136 +++++++++++++++++++++++++++++++ 5 files changed, 168 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..e3e2d01 --- /dev/null +++ b/arch/arm64/include/asm/signal32_common.h @@ -0,0 +1,28 @@ +/* + * 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 36257b7..20e8e66 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -28,7 +28,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..4a45aa6 --- /dev/null +++ b/arch/arm64/kernel/signal32_common.c @@ -0,0 +1,136 @@ +/* + * 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; +} +