public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [Linux-ia64] Bug in signal handling
@ 2001-12-02 22:05 Andreas Schwab
  2001-12-03  3:15 ` David Mosberger
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Andreas Schwab @ 2001-12-02 22:05 UTC (permalink / raw)
  To: linux-ia64

The kernel does not correctly handle interrupted syscalls that are
supposed to be restarted when two nested signal handlers are executed at
the same time.  To reproduce run this program in one terminal:

#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <string.h>

void
sigusr1 (int sig)
{
  write (2, "SIGUSR1\n", strlen ("SIGUSR1\n"));
}

void
sigusr2 (int sig)
{
  write (2, "SIGUSR2\n", strlen ("SIGUSR2\n"));
}

int
main ()
{
  char c;
  struct sigaction sa;

  printf ("%d\n", getpid ());
  sa.sa_handler = sigusr1;
  sigemptyset (&sa.sa_mask);
  sa.sa_flags = SA_RESTART;
  sigaction (SIGUSR1, &sa, NULL);
  sa.sa_handler = sigusr2;
  sigaction (SIGUSR2, &sa, NULL);
  read (1, &c, 1);
  return 0;
}

Then send both SIGUSR1 and SIGUSR2 to the process from another terminal.
If they arrive close enough then the first signal handler will be
interupted at GATE_ADDR by the second handler.  But ia64_do_signal is
again called with in_syscall == 1, and it will call ia64_decrement_ip
before setting up the signal handler frame.  Thus when the second signal
returns then rt_sigreturn it will return to GATE_ADDR - 16 and crashes.

Andreas.

-- 
Andreas Schwab                                  "And now for something
Andreas.Schwab@suse.de				completely different."
SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-12-05  2:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-12-02 22:05 [Linux-ia64] Bug in signal handling Andreas Schwab
2001-12-03  3:15 ` David Mosberger
2001-12-04 19:53 ` David Mosberger
2001-12-05  1:14 ` Richard Henderson
2001-12-05  2:15 ` David Mosberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox