• Marco Elver's avatar
    signal: Deliver SIGTRAP on perf event asynchronously if blocked · 78ed93d7
    Marco Elver authored
    With SIGTRAP on perf events, we have encountered termination of
    processes due to user space attempting to block delivery of SIGTRAP.
    Consider this case:
    
        <set up SIGTRAP on a perf event>
        ...
        sigset_t s;
        sigemptyset(&s);
        sigaddset(&s, SIGTRAP | <and others>);
        sigprocmask(SIG_BLOCK, &s, ...);
        ...
        <perf event triggers>
    
    When the perf event triggers, while SIGTRAP is blocked, force_sig_perf()
    will force the signal, but revert back to the default handler, thus
    terminating the task.
    
    This makes sense for error conditions, but not so much for explicitly
    requested monitoring. However, the expectation is still that signals
    generated by perf events are synchronous, which will no longer be the
    case if the signal is blocked and delivered later.
    
    To give user space the ability to clearly distinguish synchronous from
    asynchronous signals, introduce siginfo_t::si_perf_flags and
    TRAP_PERF_FLAG_ASYNC (opted for flags in case mo...
    78ed93d7
signal.c 25.7 KB