• Oleg Nesterov's avatar
    fork: unify and tighten up CLONE_NEWUSER/CLONE_NEWPID checks · 40a0d32d
    Oleg Nesterov authored
    do_fork() denies CLONE_THREAD | CLONE_PARENT if NEWUSER | NEWPID.
    
    Then later copy_process() denies CLONE_SIGHAND if the new process will
    be in a different pid namespace (task_active_pid_ns() doesn't match
    current->nsproxy->pid_ns).
    
    This looks confusing and inconsistent.  CLONE_NEWPID is very similar to
    the case when ->pid_ns was already unshared, we want the same
    restrictions so copy_process() should also nack CLONE_PARENT.
    
    And it would be better to deny CLONE_NEWUSER && CLONE_SIGHAND as well
    just for consistency.
    
    Kill the "CLONE_NEWUSER | CLONE_NEWPID" check in do_fork() and change
    copy_process() to do the same check along with ->pid_ns check we already
    have.
    Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
    Acked-by: default avatarAndy Lutomirski <luto@amacapital.net>
    Cc: "Eric W. Biederman" <ebiederm@xmission.com>
    Cc: Colin Walters <walters@redhat.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    40a0d32d
fork.c 45.7 KB