Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e4cc0a9c876d4d4eadaef97a2bff4a199946d202
Commit:     e4cc0a9c876d4d4eadaef97a2bff4a199946d202
Parent:     4e021306cff4277764a42065214fc73f2d26be4b
Author:     Oleg Nesterov <[EMAIL PROTECTED]>
AuthorDate: Fri Feb 8 04:19:09 2008 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Fri Feb 8 09:22:27 2008 -0800

    fix setsid() for sub-namespace /sbin/init
    
    sys_setsid() still deals with pid_t's from the global namespace. This means
    that the "session > 1" check can't help for sub-namespace init, setsid() 
can't
    succeed because copy_process(CLONE_NEWPID) populates PIDTYPE_PGID/SID links.
    
    Remove the usage of task_struct->pid and convert the code to use "struct 
pid".
    This also simplifies and speedups the code, saves one find_pid().
    
    Signed-off-by: Oleg Nesterov <[EMAIL PROTECTED]>
    Cc: "Eric W. Biederman" <[EMAIL PROTECTED]>
    Acked-by: Pavel Emelyanov <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 kernel/sys.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/kernel/sys.c b/kernel/sys.c
index 42136dd..e13bc51 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1045,35 +1045,33 @@ asmlinkage long sys_getsid(pid_t pid)
 asmlinkage long sys_setsid(void)
 {
        struct task_struct *group_leader = current->group_leader;
-       pid_t session;
+       struct pid *sid = task_pid(group_leader);
+       pid_t session = pid_vnr(sid);
        int err = -EPERM;
 
        write_lock_irq(&tasklist_lock);
-
        /* Fail if I am already a session leader */
        if (group_leader->signal->leader)
                goto out;
 
-       session = group_leader->pid;
-       /* Fail if a process group id already exists that equals the
-        * proposed session id.
+       /* Fail if a process group id already exists that equals the proposed
+        * session id.
         *
-        * Don't check if session id == 1 because kernel threads use this
-        * session id and so the check will always fail and make it so
-        * init cannot successfully call setsid.
+        * Don't check if session == 1 because kernel threads and CLONE_NEWPID
+        * tasks use this session id and so the check will always fail and make
+        * it so init cannot successfully call setsid.
         */
-       if (session > 1 && find_task_by_pid_type_ns(PIDTYPE_PGID,
-                               session, &init_pid_ns))
+       if (session != 1 && pid_task(sid, PIDTYPE_PGID))
                goto out;
 
        group_leader->signal->leader = 1;
-       __set_special_pids(session, session);
+       __set_special_pids(pid_nr(sid), pid_nr(sid));
 
        spin_lock(&group_leader->sighand->siglock);
        group_leader->signal->tty = NULL;
        spin_unlock(&group_leader->sighand->siglock);
 
-       err = task_pgrp_vnr(group_leader);
+       err = session;
 out:
        write_unlock_irq(&tasklist_lock);
        return err;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to