Skip to content

Commit 0f24528

Browse files
Serge E. HallynLinus Torvalds
authored andcommitted
[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>
1 parent 444f378 commit 0f24528

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎include/linux/pid_namespace.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static inline void put_pid_ns(struct pid_namespace *ns)
3939

4040
static inline struct task_struct *child_reaper(struct task_struct *tsk)
4141
{
42-
return tsk->nsproxy->pid_ns->child_reaper;
42+
return init_pid_ns.child_reaper;
4343
}
4444

4545
#endif /* _LINUX_PID_NS_H */

‎kernel/exit.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,8 +938,8 @@ fastcall NORET_TYPE void do_exit(long code)
938938

939939
tsk->exit_code = code;
940940
proc_exit_connector(tsk);
941-
exit_notify(tsk);
942941
exit_task_namespaces(tsk);
942+
exit_notify(tsk);
943943
#ifdef CONFIG_NUMA
944944
mpol_free(tsk->mempolicy);
945945
tsk->mempolicy = NULL;

‎kernel/pid.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ fastcall void free_pid(struct pid *pid)
197197
hlist_del_rcu(&pid->pid_chain);
198198
spin_unlock_irqrestore(&pidmap_lock, flags);
199199

200-
free_pidmap(current->nsproxy->pid_ns, pid->nr);
200+
free_pidmap(&init_pid_ns, pid->nr);
201201
call_rcu(&pid->rcu, delayed_put_pid);
202202
}
203203

0 commit comments

Comments
 (0)