]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
pid: support ns lookup
authorChristian Brauner <brauner@kernel.org>
Fri, 12 Sep 2025 11:52:45 +0000 (13:52 +0200)
committerChristian Brauner <brauner@kernel.org>
Fri, 19 Sep 2025 12:26:15 +0000 (14:26 +0200)
Support the generic ns lookup infrastructure to support file handles for
namespaces.

Signed-off-by: Christian Brauner <brauner@kernel.org>
kernel/pid_namespace.c

index 20ce4052d1c51315c6047215ec46b1cd3b047d43..228ae20299f9aaf0c5938f25d2d4ede8a66a6f26 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/sched/task.h>
 #include <linux/sched/signal.h>
 #include <linux/idr.h>
+#include <linux/nstree.h>
 #include <uapi/linux/wait.h>
 #include "pid_sysctl.h"
 
@@ -122,6 +123,7 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns
        ns->memfd_noexec_scope = pidns_memfd_noexec_scope(parent_pid_ns);
 #endif
 
+       ns_tree_add(ns);
        return ns;
 
 out_free_inum:
@@ -147,6 +149,7 @@ static void delayed_free_pidns(struct rcu_head *p)
 
 static void destroy_pid_namespace(struct pid_namespace *ns)
 {
+       ns_tree_remove(ns);
        unregister_pidns_sysctls(ns);
 
        ns_free_inum(&ns->ns);
@@ -473,6 +476,7 @@ static __init int pid_namespaces_init(void)
 #endif
 
        register_pid_ns_sysctl_table_vm();
+       ns_tree_add(&init_pid_ns);
        return 0;
 }