stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] llist: Fix missing lockless_dereference()
@ 2015-02-07  2:08 Mathieu Desnoyers
  2015-02-07 22:16 ` Greg KH
  2015-02-10 14:03 ` Peter Hurley
  0 siblings, 2 replies; 18+ messages in thread
From: Mathieu Desnoyers @ 2015-02-07  2:08 UTC (permalink / raw)
  To: Huang Ying
  Cc: linux-kernel, Mathieu Desnoyers, Paul McKenney, David Howells,
	Pranith Kumar, stable

A lockless_dereference() appears to be missing in llist_del_first().
It should only matter for Alpha in practice.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
CC: Huang Ying <ying.huang@intel.com>
CC: Paul McKenney <paulmck@linux.vnet.ibm.com>
CC: David Howells <dhowells@redhat.com>
CC: Pranith Kumar <bobby.prani@gmail.com>
CC: stable@vger.kernel.org # v3.1+
---
 lib/llist.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/llist.c b/lib/llist.c
index f76196d..f34e176 100644
--- a/lib/llist.c
+++ b/lib/llist.c
@@ -26,6 +26,7 @@
 #include <linux/export.h>
 #include <linux/interrupt.h>
 #include <linux/llist.h>
+#include <linux/rcupdate.h>
 
 
 /**
@@ -67,7 +68,12 @@ struct llist_node *llist_del_first(struct llist_head *head)
 {
 	struct llist_node *entry, *old_entry, *next;
 
-	entry = head->first;
+	/*
+	 * Load entry before entry->next. Matches the implicit
+	 * memory barrier before the cmpxchg in llist_add_batch(),
+	 * which ensures entry->next is stored before entry.
+	 */
+	entry = lockless_dereference(head->first);
 	for (;;) {
 		if (entry == NULL)
 			return NULL;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2015-02-10 18:03 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-07  2:08 [PATCH] llist: Fix missing lockless_dereference() Mathieu Desnoyers
2015-02-07 22:16 ` Greg KH
2015-02-07 22:30   ` Mathieu Desnoyers
2015-02-08  0:18     ` Matt Turner
2015-02-08  0:29       ` Greg KH
2015-02-08  0:47     ` Michael Cree
2015-02-08  0:59       ` Greg KH
2015-02-08  1:12         ` Michael Cree
2015-02-08  1:20           ` Greg KH
2015-02-08  4:25       ` Mathieu Desnoyers
2015-02-10  1:52         ` Huang Ying
2015-02-10  3:42           ` Mathieu Desnoyers
2015-02-10  9:30         ` Michael Cree
2015-02-08  0:09   ` Paul E. McKenney
2015-02-10 14:03 ` Peter Hurley
2015-02-10 16:38   ` Paul E. McKenney
2015-02-10 17:29     ` Peter Hurley
2015-02-10 18:03       ` Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).