diff options
author | Oleg Nesterov <oleg@tv-sign.ru> | 2008-04-30 00:54:26 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-30 08:29:48 -0700 |
commit | 24336eaeecea860b2a82530e07c80bc7e0558b73 (patch) | |
tree | 12a34660f732e12ba18262083c1a2eea5a824f6a /include/linux/pid.h | |
parent | 65450cebc6a2efde80ed45514f727e6e4dc1eafd (diff) | |
download | linux-24336eaeecea860b2a82530e07c80bc7e0558b73.tar.gz linux-24336eaeecea860b2a82530e07c80bc7e0558b73.tar.bz2 linux-24336eaeecea860b2a82530e07c80bc7e0558b73.zip |
pids: introduce change_pid() helper
Based on Eric W. Biederman's idea.
Without tasklist_lock held task_session()/task_pgrp() can return NULL if the
caller races with setprgp()/setsid() which does detach_pid() + attach_pid().
This can happen even if task == current.
Intoduce the new helper, change_pid(), which should be used instead. This way
the caller always sees the special pid != NULL, either old or new.
Also change the prototype of attach_pid(), it always returns 0 and nobody
check the returned value.
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Pavel Emelyanov <xemul@openvz.org>
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/pid.h')
-rw-r--r-- | include/linux/pid.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/linux/pid.h b/include/linux/pid.h index c7980810eb09..8d199033c0ca 100644 --- a/include/linux/pid.h +++ b/include/linux/pid.h @@ -89,9 +89,11 @@ extern struct pid *get_task_pid(struct task_struct *task, enum pid_type type); * attach_pid() and detach_pid() must be called with the tasklist_lock * write-held. */ -extern int attach_pid(struct task_struct *task, enum pid_type type, - struct pid *pid); +extern void attach_pid(struct task_struct *task, enum pid_type type, + struct pid *pid); extern void detach_pid(struct task_struct *task, enum pid_type); +extern void change_pid(struct task_struct *task, enum pid_type, + struct pid *pid); extern void transfer_pid(struct task_struct *old, struct task_struct *new, enum pid_type); |