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.

user: 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/user_namespace.c
··· 21 21 #include <linux/fs_struct.h> 22 22 #include <linux/bsearch.h> 23 23 #include <linux/sort.h> 24 + #include <linux/nstree.h> 24 25 25 26 static struct kmem_cache *user_ns_cachep __ro_after_init; 26 27 static DEFINE_MUTEX(userns_state_mutex); ··· 159 158 goto fail_keyring; 160 159 161 160 set_cred_user_ns(new, ns); 161 + ns_tree_add(ns); 162 162 return 0; 163 163 fail_keyring: 164 164 #ifdef CONFIG_PERSISTENT_KEYRINGS ··· 202 200 do { 203 201 struct ucounts *ucounts = ns->ucounts; 204 202 parent = ns->parent; 203 + ns_tree_remove(ns); 205 204 if (ns->gid_map.nr_extents > UID_GID_MAP_MAX_BASE_EXTENTS) { 206 205 kfree(ns->gid_map.forward); 207 206 kfree(ns->gid_map.reverse); ··· 221 218 retire_userns_sysctls(ns); 222 219 key_free_user_ns(ns); 223 220 ns_free_inum(&ns->ns); 224 - kmem_cache_free(user_ns_cachep, ns); 221 + /* Concurrent nstree traversal depends on a grace period. */ 222 + kfree_rcu(ns, ns.ns_rcu); 225 223 dec_user_namespaces(ucounts); 226 224 ns = parent; 227 225 } while (refcount_dec_and_test(&parent->ns.count)); ··· 1416 1412 static __init int user_namespaces_init(void) 1417 1413 { 1418 1414 user_ns_cachep = KMEM_CACHE(user_namespace, SLAB_PANIC | SLAB_ACCOUNT); 1415 + ns_tree_add(&init_user_ns); 1419 1416 return 0; 1420 1417 } 1421 1418 subsys_initcall(user_namespaces_init);