Skip to contentSkip to conversation

siginfo & 32 bits compat, what is the story ?

DISCUSSION Matthew Wilcox 2 participants 2 messages Apr 20, 2004 1 message not in the archive Generic include/asm header files

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 1 line · Helge Deller

is Andy talking about you... ?

Thanks for forwarding this to me, Helge. No, Andi's talking about Carlos.

Quoted 11 lines

---------- Forwarded Message ----------

Subject: Re: siginfo & 32 bits compat, what is the story ?
Date: Tuesday 20 April 2004 00:44
From: Andi Kleen <[email protected]>
To: Benjamin Herrenschmidt <[email protected]>
Cc: [email protected], [email protected]

BTW there was a merged version from some PA-RISC person (with yet another rewritten siginfo copy function) discussed, but for some reason he dropped the ball.

Andi, you vetoed the patch. Don't blame Carlos for it. That's really petty of you.

Here's the patch that's currently sitting in the parisc tree. Carlos may have a better one; I know there was one sitting in the -mm tree for a while before Andi's whinings persuaded Andrew to drop it. I hope someone manages to push it in over Andi's complaints this time.

include/asm-generic/compat_signal.h +25 -0
diff -urpNX dontdiff linus-2.6/include/asm-generic/compat_signal.h parisc-2.6/include/asm-generic/compat_signal.h
@@ -0,0 +1,25 @@
+#ifndef _ASM_GENERIC_COMPAT_SIGNAL_H
+#define _ASM_GENERIC_COMPAT_SIGNAL_H
+
+#ifndef __ASSEMBLY__
+#include <linux/compat.h>
+
+typedef compat_uptr_t compat_sighandler_t;
+
+typedef struct compat_sigaltstack {
+	compat_uptr_t ss_sp;
+	compat_int_t ss_flags;
+	compat_size_t ss_size;
+} compat_stack_t;
+
+/* Most things should be clean enough to redefine this at will, if care
+   is taken to make libc match.  */
+
+struct compat_sigaction {
+	compat_sighandler_t sa_handler;
+	compat_uint_t sa_flags;
+	compat_sigset_t sa_mask;		/* mask last for extensibility */
+};
+
+#endif /* !__ASSEMBLY__ */
+#endif /* !_ASM_GENERIC_COMPAT_SIGNAL_H */
include/asm-ia64/compat.h +1 -0
diff -urpNX dontdiff linus-2.6/include/asm-ia64/compat.h parisc-2.6/include/asm-ia64/compat.h
@@ -27,6 +27,7 @@ typedef u16		compat_ipc_pid_t;
 typedef s32		compat_daddr_t;
 typedef u32		compat_caddr_t;
 typedef __kernel_fsid_t	compat_fsid_t;
+typedef s32		compat_timer_t;
 
 typedef s32		compat_int_t;
 typedef s32		compat_long_t;
include/asm-ia64/compat_siginfo.h +2 -0
diff -urpNX dontdiff linus-2.6/include/asm-ia64/compat_siginfo.h parisc-2.6/include/asm-ia64/compat_siginfo.h
@@ -0,0 +1,2 @@
+/* We use the generic compat struct */
+#include <asm-generic/compat_siginfo.h>
include/linux/compat.h +12 -1
diff -urpNX dontdiff linus-2.6/include/linux/compat.h parisc-2.6/include/linux/compat.h
@@ -6,10 +6,16 @@
  */
 #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 <linux/sem.h>
 
 #include <asm/compat.h>
@@ -17,6 +23,11 @@
 #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) (personality(x->personality) == PER_LINUX32)
+#endif
+	
 struct compat_itimerspec { 
 	struct compat_timespec it_interval;
 	struct compat_timespec it_value;
include/linux/compat_siginfo.h +170 -0

170 lines not on this page · raw message

kernel/compat_signal.c +124 -0

124 lines not on this page · raw message

kernel/signal.c +7 -0
diff -urpNX dontdiff linus-2.6/kernel/signal.c parisc-2.6/kernel/signal.c
@@ -21,6 +21,7 @@
 #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>
@@ -2009,6 +2010,12 @@ int copy_siginfo_to_user(siginfo_t __use
 	if (from->si_code < 0)
 		return __copy_to_user(to, from, sizeof(siginfo_t))
 			? -EFAULT : 0;
+	
+	/* Use compat_siginfo_t with 32-bit signals */
+	if(is_compat_task(current)){
+		return compat_copy_siginfo_to_user((compat_siginfo_t __user *)to,from);
+	}
+	
 	/*
 	 * If you change siginfo_t structure, please be sure
 	 * this code is fixed accordingly.
Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain
#2 lore raw
Quoted 2 lines

Andi, you vetoed the patch. Don't blame Carlos for it. That's really petty of you.

I requested just one fix for clear brokenness in it, nothing more.

With that change (moving the decision about 32bit vs 64bit thread into architecture specific code) the patch would be fine for me. But for some reason Carlos never did that change.

-Andi