Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=7d8952440f4090522b740257f1c6b2cf96413969
Commit:     7d8952440f4090522b740257f1c6b2cf96413969
Parent:     432bd6cbf9f016f5480153b1cdfbd046f8d4fb1e
Author:     Guillaume Chazarain <[EMAIL PROTECTED]>
AuthorDate: Wed Jan 31 23:48:14 2007 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Thu Feb 1 16:22:41 2007 -0800

    [PATCH] procfs: Fix listing of /proc/NOT_A_TGID/task
    
    Listing /proc/PID/task were PID is not a TGID should not result in
    duplicated entries.
    
        [g ~]$ pidof thunderbird-bin
        2751
        [g ~]$ ls /proc/2751/task
        2751  2770  2771  2824  2826  2834  2835  2851  2853
        [g ~]$ ls /proc/2770/task
        2751  2770  2771  2824  2826  2834  2835  2851  2853
        2770  2771  2824  2826  2834  2835  2851  2853
        [g ~]$
    
    Signed-off-by: Guillaume Chazarain <[EMAIL PROTECTED]>
    Acked-by: "Eric W. Biederman" <[EMAIL PROTECTED]>
    Cc: Oleg Nesterov <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 fs/proc/base.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index ff7a668..1a979ea 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2328,13 +2328,23 @@ static int proc_task_readdir(struct file * filp, void * 
dirent, filldir_t filldi
 {
        struct dentry *dentry = filp->f_path.dentry;
        struct inode *inode = dentry->d_inode;
-       struct task_struct *leader = get_proc_task(inode);
+       struct task_struct *leader = NULL;
        struct task_struct *task;
        int retval = -ENOENT;
        ino_t ino;
        int tid;
        unsigned long pos = filp->f_pos;  /* avoiding "long long" filp->f_pos */
 
+       task = get_proc_task(inode);
+       if (!task)
+               goto out_no_task;
+       rcu_read_lock();
+       if (pid_alive(task)) {
+               leader = task->group_leader;
+               get_task_struct(leader);
+       }
+       rcu_read_unlock();
+       put_task_struct(task);
        if (!leader)
                goto out_no_task;
        retval = 0;
-
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