lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 06 Oct 2017 15:08:54 -0400
From:   Rik van Riel <riel@...riel.com>
To:     Gargi Sharma <gs051095@...il.com>, linux-kernel@...r.kernel.org
Cc:     julia.lawall@...6.fr, akpm@...ux-foundation.org, mingo@...nel.org,
        pasha.tatashin@...cle.com, ktkhai@...tuozzo.com, oleg@...hat.com,
        ebiederm@...ssion.com, hch@...radead.org
Subject: Re: [PATCH v3 1/2] pid: Replace pid bitmap implementation with IDR
 API

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 <riel@...hat.com>

-- 
All Rights Reversed.
Download attachment "signature.asc" of type "application/pgp-signature" (474 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ