|
@@ -374,6 +374,29 @@ static struct ns_common *pidns_get(struct task_struct *task)
|
|
|
return ns ? &ns->ns : NULL;
|
|
|
}
|
|
|
|
|
|
+static struct ns_common *pidns_for_children_get(struct task_struct *task)
|
|
|
+{
|
|
|
+ struct pid_namespace *ns = NULL;
|
|
|
+
|
|
|
+ task_lock(task);
|
|
|
+ if (task->nsproxy) {
|
|
|
+ ns = task->nsproxy->pid_ns_for_children;
|
|
|
+ get_pid_ns(ns);
|
|
|
+ }
|
|
|
+ task_unlock(task);
|
|
|
+
|
|
|
+ if (ns) {
|
|
|
+ read_lock(&tasklist_lock);
|
|
|
+ if (!ns->child_reaper) {
|
|
|
+ put_pid_ns(ns);
|
|
|
+ ns = NULL;
|
|
|
+ }
|
|
|
+ read_unlock(&tasklist_lock);
|
|
|
+ }
|
|
|
+
|
|
|
+ return ns ? &ns->ns : NULL;
|
|
|
+}
|
|
|
+
|
|
|
static void pidns_put(struct ns_common *ns)
|
|
|
{
|
|
|
put_pid_ns(to_pid_ns(ns));
|
|
@@ -443,6 +466,17 @@ const struct proc_ns_operations pidns_operations = {
|
|
|
.get_parent = pidns_get_parent,
|
|
|
};
|
|
|
|
|
|
+const struct proc_ns_operations pidns_for_children_operations = {
|
|
|
+ .name = "pid_for_children",
|
|
|
+ .real_ns_name = "pid",
|
|
|
+ .type = CLONE_NEWPID,
|
|
|
+ .get = pidns_for_children_get,
|
|
|
+ .put = pidns_put,
|
|
|
+ .install = pidns_install,
|
|
|
+ .owner = pidns_owner,
|
|
|
+ .get_parent = pidns_get_parent,
|
|
|
+};
|
|
|
+
|
|
|
static __init int pid_namespaces_init(void)
|
|
|
{
|
|
|
pid_ns_cachep = KMEM_CACHE(pid_namespace, SLAB_PANIC);
|