lkml.org 
[lkml]   [2009]   [Mar]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: Q: SEGSEGV && uc_mcontext->ip (Was: Signal delivery order)
    Date
    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(&current->sighand->siglock);
    > > > + siginitsetinv(&current->blocked, sigmask(si_signo) |
    > > > + sigmask(SIGKILL) | sigmask(SIGSTOP));
    > > > + spin_unlock_irq(&current->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: it would violate the
    standard to prevent all other signals from being delivered until the
    sigsegv handler returns.

    > Probably it is better to just change force_sig_info(), in this case
    > SIGFPE/etc will have the same behaviour.

    Indeed, uniformity seems preferable to me.

    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.

    > > The only thing that
    > > worries me is this remark from Oleg
    > > (http://marc.info/?l=linux-kernel&m=123711058421913&w=2):
    > >
    > > "But please note that it is still possible to hit
    > > is_signal_blocked() even with test_with_kill(), but the probability
    > > is very low."
    >
    > Sorry for confusion. Initially I misread test_with_kill() case, and
    > then forgot to remove this part. I think this is not possible.

    Thanks for the clarification.

    > Oleg.
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2009-03-17 11:23    [W:0.025 / U:0.308 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site