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

pid_namespace: make freeing struct pid_namespace rcu-delayed

makes procfs ->premission() instances safety in RCU mode independent
from vfsmount_lock.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 1adfcb03 1dcddd4a

+8 -1
+1
include/linux/pid_namespace.h
··· 23 23 struct pid_namespace { 24 24 struct kref kref; 25 25 struct pidmap pidmap[PIDMAP_ENTRIES]; 26 + struct rcu_head rcu; 26 27 int last_pid; 27 28 unsigned int nr_hashed; 28 29 struct task_struct *child_reaper;
+7 -1
kernel/pid_namespace.c
··· 132 132 return ERR_PTR(err); 133 133 } 134 134 135 + static void delayed_free_pidns(struct rcu_head *p) 136 + { 137 + kmem_cache_free(pid_ns_cachep, 138 + container_of(p, struct pid_namespace, rcu)); 139 + } 140 + 135 141 static void destroy_pid_namespace(struct pid_namespace *ns) 136 142 { 137 143 int i; ··· 146 140 for (i = 0; i < PIDMAP_ENTRIES; i++) 147 141 kfree(ns->pidmap[i].page); 148 142 put_user_ns(ns->user_ns); 149 - kmem_cache_free(pid_ns_cachep, ns); 143 + call_rcu(&ns->rcu, delayed_free_pidns); 150 144 } 151 145 152 146 struct pid_namespace *copy_pid_ns(unsigned long flags,