Author: Oleg Nesterov <email@example.com>
AuthorDate: Thu Apr 2 16:58:38 2009 -0700
Committer: Linus Torvalds <firstname.lastname@example.org>
CommitDate: Thu Apr 2 19:05:02 2009 -0700
pids: refactor vnr/nr_ns helpers to make them safe
Inho, the safety rules for vnr/nr_ns helpers are horrible and buggy.
task_pid_nr_ns(task) needs rcu/tasklist depending on task == current.
As for "special" pids, vnr/nr_ns helpers always need rcu. However, if
task != current, they are unsafe even under rcu lock, we can't trust
task->group_leader without the special checks.
And almost every helper has a callsite which needs a fix.
Also, it is a bit annoying that the implementations of, say,
task_pgrp_vnr() and task_pgrp_nr_ns() are not "symmetrical".
This patch introduces the new helper, __task_pid_nr_ns(), which is always
safe to use, and turns all other helpers into the trivial wrappers.
After this I'll send another patch which converts task_tgid_xxx() as well,
they're are a bit special.
Signed-off-by: Oleg Nesterov <email@example.com>
Cc: Louis Rilling <Louis.Rilling@kerlabs.com>
Cc: "Eric W. Biederman" <firstname.lastname@example.org>
Cc: Pavel Emelyanov <email@example.com>
Cc: Sukadev Bhattiprolu <firstname.lastname@example.org>
Cc: Roland McGrath <email@example.com>
Signed-off-by: Andrew Morton <firstname.lastname@example.org>
Signed-off-by: Linus Torvalds <email@example.com>
include/linux/sched.h | 27 ++++++++++++++++++++-------
kernel/pid.c | 31 ++++++++++++++++---------------
2 files changed, 36 insertions(+), 22 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 722dd31..49df878 100644