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>] [day] [month] [year] [list]
Date:	Wed, 13 Feb 2008 14:41:34 -0800
From:	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
To:	Stephen Hemminger <"stephen.hemminger@...tta.com"@mail.vyatta.com>
Cc:	linux-kernel@...r.kernel.org, shemminger@...tta.com,
	davem@...emloft.net, netdev@...r.kernel.org, dipankar@...ibm.com,
	ego@...ibm.com, herbert@...dor.apana.org.au,
	akpm@...ux-foundation.org
Subject: Re: [PATCH 1/2] remove rcu_assign_pointer(NULL) penalty with type/macro safety

On Wed, Feb 13, 2008 at 02:35:37PM -0800, Stephen Hemminger wrote:
> On Wed, 13 Feb 2008 14:00:24 -0800
> "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com> wrote:
> 
> > Hello!
> > 
> > This is an updated version of the patch posted last November:
> > 
> > 	http://archives.free.net.ph/message/20071201.003721.cd6ff17c.en.html
> > 
> > This new version permits arguments with side effects, for example:
> > 
> > 	rcu_assign_pointer(global_p, p++);
> > 
> > and also verifies that the arguments are pointers, while still avoiding
> > the unnecessary memory barrier when assigning NULL to a pointer.
> > This memory-barrier avoidance means that rcu_assign_pointer() is now only
> > permitted for pointers (not array indexes), and so this version emits a
> > compiler warning if the first argument is not a pointer.  I built a "make
> > allyesconfig" version on an x86 system, and received no such warnings.
> > If RCU is ever applied to array indexes, then the second patch in this
> > series should be applied, and the resulting rcu_assign_index() be used.
> > 
> > Given the rather surprising history of subtlely broken implementations of
> > rcu_assign_pointer(), I took the precaution of generating a full set of
> > test cases and verified that memory barriers and compiler warnings were
> > emitted when required.  I guess it is the simple things that get you...
> > 
> > Signed-off-by: Paul E. McKenney <paulmck@...ux.vnet.ibm.com>
> > ---
> > 
> >  rcupdate.h |   16 ++++++++++++----
> >  1 file changed, 12 insertions(+), 4 deletions(-)
> > 
> > diff -urpNa -X dontdiff linux-2.6.24/include/linux/rcupdate.h linux-2.6.24-rap/include/linux/rcupdate.h
> > --- linux-2.6.24/include/linux/rcupdate.h	2008-01-24 14:58:37.000000000 -0800
> > +++ linux-2.6.24-rap/include/linux/rcupdate.h	2008-02-13 13:36:47.000000000 -0800
> > @@ -270,12 +270,20 @@ extern struct lockdep_map rcu_lock_map;
> >   * structure after the pointer assignment.  More importantly, this
> >   * call documents which pointers will be dereferenced by RCU read-side
> >   * code.
> > + *
> > + * Throws a compiler warning for non-pointer arguments.
> > + *
> > + * Does not insert a memory barrier for a NULL pointer.
> >   */
> >  
> > -#define rcu_assign_pointer(p, v)	({ \
> > -						smp_wmb(); \
> > -						(p) = (v); \
> > -					})
> > +#define rcu_assign_pointer(p, v)	\
> > +	({ \
> > +		typeof(*p) *_________p1 = (v); \
> > +		\
> > +		if (!__builtin_constant_p(v) || (_________p1 != NULL)) \
> > +			smp_wmb(); \
> > +		(p) = _________p1; \
> > +	})
> >  
> >  /**
> >   * synchronize_sched - block until all CPUs have exited any non-preemptive
> 
> Will this still work if p is unsigned long?

Hello, Steve,

If p is unsigned long, then use rcu_assign_index() from the next patch in
the set.  Looks like Andrew has applied it to -mm -- so please make sure
that he is aware if you do use it.

							Thanx, Paul
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ