• Eric W. Biederman's avatar
    ptrace: Properly initialize ptracer_cred on fork · 7c24a70c
    Eric W. Biederman authored
    commit c70d9d80 upstream.
    
    When I introduced ptracer_cred I failed to consider the weirdness of
    fork where the task_struct copies the old value by default.  This
    winds up leaving ptracer_cred set even when a process forks and
    the child process does not wind up being ptraced.
    
    Because ptracer_cred is not set on non-ptraced processes whose
    parents were ptraced this has broken the ability of the enlightenment
    window manager to start setuid children.
    
    Fix this by properly initializing ptracer_cred in ptrace_init_task
    
    This must be done with a little bit of care to preserve the current value
    of ptracer_cred when ptrace carries through fork.  Re-reading the
    ptracer_cred from the ptracing process at this point is inconsistent
    with how PT_PTRACE_CAP has been maintained all of these years.
    Tested-by: 's avatarTakashi Iwai <tiwai@suse.de>
    Fixes: 64b875f7 ("ptrace: Capture the ptracer's creds not PT_PTRACE_CAP")
    Signed-off-by: 's avatar"Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: 's avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    7c24a70c