Resent-Date: Fri, 16 Jul 1999 12:08:52 +0200 (MET DST)
Date: Fri, 16 Jul 1999 12:08:41 +0200 (MET DST)
From: Roman Zippel <zippel@fh-brandenburg.de>
X-Sender: zippel@zeus
To: Linux/m68k <linux-m68k@lists.linux-m68k.org>
Subject: bug in signal handling
Resent-From: linux-m68k@phil.uni-sb.de

Hi,

I think I found a bug in our signal handling, below is a patch for 2.0.36
and not tested yet, so it's more a request for comments.
Anyway, it's possible that during a return from a signal, when the return
code on the stack is executed, the return code is overwritten, if another
another signal is delivered to the process. The problem is that the stack
is too early incremented.
2.2 has the same problem, but only for non-realtime signals, for realtime
signals the right thing is already done. On the other hand you will notice
that bug only if you have very signal intensive processes.

bye, Roman

--- arch/m68k/kernel/signal.c.org	Fri Jul 16 11:24:25 1999
+++ arch/m68k/kernel/signal.c	Fri Jul 16 11:26:21 1999
@@ -92,7 +92,7 @@
 	int fsize = 0;
 	int formatvec = 0;
 	unsigned long fp;
-	unsigned long usp = rdusp();
+	unsigned long usp = rdusp() + 16;
 
 #if 0
 	printk("sys_sigreturn, usp=%08x\n", (unsigned) usp);
@@ -236,8 +236,7 @@
  *	       signum  (parm #1)
  *	       sigcode (parm #2 ; vector number)
  *	       scp     (parm #3 ; sigcontext pointer, pointer to #1 below)
- *	       code1   (addaw #20,sp) ; pop parms and code off stack
- *	       code2   (moveq #119,d0; trap #0) ; sigreturn syscall
+ *	       code    (moveq #119,d0; trap #0) ; sigreturn syscall
  *     #1|     oldmask
  *	 |     old usp
  *	 |     d0      (first saved reg)
@@ -300,7 +299,6 @@
 	put_user((ulong)(frame+6), tframe); tframe++;
 
 /* set up the return code... */
-	put_user(0xdefc0014,tframe); tframe++; /* addaw #20,sp */
 	put_user(0x70774e40,tframe); tframe++; /* moveq #119,d0; trap #0 */
 
 /* Flush caches so the instructions will be correctly executed. (MA) */


