Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[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 <guichaz@yahoo.fr>
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Guillaume Chazarain and committed by
Linus Torvalds
7d895244 432bd6cb

+11 -1
+11 -1
fs/proc/base.c
··· 2328 2328 { 2329 2329 struct dentry *dentry = filp->f_path.dentry; 2330 2330 struct inode *inode = dentry->d_inode; 2331 - struct task_struct *leader = get_proc_task(inode); 2331 + struct task_struct *leader = NULL; 2332 2332 struct task_struct *task; 2333 2333 int retval = -ENOENT; 2334 2334 ino_t ino; 2335 2335 int tid; 2336 2336 unsigned long pos = filp->f_pos; /* avoiding "long long" filp->f_pos */ 2337 2337 2338 + task = get_proc_task(inode); 2339 + if (!task) 2340 + goto out_no_task; 2341 + rcu_read_lock(); 2342 + if (pid_alive(task)) { 2343 + leader = task->group_leader; 2344 + get_task_struct(leader); 2345 + } 2346 + rcu_read_unlock(); 2347 + put_task_struct(task); 2338 2348 if (!leader) 2339 2349 goto out_no_task; 2340 2350 retval = 0;