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]
Message-ID: <3f6b04b3-af22-49f0-8d3c-269640f9f762@paulmck-laptop>
Date:   Tue, 18 Jul 2023 11:32:01 -0700
From:   "Paul E. McKenney" <paulmck@...nel.org>
To:     Alan Huang <mmpgouride@...il.com>
Cc:     Joel Fernandes <joel@...lfernandes.org>, rcu@...r.kernel.org,
        linux-kernel@...r.kernel.org, kernel-team@...a.com,
        rostedt@...dmis.org
Subject: Re: [PATCH rcu 6/6] rcu: Use WRITE_ONCE() for assignments to ->next
 for rculist_nulls

On Tue, Jul 18, 2023 at 10:48:07PM +0800, Alan Huang wrote:
> 
> > 2023年7月18日 21:49,Joel Fernandes <joel@...lfernandes.org> 写道:
> > 
> > On 7/17/23 14:03, Paul E. McKenney wrote:
> >> From: Alan Huang <mmpgouride@...il.com>
> >> When the objects managed by rculist_nulls are allocated with
> >> SLAB_TYPESAFE_BY_RCU, old readers may still hold references to an object
> >> even though it is just now being added, which means the modification of
> >> ->next is visible to readers.  This patch therefore uses WRITE_ONCE()
> >> for assignments to ->next.
> >> Signed-off-by: Alan Huang <mmpgouride@...il.com>
> >> Signed-off-by: Paul E. McKenney <paulmck@...nel.org>
> > 
> > Did we ever conclude that the READ_ONCE() counterparts were not needed? ;-)
> 
> Read-side is already protected by rcu_dereference_raw() in hlist_nulls_for_each_entry_{rcu, safe}.

It turns out that different traversal synchronization designs want
different pointers using WRITE_ONCE().

> > But incremental progress and all, so this LGTM:
> > Reviewed-by: Joel Fernandes (Google) <joel@...lfernandes.org>

I will apply all four on my next rebase, thank you!

							Thanx, Paul

> > thanks,
> > 
> > - Joel
> > 
> > 
> >> ---
> >>  include/linux/rculist_nulls.h | 4 ++--
> >>  1 file changed, 2 insertions(+), 2 deletions(-)
> >> diff --git a/include/linux/rculist_nulls.h b/include/linux/rculist_nulls.h
> >> index ba4c00dd8005..89186c499dd4 100644
> >> --- a/include/linux/rculist_nulls.h
> >> +++ b/include/linux/rculist_nulls.h
> >> @@ -101,7 +101,7 @@ static inline void hlist_nulls_add_head_rcu(struct hlist_nulls_node *n,
> >>  {
> >>   struct hlist_nulls_node *first = h->first;
> >>  - n->next = first;
> >> + WRITE_ONCE(n->next, first);
> >>   WRITE_ONCE(n->pprev, &h->first);
> >>   rcu_assign_pointer(hlist_nulls_first_rcu(h), n);
> >>   if (!is_a_nulls(first))
> >> @@ -137,7 +137,7 @@ static inline void hlist_nulls_add_tail_rcu(struct hlist_nulls_node *n,
> >>   last = i;
> >>     if (last) {
> >> - n->next = last->next;
> >> + WRITE_ONCE(n->next, last->next);
> >>   n->pprev = &last->next;
> >>   rcu_assign_pointer(hlist_nulls_next_rcu(last), n);
> >>   } else {
> > 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ