Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751198AbdFDMFW (ORCPT ); Sun, 4 Jun 2017 08:05:22 -0400 Received: from mail-bl2nam02on0041.outbound.protection.outlook.com ([104.47.38.41]:25248 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751278AbdFDMDa (ORCPT ); Sun, 4 Jun 2017 08:03:30 -0400 Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=caviumnetworks.com; From: Yury Norov To: Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arnd Bergmann Cc: Yury Norov , Andrew Pinski , Andrew Pinski , Adam Borowski , Chris Metcalf , Steve Ellcey , Maxim Kuvyrkov , Ramana Radhakrishnan , Florian Weimer , Bamvor Zhangjian , Andreas Schwab , Chris Metcalf , Heiko Carstens , schwidefsky@de.ibm.com, broonie@kernel.org, Joseph Myers , christoph.muellner@theobroma-systems.com, szabolcs.nagy@arm.com, klimov.linux@gmail.com, Nathan_Lynch@mentor.com, agraf@suse.de, Prasun.Kapoor@caviumnetworks.com, geert@linux-m68k.org, philipp.tomsich@theobroma-systems.com, manuel.montezelo@gmail.com, linyongting@huawei.com, davem@davemloft.net, zhouchengming1@huawei.com Subject: [PATCH 16/20] arm64: signal32: move ilp32 and aarch32 common code to separated file Date: Sun, 4 Jun 2017 15:00:05 +0300 Message-Id: <20170604120009.342-17-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170604120009.342-1-ynorov@caviumnetworks.com> References: <20170604120009.342-1-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [176.59.55.28] X-ClientProxiedBy: HE1PR09CA0078.eurprd09.prod.outlook.com (2603:10a6:7:3d::22) To DM2PR0701MB1280.namprd07.prod.outlook.com (2a01:111:e400:5118::18) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM2PR0701MB1280: X-MS-Office365-Filtering-Correlation-Id: 93fbe0e4-92ba-47e6-b836-08d4ab41b24e X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:DM2PR0701MB1280; X-Microsoft-Exchange-Diagnostics: 1;DM2PR0701MB1280;3:wejLMckRdzawNpaXk5KkxSW63ky9WcKX/cnVgKwH8y5mt2oFIL9jyaVZfLt4+/HiTAHap/3JwQMFgJ45BUkQlRSdUJarfsIOTimMmPmP97nAWpHD85e55d8CDOiNpk5bO3+gePHTe8kVFB+QXbNTV58SxNweXYR87UhHAqAXAlmM+RRkAKhk6Y5L9jwJUGI1P2+HdQbFKPRN1lwfnERHS+AXkXzecGHQbnGdaycH6Dj0ZxaN5QHKjIvfCLkO7V8fi/QU7U9mRTaVLWxuL0HxMFNKWwkq9zX83+YvJ995FsRZ7zlJH+9jpirfLtI/oJpXaocnyLDeFRxqR1P9aAmj/g==;25:iQxuQg5sIQ75eof5glRei/P/zgb+rMtDyepkII/ZZ8XyJg5dJIcKgHje6DDv4rZtfhe/0D2WEinlNufxjpP7pz99hnLT042C2jxX4tgUKPGdJYqY9A77IqHvgI7EunHaKlhb+nnrBtuFtY74vLSZySygca1aaQWkcbbv+9c5phUDFTtWRji8MkmDQqtDOTQ1pfwXMmxGF7M134yz00ingwteJw04xnNjdgXz1eDA+zAPOEJKRoj1fFaRx2aogRSJIEDYuu5fB/WBsB4vY8dHkzBr2NCFXqNnrJKlzL2APbEIYi04SO38paIlJyO24N/dKA8dZAbRR1oyHpbwiUu5aG/YF7QWazapIVgDxFwjOTEEV9TIEOHevSeqDqageYq5izvFeJqSyO+E2Stk9ge3TK2pXyvknfomB2gnLWu/wMvm4nVjyx8knC6Asxw00XkAFzHaIjmynzb+5scvQ3FOAXvvQNBqzc7xSMaIhEn8t9M= X-Microsoft-Exchange-Diagnostics: 1;DM2PR0701MB1280;31:1tjCtSYqbQcuiG1eR4XIVKm9Cj4/CtfPsJJWHCeq0771vdM6ejxYD/O7juYmhUJirUHK9ghT5XF1xMjvetfIKOtMVYKgcFH110gmDtwJ4Fpf8ETbgOM2StCkjK3ZMs7dqDW5ps7UVJ0ZKRyxMQT/p7kIXTdjswSeLXSrn0PhjFazGyz+lI5lABDn+XcsVh8LG9JVZ9ji/TEQen98gtLCmkcIvyPbKO16+UsOnMUPINg=;20:Qqs9I1hYCfS7HjKMsm6IhnclXt8XrkILKRjJYHMvs2/e2JEtIpOBOpplO2KrRGyOr2veOhouH2u6y/0VKDqkGL+LPmOf9IDLMIkRdIMz6uY8npWbK5yRgKCmeX01G3W0qAqOTN1GRT9ERzk1AJwAjNUDkeGW59kO9CguTY3vCYilROy8TyP6YT2c6iPRmDthQAitGGqRjErxVSLmBF0yWxsyPFtvej0qa9D9jwNVJZDDc19APOtPFwQqdD4rXQJ03nvuW2jixbqza3w4ycxoq0f5MSCJ+vErFiMvAARnih1CVmRmDc0TT7jeXGLsC21goL28FpxfZ5ptAuddHspDkYrIYoTCRcMMJqmh/uyufaQvQy57ecbPoN/31FvO6stLWb1MrFUokfimkukt6piwcREFG170qMsRIeVfiG+H+d4AEhxeFpZjOIj78WPBAVD4AFapbcF4p4s5/4dipg/mjyzkcyFMcYkYHd4RgLTy1O/wr8OceBXiF6IrllrdzNoyNXZJGX0f7i14pri//6XE8nSVRhs+7kdM264V1fpnfsju4g0YphDXxoNQfhrwvNzGobQJcQU9C6AiH2ABznFhoZ/NFOUAwczcAweJn2t0Obs= 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:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(3002001)(10201501046)(93006095)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123555025)(20161123560025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM2PR0701MB1280;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM2PR0701MB1280; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM2PR0701MB1280;4:EwXlQIU5N4R0GQmGicqKr5984xpNh8bILGQQPwB5?= =?us-ascii?Q?pI6J0h1rwo8L2Qw93uYWGWAEdHukA2uNdQe7nPRH7DJ4JTdzK0jvhpQnYycR?= =?us-ascii?Q?8ADOYMxyuZLLBgPe1hr7bnepluvjnFr40Tca1R7SAq177+bbzW5YN3uu7/tV?= =?us-ascii?Q?s7mJhMxXqLjIQHzfpLJR6e7isnJVEHMtKL82Up1gm/TUqE5a8BhNGFHf9gZK?= =?us-ascii?Q?+GsQl/kefyd7TaqLF0PbL67T8FArzc5gfwQ6B9Tr2ehM+pF8MnlN9dpEhVxm?= =?us-ascii?Q?1vCSxTaDjSbX1JtG+uium2AeLntpk2j74Z9Rx042lasxtSdj3B0p4acexrrK?= =?us-ascii?Q?VqlUH+KU/Jpzk/vggOzplc2Q0QlWlm8LkYqrSANnCFlyd236eFy0GbVMmc7m?= =?us-ascii?Q?kJSLWss+yqIPCc1LgnFxa+P72lny6s2RMiouHXvs18WAgud1YAD9zErp5MhV?= =?us-ascii?Q?8gAZrXuRKwyFVFvJIw6eLDxhTNtP9GCReYSMsyLfhNqs3RW+U4ChaA3C3Csu?= =?us-ascii?Q?Ww127iyPXCdqLyvok2TrjkNMVkPyIy0TVA1LRfQpKP5GZF3yZM1+brCbMsBs?= =?us-ascii?Q?MiQrQI2Lgf6SiNzItBhV7W24xgWJOrQ6s4s+gHnX2mscrgbRwbww8NRfazPr?= =?us-ascii?Q?fdxKxw5PwputTIK2bf94ROCM0kt6hRCHrQQBjxnYmomVgcmw5oAuZC/dRRfY?= =?us-ascii?Q?vn9eT60GH+EVkiIXvM4jfofwn4UIXOR80qFi4JrOu73C/O3d3e8UJx+H77Jx?= =?us-ascii?Q?+X+91dmRxbj0P3nTDRvKiaXR4inGKkFiYklAD0YHMbJ4wz7OpN09Dlwt3x/P?= =?us-ascii?Q?8qdgpB/xp337uZABAZDOsBMNn/4vsqpEkslCC8+D/Ug8xOO83yROTetz0CFh?= =?us-ascii?Q?IwrpYIpQzjZHRxQnmN31oTJTN445CQAkJoF0vNb9f+a8+vcYzPOP04fEgEkG?= =?us-ascii?Q?LjEljvXfMD7P0UKu6aEyaRJV3nya6cm1R1jKw1ffPPZzLH/+sppN3iuRIuP7?= =?us-ascii?Q?zlftMN09IE2pchNVxJ7r05KUTNTjN4PIt+otOkQ3hcFTzIfFCF8ChFSj3v3X?= =?us-ascii?Q?Wu+Xgx7VyhO2lk2L4wBfg2fPJQ6kg0ptfixkBp2qrhjnb4/cehGntE18P+AY?= =?us-ascii?Q?qEwAQI17H0R3X4/yBERzHq4poDtztGbCiE55CnXlvUlu371trsf97cSmykM+?= =?us-ascii?Q?P9bXBkM4DUxtqJz3KYf4AVCUsV5la4fRsyZXF2DRqF2tDfmi+vX1I8VxIMC7?= =?us-ascii?Q?FT7jZHxih3Kdu9mgRpcfMq+vAIhxFMK/9Le5Cndo?= X-Forefront-PRVS: 03283976A6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6069001)(6009001)(39400400002)(39410400002)(6666003)(54906002)(2950100002)(81166006)(47776003)(42882006)(66066001)(50986999)(76176999)(36756003)(305945005)(38730400002)(6486002)(50466002)(53936002)(8676002)(7416002)(4326008)(25786009)(5660300001)(6306002)(5003940100001)(6496005)(76506005)(42186005)(189998001)(50226002)(3846002)(72206003)(6116002)(575784001)(33646002)(2906002)(48376002)(1076002)(478600001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM2PR0701MB1280;H:localhost;FPR:;SPF:None;MLV:sfv;LANG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YGKF9b0+C61DAycq3UhNIS1CiLeoTuVvPlY0/R0jIQHLFfg5cjXq7Rsumsdu+rk6KjcHSCY+1mB5C/lUhJC+YUFfjEFIfUJSayduB3Fj4PK+z9lleDyiAnw487aL9i8j/AQpaL3YLm8yhZ9PhJUZc8lGIxPAmSkPYW3ww9byRQm7VnQccK9VGSEJdpBWHzX3WqcyJI+N8WAFH8bJhk+58827XPBeZbZ2BeLqR7Ef+aDDujLHGoi2y93SPvKiHxQlywOIDZ185oXr/KStXb2AjKHY6rVM0/oeocFO24yhpk85fGmNHgdtW7/fLGHzgCDeyADjN;24:221Lnonw9kTwGnnB5E4r8QA9e1Nn/7byrKbvU3NIIumvBU4fT7UojofR45JZQTXBPJvhzFUrvUVIdsdW/eebWqzqqS/bPkSRV1xkkrG7j5k= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM2PR0701MB1280;7:7xD3oJEIk8v41HRTdbZPox6uaqiijqFoY7BkvQCwZynysDkqBoRV0TcjG2AZVQrut8mpSd5742j15q3soEaC83CzOQkZSs91eLUcAk4j0lVI+C5HcnQfWoR6YQK41JReth1s8fyYo02dVnbbbH1yHcGA+uFKSy8dV8Ug+6eipviVmBlq+gRzu9plxUTBgKL2M+ITxfSir65HcijDvsEjnA/r5pBe7e76h6Pq2ak7UZvRZVYNCdbdRTM3uQKiX6GlOiZqI93tuN/7npV9QtfKZp9ch7lhD8vBc6BsphHSnotkPHU0a58DKUoylzFB25xKrZYatuA4fr9skoL4aKqhPA== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2017 12:03:21.2872 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0701MB1280 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 11399 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 e68fcce538e1..1c4ede717bd2 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 000000000000..36c1ebc07a97 --- /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 7e0c48f858f1..1dd659907f34 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 c747a0fc5d7d..181cc3012bda 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 000000000000..5bddc25dca12 --- /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.11.0