Messages in this thread | | | From | Andy Lutomirski <> | Date | Thu, 22 Aug 2013 11:05:21 -0700 | Subject | Re: [PATCH 2/3] pidns: kill the unnecessary CLONE_NEWPID in copy_process() |
| |
On Thu, Aug 22, 2013 at 10:10 AM, Oleg Nesterov <oleg@redhat.com> wrote: > 8382fcac "pidns: Outlaw thread creation after unshare(CLONE_NEWPID)" > nacks CLONE_NEWPID if the forking process unshared pid_ns. This is > correct but unnecessary, copy_pid_ns() does the same check. > > Test-case (needs root or CLONE_NEWUSER should be added): > > static int child(void *arg) > { > return 0; > } > > static char stack[16 * 1024]; > > int main(void) > { > pid_t pid; > > assert(unshare(CLONE_NEWPID) == 0); > > pid = clone(child, stack + sizeof(stack) / 2, > CLONE_NEWPID | SIGCHLD, NULL); > assert(pid < 0 && errno == EINVAL); > > return 0; > } > > clone(CLONE_NEWPID) correctly fails with or without this change.
Acked-by: Andy Lutomirski <luto@amacapital.net>
> > Signed-off-by: Oleg Nesterov <oleg@redhat.com> > --- > kernel/fork.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/kernel/fork.c b/kernel/fork.c > index 86f5376..8d56338 100644 > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -1176,7 +1176,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, > * If the new process will be in a different pid namespace don't > * allow the creation of threads, or share the signal handlers. > */ > - if ((clone_flags & (CLONE_SIGHAND | CLONE_NEWPID)) && > + if ((clone_flags & CLONE_SIGHAND) && > (task_active_pid_ns(current) != current->nsproxy->pid_ns)) > return ERR_PTR(-EINVAL); > > -- > 1.5.5.1 >
-- Andy Lutomirski AMA Capital Management, LLC
| |