aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/pid.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/kernel/pid.c b/kernel/pid.c
index a2b4cbbdd63d..4b17acdb862f 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -73,10 +73,20 @@ struct pid_namespace init_pid_ns = {
73}; 73};
74EXPORT_SYMBOL_GPL(init_pid_ns); 74EXPORT_SYMBOL_GPL(init_pid_ns);
75 75
76int is_global_init(struct task_struct *tsk) 76int is_container_init(struct task_struct *tsk)
77{ 77{
78 return tsk == init_pid_ns.child_reaper; 78 int ret = 0;
79 struct pid *pid;
80
81 rcu_read_lock();
82 pid = task_pid(tsk);
83 if (pid != NULL && pid->numbers[pid->level].nr == 1)
84 ret = 1;
85 rcu_read_unlock();
86
87 return ret;
79} 88}
89EXPORT_SYMBOL(is_container_init);
80 90
81/* 91/*
82 * Note: disable interrupts while the pidmap_lock is held as an 92 * Note: disable interrupts while the pidmap_lock is held as an
@@ -192,8 +202,7 @@ fastcall void put_pid(struct pid *pid)
192 if ((atomic_read(&pid->count) == 1) || 202 if ((atomic_read(&pid->count) == 1) ||
193 atomic_dec_and_test(&pid->count)) { 203 atomic_dec_and_test(&pid->count)) {
194 kmem_cache_free(ns->pid_cachep, pid); 204 kmem_cache_free(ns->pid_cachep, pid);
195 if (ns != &init_pid_ns) 205 put_pid_ns(ns);
196 put_pid_ns(ns);
197 } 206 }
198} 207}
199EXPORT_SYMBOL_GPL(put_pid); 208EXPORT_SYMBOL_GPL(put_pid);
@@ -244,9 +253,7 @@ struct pid *alloc_pid(struct pid_namespace *ns)
244 tmp = tmp->parent; 253 tmp = tmp->parent;
245 } 254 }
246 255
247 if (ns != &init_pid_ns) 256 get_pid_ns(ns);
248 get_pid_ns(ns);
249
250 pid->level = ns->level; 257 pid->level = ns->level;
251 pid->nr = pid->numbers[0].nr; 258 pid->nr = pid->numbers[0].nr;
252 atomic_set(&pid->count, 1); 259 atomic_set(&pid->count, 1);