Skip to content

Commit 5167246

Browse files
oleg-nesterovtorvalds
authored andcommitted
pidns: kill the unnecessary CLONE_NEWPID in copy_process()
Commit 8382fca ("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. Remove the CLONE_NEWPID check to cleanup the code and prepare for the next change. Test-case: static int child(void *arg) { return 0; } static char stack[16 * 1024]; int main(void) { pid_t pid; assert(unshare(CLONE_NEWUSER | 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. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Andy Lutomirski <luto@amacapital.net> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Colin Walters <walters@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e79f525 commit 5167246

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎kernel/fork.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,9 +1177,8 @@ static struct task_struct *copy_process(unsigned long clone_flags,
11771177
* allow it to share a thread group or signal handlers with the
11781178
* forking task.
11791179
*/
1180-
if ((clone_flags & (CLONE_SIGHAND | CLONE_NEWPID)) &&
1181-
(task_active_pid_ns(current) !=
1182-
current->nsproxy->pid_ns_for_children))
1180+
if ((clone_flags & CLONE_SIGHAND) && (task_active_pid_ns(current) !=
1181+
current->nsproxy->pid_ns_for_children))
11831182
return ERR_PTR(-EINVAL);
11841183

11851184
retval = security_task_create(clone_flags);

0 commit comments

Comments
 (0)