From: Pavel Emelyanov There are some places that are known to operate on tasks' global pids only: * the rest_init() call (called on boot) * the kgdb's getthread * the create_kthread() (since the kthread is run in init ns) So use the find_task_by_pid_ns(..., &init_pid_ns) there and schedule the find_task_by_pid for removal. Signed-off-by: Pavel Emelyanov Cc: "Eric W. Biederman" Signed-off-by: Andrew Morton --- Documentation/feature-removal-schedule.txt | 18 ++++++++++++++++++ include/linux/sched.h | 2 +- init/main.c | 2 +- kernel/kthread.c | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff -puN Documentation/feature-removal-schedule.txt~deprecate-find_task_by_pid Documentation/feature-removal-schedule.txt --- a/Documentation/feature-removal-schedule.txt~deprecate-find_task_by_pid +++ a/Documentation/feature-removal-schedule.txt @@ -121,6 +121,24 @@ Who: Kay Sievers --------------------------- +What: find_task_by_pid +When: 2.6.26 +Why: With pid namespaces, calling this funciton will return the + wrong task when called from inside a namespace. + + The best way to save a task pid and find a task by this + pid later, is to find this task's struct pid pointer (or get + it directly from the task) and call pid_task() later. + + If someone really needs to get a task by its pid_t, then + he most likely needs the find_task_by_vpid() to get the + task from the same namespace as the current task is in, but + this may be not so in general. + +Who: Pavel Emelyanov + +--------------------------- + What: ACPI procfs interface When: July 2008 Why: ACPI sysfs conversion should be finished by January 2008. diff -puN include/linux/sched.h~deprecate-find_task_by_pid include/linux/sched.h --- a/include/linux/sched.h~deprecate-find_task_by_pid +++ a/include/linux/sched.h @@ -1643,7 +1643,7 @@ extern struct pid_namespace init_pid_ns; extern struct task_struct *find_task_by_pid_type_ns(int type, int pid, struct pid_namespace *ns); -extern struct task_struct *find_task_by_pid(pid_t nr); +extern struct task_struct *find_task_by_pid(pid_t nr) __deprecated; extern struct task_struct *find_task_by_vpid(pid_t nr); extern struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns); diff -puN init/main.c~deprecate-find_task_by_pid init/main.c --- a/init/main.c~deprecate-find_task_by_pid +++ a/init/main.c @@ -437,7 +437,7 @@ static void noinline __init_refok rest_i kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); numa_default_policy(); pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES); - kthreadd_task = find_task_by_pid(pid); + kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns); unlock_kernel(); /* diff -puN kernel/kthread.c~deprecate-find_task_by_pid kernel/kthread.c --- a/kernel/kthread.c~deprecate-find_task_by_pid +++ a/kernel/kthread.c @@ -99,7 +99,7 @@ static void create_kthread(struct kthrea struct sched_param param = { .sched_priority = 0 }; wait_for_completion(&create->started); read_lock(&tasklist_lock); - create->result = find_task_by_pid(pid); + create->result = find_task_by_pid_ns(pid, &init_pid_ns); read_unlock(&tasklist_lock); /* * root may have changed our (kthreadd's) priority or CPU mask. _