aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/fork.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2007-12-05 02:45:04 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-12-05 12:21:18 -0500
commit5cd17569fd0eeca510735e63a6061291e3971bf6 (patch)
tree0583bb9f4cc103251da96ba743396a877f4c83b5 /kernel/fork.c
parente00ba3dae077f54cfd2af42e939a618caa7a3bca (diff)
fix clone(CLONE_NEWPID)
Currently we are complicating the code in copy_process, the clone ABI, and if we fix the bugs sys_setsid itself, with an unnecessary open coded version of sys_setsid. So just simplify everything and don't special case the session and pgrp of the initial process in a pid namespace. Having this special case actually presents to user space the classic linux startup conditions with session == pgrp == 0 for /sbin/init. We already handle sending signals to processes in a child pid namespace. We need to handle sending signals to processes in a parent pid namespace for cases like SIGCHILD and SIGIO. This makes nothing extra visible inside a pid namespace. So this extra special case appears to have no redeeming merits. Further removing this special case increases the flexibility of how we can use pid namespaces, by not requiring the initial process in a pid namespace to be a daemon. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Cc: Oleg Nesterov <oleg@tv-sign.ru> Cc: Pavel Emelyanov <xemul@openvz.org> Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 8ca1a14cdc8c..8dd8ff281009 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1292,23 +1292,14 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1292 __ptrace_link(p, current->parent); 1292 __ptrace_link(p, current->parent);
1293 1293
1294 if (thread_group_leader(p)) { 1294 if (thread_group_leader(p)) {
1295 if (clone_flags & CLONE_NEWPID) { 1295 if (clone_flags & CLONE_NEWPID)
1296 p->nsproxy->pid_ns->child_reaper = p; 1296 p->nsproxy->pid_ns->child_reaper = p;
1297 p->signal->tty = NULL;
1298 set_task_pgrp(p, p->pid);
1299 set_task_session(p, p->pid);
1300 attach_pid(p, PIDTYPE_PGID, pid);
1301 attach_pid(p, PIDTYPE_SID, pid);
1302 } else {
1303 p->signal->tty = current->signal->tty;
1304 set_task_pgrp(p, task_pgrp_nr(current));
1305 set_task_session(p, task_session_nr(current));
1306 attach_pid(p, PIDTYPE_PGID,
1307 task_pgrp(current));
1308 attach_pid(p, PIDTYPE_SID,
1309 task_session(current));
1310 }
1311 1297
1298 p->signal->tty = current->signal->tty;
1299 set_task_pgrp(p, task_pgrp_nr(current));
1300 set_task_session(p, task_session_nr(current));
1301 attach_pid(p, PIDTYPE_PGID, task_pgrp(current));
1302 attach_pid(p, PIDTYPE_SID, task_session(current));
1312 list_add_tail_rcu(&p->tasks, &init_task.tasks); 1303 list_add_tail_rcu(&p->tasks, &init_task.tasks);
1313 __get_cpu_var(process_counts)++; 1304 __get_cpu_var(process_counts)++;
1314 } 1305 }