• Oleg Nesterov's avatar
    ptrace: tracehook_report_clone: fix false positives · 087eb437
    Oleg Nesterov authored
    The "trace || CLONE_PTRACE" check in tracehook_report_clone() is not right,
    
    - If the untraced task does clone(CLONE_PTRACE) the new child is not traced,
      we must not queue SIGSTOP.
    
    - If we forked the traced task, but the tracer exits and untraces both the
      forking task and the new child (after copy_process() drops tasklist_lock),
      we should not queue SIGSTOP too.
    
    Change the code to check task_ptrace() != 0 instead. This is still racy, but
    the race is harmless.
    
    We can race with another tracer attaching to this child, or the tracer can
    exit and detach in parallel. But giwen that we didn't do wake_up_new_task()
    yet, the child must have the pending SIGSTOP anyway.
    Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
    Acked-by: default avatarRoland McGrath <roland@redhat.com>
    Cc: Christoph Hellwig <hch@infradead.org>
    Cc: Ingo Molnar <mingo@elte.hu>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    087eb437
fork.c 41.4 KB