mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: <linux-kernel@vger.kernel.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Linus Torvalds <torvalds@transmeta.com>
Subject: [PATCH] Possible bug in dequeue_signal()
Date: Sun, 26 Aug 2001 19:02:24 +0200	[thread overview]
Message-ID: <20010826170224.13518@smtp.wanadoo.fr> (raw)

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.



                 reply	other threads:[~2001-08-26 17:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20010826170224.13518@smtp.wanadoo.fr \
    --to=benh@kernel.crashing.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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 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®