[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090317104330.GA13912@redhat.com>
Date: Tue, 17 Mar 2009 11:43:31 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Gábor Melis <mega@...es.hu>
Cc: Davide Libenzi <davidel@...ilserver.org>,
Ingo Molnar <mingo@...e.hu>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Roland McGrath <roland@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Chris Friesen <cfriesen@...tel.com>,
linux-kernel@...r.kernel.org
Subject: Re: Q: SEGSEGV && uc_mcontext->ip (Was: Signal delivery order)
On 03/17, Gábor Melis wrote:
>
> On Martes 17 Marzo 2009, Oleg Nesterov wrote:
> > On 03/17, Gábor Melis wrote:
> > > On Martes 17 Marzo 2009, Oleg Nesterov wrote:
> > > > But this doesn't look very nice. So, perhaps we can do another
> > > > change?
> > > >
> > > > --- arch/x86/mm/fault.c
> > > > +++ arch/x86/mm/fault.c
> > > > @@ -177,6 +177,13 @@ static void force_sig_info_fault(int si_
> > > > {
> > > > siginfo_t info;
> > > >
> > > > + current->saved_sigmask = current->blocked;
> > > > + spin_lock_irq(¤t->sighand->siglock);
> > > > + siginitsetinv(¤t->blocked, sigmask(si_signo) |
> > > > + sigmask(SIGKILL) | sigmask(SIGSTOP));
> > > > + spin_unlock_irq(¤t->sighand->siglock);
> > > > + set_restore_sigmask();
> > > > +
> > > > info.si_signo = si_signo;
> > > > info.si_errno = 0;
> > > > info.si_code = si_code;
> > > >
> > > > But this is a user-visible change, all signals will be blocked
> > > > until sigsegv_handler() returns. But with this change
> > > > sigsegv_handler() always has the "correct" rt_sigframe.
> > >
> > > As an application developer what I'd like to have is this:
> > > synchronously generated signals are delivered before asynchronously
> > > generated ones. That is, if a number of signals are generated but
> > > not yet delivered then the synchronously generated ones are
> > > delivered first. I guess, in the kernel this would mean that the
> > > private/non-private distinction is not enough.
> >
> > With the change like above, no other signal (except SIGKILL) can be
> > delivered until the signal handler returns.
>
> Surely, you don't mean the above literally:
I literally meant the above ;)
> it would violate the
> standard to prevent all other signals from being delivered until the
> sigsegv handler returns.
Yes. That is why I didn't send the patch but asked the question.
But, just in case, this will not happen if the signal was sent from
user-space via kill/tkill.
> While we are at it, an interesting case is when a synchronously
> generated signal and an asynchronously generated signal - that is also
> of the type that can be synchronously generated - are to be delivered.
> Say we have a fault and a sigsegv generated but some misguided soul
> pthread_kill()s with sigtrap. In this case the sigsegv shall be
> delivered first, and the async sigtrap later.
In this case we can do nothing. The second signal will be lost.
But this is not the problem. If sigsegv_handler() wants to play
with context, it should check SI_FROMKERNEL() first. If we lose
the SIGSEGV from the fault, it will be re-generated.
Oleg.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists