In short: exit_ptrace()->ptrace_detach_task() is very wrong when it tries to detach the !stopped tracee, we can not trust get_stop_event() in this case.
This means that in the case like ptrace(PTRACE_CONT, ..., SIGXXX); exit(); // ---> calls ptrace_detach_task() the tracee can miss SIGXXX if ptrace_detach_task() does utrace_control(UTRACE_DETACH) before the tracee calls ->report_signal(). 5/5 is the actual fix. 1-4 are preparations to simplify the review and document the changes. Oleg.