Skip to content

Commit 8382fca

Browse files
committed
pidns: Outlaw thread creation after unshare(CLONE_NEWPID)
The sequence: unshare(CLONE_NEWPID) clone(CLONE_THREAD|CLONE_SIGHAND|CLONE_VM) Creates a new process in the new pid namespace without setting pid_ns->child_reaper. After forking this results in a NULL pointer dereference. Avoid this and other nonsense scenarios that can show up after creating a new pid namespace with unshare by adding a new check in copy_prodcess. Pointed-out-by: Oleg Nesterov <[email protected]> Acked-by: Oleg Nesterov <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent a49f0d1 commit 8382fca

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

kernel/fork.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,14 @@ static struct task_struct *copy_process(unsigned long clone_flags,
11661166
current->signal->flags & SIGNAL_UNKILLABLE)
11671167
return ERR_PTR(-EINVAL);
11681168

1169+
/*
1170+
* If the new process will be in a different pid namespace
1171+
* don't allow the creation of threads.
1172+
*/
1173+
if ((clone_flags & (CLONE_VM|CLONE_NEWPID)) &&
1174+
(task_active_pid_ns(current) != current->nsproxy->pid_ns))
1175+
return ERR_PTR(-EINVAL);
1176+
11691177
retval = security_task_create(clone_flags);
11701178
if (retval)
11711179
goto fork_out;

0 commit comments

Comments
 (0)