On Fri, 2017-10-06 at 07:53 -0400, Gargi Sharma wrote: > @@ -308,8 +165,28 @@ struct pid *alloc_pid(struct pid_namespace *ns) The code looks like it addresses all of Oleg's comments now, but the comments could be a little clearer, IMHO.   >   tmp = ns; >   pid->level = ns->level; > + >   for (i = ns->level; i >= 0; i--) { > - nr = alloc_pidmap(tmp); > + int pid_min = 1; > + idr_preload(GFP_KERNEL); > + spin_lock_irq(&pidmap_lock); > + > + /* > +  * init really needs pid 1, but after reaching the > maximum > +  * wrap back to RESERVED_PIDS > +  */ > + if (idr_get_cursor(&tmp->idr) > RESERVED_PIDS) > + pid_min = RESERVED_PIDS; > + > + /* > +  * allocate a NULL pointer so that find_pid_ns can't > +  * find pid that is not fully initialized > +  */ /* * Store a null pointer so find_pid_ns does not find * a partially initialized PID (see below). */ > + nr = idr_alloc_cyclic(&tmp->idr, NULL, pid_min, > +       pid_max, GFP_ATOMIC); > + spin_unlock_irq(&pidmap_lock); > + idr_preload_end(); > + >   if (nr < 0) { >   retval = nr; >   goto out_free; > @@ -339,6 +216,7 @@ struct pid *alloc_pid(struct pid_namespace *ns) >   for ( ; upid >= pid->numbers; --upid) { >   hlist_add_head_rcu(&upid->pid_chain, >   &pid_hash[pid_hashfn(upid->nr, upid- > >ns)]); /* Make the PID visible to find_pid_ns. */ > + idr_replace(&upid->ns->idr, pid, upid->nr); >   upid->ns->nr_hashed++; >   } >   spin_unlock_irq(&pidmap_lock); > Everything else looks great to me. Reviewed-by: Rik van Riel -- All Rights Reversed.