2004-04-15 04:02:45

by Jakub Jelinek

[permalink] [raw]
Subject: [PATCH] Fix mq 32-bit compatibility

Hi!

The first change removes just a useless put_user (si_int and si_ptr
are part of the same union, si_ptr is on all arches covering whole
union), the rest is fixes for signal handling of SI_MESGQ.

Tested on x86-64 with 32-bit glibc make check.
Please apply.

--- linux-2.6.5/kernel/signal.c.jj 2004-04-08 22:56:25.000000000 +0200
+++ linux-2.6.5/kernel/signal.c 2004-04-14 23:03:22.000000000 +0200
@@ -2084,7 +2084,6 @@ int copy_siginfo_to_user(siginfo_t __use
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);
err |= __put_user(from->si_ptr, &to->si_ptr);
break;
default: /* this is just in case for now ... */
--- linux-2.6.5/include/asm-mips/siginfo.h.jj 2004-04-04 05:37:07.000000000 +0200
+++ linux-2.6.5/include/asm-mips/siginfo.h 2004-04-14 23:54:20.593383783 +0200
@@ -175,7 +175,7 @@ typedef struct siginfo32 {
#undef SI_MESGQ
#define SI_ASYNCIO -2 /* sent by AIO completion */
#define SI_TIMER __SI_CODE(__SI_TIMER,-3) /* sent by timer expiration */
-#define SI_MESGQ -4 /* sent by real time mesq state change */
+#define SI_MESGQ __SI_CODE(__SI_MESGQ,-4) /* sent by real time mesq state change */

#ifdef __KERNEL__

--- linux-2.6.5/arch/sparc64/kernel/signal32.c.jj 2004-04-14 21:41:52.000000000 +0200
+++ linux-2.6.5/arch/sparc64/kernel/signal32.c 2004-04-14 23:48:56.152527809 +0200
@@ -129,8 +129,8 @@ int copy_siginfo_to_user32(siginfo_t32 _
err |= __put_user(from->si_trapno, &to->si_trapno);
err |= __put_user((long)from->si_addr, &to->si_addr);
break;
- case __SI_RT: /* This is not generated by the kernel as of now. */
- case __SI_MESGQ:
+ case __SI_RT >> 16: /* This is not generated by the kernel as of now. */
+ case __SI_MESGQ >> 16:
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);
--- linux-2.6.5/arch/s390/kernel/compat_signal.c.jj 2004-04-14 21:41:52.000000000 +0200
+++ linux-2.6.5/arch/s390/kernel/compat_signal.c 2004-04-14 23:50:05.429112543 +0200
@@ -74,8 +74,8 @@ int copy_siginfo_to_user32(siginfo_t32 *
err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
else {
switch (from->si_code >> 16) {
- case __SI_RT: /* This is not generated by the kernel as of now. */
- case __SI_MESGQ:
+ case __SI_RT >> 16: /* This is not generated by the kernel as of now. */
+ case __SI_MESGQ >> 16:
err |= __put_user(from->si_int, &to->si_int);
/* fallthrough */
case __SI_KILL >> 16:
--- linux-2.6.5/arch/mips/kernel/signal32.c.jj 2004-04-14 21:41:52.000000000 +0200
+++ linux-2.6.5/arch/mips/kernel/signal32.c 2004-04-14 23:51:19.875770732 +0200
@@ -358,8 +358,8 @@ static int copy_siginfo_to_user32(siginf
err |= __put_user(from->si_band, &to->si_band);
err |= __put_user(from->si_fd, &to->si_fd);
break;
- case __SI_RT: /* This is not generated by the kernel as of now. */
- case __SI_MESGQ:
+ case __SI_RT >> 16: /* This is not generated by the kernel as of now. */
+ case __SI_MESGQ >> 16:
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);
--- linux-2.6.5/arch/ia64/ia32/ia32_signal.c.jj 2004-04-14 21:41:52.000000000 +0200
+++ linux-2.6.5/arch/ia64/ia32/ia32_signal.c 2004-04-14 23:50:45.420945486 +0200
@@ -114,8 +114,8 @@ copy_siginfo_from_user32 (siginfo_t *to,
err |= __get_user(to->si_band, &from->si_band);
err |= __get_user(to->si_fd, &from->si_fd);
break;
- case __SI_RT: /* This is not generated by the kernel as of now. */
- case __SI_MESGQ:
+ case __SI_RT >> 16: /* This is not generated by the kernel as of now. */
+ case __SI_MESGQ >> 16:
err |= __get_user(to->si_pid, &from->si_pid);
err |= __get_user(to->si_uid, &from->si_uid);
err |= __get_user(to->si_int, &from->si_int);
--- linux-2.6.5/arch/x86_64/ia32/ia32_signal.c.jj 2004-04-14 21:41:52.000000000 +0200
+++ linux-2.6.5/arch/x86_64/ia32/ia32_signal.c 2004-04-14 23:21:20.000000000 +0200
@@ -85,8 +85,8 @@ int ia32_copy_siginfo_to_user(siginfo_t3
err |= __put_user(from->si_overrun, &to->si_overrun);
err |= __put_user((u32)(u64)from->si_ptr, &to->si_ptr);
break;
- case __SI_RT: /* This is not generated by the kernel as of now. */
- case __SI_MESGQ:
+ case __SI_RT >> 16: /* This is not generated by the kernel as of now. */
+ case __SI_MESGQ >> 16:
err |= __put_user(from->si_uid, &to->si_uid);
err |= __put_user(from->si_int, &to->si_int);
break;

Jakub