mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Ed Swierk <eswierk@aristanetworks.com>, Oleg Nesterov <oleg@redhat.com>
Cc: rml@tech9.net, linux-kernel@vger.kernel.org,
	kpreempt-tech@lists.sourceforge.net
Subject: Re: [PATCH] Fix BUG: using smp_processor_id() in preemptible code in print_fatal_signal()
Date: Tue, 27 Jan 2009 00:15:55 +0100	[thread overview]
Message-ID: <20090126231555.GB6556@elte.hu> (raw)
In-Reply-To: <1233010818.14510.11.camel@localhost.localdomain>


* Ed Swierk <eswierk@aristanetworks.com> wrote:

> With print-fatal-signals=1 on a kernel with CONFIG_PREEMPT=y, sending an
> unexpected signal to a process causes a BUG: using smp_processor_id() in
> preemptible code.
> 
> get_signal_to_deliver() releases the siglock before calling
> print_fatal_signal(), which calls show_regs(), which calls
> smp_processor_id(), which is not supposed to be called from a
> preemptible thread.
> 
> Calling print_fatal_signal() before releasing the siglock avoids this
> problem.
> 
> Signed-off-by: Ed Swierk <eswierk@aristanetworks.com>
> 
> ---
> Index: linux-2.6.27.4/kernel/signal.c
> ===================================================================
> --- linux-2.6.27.4.orig/kernel/signal.c
> +++ linux-2.6.27.4/kernel/signal.c
> @@ -1848,6 +1848,11 @@ relock:
>  			continue;
>  		}
>  
> +		if (sig_kernel_coredump(signr) && print_fatal_signals) {
> +			/* hold lock for smp_processor_id() */
> +			print_fatal_signal(regs, info->si_signo);
> +		}
> +
>  		spin_unlock_irq(&sighand->siglock);

This trades a (harmless) debug warning against a potential deadlock or 
even a crash, because print_fatal_signal() can do this:

                        __get_user(insn, (unsigned char *)(regs->ip + i));

which will work without a fault most of the time but might also generate a 
pagefault and schedule away from atomic context.

So please add preempt_disable()+preempt_enable() calls around the 
show_regs() call instead.

	Ingo

  reply	other threads:[~2009-01-26 23:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-26 23:00 Ed Swierk
2009-01-26 23:15 ` Ingo Molnar [this message]
2009-01-26 23:33   ` Ed Swierk
2009-01-26 23:37     ` Ingo Molnar
2009-01-27  0:41       ` Oleg Nesterov
2009-01-27  1:34         ` Ed Swierk
2009-01-27  3:02           ` Oleg Nesterov
2009-01-27 12:46             ` Ingo Molnar

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=20090126231555.GB6556@elte.hu \
    --to=mingo@elte.hu \
    --cc=eswierk@aristanetworks.com \
    --cc=kpreempt-tech@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=rml@tech9.net \
    /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®