diff options
author | Oleg Nesterov <oleg@tv-sign.ru> | 2006-10-02 05:18:59 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-02 10:57:25 -0400 |
commit | 1a657f78dcc8ea7c53eaa1f2a45ea2315738c15f (patch) | |
tree | a19972027792082fed505c8d540f7d877e37c0ab /kernel | |
parent | 1c0d04c9e44f4a248335c33d2be7c7f7b06ff359 (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 'kernel')
-rw-r--r-- | kernel/pid.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/kernel/pid.c b/kernel/pid.c index e4779bbb2058..b914392085f9 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -304,6 +304,15 @@ struct task_struct *find_task_by_pid_type(int type, int nr) | |||
304 | 304 | ||
305 | EXPORT_SYMBOL(find_task_by_pid_type); | 305 | EXPORT_SYMBOL(find_task_by_pid_type); |
306 | 306 | ||
307 | struct pid *get_task_pid(struct task_struct *task, enum pid_type type) | ||
308 | { | ||
309 | struct pid *pid; | ||
310 | rcu_read_lock(); | ||
311 | pid = get_pid(task->pids[type].pid); | ||
312 | rcu_read_unlock(); | ||
313 | return pid; | ||
314 | } | ||
315 | |||
307 | struct task_struct *fastcall get_pid_task(struct pid *pid, enum pid_type type) | 316 | struct task_struct *fastcall get_pid_task(struct pid *pid, enum pid_type type) |
308 | { | 317 | { |
309 | struct task_struct *result; | 318 | struct task_struct *result; |