Prev: pid: Remove the child_reaper special case in init/main.c
Next: pidns: Support unsharing the pid namespace.
From: Oleg Nesterov on 20 Jun 2010 14:50 On 06/20, Eric W. Biederman wrote: > > In the case of unsharing or joining a pid namespace, it becomes > possible to attempt to allocate a pid after zap_pid_namespace has > killed everything in the namespace. Close the hole for now by simply > not allowing any of those pid allocations to succeed. At least for > now it is too strange to think about. Well, I didn't read the next patch, so I don't understand the changelog. Still, a couple of stupid questions. Feel free to ignore me... > --- a/include/linux/pid_namespace.h > +++ b/include/linux/pid_namespace.h > @@ -20,6 +20,7 @@ struct pid_namespace { > struct kref kref; > struct pidmap pidmap[PIDMAP_ENTRIES]; > int last_pid; > + atomic_t dead; Why it is atomic_t? It is used like a simple boolean, and the next patch doesn't use ns->dead. > @@ -248,6 +248,10 @@ struct pid *alloc_pid(struct pid_namespace *ns) > struct pid_namespace *tmp; > struct upid *upid; > > + pid = NULL; > + if (atomic_read(&ns->dead)) > + goto out; > + > [...snip...] > @@ -161,6 +162,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns) > * > */ > read_lock(&tasklist_lock); > + atomic_set(&pid_ns->dead, 1); > nr = next_pidmap(pid_ns, 1); The only caller of alloc_pid() is copy_process(). So, at first glance this patch tries to block the attempts to create the tasks in this namespace. But what if copy_process() has already called alloc_pid() using this ns, but didn't do attach_pid() yet? Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |