diff options
author | Oleg Nesterov <oleg@redhat.com> | 2009-04-02 19:58:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-02 22:05:02 -0400 |
commit | 6dda81f4384b94930826eded254d8c16f89a9248 (patch) | |
tree | a7b27ca16a6feba637cb01e68b54c58b6ca07bc2 /include/linux/sched.h | |
parent | 8e654fba4a376f436bdfe361fc5cdbc87ac09b35 (diff) |
pids: document task_pgrp/task_session is not safe without tasklist/rcu
Even if task == current, it is not safe to dereference the result of
task_pgrp/task_session. We can race with another thread which changes the
special pid via setpgid/setsid.
Document this. The next 2 patches give an example of the unsafe usage, we
have more bad users.
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Louis Rilling <Louis.Rilling@kerlabs.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Pavel Emelyanov <xemul@openvz.org>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
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/sched.h')
-rw-r--r-- | include/linux/sched.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index b47c94e7560b..722dd313bf8a 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -1489,6 +1489,11 @@ static inline struct pid *task_tgid(struct task_struct *task) | |||
1489 | return task->group_leader->pids[PIDTYPE_PID].pid; | 1489 | return task->group_leader->pids[PIDTYPE_PID].pid; |
1490 | } | 1490 | } |
1491 | 1491 | ||
1492 | /* | ||
1493 | * Without tasklist or rcu lock it is not safe to dereference | ||
1494 | * the result of task_pgrp/task_session even if task == current, | ||
1495 | * we can race with another thread doing sys_setsid/sys_setpgid. | ||
1496 | */ | ||
1492 | static inline struct pid *task_pgrp(struct task_struct *task) | 1497 | static inline struct pid *task_pgrp(struct task_struct *task) |
1493 | { | 1498 | { |
1494 | return task->group_leader->pids[PIDTYPE_PGID].pid; | 1499 | return task->group_leader->pids[PIDTYPE_PGID].pid; |