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] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 10 Oct 2017 10:35:46 +0100
From:   David Howells <dhowells@...hat.com>
To:     "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
Cc:     dhowells@...hat.com, linux-kernel@...r.kernel.org,
        mingo@...nel.org, torvalds@...ux-foundation.org,
        mark.rutland@....com, linux-arch@...r.kernel.org,
        peterz@...radead.org, will.deacon@....com,
        Jonathan Corbet <corbet@....net>,
        Alexander Kuleshov <kuleshovmail@...il.com>
Subject: Re: [PATCH RFC tip/core/rcu 12/15] lib/assoc_array: Remove smp_read_barrier_depends()

Paul E. McKenney <paulmck@...ux.vnet.ibm.com> wrote:

>  static inline void *assoc_array_ptr_to_leaf(const struct assoc_array_ptr *x)
>  {
> -	return (void *)((unsigned long)x & ~ASSOC_ARRAY_PTR_TYPE_MASK);
> +	return (void *)((unsigned long)READ_ONCE(x) & /* Address dependency. */
> +		~ASSOC_ARRAY_PTR_TYPE_MASK);
>  }

This is the wrong place to do this.  assoc_array_ptr_to_leaf() is effectively
no more than a special cast; it removes a metadata bit from a pointer.  x is
the value we're modifying, not *x, and x was read by the caller.

>  static inline
>  unsigned long __assoc_array_ptr_to_meta(const struct assoc_array_ptr *x)
>  {
> -	return (unsigned long)x &
> +	return (unsigned long)READ_ONCE(x) & /* Address dependency. */
>  		~(ASSOC_ARRAY_PTR_SUBTYPE_MASK | ASSOC_ARRAY_PTR_TYPE_MASK);
>  }

Ditto.

> -		ptr = READ_ONCE(node->slots[slot]);
> +		ptr = READ_ONCE(node->slots[slot]); /* Address dependency. */
>  		has_meta |= (unsigned long)ptr;
>  		if (ptr && assoc_array_ptr_is_leaf(ptr)) {
> -			/* We need a barrier between the read of the pointer
> -			 * and dereferencing the pointer - but only if we are
> -			 * actually going to dereference it.
> -			 */
> -			smp_read_barrier_depends();
> -

For example, you can see the READ_ONCE() here; that is already done.

Can you also not just delete the comment, but rephrase it to indicate that a
barrier is necessary and it's done by READ_ONCE(), please?

David

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ