• Eric W. Biederman's avatar
    pid: sys_wait... fixes · 161550d7
    Eric W. Biederman authored
    This modifies do_wait and eligible child to take a pair of enum pid_type
    and struct pid *pid to precisely specify what set of processes are eligible
    to be waited for, instead of the raw pid_t value from sys_wait4.
    
    This fixes a bug in sys_waitid where you could not wait for children in
    just process group 1.
    
    This fixes a pid namespace crossing case in eligible_child.  Allowing us to
    wait for a processes in our current process group even if our current
    process group == 0.
    
    This allows the no child with this pid case to be optimized.  This allows
    us to optimize the pid membership test in eligible child to be optimized.
    
    This even closes a theoretical pid wraparound race where in a threaded
    parent if two threads are waiting for the same child and one thread picks
    up the child and the pid numbers wrap around and generate another child
    with that same pid before the other thread is scheduled (teribly insanely
    unlikely) we could end up waiting on the second child with the same pid#
    and not discover that the specific child we were waiting for has exited.
    
    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
    Cc: Oleg Nesterov <oleg@tv-sign.ru>
    Cc: Pavel Emelyanov <xemul@openvz.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    161550d7
exit.c 41.8 KB