From patchwork Tue May 24 00:04:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 9132581 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 39F0A607D3 for ; Tue, 24 May 2016 00:20:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DE0F28237 for ; Tue, 24 May 2016 00:20:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 221C028252; Tue, 24 May 2016 00:20:27 +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=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 74F8628237 for ; Tue, 24 May 2016 00:20:26 +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 1b504K-00027j-88; Tue, 24 May 2016 00:19:32 +0000 Received: from mail-by2on0076.outbound.protection.outlook.com ([207.46.100.76] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b4zrt-0005wv-TJ for linux-arm-kernel@lists.infradead.org; Tue, 24 May 2016 00:06:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-caviumnetworks-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=nOMpsplU4cwA54BZr0q7FXWWTacGJEBW+auHUEIfM+c=; b=Dfjl6n1CzzsNHYINMvMPXNvnjaX2DBpUcQKcokSvG/5CqJmTAFotQXaH1ftkCJUB3QMERnYPiP0MrDe4Z/jX/0ZauAEbd67GY2NdqUe4FipWGfbtdxHs8PdM/DqfwHfQ6XqeHlTxIpGq4K8t1WCEkBLk3kZM0wHR4bIeGCJuf5g= Authentication-Results: arndb.de; dkim=none (message not signed) header.d=none;arndb.de; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost (50.233.148.158) by SN1PR07MB2237.namprd07.prod.outlook.com (10.164.47.143) with Microsoft SMTP Server (TLS) id 15.1.497.12; Tue, 24 May 2016 00:06:19 +0000 From: Yury Norov To: , , , , , , , Subject: [PATCH 20/23] arm64: signal32: move ilp32 and aarch32 common code to separated file Date: Tue, 24 May 2016 03:04:49 +0300 Message-ID: <1464048292-30136-21-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1464048292-30136-1-git-send-email-ynorov@caviumnetworks.com> References: <1464048292-30136-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [50.233.148.158] X-ClientProxiedBy: DM3PR13CA0023.namprd13.prod.outlook.com (10.164.193.33) To SN1PR07MB2237.namprd07.prod.outlook.com (10.164.47.143) X-MS-Office365-Filtering-Correlation-Id: 6efd1f0a-3687-4047-411a-08d383673c08 X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2237; 2:Yj6jCX5dQHcIhomYV4Uq3v5xoBzVnpXeTjYhDevvpPegMa33T5ZqQmbc4Zgg7pKl5SmuTBmX04VgtwBfKvZjfYD1hAhWSya+F/08Yfv2lVeiTXMem9M181YXF/eAYKbk1gQSYufn2UdVzzxsl/1J3z1do4Igyi4KBf7/88uAChH61Mr0lL/hw4ADxF9YLo2G; 3:1oC8tVbN24o6nxK8y0Gvgav4UBowmzZkhv6qQ36pFiy/Lepdj4wo+m3wOOMV3/mwskxO6k9YGHBBdcmbuhrwNvMghWrpMyPIhYMF2KQZ7wwFerjOkgg3go5aZPfa2xyq X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR07MB2237; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2237; 25:0ZsLw80tM60uyW3pGhWrrOVH995w2eF44xcBNWQ916sAHy2VYPgJKesk8ptjBld9lVKv5jZQvpqTb24ifOqkyL6djYj5OZmIRRtxPHgdw4fzYHFRZVk/WlsF1zTHBER7EvBQhymj7s9muXsVUnV205TB8ZB9xzsZ0ZBkD/vHzIH+Eqq5feqiAugJTldpIFoXQJHKd8wr96U41cllVpdQLrRd6R/tzR/PuDtYbFdDn9BlfC9g2s0o/2IQNpXuHPaBVE/D3MWvsfhVDqgV5bdb41WjwcWAy9K2Ap+DggWYmt7nR1vprFMNDGuCkMBDBhjOMgmtIoqGvoE7sf4bg/79LkFuWXazFL32MoneXNHaZooT/i1BOP/uXaMAd0sXmul1ORqBwVDMfdakNPES1GwIsMDL/8R1kuI+U+ZXc19R6SezEEED7En9Ljx5ldVxQs6UP1d3nluizYD7BftZokjDOMUt1P8lNB8oHqcBymWDLrqftlwjegw+yt2O+1y74ui4QJ2oJ0PdrOqcy6HFkgGniyCz3s2R2XzFfKC/TMpYkXwlaQmGP5Dt2uWiLQwXDJGt77CV5sXpqBbX2KAsTsfG6uhHVucEj8tSGBeQMUNp6uU9W3gMdUcVc/vaTE62ktRr35FfVFZ4bzMkCJbWisWudYw8aaZ8EaT+FPE8GLcSSTWxkpgh7u7ekNFITcy1ot2sFQksYzEvhiEhwmq0gtshb2eJuqFuaFLbAacWUYiKJieipLix0Ls5/Uo4kCu5avtjYOx38109o+4AXubed8p86Mq1oE/6FCn5fDUb98MCuHeyXwNUJXJeDSR5zW/0BMyDsZuBNobjX8pTsuHKYGqbTu/8JpBofQPD88Bpwz9r4/gD+7kpGKEgy0KP0qi871YN X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2237; 20:SL8SyYo0CGZJ6qti4U8CaYobh+Z8IqUywDY4jnO91nhh5hv29fTAkXBcWdmkvunKhxOpcTVYwwOpRHkhlF0fUNQyxY9NSWNwwQobNDPsOx3UykfO6tKnKJ5mTnHvDeYUoDVF4TXUsiiMkdhAH1oeOnFA8kLPq2O+4N+NvciKTPw5rOdRshuVr5xcIddVpSh80letqk3xET8pIcdKiflkIbxVon/S9+Gp62KR6+NvM+hE/qTgFGt18CrajVtdHt2QOdDHtQmnp4U0AA0x4EBH2YYIfQlp/Ktrb8JTaARMV+JOOTuMoGIxf0rjSGkCTLcDEdX+fvJo6zw4g2bWiSeTwM0VxyoAHjgk8M6b2vdz9EAMxlXVVaWyYSVhOREtJBmXf4v8Vf7GXLQaAsIGGwE7+s4Hc49URk2GSqWasLG3hshXsE07u1zbxf6u8pVKnTQFfr12Ek50pz/duMAzNZQ1ERbSIP6oUFBlgpIh3bbW6DInYBmqRrgJRTdUZHS4Wp1FZ3vRu6nX2vWpCqUT2cWV8uf5NwvwiKUbsBQbCuJUbQ0XRcVOJw14A/ZBiF38Em3vfda1g7nWvEzpVrZnnwBHdou6JU+/84IeoP5b20oOmKk= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:SN1PR07MB2237; BCL:0; PCL:0; RULEID:; SRVR:SN1PR07MB2237; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2237; 4:jMxi+J/90Xx3Lnc7yeM4RiANqiT31NWu9m5XrYB24vEjGANgSwtGWDdvauvYI66Jn4XkYH5cyNYK+J+A1wQrwezYpe3aZ1MLM2tcWmjW+jINyMLRYIbkAJYjMoJcLVn6Eqen0bhkyTZwkdmG66qhrpr7nYz3CX8J7L0ZIew70jrFOAM5Ylf42iKVj4T7oPa00T9JqPpzdhKNfFrUBQZArlNCTkFszrgHpgsiKYGV3ONy/yQja0CAB7+RuA/46z2i258Q5kpog6DPjOVE+JolRdc8lH4qFDDcJ6zuUiZkyQELh4k5TnhmMBUtDqpv7iGQuDNHQ7v6IkPdPss0K3Cb20I6iheJxZIvgZtCbJ9burynPNFSdHFhhvS9PDJqPMmd X-Forefront-PRVS: 09525C61DB X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(19580405001)(19580395003)(92566002)(81166006)(5008740100001)(586003)(47776003)(189998001)(8676002)(5001770100001)(36756003)(4326007)(6116002)(77096005)(2906002)(50986999)(229853001)(33646002)(15975445007)(5003940100001)(42186005)(50466002)(5004730100002)(2950100001)(76176999)(76506005)(48376002)(66066001)(50226002)(2201001)(2004002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR07MB2237; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2237; 23:UKdMdOurH7e80JS7g1lHR0epPxtvyURq4ghLOTS5cbBYl6k/DzbeFWaABuHtb1yur7Una+5C+N7yZdCdhKxqacw85TciWQatRZCImW6fVe8cHbPMqgX9gILLbqHc0/ZaRlA5n4ixIVzjmNo91aRC+vg0xyHxaNhz6oIn07rTOD7xnEacJNkPTEckwViVeKKIzCkm85yaZoeKY3w0YeydAWNoJj6Vb+xNIHV02keXpv6jDatMIVQl861zST1LFd6L990Mf5akyrMS1JhYj74AgJOqPyq9QUGimzIBUlNttpiCzSOyX+f27HrsVrElBriR5ofo5JBDfXO/S7wppXMNPaxcIBtH1ZqSuECADi5CrB2LuKgXA4t30wWuCt/j53r+1UGCrAk8npkltDUNjCejA+zu7Tryr+a1mbMS++sulFVLMZmKOObsZzwmts1bB0SXw8ugjUCCpCw4NYMUXnzlJlrS0fkLNmHhuQDT7B0wmYeJFHuLV/3eMUA6Jk0oywXs4cN1KqRnnR6dPcyn3gQRHny7cj26jjN1Ij3XGMVAHcWOCpkA+hXB7my4fO6i0tZdKHT7oR85hRuN0YeFW5Qe3iaJaGOTL6nZTThEh1hFK6dBcFhDTXUuO7eontCc709pFmziSCr39UC83zf/phP5FXhAz+pNse8yDB5KX4DCQcNh6kHyr68lpb8TgFbomm0jpbvVOfS2whDyKzSY17dW1Lldl3+6Eba4pSgpZcUVuy8C7Z4KYUgyneQBKGUV6EpTE5YsSG4TublZYWnMB8awcyJ+q5zpbaQeQCFiNUJK+v5RdTbTOG7PY9HZAcB0TZUwXcbqi7TY77RXz9Gh3/HVGlkzutOLgWuWNwNB/oBhy8I0FHMetROh3OmXQttXYY+oDjIOXUZbSSHflwT6ImBdjW5ri0aby8MTVuJIQBrcAcjvGeGoiUi3ipBHBHVLCvK7 X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2237; 5:PYAPUaFgAeffYN55dFbcBZo1QAPbrj3SZ0c6/M/pwFEV5tw8NthCJOm6ATeFgvL2u4ECqBG8NQhWgAbDG3J93rqMR+W8DzdwP76imxhvvgvWg9LdJlZejwfVDJkT/69KtHkpUNLd3W7IQFRZSOuNkQ==; 24:LSoLddV8NC5AdbWyB64KK3sK9kwR8qr61Uxd1NdPQ692AlCj0a04XW0n/nBjaJKbHSlaLe8s8iN7m4PC6mH0y9o3V92Y7iFEbMjii8qnfqQ=; 7:BTLlFRBgdOgeHySbyAVKbXnomuvHgC4DD0B2tWNDMizCzFVRo7/6QN9QwfPPqwFFCO8tiy66SxPCvq+LzYVO0xtJTGcflIX/ivQH9Is4GANzkApG7qL0P0ajF/WImfHlxeYU1rKooCcGouh+N7oULuyWyEVi4b45TN3kpEvRTk8I3GJofzxAf9AssqMTN7Jk SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2016 00:06:19.9228 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2237 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160523_170642_631659_1333B451 X-CRM114-Status: GOOD ( 16.45 ) 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, 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, schwidefsky@de.ibm.com, bamvor.zhangjian@huawei.com, philipp.tomsich@theobroma-systems.com, 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 | 1 + arch/arm64/kernel/signal32.c | 85 ----------------------- arch/arm64/kernel/signal32_common.c | 115 +++++++++++++++++++++++++++++++ 4 files changed, 141 insertions(+), 85 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 7aa65ea..3ed55eb 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -29,6 +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) += 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; +} +