linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [patch] signal handler defaulting fix ...
       [not found] <2cfBL-6uJ-9@gated-at.bofh.it>
@ 2004-07-03 13:54 ` Kai Henningsen
  0 siblings, 0 replies; 10+ messages in thread
From: Kai Henningsen @ 2004-07-03 13:54 UTC (permalink / raw)
  To: froese; +Cc: linux-kernel

froese@gmx.de (Edgar Toernig)  wrote on 29.06.04 in <2cfBL-6uJ-9@gated-at.bofh.it>:

> Not the signal part.  It was written for libc5.  There, signals set
> with signal(2) were reset when raised (SysV-style).  Leaving such a
> signal handler with longjmp was perfectly valid.
>
> Glibc2 changed the rules: signals set with signal(2) are not reset
> but blocked during delivery (BSD-style).  It worked for a while
> because the kernel ignored the sigmask for some signals.
>
> So, if one is to blame then glibc2 by breaking compatibility.

You might want to study /usr/include/signal.h and /usr/include/feature.h.

And then you might try stuff like -D_SVID_SOURCE or -Dsignal=sysv_signal,  
for example.

And stop blaming glibc for your failures.

MfG Kai

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

* Re: [patch] signal handler defaulting fix ...
  2004-06-29  1:24         ` Edgar Toernig
@ 2004-06-29 12:02           ` Jörn Engel
  0 siblings, 0 replies; 10+ messages in thread
From: Jörn Engel @ 2004-06-29 12:02 UTC (permalink / raw)
  To: Edgar Toernig
  Cc: Linus Torvalds, Davide Libenzi, Andrew Morton, Linux Kernel Mailing List

On Tue, 29 June 2004 03:24:41 +0200, Edgar Toernig wrote:
> Linus Torvalds wrote:
> > 
> > So? That program is buggy.
> 
> Not the signal part.  It was written for libc5.  There, signals set
> with signal(2) were reset when raised (SysV-style).  Leaving such a
> signal handler with longjmp was perfectly valid.

But has a very distinct problem.  A segmentation fault is usually a
bug and deserves a core dump.  Sane default behaviour.  If the program
tells the kernel, it can handle segmentation faults on it's own, fine.
But if - while handling the fault - it creates a second one, the claim
was obviously false.  Coredump, done.

Now, how can the kernel tell, whether a second segmentation fault
happened inside the handler or after successfully handling the first
one?  Right, with longjmp it can't.  Coredump, done.

Jörn

-- 
Victory in war is not repetitious.
-- Sun Tzu

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

* Re: [patch] signal handler defaulting fix ...
  2004-06-28 22:08       ` Linus Torvalds
  2004-06-28 22:13         ` Davide Libenzi
@ 2004-06-29  1:24         ` Edgar Toernig
  2004-06-29 12:02           ` Jörn Engel
  1 sibling, 1 reply; 10+ messages in thread
From: Edgar Toernig @ 2004-06-29  1:24 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Davide Libenzi, Andrew Morton, Linux Kernel Mailing List

Linus Torvalds wrote:
> 
> On Mon, 28 Jun 2004, Davide Libenzi wrote:
> > 
> > It's not that the program try to block the signal. It's the kernel that 
> > during the delivery disables the signal. Then when the signal handler 
> > longjmp(), the signal remains disabled. The next time the signal is raised 
> > again, the kernel does not honor the existing handler, but it reset to 
> > SIG_DFL.
> 
> So? That program is buggy.

Not the signal part.  It was written for libc5.  There, signals set
with signal(2) were reset when raised (SysV-style).  Leaving such a
signal handler with longjmp was perfectly valid.

Glibc2 changed the rules: signals set with signal(2) are not reset
but blocked during delivery (BSD-style).  It worked for a while
because the kernel ignored the sigmask for some signals.

So, if one is to blame then glibc2 by breaking compatibility.

With Davide's patch the kernel would be a little bit more tolerant to
old code by keeping the 2.4 behaviour.  The current strict behaviour
becomes OK when signal(2) is no longer part of glibc...

Ciao, ET.

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

* Re: [patch] signal handler defaulting fix ...
  2004-06-28 22:08       ` Linus Torvalds
@ 2004-06-28 22:13         ` Davide Libenzi
  2004-06-29  1:24         ` Edgar Toernig
  1 sibling, 0 replies; 10+ messages in thread
From: Davide Libenzi @ 2004-06-28 22:13 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Linux Kernel Mailing List

On Mon, 28 Jun 2004, Linus Torvalds wrote:

> On Mon, 28 Jun 2004, Davide Libenzi wrote:
> > 
> > It's not that the program try to block the signal. It's the kernel that 
> > during the delivery disables the signal. Then when the signal handler 
> > longjmp(), the signal remains disabled. The next time the signal is raised 
> > again, the kernel does not honor the existing handler, but it reset to 
> > SIG_DFL.
> 
> So? That program is buggy. Setting the signal handler to SIG_DFL causes it 
> to be killed with a nice "killed by SIGFPE" message, and now the bug is 
> visible, and can be fixed.
> 
> Hint: it should have done a siglongjmp().

That's what I posted him. Three examples on how to make the thing work 
w/out kernel fixes. Then Andries investigated about POSIX compliancy and 
noticed that basically it is undefined the behaviour a program will get. 
Let's leave as is then.



- Davide


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

* Re: [patch] signal handler defaulting fix ...
  2004-06-28 21:55     ` Davide Libenzi
@ 2004-06-28 22:08       ` Linus Torvalds
  2004-06-28 22:13         ` Davide Libenzi
  2004-06-29  1:24         ` Edgar Toernig
  0 siblings, 2 replies; 10+ messages in thread
From: Linus Torvalds @ 2004-06-28 22:08 UTC (permalink / raw)
  To: Davide Libenzi; +Cc: Andrew Morton, Linux Kernel Mailing List



On Mon, 28 Jun 2004, Davide Libenzi wrote:
> 
> It's not that the program try to block the signal. It's the kernel that 
> during the delivery disables the signal. Then when the signal handler 
> longjmp(), the signal remains disabled. The next time the signal is raised 
> again, the kernel does not honor the existing handler, but it reset to 
> SIG_DFL.

So? That program is buggy. Setting the signal handler to SIG_DFL causes it 
to be killed with a nice "killed by SIGFPE" message, and now the bug is 
visible, and can be fixed.

Hint: it should have done a siglongjmp().

		Linus

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

* Re: [patch] signal handler defaulting fix ...
  2004-06-28 21:49   ` Linus Torvalds
@ 2004-06-28 21:55     ` Davide Libenzi
  2004-06-28 22:08       ` Linus Torvalds
  0 siblings, 1 reply; 10+ messages in thread
From: Davide Libenzi @ 2004-06-28 21:55 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Linux Kernel Mailing List

On Mon, 28 Jun 2004, Linus Torvalds wrote:

> On Mon, 28 Jun 2004, Andrew Morton wrote:
> >
> > Davide Libenzi <davidel@xmailserver.org> wrote:
> > >
> > > 
> > > Following up from the other thread (2.6.x signal handler bug) this bring 
> > > 2.4 behaviour in 2.6.
> > > 
> > 
> > Pity the poor person who tries to understand this change in a year's time. 
> > Could we have a real changelog please?
> 
> Also, do we really care? The 2.6.x behaviour is nicer in that it tends to
> kill programs more abruptly, while 2.4.x will just let a blocked signal
> through - possibly letting the program continue, but causing "impossible"  
> bugs in user space.
> 
> I don't think we've had any complaints about the 2.6.x behaviour apart
> from the initial discussion a few months ago. I'd much rather have a
> debuggable "kill a program that tries to block a synchronous interrupt",
> than a potentially totally un-debuggable "let the signal through".

It's not that the program try to block the signal. It's the kernel that 
during the delivery disables the signal. Then when the signal handler 
longjmp(), the signal remains disabled. The next time the signal is raised 
again, the kernel does not honor the existing handler, but it reset to 
SIG_DFL.



- Davide


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

* Re: [patch] signal handler defaulting fix ...
  2004-06-28 21:40 ` Andrew Morton
  2004-06-28 21:49   ` Linus Torvalds
@ 2004-06-28 21:49   ` Jörn Engel
  1 sibling, 0 replies; 10+ messages in thread
From: Jörn Engel @ 2004-06-28 21:49 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Davide Libenzi, linux-kernel, torvalds

On Mon, 28 June 2004 14:40:03 -0700, Andrew Morton wrote:
> Davide Libenzi <davidel@xmailserver.org> wrote:
> >
> > 
> > Following up from the other thread (2.6.x signal handler bug) this bring 
> > 2.4 behaviour in 2.6.
> > 
> 
> Pity the poor person who tries to understand this change in a year's time. 
> Could we have a real changelog please?

It better be a good one.  I've hit a real problem that raised more
than a few eyebrows.  In short, if some program is stupid enough to
cause a segfault inside a segfault-handler, it doesn't have a reason
to survive.

Your patch will let the poor creature live an unhappy life.  No good.

Jörn

-- 
More computing sins are committed in the name of efficiency (without
necessarily achieving it) than for any other single reason - including
blind stupidity.
-- W. A. Wulf 

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

* Re: [patch] signal handler defaulting fix ...
  2004-06-28 21:40 ` Andrew Morton
@ 2004-06-28 21:49   ` Linus Torvalds
  2004-06-28 21:55     ` Davide Libenzi
  2004-06-28 21:49   ` Jörn Engel
  1 sibling, 1 reply; 10+ messages in thread
From: Linus Torvalds @ 2004-06-28 21:49 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Davide Libenzi, linux-kernel



On Mon, 28 Jun 2004, Andrew Morton wrote:
>
> Davide Libenzi <davidel@xmailserver.org> wrote:
> >
> > 
> > Following up from the other thread (2.6.x signal handler bug) this bring 
> > 2.4 behaviour in 2.6.
> > 
> 
> Pity the poor person who tries to understand this change in a year's time. 
> Could we have a real changelog please?

Also, do we really care? The 2.6.x behaviour is nicer in that it tends to
kill programs more abruptly, while 2.4.x will just let a blocked signal
through - possibly letting the program continue, but causing "impossible"  
bugs in user space.

I don't think we've had any complaints about the 2.6.x behaviour apart
from the initial discussion a few months ago. I'd much rather have a
debuggable "kill a program that tries to block a synchronous interrupt",
than a potentially totally un-debuggable "let the signal through".

		Linus

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

* Re: [patch] signal handler defaulting fix ...
  2004-06-28 21:34 Davide Libenzi
@ 2004-06-28 21:40 ` Andrew Morton
  2004-06-28 21:49   ` Linus Torvalds
  2004-06-28 21:49   ` Jörn Engel
  0 siblings, 2 replies; 10+ messages in thread
From: Andrew Morton @ 2004-06-28 21:40 UTC (permalink / raw)
  To: Davide Libenzi; +Cc: linux-kernel, torvalds

Davide Libenzi <davidel@xmailserver.org> wrote:
>
> 
> Following up from the other thread (2.6.x signal handler bug) this bring 
> 2.4 behaviour in 2.6.
> 

Pity the poor person who tries to understand this change in a year's time. 
Could we have a real changelog please?


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

* [patch] signal handler defaulting fix ...
@ 2004-06-28 21:34 Davide Libenzi
  2004-06-28 21:40 ` Andrew Morton
  0 siblings, 1 reply; 10+ messages in thread
From: Davide Libenzi @ 2004-06-28 21:34 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Linus Torvalds, Andrew Morton


Following up from the other thread (2.6.x signal handler bug) this bring 
2.4 behaviour in 2.6.


Signed-off-by: Davide Libenzi <davidel@xmailserver.org>



- Davide



--- a/kernel/signal.c	2004-06-28 14:28:51.000000000 -0700
+++ b/kernel/signal.c	2004-06-28 14:29:31.000000000 -0700
@@ -820,8 +820,9 @@
 	int ret;
 
 	spin_lock_irqsave(&t->sighand->siglock, flags);
-	if (sigismember(&t->blocked, sig) || t->sighand->action[sig-1].sa.sa_handler == SIG_IGN) {
+	if (t->sighand->action[sig-1].sa.sa_handler == SIG_IGN)
 		t->sighand->action[sig-1].sa.sa_handler = SIG_DFL;
+	if (sigismember(&t->blocked, sig)) {
 		sigdelset(&t->blocked, sig);
 		recalc_sigpending_tsk(t);
 	}

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

end of thread, other threads:[~2004-07-04  4:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <2cfBL-6uJ-9@gated-at.bofh.it>
2004-07-03 13:54 ` [patch] signal handler defaulting fix Kai Henningsen
2004-06-28 21:34 Davide Libenzi
2004-06-28 21:40 ` Andrew Morton
2004-06-28 21:49   ` Linus Torvalds
2004-06-28 21:55     ` Davide Libenzi
2004-06-28 22:08       ` Linus Torvalds
2004-06-28 22:13         ` Davide Libenzi
2004-06-29  1:24         ` Edgar Toernig
2004-06-29 12:02           ` Jörn Engel
2004-06-28 21:49   ` Jörn Engel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).