Fix struct siginfo - patch for 2.3.41

Andreas Jaeger aj en suse.de
Vie Ene 21 17:16:54 CST 2000


Hi Linus,

Here's a patch against kernel 2.3.40 to fix struct siginfo.  

The fix for struct siginfo in 2.3.39 was not necessary since uid_t was
already aligned on a 32bit boundary for ix86 and arm.  This patch
basically just reverts the patches for struct siginfo which went into
2.3.39.  Since siginfo is sent directly to a signal function without
any interference of the C library, we have to be very careful changing
it.

The patch is safe since accessing the si_uid in struct siginfo doesn't
work currently with any glibc version.  As Chris Wing commented:
> On the bright side, if we change it now, every program using glibc will
> work properly on i386, there will be less overhead in the signal code
> (good because real-time signals should be FAST), and the only platform
> that will require recompiles is m68k.

The patch hasthe following features:
- Full binary compatibility between older and newer kernels on ix86
  and arm.  Since glibc already accesses uid as 32bit value in struct
  siginfo this gives compatibility with glibc.
- Fixes m68k - but m68k was totally broken in glibc anyway.  I don't think
  anybody could have used this at all on m68k.

The other platforms don't have a problem.

Linus, please apply this for 2.3.41.

Thanks,
Andreas

diff -ur linux/arch/arm/kernel/signal.c linux-2.3.40/arch/arm/kernel/signal.c
--- linux/arch/arm/kernel/signal.c	Wed Jan 19 12:17:36 2000
+++ linux-2.3.40/arch/arm/kernel/signal.c	Wed Jan 19 12:14:24 2000
@@ -18,7 +18,6 @@
 #include <linux/stddef.h>
 #include <linux/binfmts.h>
 #include <linux/tty.h>
-#include <linux/highuid.h>
 
 #include <asm/ucontext.h>
 #include <asm/uaccess.h>
@@ -502,7 +501,6 @@
 				info.si_code = SI_USER;
 				info.si_pid = current->p_pptr->pid;
 				info.si_uid = current->p_pptr->uid;
-				info.si_uid16 = high2lowuid(current->p_pptr->uid);
 			}
 
 			/* If the (new) signal is now blocked, requeue it.  */
diff -ur linux/arch/i386/kernel/signal.c linux-2.3.40/arch/i386/kernel/signal.c
--- linux/arch/i386/kernel/signal.c	Tue Jan 11 03:15:58 2000
+++ linux-2.3.40/arch/i386/kernel/signal.c	Wed Jan 19 12:14:24 2000
@@ -19,7 +19,6 @@
 #include <linux/ptrace.h>
 #include <linux/unistd.h>
 #include <linux/stddef.h>
-#include <linux/highuid.h>
 #include <asm/ucontext.h>
 #include <asm/uaccess.h>
 
@@ -643,7 +642,6 @@
 				info.si_code = SI_USER;
 				info.si_pid = current->p_pptr->pid;
 				info.si_uid = current->p_pptr->uid;
-				info.si_uid16 = high2lowuid(current->p_pptr->uid);
 			}
 
 			/* If the (new) signal is now blocked, requeue it.  */
diff -ur linux/arch/m68k/kernel/signal.c linux-2.3.40/arch/m68k/kernel/signal.c
--- linux/arch/m68k/kernel/signal.c	Tue Jan 11 03:15:58 2000
+++ linux-2.3.40/arch/m68k/kernel/signal.c	Wed Jan 19 12:14:24 2000
@@ -37,7 +37,6 @@
 #include <linux/ptrace.h>
 #include <linux/unistd.h>
 #include <linux/stddef.h>
-#include <linux/highuid.h>
 
 #include <asm/setup.h>
 #include <asm/uaccess.h>
@@ -1049,7 +1048,6 @@
 				info.si_code = SI_USER;
 				info.si_pid = current->p_pptr->pid;
 				info.si_uid = current->p_pptr->uid;
-				info.si_uid16 = high2lowuid(current->p_pptr->uid);
 			}
 
 			/* If the (new) signal is now blocked, requeue it.  */
diff -ur linux/include/asm-arm/siginfo.h linux-2.3.40/include/asm-arm/siginfo.h
--- linux/include/asm-arm/siginfo.h	Tue Jan 11 03:15:58 2000
+++ linux-2.3.40/include/asm-arm/siginfo.h	Wed Jan 19 12:14:24 2000
@@ -24,8 +24,7 @@
 		/* kill() */
 		struct {
 			pid_t _pid;		/* sender's pid */
-			old_uid_t _uid;		/* backwards compatibility */
-			uid_t _uid32;		/* sender's uid */
+			uid_t _uid;		/* sender's uid */
 		} _kill;
 
 		/* POSIX.1b timers */
@@ -37,19 +36,17 @@
 		/* POSIX.1b signals */
 		struct {
 			pid_t _pid;		/* sender's pid */
-			old_uid_t _uid;		/* backwards compatibility */
+			uid_t _uid;		/* sender's uid */
 			sigval_t _sigval;
-			uid_t _uid32;		/* sender's uid */
 		} _rt;
 
 		/* SIGCHLD */
 		struct {
 			pid_t _pid;		/* which child */
-			old_uid_t _uid;		/* backwards compatibility */
+			uid_t _uid;		/* sender's uid */
 			int _status;		/* exit code */
 			clock_t _utime;
 			clock_t _stime;
-			uid_t _uid32;		/* sender's uid */
 		} _sigchld;
 
 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
@@ -65,18 +62,11 @@
 	} _sifields;
 } siginfo_t;
 
-#define UID16_SIGINFO_COMPAT_NEEDED
-
 /*
  * How these fields are to be accessed.
  */
 #define si_pid		_sifields._kill._pid
-#ifdef __KERNEL__
-#define si_uid		_sifields._kill._uid32
-#define si_uid16	_sifields._kill._uid
-#else
 #define si_uid		_sifields._kill._uid
-#endif /* __KERNEL__ */
 #define si_status	_sifields._sigchld._status
 #define si_utime	_sifields._sigchld._utime
 #define si_stime	_sifields._sigchld._stime
diff -ur linux/include/asm-i386/siginfo.h linux-2.3.40/include/asm-i386/siginfo.h
--- linux/include/asm-i386/siginfo.h	Tue Jan 11 03:29:05 2000
+++ linux-2.3.40/include/asm-i386/siginfo.h	Wed Jan 19 12:14:24 2000
@@ -24,8 +24,7 @@
 		/* kill() */
 		struct {
 			pid_t _pid;		/* sender's pid */
-			old_uid_t _uid;		/* backwards compatibility */
-			uid_t _uid32;		/* sender's uid */
+			uid_t _uid;		/* sender's uid */
 		} _kill;
 
 		/* POSIX.1b timers */
@@ -37,19 +36,17 @@
 		/* POSIX.1b signals */
 		struct {
 			pid_t _pid;		/* sender's pid */
-			old_uid_t _uid;		/* backwards compatibility */
+			uid_t _uid;		/* sender's uid */
 			sigval_t _sigval;
-			uid_t _uid32;		/* sender's uid */
 		} _rt;
 
 		/* SIGCHLD */
 		struct {
 			pid_t _pid;		/* which child */
-			old_uid_t _uid;		/* backwards compatibility */
+			uid_t _uid;		/* sender's uid */
 			int _status;		/* exit code */
 			clock_t _utime;
 			clock_t _stime;
-			uid_t _uid32;		/* sender's uid */
 		} _sigchld;
 
 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
@@ -65,18 +62,11 @@
 	} _sifields;
 } siginfo_t;
 
-#define UID16_SIGINFO_COMPAT_NEEDED
-
 /*
  * How these fields are to be accessed.
  */
 #define si_pid		_sifields._kill._pid
-#ifdef __KERNEL__
-#define si_uid		_sifields._kill._uid32
-#define si_uid16	_sifields._kill._uid
-#else
 #define si_uid		_sifields._kill._uid
-#endif /* __KERNEL__ */
 #define si_status	_sifields._sigchld._status
 #define si_utime	_sifields._sigchld._utime
 #define si_stime	_sifields._sigchld._stime
diff -ur linux/include/asm-m68k/siginfo.h linux-2.3.40/include/asm-m68k/siginfo.h
--- linux/include/asm-m68k/siginfo.h	Tue Jan 11 03:15:58 2000
+++ linux-2.3.40/include/asm-m68k/siginfo.h	Wed Jan 19 12:14:24 2000
@@ -24,8 +24,7 @@
 		/* kill() */
 		struct {
 			pid_t _pid;		/* sender's pid */
-			old_uid_t _uid;		/* backwards compatibility */
-			uid_t _uid32;		/* sender's uid */
+			uid_t _uid;		/* sender's uid */
 		} _kill;
 
 		/* POSIX.1b timers */
@@ -37,19 +36,17 @@
 		/* POSIX.1b signals */
 		struct {
 			pid_t _pid;		/* sender's pid */
-			old_uid_t _uid;		/* backwards compatibility */
+			uid_t _uid;		/* sender's uid */
 			sigval_t _sigval;
-			uid_t _uid32;		/* sender's uid */
 		} _rt;
 
 		/* SIGCHLD */
 		struct {
 			pid_t _pid;		/* which child */
-			old_uid_t _uid;		/* backwards compatibility */
+			uid_t _uid;		/* sender's uid */
 			int _status;		/* exit code */
 			clock_t _utime;
 			clock_t _stime;
-			uid_t _uid32;		/* sender's uid */
 		} _sigchld;
 
 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
@@ -65,18 +62,11 @@
 	} _sifields;
 } siginfo_t;
 
-#define UID16_SIGINFO_COMPAT_NEEDED
-
 /*
  * How these fields are to be accessed.
  */
 #define si_pid		_sifields._kill._pid
-#ifdef __KERNEL__
-#define si_uid		_sifields._kill._uid32
-#define si_uid16	_sifields._kill._uid
-#else
 #define si_uid		_sifields._kill._uid
-#endif /* __KERNEL__ */
 #define si_status	_sifields._sigchld._status
 #define si_utime	_sifields._sigchld._utime
 #define si_stime	_sifields._sigchld._stime
diff -ur linux/include/linux/highuid.h linux-2.3.40/include/linux/highuid.h
--- linux/include/linux/highuid.h	Wed Jan 19 12:17:42 2000
+++ linux-2.3.40/include/linux/highuid.h	Wed Jan 19 12:17:23 2000
@@ -63,13 +63,6 @@
 #define SET_STAT_UID(stat, uid)		(stat).st_uid = high2lowuid(uid)
 #define SET_STAT_GID(stat, gid)		(stat).st_gid = high2lowgid(gid)
 
-/* specific to kernel/signal.c */
-#ifdef UID16_SIGINFO_COMPAT_NEEDED
-#define SET_SIGINFO_UID16(var, uid)	var = high2lowuid(uid)
-#else
-#define SET_SIGINFO_UID16(var, uid)	do { ; } while (0)
-#endif
-
 #else
 
 #define SET_UID16(var, uid)	do { ; } while (0)
@@ -81,8 +74,6 @@
 #define SET_OLDSTAT_GID(stat, gid)	(stat).st_gid = gid
 #define SET_STAT_UID(stat, uid)		(stat).st_uid = uid
 #define SET_STAT_GID(stat, gid)		(stat).st_gid = gid
-
-#define SET_SIGINFO_UID16(var, uid)	do { ; } while (0)
 
 #endif /* CONFIG_UID16 */
 
diff -ur linux/kernel/signal.c linux-2.3.40/kernel/signal.c
--- linux/kernel/signal.c	Wed Jan 19 12:17:43 2000
+++ linux-2.3.40/kernel/signal.c	Wed Jan 19 12:16:38 2000
@@ -12,7 +12,6 @@
 #include <linux/smp_lock.h>
 #include <linux/init.h>
 #include <linux/sched.h>
-#include <linux/highuid.h>
 
 #include <asm/uaccess.h>
 
@@ -166,7 +165,6 @@
 			info->si_code = 0;
 			info->si_pid = 0;
 			info->si_uid = 0;
-			SET_SIGINFO_UID16(info->si_uid16, 0);
 		}
 
 		if (reset)
@@ -325,7 +323,6 @@
 				q->info.si_code = SI_USER;
 				q->info.si_pid = current->pid;
 				q->info.si_uid = current->uid;
-				SET_SIGINFO_UID16(q->info.si_uid16, current->uid);
 				break;
 			case 1:
 				q->info.si_signo = sig;
@@ -333,7 +330,6 @@
 				q->info.si_code = SI_KERNEL;
 				q->info.si_pid = 0;
 				q->info.si_uid = 0;
-				SET_SIGINFO_UID16(q->info.si_uid16, 0);
 				break;
 			default:
 				q->info = *info;
@@ -783,7 +779,6 @@
 	info.si_code = SI_USER;
 	info.si_pid = current->pid;
 	info.si_uid = current->uid;
-	SET_SIGINFO_UID16(info.si_uid16, current->uid);
 
 	return kill_something_info(sig, &info, pid);
 }

-- 
 Andreas Jaeger
  SuSE Labs aj en suse.de
   private aj en arthur.rhein-neckar.de

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo en vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



Más información sobre la lista de distribución Ayuda