mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fork:  Allow init to become a session leader.
@ 2006-02-08 16:10 Eric W. Biederman
  2006-02-08 18:28 ` Oleg Nesterov
  0 siblings, 1 reply; 3+ messages in thread
From: Eric W. Biederman @ 2006-02-08 16:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Oleg Nesterov, linux-kernel


With the bug fixes from killing session == 0 and pgrp == 0 we
have essentially made pid == 1 a session leader.  However reading
through the code I can see nothing, that sets the session->leader
flag.  In fact we actively clear it in all cases during clone.
And setsid will fail to set it because the session == 1 and
process group == 1 already exist.

So this patch forces the session leader flag and for good measure
the pgrp, session and tty of init as well.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>


---

 kernel/fork.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

6bc9fa2aca38bf739e20ae6192a068310ff9739a
diff --git a/kernel/fork.c b/kernel/fork.c
index a08e5cf..ff10b11 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1179,9 +1179,16 @@ static task_t *copy_process(unsigned lon
 		attach_pid(p, PIDTYPE_PID, p->pid);
 		attach_pid(p, PIDTYPE_TGID, p->tgid);
 		if (thread_group_leader(p)) {
-			p->signal->tty = current->signal->tty;
-			p->signal->pgrp = process_group(current);
-			p->signal->session = current->signal->session;
+			if (unlikely(p->pid == 1)) {
+				p->signal->tty = NULL;
+				p->signal->leader = 1;
+				p->signal->pgrp = 1;
+				p->signal->session = 1;
+			} else {
+				p->signal->tty = current->signal->tty;
+				p->signal->pgrp = process_group(current);
+				p->signal->session = current->signal->session;
+			}
 			attach_pid(p, PIDTYPE_PGID, process_group(p));
 			attach_pid(p, PIDTYPE_SID, p->signal->session);
 			__get_cpu_var(process_counts)++;
-- 
1.1.5.g3480


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-02-08 17:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-08 16:10 [PATCH] fork: Allow init to become a session leader Eric W. Biederman
2006-02-08 18:28 ` Oleg Nesterov
2006-02-08 17:29   ` Eric W. Biederman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®