linux-2.6 carlos
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 4 lines · Carlos O'Donell
CVSROOT:
/var/cvs
Module name: linux-2.6
Changes by: carlos 04/01/27 22:12:47
Quoted 9 lines
Modified files:
kernel :signal.ccompat_signal.c
include/linux:compat_siginfo.hcompat.hinclude/asm-parisc:compat_ucontext.hcompat_rt_sigframe.hinclude/asm-generic:compat_signal.hLog message:
Update thecompat_siginfo_tframework.
This patch is an update based on feedback from the linux-arch community. Notably we add is_compat_task() and let the compiler optimize out the code when CONFIG_COMPAT is not set. It also completes the changeover to using include/linux/compat_siginfo.h instead of the asm-generic version, which required that all arches add a compat_siginfo.h to their asm directory.
Index: kernel/signal.c
===================================================================
RCS file: /var/cvs/linux-2.6/kernel/signal.c,v
retrieving revision 1.10
retrieving revision 1.11
signal.c +3 -8
@@ -24,15 +24,11 @@#include <linux/binfmts.h> #include <linux/security.h> #include <linux/ptrace.h> +#include <linux/compat_siginfo.h> #include <asm/param.h> #include <asm/uaccess.h> #include <asm/siginfo.h> -#ifdef CONFIG_COMPAT -#include <linux/personality.h> -#include <asm/compat_siginfo.h> -#endif -/* * SLAB caches for signal bits. */
@@ -2011,12 +2007,11 @@ int copy_siginfo_to_user(siginfo_t __useif (from->si_code <0 )return __copy_to_user (to, from,sizeof (siginfo_t)) ? -EFAULT :0 ; -# ifdef CONFIG_COMPAT +/* Use compat_siginfo_t with 32-bit signals */ -if (personality (current->personality) ==PER_LINUX32 ){ +if (is_compat_task (current)){return compat_copy_siginfo_to_user ((compat_siginfo_t __user *)to,from); } -# endif /* * If you change siginfo_t structure, please be sure
Index: kernel/compat_signal.c
===================================================================
RCS file: /var/cvs/linux-2.6/kernel/compat_signal.c,v retrieving revision 1.1
retrieving revision 1.2
compat_signal.c +6 -8
@@ -4,7 +4,7 @@* 2003-12-20 Carlos O'Donell * Copied linux/kernel/compat_signal.c (copy_siginfo_to_user) * and modified to use compat_siginfo_t for thunking down to -* 32-bit userspace with an ELF64 kernel. +* 32-bit userspace from a 64-bit kernel. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -19,14 +19,12 @@* * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ -/*#define __KERNEL_SYSCALLS__*/ - +#include <linux/compat_siginfo.h> #include <asm/errno.h> -#include <asm/compat_siginfo.h> #include <asm/uaccess.h> #include <asm/siginfo.h>
@@ -41,8 +39,8 @@ int compat_copy_siginfo_to_user(compat_sreturn -EFAULT ;/* -* If you change siginfo_t structure, please be sure -* this code is fixed accordingly. +* If you change compat_siginfo_t structure *or* siginfo_t, +* 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.
@@ -86,7 +84,7 @@ int compat_copy_siginfo_to_user(compat_scase __SI_FAULT: compat_from.si_addr = (compat_uptr_t)((u64)(from->si_addr) &0xffffffffUL ); err |=__put_user (compat_from.si_addr, &to->si_addr); -#ifdef __ARCH_SI_TRAPNO +#ifdef __ARCH_SI_COMPAT_TRAPNO compat_from.si_trapno = (compat_int_t)(from->si_addr); err |=__put_user (compat_from.si_trapno, &to->si_trapno);#endif
Index: include/linux/compat_siginfo.h
===================================================================
RCS file: /var/cvs/linux-2.6/include/linux/compat_siginfo.h,v retrieving revision 1.1
retrieving revision 1.2
linux/compat_siginfo.h +4 -3
@@ -6,18 +6,18 @@#ifndef CONFIG_COMPAT -/* No compatibility layer required, add empty definitions -for the compiler */ +/* No compatibility layer required, add empty definitions for the compiler */ typedef struct compat_siginfo { }compat_siginfo_t ;static inline int compat_copy_siginfo_to_user (void *x,unsigned long y) { -return 0 ; +return -1 ; }#else +#include <linux/compiler.h> #include <asm/siginfo.h>
@@ -166,3 +166,4 @@ extern int compat_copy_siginfo_to_user(c#endif /* CONFIG_COMPAT */ #endif /* _ASM_GENERIC_COMPAT_SIGINFO_H */ +
Index: include/linux/compat.h
===================================================================
RCS file: /var/cvs/linux-2.6/include/linux/compat.h,v retrieving revision 1.6
retrieving revision 1.7
linux/compat.h +12 -1
@@ -6,15 +6,26 @@*/ #include <linux/config.h> -#ifdef CONFIG_COMPAT +#ifndef CONFIG_COMPAT + +/* Non-native task requiring compat... doesn't exist */ +#define is_compat_task(x) 0 + +#else #include <linux/stat.h> #include <linux/param.h> /* for HZ */ +#include <linux/personality.h> /* Conditional process compat */ #include <asm/compat.h> #define compat_jiffies_to_clock_t(x) \ (((unsigned long)(x) * COMPAT_USER_HZ) / HZ) +/* Non-native task requiring compat */ +#ifndef HAVE_ARCH_IS_COMPAT_TASK +#define is_compat_task(x) (x->personality == PER_LINUX32) +#endif + struct compat_itimerspec { struct compat_timespec it_interval; struct compat_timespec it_value;
Index: include/asm-parisc/compat_ucontext.h
===================================================================
RCS file: /var/cvs/linux-2.6/include/asm-parisc/compat_ucontext.h,v retrieving revision 1.1
retrieving revision 1.2
asm-parisc/compat_ucontext.h +1 -1
@@ -4,7 +4,7 @@#include <linux/compat.h> #include <asm/compat_signal.h> -/* ELF32 ucontext as seen from an ELF64 kernel */ +/* 32-bit ucontext as seen from an 64-bit kernel */ struct compat_ucontext {compat_uint_t uc_flags;compat_uptr_t uc_link;
Index: include/asm-parisc/compat_rt_sigframe.h
===================================================================
RCS file: /var/cvs/linux-2.6/include/asm-parisc/compat_rt_sigframe.h,v retrieving revision 1.1
retrieving revision 1.2
asm-parisc/compat_rt_sigframe.h +1 -1
@@ -1,5 +1,5 @@#include <linux/compat.h> -#include <asm/compat_siginfo.h> +#include <linux/compat_siginfo.h> #include <asm/compat_ucontext.h> #ifndef _ASM_PARISC_COMPAT_RT_SIGFRAME_H
Index: include/asm-generic/compat_signal.h
===================================================================
RCS file: /var/cvs/linux-2.6/include/asm-generic/compat_signal.h,v retrieving revision 1.1
retrieving revision 1.2
asm-generic/compat_signal.h +4 -7
@@ -1,8 +1,8 @@#ifndef _ASM_GENERIC_COMPAT_SIGNAL_H#define _ASM_GENERIC_COMPAT_SIGNAL_H -# ifndef __ASSEMBLY__ -# include <linux/types.h> +#ifndef __ASSEMBLY__ +#include <linux/compat.h> typedef compat_uptr_t compat_sighandler_t ;
@@ -12,8 +12,6 @@ typedef struct compat_sigaltstack {compat_size_t ss_size; } compat_stack_t; -# ifdef __KERNEL__ -/* Most things should be clean enough to redefine this at will, if care is taken to make libc match. */
@@ -23,6 +21,5 @@ struct compat_sigaction {compat_sigset_t sa_mask;/* mask last for extensibility */ }; -# endif /* __KERNEL__ */ -# endif /* !__ASSEMBLY */ -#endif /* _ASM_GENERIC_COMPAT_SIGNAL_H */ +#endif /* !__ASSEMBLY__ */ +#endif /* !_ASM_GENERIC_COMPAT_SIGNAL_H */