[PATCH] namespaces: fix task exit disaster

This is based on a patch by Eric W. Biederman, who pointed out that pid
namespaces are still fake, and we only have one ever active.

So for the time being, we can modify any code which could access
tsk->nsproxy->pid_ns during task exit to just use &init_pid_ns instead,
and move the exit_task_namespaces call in do_exit() back above
exit_notify(), so that an exiting nfs server has a valid tsk->sighand to
work with.

Long term, pulling pid_ns out of nsproxy might be the cleanest solution.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>

[ Eric's patch fixed to take care of free_pid() too ]

Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Serge E. Hallyn and committed by Linus Torvalds 0f245285 444f378b

+3 -3
+1 -1
include/linux/pid_namespace.h
··· 39 40 static inline struct task_struct *child_reaper(struct task_struct *tsk) 41 { 42 - return tsk->nsproxy->pid_ns->child_reaper; 43 } 44 45 #endif /* _LINUX_PID_NS_H */
··· 39 40 static inline struct task_struct *child_reaper(struct task_struct *tsk) 41 { 42 + return init_pid_ns.child_reaper; 43 } 44 45 #endif /* _LINUX_PID_NS_H */
+1 -1
kernel/exit.c
··· 938 939 tsk->exit_code = code; 940 proc_exit_connector(tsk); 941 - exit_notify(tsk); 942 exit_task_namespaces(tsk); 943 #ifdef CONFIG_NUMA 944 mpol_free(tsk->mempolicy); 945 tsk->mempolicy = NULL;
··· 938 939 tsk->exit_code = code; 940 proc_exit_connector(tsk); 941 exit_task_namespaces(tsk); 942 + exit_notify(tsk); 943 #ifdef CONFIG_NUMA 944 mpol_free(tsk->mempolicy); 945 tsk->mempolicy = NULL;
+1 -1
kernel/pid.c
··· 197 hlist_del_rcu(&pid->pid_chain); 198 spin_unlock_irqrestore(&pidmap_lock, flags); 199 200 - free_pidmap(current->nsproxy->pid_ns, pid->nr); 201 call_rcu(&pid->rcu, delayed_put_pid); 202 } 203
··· 197 hlist_del_rcu(&pid->pid_chain); 198 spin_unlock_irqrestore(&pidmap_lock, flags); 199 200 + free_pidmap(&init_pid_ns, pid->nr); 201 call_rcu(&pid->rcu, delayed_put_pid); 202 } 203