Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

uts: support ns lookup

Support the generic ns lookup infrastructure to support file handles for
namespaces.

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

+6 -1
+6 -1
kernel/utsname.c
··· 13 13 #include <linux/cred.h> 14 14 #include <linux/user_namespace.h> 15 15 #include <linux/proc_ns.h> 16 + #include <linux/nstree.h> 16 17 #include <linux/sched/task.h> 17 18 18 19 static struct kmem_cache *uts_ns_cache __ro_after_init; ··· 59 58 memcpy(&ns->name, &old_ns->name, sizeof(ns->name)); 60 59 ns->user_ns = get_user_ns(user_ns); 61 60 up_read(&uts_sem); 61 + ns_tree_add(ns); 62 62 return ns; 63 63 64 64 fail_free: ··· 95 93 96 94 void free_uts_ns(struct uts_namespace *ns) 97 95 { 96 + ns_tree_remove(ns); 98 97 dec_uts_namespaces(ns->ucounts); 99 98 put_user_ns(ns->user_ns); 100 99 ns_free_inum(&ns->ns); 101 - kmem_cache_free(uts_ns_cache, ns); 100 + /* Concurrent nstree traversal depends on a grace period. */ 101 + kfree_rcu(ns, ns.ns_rcu); 102 102 } 103 103 104 104 static inline struct uts_namespace *to_uts_ns(struct ns_common *ns) ··· 166 162 offsetof(struct uts_namespace, name), 167 163 sizeof_field(struct uts_namespace, name), 168 164 NULL); 165 + ns_tree_add(&init_uts_ns); 169 166 }