Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2015-03-19 11:38:14 +0100
committerJiri Slaby <jslaby@suse.cz>2015-03-19 11:38:14 +0100
commitb63e425743eb3a356de0978623655a283be38622 (patch)
tree18a2c64d071930d67a11ce0b25c0a8e033186190
parentce17b0380349c3d81404c389ace85511da56f500 (diff)
- mutex: Fix/document access-once assumption inrpm-3.0.101-53
mutex_can_spin_on_owner() (bnc#923099). - Refresh patches.fixes/0001-locking-mcs-Add-some-needed-ACCESS_ONCE-calls.patch.
-rw-r--r--patches.fixes/0001-locking-mcs-Add-some-needed-ACCESS_ONCE-calls.patch27
-rw-r--r--patches.fixes/mutex-Fix-document-access-once-assumption-in-mutex_c.patch52
-rw-r--r--series.conf1
3 files changed, 56 insertions, 24 deletions
diff --git a/patches.fixes/0001-locking-mcs-Add-some-needed-ACCESS_ONCE-calls.patch b/patches.fixes/0001-locking-mcs-Add-some-needed-ACCESS_ONCE-calls.patch
index 47be5b4009..bf544e4f0b 100644
--- a/patches.fixes/0001-locking-mcs-Add-some-needed-ACCESS_ONCE-calls.patch
+++ b/patches.fixes/0001-locking-mcs-Add-some-needed-ACCESS_ONCE-calls.patch
@@ -13,14 +13,12 @@ a stale value - wrap for volatile loads around ACCESS_ONCE.
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
- kernel/mutex.c | 6 ++++--
- 1 file changed, 4 insertions(+), 2 deletions(-)
+ kernel/mutex.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
-diff --git a/kernel/mutex.c b/kernel/mutex.c
-index fd05060..5a94529 100644
--- a/kernel/mutex.c
+++ b/kernel/mutex.c
-@@ -217,7 +217,7 @@ bool osq_lock(struct mutex *mutex, struct optimistic_spin_queue **lock)
+@@ -217,7 +217,7 @@ bool osq_lock(struct mutex *mutex, struc
* cmpxchg in an attempt to undo our queueing.
*/
@@ -29,22 +27,3 @@ index fd05060..5a94529 100644
/*
* If we need to reschedule bail... so we can block.
*/
-@@ -316,12 +316,14 @@ void osq_unlock(struct optimistic_spin_queue **lock)
- static inline int mutex_can_spin_on_owner(struct mutex *lock)
- {
- int retval = 1;
-+ struct task_struct *owner;
-
- if (need_resched())
- return 0;
-
- rcu_read_lock();
-- if (lock->owner)
-+ owner = ACCESS_ONCE(lock->owner);
-+ if (owner)
- retval = lock->owner->on_cpu;
- rcu_read_unlock();
- /*
---
-2.1.4
-
diff --git a/patches.fixes/mutex-Fix-document-access-once-assumption-in-mutex_c.patch b/patches.fixes/mutex-Fix-document-access-once-assumption-in-mutex_c.patch
new file mode 100644
index 0000000000..2113b35bf5
--- /dev/null
+++ b/patches.fixes/mutex-Fix-document-access-once-assumption-in-mutex_c.patch
@@ -0,0 +1,52 @@
+From: Peter Zijlstra <peterz@infradead.org>
+Date: Fri, 19 Jul 2013 20:31:01 +0200
+Subject: mutex: Fix/document access-once assumption in
+ mutex_can_spin_on_owner()
+Git-commit: 1e40c2edef2537f87f94d0baf80aeaeb7d51cc23
+Patch-mainline: v3.12-rc1
+References: bnc#923099
+
+mutex_can_spin_on_owner() is technically broken in that it would
+in theory allow the compiler to load lock->owner twice, seeing a
+pointer first time and a NULL pointer the second time.
+
+Linus pointed out that a compiler has to be seriously broken to
+not compile this correctly - but nevertheless this change
+is correct as it will better document the implementation.
+
+Signed-off-by: Peter Zijlstra <peterz@infradead.org>
+Acked-by: Davidlohr Bueso <davidlohr.bueso@hp.com>
+Acked-by: Waiman Long <Waiman.Long@hp.com>
+Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
+Acked-by: Thomas Gleixner <tglx@linutronix.de>
+Acked-by: Rik van Riel <riel@redhat.com>
+Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Cc: David Howells <dhowells@redhat.com>
+Link: http://lkml.kernel.org/r/20130719183101.GA20909@twins.programming.kicks-ass.net
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ kernel/mutex.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+--- a/kernel/mutex.c
++++ b/kernel/mutex.c
+@@ -315,14 +315,16 @@ void osq_unlock(struct optimistic_spin_q
+ */
+ static inline int mutex_can_spin_on_owner(struct mutex *lock)
+ {
++ struct task_struct *owner;
+ int retval = 1;
+
+ if (need_resched())
+ return 0;
+
+ rcu_read_lock();
+- if (lock->owner)
+- retval = lock->owner->on_cpu;
++ owner = ACCESS_ONCE(lock->owner);
++ if (owner)
++ retval = owner->on_cpu;
+ rcu_read_unlock();
+ /*
+ * if lock->owner is not set, the mutex owner may have just acquired
diff --git a/series.conf b/series.conf
index dbfa5bf09b..a098928526 100644
--- a/series.conf
+++ b/series.conf
@@ -418,6 +418,7 @@
patches.suse/0001-locking-mutex-Remove-MUTEX_SPIN_USE_MCS_QUEUE.patch
# fate#317234
patches.suse/0002-mutex-Do-not-unnecessarily-deal-with-waiters.patch
+ patches.fixes/mutex-Fix-document-access-once-assumption-in-mutex_c.patch
patches.fixes/0001-locking-mcs-Add-some-needed-ACCESS_ONCE-calls.patch
patches.fixes/0002-locking-mutex-Disable-optimistic-spinning-on-some-ar.patch
patches.fixes/0003-locking-Update-atomic-rmw-flags.patch