mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Possible bug in dequeue_signal()
@ 2001-08-26 17:02 Benjamin Herrenschmidt
  0 siblings, 0 replies; only message in thread
From: Benjamin Herrenschmidt @ 2001-08-26 17:02 UTC (permalink / raw)
  To: linux-kernel; +Cc: Alan Cox, Linus Torvalds

I had a crash on PPC that I tracked down to be a bug in dequeue_signal()
in kernel/signal.c, and that probably happens on other archs as well.

do_signal() can loop & block. The exit condition of the loop in this case
is when dequeue_signal() returns 0. It continues calling it until that
point, it doesn't re-check current->sigpending.

That means on the second iteration, dequeue_signal() can actually be called
with no pending signal.

A that point, dequeue_signal() calls next_signal() which returns 0. The
problem begins when the current task has a "notifier" installed (which
in my case was done by DRM). If current->notifier is non-null, then we
call sigismember() passing it 0 as the "sig" parameter.

sigismember will then do pointer arithmetic with "sig-1", that is
0xffffffff which will crashes when dereferencing.

The patch is simple:

===== kernel/signal.c 1.1 vs edited =====
--- 1.1/kernel/signal.c	Sat Jan  6 08:26:12 2001
+++ edited/kernel/signal.c	Sun Aug 26 18:50:51 2001
@@ -242,7 +242,7 @@
 #endif
 
 	sig = next_signal(current, mask);
-	if (current->notifier) {
+	if (sig && current->notifier) {
 		if (sigismember(current->notifier_mask, sig)) {
 			if (!(current->notifier)(current->notifier_data)) {
 				current->sigpending = 0;

(You may want to factor with the other if (sig) that is
done just after that code).

Ben.



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-08-26 17:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-26 17:02 [PATCH] Possible bug in dequeue_signal() Benjamin Herrenschmidt

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

all inboxes | Powered by JetHome®