• Roland McGrath's avatar
    [PATCH] cleanup ptrace stops and remove notify_parent · cece79ae
    Roland McGrath authored
    This adds a new state TASK_TRACED that is used in place of TASK_STOPPED
    when a thread stops because it is ptraced.  Now ptrace operations are only
    permitted when the target is in TASK_TRACED state, not in TASK_STOPPED. 
    This means that if a process is stopped normally by a job control signal
    and then you PTRACE_ATTACH to it, you will have to send it a SIGCONT before
    you can do any ptrace operations on it.  (The SIGCONT will be reported to
    ptrace and then you can discard it instead of passing it through when you
    call PTRACE_CONT et al.)
    
    If a traced child gets orphaned while in TASK_TRACED state, it morphs into
    TASK_STOPPED state.  This makes it again possible to resume or destroy the
    process with SIGCONT or SIGKILL.
    
    All non-signal tracing stops should now be done via ptrace_notify.  I've
    updated the syscall tracing code in several architectures to do this
    instead of replicating the work by hand.  I also fixed several that were
    unnecessarily repeating some of the checks in ptrace_check_attach.  Calling
    ptrace_check_attach alone is sufficient, and the old checks repeated before
    are now incorrect, not just superfluous.
    
    I've closed a race in ptrace_check_attach.  With this, we should have a
    robust guarantee that when ptrace starts operating, the task will be in
    TASK_TRACED state and won't come out of it.  This is because the only way
    to resume from TASK_TRACED is via ptrace operations, and only the one
    parent thread attached as the tracer can do those.
    
    This patch also cleans up the do_notify_parent and do_notify_parent_cldstop
    code so that the dead and stopped cases are completely disjoint.  The
    notify_parent function is gone.
    Signed-off-by: default avatarRoland McGrath <roland@redhat.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    cece79ae
ptrace.c 5.75 KB