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:	Wed, 18 Dec 2013 18:15:08 -0800
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	Fan Du <fan.du@...driver.com>
Cc:	王聪 <xiyou.wangcong@...il.com>,
	steffen.klassert@...unet.com, davem@...emloft.net,
	netdev@...r.kernel.org
Subject: Re: [PATCHv2 ipsec-next] xfrm: Namespacify xfrm_policy_sk_bundles

On Thu, 2013-12-19 at 09:35 +0800, Fan Du wrote:
> Hi, Eric and Cong
> 

> Here is my understanding about llist_add_batch, assume when add one single
> entry into list, i.e., new_last equates new_first.
> 
>    1         do {
>    2                 new->next = first = ACCESS_ONCE(head->first);
>    3         } while (cmpxchg(&head->first, first, new) != first);
> 
> 
> Caller 1:Add new1 into head                          Caller 2:Add new2 into head
>       line 2: Link head into new1
>                                                       line 2: Link head into new2
>                                                       line 3: Make the cmpxchg, then succeed.
> 
>                                                       After this, new2 -> old_head
>       line 3: Make the cmpxchg, failed, try
>               again will succeed, after this
>               new1 -> new2 -> old_head
> 
> So in order to not use locks, try again if cmpxchg found out someone else
> has update the head. For the case involved in the patch, the problem is, after
> xchg, assign the old head to the new->next will race with the delete part when
> saving the head for deleting after setting the head to NULL, as the traverse
> of saved head probably not see a consistent list, that's a broken one.
> 
> I think an analogy of llist_add_batch for the updating part will be ok for this:
> 
>                          struct dst_entry *first;
>                          do {
>                                  xdst->u.dst.next = first = ACCESS_ONCE(xfrm_policy_sk_bundles);
>                          } while (cmpxchg(&xfrm_policy_sk_bundles, first, &xdst->u.dst) != first);
> 
> 
> And the deleting part:
> 
>                          head = xchg(&net->xfrm.xfrm_policy_sk_bundles, NULL);
> 
> 

The point is to _use_ the helpers, so that code review is easy.

llist.h is safe, it was extensively discussed and adopted.

If you want to get rid of the spinlock, then use llist_del_all() for the
deleting, and llist_add() for the addition.

Really, its that simple.



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ