aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@tv-sign.ru>2006-10-02 05:18:59 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-02 10:57:25 -0400
commit1a657f78dcc8ea7c53eaa1f2a45ea2315738c15f (patch)
treea19972027792082fed505c8d540f7d877e37c0ab /fs/proc
parent1c0d04c9e44f4a248335c33d2be7c7f7b06ff359 (diff)
[PATCH] introduce get_task_pid() to fix unsafe get_pid()
proc_pid_make_inode: ei->pid = get_pid(task_pid(task)); I think this is not safe. get_pid() can be preempted after checking "pid != NULL". Then the task exits, does detach_pid(), and RCU frees the pid. Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/base.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index a317eb2c4442..82da55b5cffe 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -958,7 +958,7 @@ static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_st
958 /* 958 /*
959 * grab the reference to task. 959 * grab the reference to task.
960 */ 960 */
961 ei->pid = get_pid(task_pid(task)); 961 ei->pid = get_task_pid(task, PIDTYPE_PID);
962 if (!ei->pid) 962 if (!ei->pid)
963 goto out_unlock; 963 goto out_unlock;
964 964
@@ -1677,7 +1677,7 @@ static struct dentry *proc_base_instantiate(struct inode *dir,
1677 /* 1677 /*
1678 * grab the reference to the task. 1678 * grab the reference to the task.
1679 */ 1679 */
1680 ei->pid = get_pid(task_pid(task)); 1680 ei->pid = get_task_pid(task, PIDTYPE_PID);
1681 if (!ei->pid) 1681 if (!ei->pid)
1682 goto out_iput; 1682 goto out_iput;
1683 1683