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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu,  8 Dec 2016 13:54:40 -0800
From:   Joel Fernandes <joelaf@...gle.com>
To:     linux-kernel@...r.kernel.org
Cc:     Joel Fernandes <joelaf@...gle.com>,
        Huang Ying <ying.huang@...el.com>,
        Ingo Molnar <mingo@...nel.org>,
        Will Deacon <will.deacon@....com>,
        Paul McKenney <paulmck@...ux.vnet.ibm.com>
Subject: [RFC] llist: Fix code comments about llist_del_first locking

Usage llist_del_first needs lock protection, however the table in the
comments of llist.h show a '-'. Correct this, and also add better
comments on top.

Cc: Huang Ying <ying.huang@...el.com>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Will Deacon <will.deacon@....com>
Cc: Paul McKenney <paulmck@...ux.vnet.ibm.com>
Signed-off-by: Joel Fernandes <joelaf@...gle.com>
---
 include/linux/llist.h | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/include/linux/llist.h b/include/linux/llist.h
index fd4ca0b..15e4949 100644
--- a/include/linux/llist.h
+++ b/include/linux/llist.h
@@ -3,14 +3,15 @@
 /*
  * Lock-less NULL terminated single linked list
  *
- * If there are multiple producers and multiple consumers, llist_add
- * can be used in producers and llist_del_all can be used in
- * consumers.  They can work simultaneously without lock.  But
- * llist_del_first can not be used here.  Because llist_del_first
- * depends on list->first->next does not changed if list->first is not
- * changed during its operation, but llist_del_first, llist_add,
- * llist_add (or llist_del_all, llist_add, llist_add) sequence in
- * another consumer may violate that.
+ * If there are multiple producers and multiple consumers, llist_add can be
+ * used in producers and llist_del_all can be used in consumers.  They can work
+ * simultaneously without lock.  But llist_del_first will need to use a lock
+ * with any other operation (ABA problem).  This is because llist_del_first
+ * depends on list->first->next not changing but there's no way to be sure
+ * about that and the cmpxchg in llist_del_first may succeed if list->first is
+ * the same after concurrent operations. For example, a llist_del_first,
+ * llist_add, llist_add (or llist_del_all, llist_add, llist_add) sequence in
+ * another consumer may cause violations.
  *
  * If there are multiple producers and one consumer, llist_add can be
  * used in producers and llist_del_all or llist_del_first can be used
@@ -19,7 +20,7 @@
  * This can be summarized as follow:
  *
  *           |   add    | del_first |  del_all
- * add       |    -     |     -     |     -
+ * add       |    -     |     L     |     -
  * del_first |          |     L     |     L
  * del_all   |          |           |     -
  *
-- 
2.8.0.rc3.226.g39d4020

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ