• Oleg Nesterov's avatar
    do_wait: fix security checks · f2cc3eb1
    Oleg Nesterov authored
    Imho, the current usage of security_task_wait() is not logical.
    
    Suppose we have the single child p, and security_task_wait(p) return
    -EANY.  In that case waitpid(-1) returns this error.  Why? Isn't it
    better to return ECHLD? We don't really have reapable children.
    
    Now suppose that child was stolen by gdb.  In that case we find this
    child on ->ptrace_children and set flag = 1, but we don't check that the
    child was denied.  So, do_wait(..., WNOHANG) returns 0, this doesn't
    match the behaviour above.  Without WNOHANG do_wait() blocks only to
    return the error later, when the child will be untraced.  Inho, really
    strange.
    
    I think eligible_child() should return the error only if the child's pid
    was requested explicitly, otherwise we should silently ignore the tasks
    which were nacked by security_task_wait().
    Signed-off-by: default avatarOleg Nesterov <oleg@tv-sign.ru>
    Cc: Roland McGrath <roland@redhat.com>
    Cc: Chris Wright <chrisw@sous-sol.org>
    Cc: Eric Paris <eparis@redhat.com>
    Cc: James Morris <jmorris@namei.org>
    Cc: Stephen Smalley <sds@tycho.nsa.gov>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    f2cc3eb1
exit.c 42.1 KB