aboutsummaryrefslogtreecommitdiff
path: root/kernel/cgroup/namespace.c
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2025-09-12 13:52:42 +0200
committerChristian Brauner <brauner@kernel.org>2025-09-19 14:26:15 +0200
commit7c60593985331e7839ec3fea6328a3253a325e82 (patch)
tree7f40838c0cd6e7254954591777ae9637682e5508 /kernel/cgroup/namespace.c
parent7d7d164989586c0ad61934975c40ca795dc134c7 (diff)
cgroup: support ns lookup
Support the generic ns lookup infrastructure to support file handles for namespaces. Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'kernel/cgroup/namespace.c')
-rw-r--r--kernel/cgroup/namespace.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/kernel/cgroup/namespace.c b/kernel/cgroup/namespace.c
index 0391b6ab0bf1..fc12c416dfeb 100644
--- a/kernel/cgroup/namespace.c
+++ b/kernel/cgroup/namespace.c
@@ -5,7 +5,7 @@
#include <linux/slab.h>
#include <linux/nsproxy.h>
#include <linux/proc_ns.h>
-
+#include <linux/nstree.h>
/* cgroup namespaces */
@@ -30,16 +30,19 @@ static struct cgroup_namespace *alloc_cgroup_ns(void)
ret = ns_common_init(&new_ns->ns, &cgroupns_operations, true);
if (ret)
return ERR_PTR(ret);
+ ns_tree_add(new_ns);
return no_free_ptr(new_ns);
}
void free_cgroup_ns(struct cgroup_namespace *ns)
{
+ ns_tree_remove(ns);
put_css_set(ns->root_cset);
dec_cgroup_namespaces(ns->ucounts);
put_user_ns(ns->user_ns);
ns_free_inum(&ns->ns);
- kfree(ns);
+ /* Concurrent nstree traversal depends on a grace period. */
+ kfree_rcu(ns, ns.ns_rcu);
}
EXPORT_SYMBOL(free_cgroup_ns);