Re: /proc visibility patch breaks GDB, etc.

From: Andrew Morton
Date: Thu Feb 26 2004 - 18:31:06 EST


Kingsley Cheung <kingsley@xxxxxxxxxx> wrote:
>
> Am I correct to assume though that the corresponding change in
> proc_task_lookup() should stay? The existing behaviour there was that
> one could do say,
>
> cat /proc/<pid>/task/<tid>/stat, where tid could be any thread and not
> a part of the thread group pid.

That sounds especially broken - let's hope that nobody has started using it
(but how did you even discover this? Code audit?)

How's this?

diff -puN fs/proc/base.c~proc-thread-visibility-revert fs/proc/base.c
--- 25/fs/proc/base.c~proc-thread-visibility-revert Thu Feb 26 15:17:48 2004
+++ 25-akpm/fs/proc/base.c Thu Feb 26 15:17:48 2004
@@ -1582,13 +1582,14 @@ struct dentry *proc_pid_lookup(struct in
read_unlock(&tasklist_lock);
if (!task)
goto out;
- if (!thread_group_leader(task))
- goto out_drop_task;

inode = proc_pid_make_inode(dir->i_sb, task, PROC_TGID_INO);

- if (!inode)
- goto out_drop_task;
+
+ if (!inode) {
+ put_task_struct(task);
+ goto out;
+ }
inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
inode->i_op = &proc_tgid_base_inode_operations;
inode->i_fop = &proc_tgid_base_operations;
@@ -1613,8 +1614,6 @@ struct dentry *proc_pid_lookup(struct in
goto out;
}
return NULL;
-out_drop_task:
- put_task_struct(task);
out:
return ERR_PTR(-ENOENT);
}

_

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/