Skip to content

Commit

Permalink
pid_namespace: make freeing struct pid_namespace rcu-delayed
Browse files Browse the repository at this point in the history
makes procfs ->premission() instances safety in RCU mode independent
from vfsmount_lock.

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Oct 25, 2013
1 parent 1dcddd4 commit 1adfcb0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/linux/pid_namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct bsd_acct_struct;
struct pid_namespace {
struct kref kref;
struct pidmap pidmap[PIDMAP_ENTRIES];
struct rcu_head rcu;
int last_pid;
unsigned int nr_hashed;
struct task_struct *child_reaper;
Expand Down
8 changes: 7 additions & 1 deletion kernel/pid_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns
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)
{
int i;
Expand All @@ -140,7 +146,7 @@ static void destroy_pid_namespace(struct pid_namespace *ns)
for (i = 0; i < PIDMAP_ENTRIES; i++)
kfree(ns->pidmap[i].page);
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,
Expand Down

0 comments on commit 1adfcb0

Please sign in to comment.