From: Ralf Baechle <ralf@oss.sgi.com>
To: Atsushi Nemoto <nemoto@toshiba-tops.co.jp>
Cc: linux-mips@oss.sgi.com
Subject: Re: setup_frame() failure
Date: Sat, 8 Sep 2001 01:36:38 +0200 [thread overview]
Message-ID: <20010908013638.A19154@dea.linux-mips.net> (raw)
In-Reply-To: <20010907.202652.71083122.nemoto@toshiba-tops.co.jp>; from nemoto@toshiba-tops.co.jp on Fri, Sep 07, 2001 at 08:26:52PM +0900
On Fri, Sep 07, 2001 at 08:26:52PM +0900, Atsushi Nemoto wrote:
> I found that if setup_frame() fails in certain conditions the process
> which caused the signal grabs CPU and never be killed.
>
> Here is a sample test program.
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <signal.h>
>
> void sighandler(int sig)
> {
> printf("SIGNAL %d!\n", sig);
> exit(2);
> }
> void setup_signal(int sig)
> {
> struct sigaction act;
> memset(&act, 0, sizeof(act));
> act.sa_handler = sighandler;
> act.sa_flags = SA_NOMASK | SA_RESTART;
> sigaction(sig, &act, 0);
> }
>
> int main(int argc, char **argv)
> {
> setup_signal(SIGILL);
> setup_signal(SIGQUIT);
> setup_signal(SIGINT);
>
> __asm__ __volatile__("move $29,$0");
> __asm__ __volatile__("mfc0 $0,$0");
> printf("done!\n");
> return 0;
> }
>
>
> This program setups signal handlers and causes Coprocessor Unusable
> Exception with $sp == 0.
>
> If we run this program,
>
> 1. "mfc1" instruction raises a exception.
> 2. The exception handler queues SIGILL(4).
> 3. do_signal() dequeue a signal with LOWEST number.
> 4. setup_frame() fails and queues SIGSEGV(11).
> 5. returns to user process.
> 6. again from 1. (forever)
>
> So, even SIGKILL can not kill the process. (SIGHUP can do it).
>
> I make a change for do_signal() to check failure of setup_frame() and
> continue processing pending signals. It seems work for me. Here is
> the patch. Any comments are welcome.
Nice test case. Thanks. I decied for a differnet fix attached below.
Ralf
Index: arch/mips64/kernel/traps.c
===================================================================
RCS file: /home/pub/cvs/linux/arch/mips64/kernel/traps.c,v
retrieving revision 1.20
diff -u -r1.20 traps.c
--- arch/mips64/kernel/traps.c 2001/07/11 23:32:54 1.20
+++ arch/mips64/kernel/traps.c 2001/09/07 23:29:16
@@ -347,11 +347,9 @@
void do_ri(struct pt_regs *regs)
{
- printk("Cpu%d[%s:%d] Illegal instruction at %08lx ra=%08lx\n",
- smp_processor_id(), current->comm, current->pid, regs->cp0_epc,
- regs->regs[31]);
if (compute_return_epc(regs))
return;
+
force_sig(SIGILL, current);
}
@@ -388,6 +386,7 @@
return;
bad_cid:
+ compute_return_epc(regs);
force_sig(SIGILL, current);
}
Index: arch/mips/kernel/traps.c
===================================================================
RCS file: /home/pub/cvs/linux/arch/mips/kernel/traps.c,v
retrieving revision 1.78
diff -u -r1.78 traps.c
--- arch/mips/kernel/traps.c 2001/09/06 13:22:24 1.78
+++ arch/mips/kernel/traps.c 2001/09/07 23:29:16
@@ -606,9 +606,6 @@
asmlinkage void do_ri(struct pt_regs *regs)
{
- unsigned int opcode;
-
- get_insn_opcode(regs, &opcode);
if (compute_return_epc(regs))
return;
@@ -659,6 +656,7 @@
return;
bad_cid:
+ compute_return_epc(regs);
force_sig(SIGILL, current);
}
next prev parent reply other threads:[~2001-09-08 0:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-09-07 11:26 setup_frame() failure Atsushi Nemoto
2001-09-07 23:36 ` Ralf Baechle [this message]
2001-09-10 2:44 ` Atsushi Nemoto
2001-09-12 4:09 ` Atsushi Nemoto
2001-09-13 1:11 ` Ralf Baechle
2001-09-14 2:16 ` Atsushi Nemoto
2001-09-14 20:14 ` Ralf Baechle
2001-09-17 3:28 ` Atsushi Nemoto
2001-09-10 7:28 ` Carsten Langgaard
2001-09-10 9:19 ` Ralf Baechle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010908013638.A19154@dea.linux-mips.net \
--to=ralf@oss.sgi.com \
--cc=linux-mips@oss.sgi.com \
--cc=nemoto@toshiba-tops.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.