Commit 1adfcb03 authored by Al Viro's avatar Al Viro

pid_namespace: make freeing struct pid_namespace rcu-delayed

makes procfs ->premission() instances safety in RCU mode independent
from vfsmount_lock.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 1dcddd4a
...@@ -23,6 +23,7 @@ struct bsd_acct_struct; ...@@ -23,6 +23,7 @@ struct bsd_acct_struct;
struct pid_namespace { struct pid_namespace {
struct kref kref; struct kref kref;
struct pidmap pidmap[PIDMAP_ENTRIES]; struct pidmap pidmap[PIDMAP_ENTRIES];
struct rcu_head rcu;
int last_pid; int last_pid;
unsigned int nr_hashed; unsigned int nr_hashed;
struct task_struct *child_reaper; struct task_struct *child_reaper;
......
...@@ -132,6 +132,12 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns ...@@ -132,6 +132,12 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns
return ERR_PTR(err); return ERR_PTR(err);
} }
static void delayed_free_pidns(struct rcu_head *p)
{
kmem_cache_free(pid_ns_cachep,
container_of(p, struct pid_namespace, rcu));
}
static void destroy_pid_namespace(struct pid_namespace *ns) static void destroy_pid_namespace(struct pid_namespace *ns)
{ {
int i; int i;
...@@ -140,7 +146,7 @@ static void destroy_pid_namespace(struct pid_namespace *ns) ...@@ -140,7 +146,7 @@ static void destroy_pid_namespace(struct pid_namespace *ns)
for (i = 0; i < PIDMAP_ENTRIES; i++) for (i = 0; i < PIDMAP_ENTRIES; i++)
kfree(ns->pidmap[i].page); kfree(ns->pidmap[i].page);
put_user_ns(ns->user_ns); put_user_ns(ns->user_ns);
kmem_cache_free(pid_ns_cachep, ns); call_rcu(&ns->rcu, delayed_free_pidns);
} }
struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *copy_pid_ns(unsigned long flags,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment