Skip to content
  • Oleg Nesterov's avatar
    pids: introduce change_pid() helper · 24336eae
    Oleg Nesterov authored
    
    
    Based on Eric W. Biederman's idea.
    
    Without tasklist_lock held task_session()/task_pgrp() can return NULL if the
    caller races with setprgp()/setsid() which does detach_pid() + attach_pid().
    This can happen even if task == current.
    
    Intoduce the new helper, change_pid(), which should be used instead.  This way
    the caller always sees the special pid != NULL, either old or new.
    
    Also change the prototype of attach_pid(), it always returns 0 and nobody
    check the returned value.
    
    Signed-off-by: default avatarOleg Nesterov <oleg@tv-sign.ru>
    Cc:  "Eric W. Biederman" <ebiederm@xmission.com>
    Cc: Pavel Emelyanov <xemul@openvz.org>
    Cc: Roland McGrath <roland@redhat.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    24336eae