Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753442AbdCAWAF (ORCPT ); Wed, 1 Mar 2017 17:00:05 -0500 Received: from mail-dm3nam03on0054.outbound.protection.outlook.com ([104.47.41.54]:24736 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752642AbdCAV76 (ORCPT ); Wed, 1 Mar 2017 16:59:58 -0500 Authentication-Results: lists.infradead.org; dkim=none (message not signed) header.d=none;lists.infradead.org; dmarc=none action=none header.from=caviumnetworks.com; From: Yury Norov To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arnd Bergmann , Catalin Marinas 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: Thu, 2 Mar 2017 00:49:24 +0530 Message-Id: <1488395968-14313-17-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488395968-14313-1-git-send-email-ynorov@caviumnetworks.com> References: <1488395968-14313-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [27.97.135.110] X-ClientProxiedBy: AM5PR0101CA0008.eurprd01.prod.exchangelabs.com (10.169.240.18) To SN1PR07MB2255.namprd07.prod.outlook.com (10.164.47.149) X-MS-Office365-Filtering-Correlation-Id: 66fac827-3b5e-44a7-d977-08d460d858da X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:SN1PR07MB2255; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2255;3:br/ktN7/ZgMX/sOt36qZF8TGl76eLV5wxYN/U75hab0ewphbdFowPPqSQFU5oS4/+2wPssPx1fHmWKiMDovCb6HRrZvUQMMPHgv9mFiIBaqQqB/ybT67K84EV0AaWIvjr4Cwbg9KuW9CS8FXmh2/4lMyxpjs533IvjU/ViTZ0yGCkPY+Q8P+gS1hrn/SwFupaHYF6BbGgdJXIPnq/7E/MG+fIL/ufW3m7KHtm56BAbZjiUyCdnBc0g++ep9iLLU9BIWmFaZzEyy+rfItZ+PdpQ==;25:Xl6nMx0rXEI892y487yakywrsyHAgnaYxm+q0ct/apJay+Xobr0QxUnsu4FXSwlu3L6bup9TmzRc7MDfr2TA1/Mx2hcJIe3PrNJ+oNxjcXlv0VLBL6x7cuFpFW1Jtv4jRCDavqPS3OHl0nCJ7j1Hs+d2rHS3ZWWf80Bjc9pPj6LvvDmpGYfNPJvn5Jot+GiZI5B2NSURo8g8dTaD/AOo7z/f2wa1nVXC5Kik7Zsis8khHA91Z13ChS0BDsZxxWjkk3UlU3C3M11cKwra7F7R1J3OTihIT/rLje9H8Nd0EE1R2eBLv2hzp5xsHiVWLOa2jPr+1YKFz+5Gy3n9NtDQQeRarQF6GLkX9kH2rSmGosqoY8GwctURnbcUhrJt21Uwb+nFCcinbb4v/31zY2FAUytGO1hoaWEkBTiMUPJw+mFMfIBhEnORahVtJb/E9dfdUGeAqxUahQ4fqo99fjMpOA== X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2255;31:Dq34M2hwdlIaQVKXDI0dpSeA9VL+whQBqE1sYJ0cuaPCtLIK4DBpJ6zoOI7IG36JpHahMMqHxiAfAKSICCpDIsPu7j7w37DAQL2vrz1Uitmf141VrZzR4mXi3Zy2YqlBMVkLQCsUiM+dABurYt+hb4tF3Y1Mg6WaGlTuK5oVgJuW2kWMlyxM5NTKgSpjjJWvWllMZTUisdkplwIrGj7KqpF/APCO+wDN1YU81ZUBSjE=;20:gzcbgbyv1b4nSycfk04qbKlnxWzmn2lMwHhFgIr6A53HQNJAxUtZgvdYERduM/4x5dNqkckN9NrR2OKKHbvvynAD6MbwmBGczmNIQn8oowPXGMYQrp99mqxku2C8PQgPcMVNG7iyc7QjzgtcfY4Nggdi1fXvzFRXn7MBM+y4OUGPzf+H0KsU5YYR9gyZtqzcFZya/aXDmiUIbnrJNDx87M32ikdiyab0EVu2SlapvXJw1GU65q3SIlcDRaVIDZmXPPIyuPnuW8kLVmYzWrk/uFWD/rM1QV33sn+1dSZCFhDQ5DtU6/bWwqYvaCE9m7jxCTs5H2Es2emq35GE8ZrPmLiijvNYmuwfcJ9ZuX4hOoRYHQdVnswYA+YQ9M97IWq6hyovTM+PZPnQp9VKOU8eiBcjQhby6IW38lXLofJ3N9WKe8YHIjDt4RplG3dR2lyAsvhqvUi0rwMCmtxKwXzTiARA3Zzlf3MyCYIeu24Ei2M+2RDSI0dqTcelxfQlx5PjfpeFurQLbhnS6/s/s4OXVdX7/1UFL+Dyewn5/7AqEz4EQhMxooFjUuQtHiP5urTVxHZl0LX4mxzP9nOldiBWGhrgSvDTvhdd1p1KSQppfR8= 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:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123562025)(20161123558025)(20161123560025)(20161123555025)(20161123564025)(6072148);SRVR:SN1PR07MB2255;BCL:0;PCL:0;RULEID:;SRVR:SN1PR07MB2255; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2255;4:lYqIEVyRfwb++17XkodtNbGcjr8s+wx2nLyEcB6TEY37CD++C/FeJkuVKyHRyxEktPAYOV/5Wt2M7qQNAFUydibKypD3fpdZH0pysQxZHLyuQc/vi0oOyspFM8db72Yde+FKFPHCMDN2eoe+vnq0+9LMf4Twtsz9pVPLudetANVIfD996JidrsHo4jaa4ge4CGhTCv5I50VGwVGmd/Je0OYAXD6UfaaJxCEVRYBQGuEsXI7Cb+SSy5q6nca87qJEnMR5HqSdYsblYT97zNQU/+dXKOE4L83c+dnDuQZ7XAny43UTxmOYbyqA2Tg1je0A63p3aZ7uoEQp8vMvnxAgBNEdjpw+jlLAMtuljbubUzqL7DV10UnY4hgOhDHzdfa0Gc49nTzfBOn5Jk0gYX8kEC6VxjdeJIh+JpiK1T57HmhRir5dipkEeW27qtz+ykVvfNwVJRmmCMUSwp5Y0qKRszSbTG6SwLuaFEPKGrLNkFzdGudsbtB5dz3akPDrm7QObf8hgOwev/t6TRmq8jYiY3EM0PIsY0bz1stWQ7a63RuHLhpZ+ZW/yjENTNjwg0ApPWrBRhmpygedDKUgaWIecl3oDBZ3AIa8nS0Bd49ZPzf7Ubmvq490CJii2JcqSp2v1hQYZ2WVnMy4CD/FP1taltyrkHrxb0ic4eZ49sKPs4nC//gGEiRrTumNCCdb6U3NSEfEkDO6GKolKzSIuqBeFC/kLftsWkyEw6FtxjmUxFYSH+ns5+1gGDoZQvY97wQt X-Forefront-PRVS: 0233768B38 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(39450400003)(2906002)(6306002)(575784001)(76506005)(92566002)(54906002)(38730400002)(66066001)(6496005)(4326008)(53936002)(47776003)(5009440100003)(36756003)(305945005)(50986999)(76176999)(7736002)(6116002)(3846002)(6666003)(189998001)(7416002)(5660300001)(48376002)(50466002)(8676002)(42186005)(2950100002)(81166006)(25786008)(33646002)(50226002)(6486002)(5003940100001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR07MB2255;H:localhost;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN1PR07MB2255;23:H0M19ahPF4YEZJbzb7RCfTCsWgAeQgKnSTbDtScmm?= =?us-ascii?Q?o2Yu2C0bohjoOZ7AIIfWup+K84j55+ngDWvTTDxjT9JOqrYLTS+3GqUx384N?= =?us-ascii?Q?HFP4fVPT04Bvi2Kl9SJkK3hz6XYLUdtucKst6avVMLrQiovFPEo9jzHoMKVc?= =?us-ascii?Q?iwQrVUBIM2nKGmKblxg5x1WbSxGMNGIMk3dnig+GwWqWttkBjhcAL/jUacv6?= =?us-ascii?Q?WaqP2j71n20Ds8Ok++JdcY/KAlSuSC20KsxyoAkjuy+cXsbJ9mY0BsCY2K6G?= =?us-ascii?Q?adXmyOe+D2bwTWU6AiVCQtNykau/5H6M+9uoCQOEDtGigTLwdKsJXUHBsC/F?= =?us-ascii?Q?N2qiCulAsvNkIUrgerDwoYEZbehPW5G54Yh+qUKX6Qqs08lbB2qfhnquZbG2?= =?us-ascii?Q?5u4N0V9fN78144U3m+QN0ikJW5xdxKVsI5x+IgCw1ItT5TX+Wcx+7Lt7DazQ?= =?us-ascii?Q?ThKcj7w+Rc0aeG5TFeH6WOCZkQrlLzHXH+Exu/9iGzN00Ck4NmS7Bir28uAk?= =?us-ascii?Q?iMcWcOSfcrTbJ5Fiu5OHL4gyDJHi+XbOQ5kETS6BLxGO6QAUmy52GtnEQHB9?= =?us-ascii?Q?YRovWbM7EgCZIGX3sgdVK0YMqgo9a5BKLK0rNhOgISLfXOZbfsPzLY1GyC6W?= =?us-ascii?Q?zOPfl652IdD4wX3DW6YG7IcGZNM1zHCbTwXIAudjjTzBdd3ghco/cCpvWJjx?= =?us-ascii?Q?FGkDceBxjy04oRqG2iGBW3gNWkKsuYY9AhT+ib7AW9G3iSrNhN8uw2suHO6+?= =?us-ascii?Q?dW7+lD7s7JpTAZEenCX+dzCRGRY3xbW9Qjrpb+4SSNslswyD/jAQF4rwbFNe?= =?us-ascii?Q?cZoeN0OOp2kiXzdRsX8D6uyBW7edbPxM2YlBR3qe13nPu8sW1ocpQglIRARl?= =?us-ascii?Q?Msx2zUFjSpRpy9IFV41lxz1cAtKH/Bmp59oQMh1VAQPQSf0lTAVQtOFT3mtk?= =?us-ascii?Q?/T0CKzGPqCrDyRFt+Y9LIi8bgrOT4AqleONGq5T1aC8Ysm0cB315ws39Caaa?= =?us-ascii?Q?XdPd06SeHwCSUtzx/ASif5h?= X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2255;6:fBIvX3VFWJcp3TDDCHV74vdNdDQFao6kgRRGizUAW1B2nE8Xh0dkjfeRRlIqChUmDh7W+xl9hlW3BEw9gwU55AXbSb+oGszNYkS/gm9cmsCa8RIx6w24VQ80AKiiAHtNuQsR1ucmH/eT2ZP/WikzxJPv28NxMX74ozxP5X1yLAO4tFADOBf0H1/ilhxC2lAaP6UE761xYQWAeK1khenCD6ayq6iRC2YI4nChh/izi9Xfsgo9Y5C4vbs/48hR21Og11rl4t8HiHpiSZ6s6ecpZeCoCqd+YQLmm5zrK97SH9tWsrZ08qiupdxe/IqKuyXDWjJ4XosBlmZXwdk70/1Lchj45E8wrivKhhVmF565or+6V/SToewVTUocMwGeTC9jK7d7c7/Hp6sBll8gwS3jgA==;5:Cp+64TzTS4tkase9uzuMWCHcqVWilQanTGSc+Old5vyZiOuXAb7+C7MSteslG6QMhLMHz4zHagemBTrT9mXCynesesH6MNHIl8BAxfuo6SfGEzPpjzCpsel/YGlYEWNzdaT9IK7lKn/xAxr0q3s+M/OW5OoRjfJSn/8TmVQa9GM=;24:JRRmGW3x2E/fDzMgFrot9OwYWv+xXAoFJLEXrbi9gn+jZ9Y8j/pfE4K+5wTkyfCFr7rKLC5+Z17HitCDp7ljiBgcRt7R91jkkFar67x1T0w= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2255;7:y7b+zD93Ye6Qux58KvSDgqaBENmTNmgmZPkMbArQ6zlwi4yijyXc2GzmK94MiQmmLbgsWGPOh4K3kcI9hWJSVHA3pBvVp7jsHr1Gj5YCeT6pOI8+FLxuwi+bH8WshcwwznKTbK7xlZgwJjqRRE+81B8zgEec8iSE58BSSXKMozns3u5gNe2DmJb3ae4cY50yRaqikJxWH4i4IwUMbcHN844kdGa7wIwobjJ65tL0y8kP3YJno+WjVBW5eIDBqkgkk/sYFs07m1BLljv8+7BRGiiTijpdIG/nahS5/gd9LxpHnShhqCF8nMwQMGYNrBYzujhGS12Fq/hZ0nhvYGYnrA== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2017 19:22:47.6959 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2255 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 11347 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 4ea7b97f..9463af5 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 c747a0f..181cc30 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..06f0258 --- /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