Return-Path: Received: from mx2.suse.de ([195.135.220.15]:43374 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755641AbdABMps (ORCPT ); Mon, 2 Jan 2017 07:45:48 -0500 From: Jiri Slaby To: stable@vger.kernel.org Cc: Thomas Gleixner , David Daney , Linus Torvalds , Mark Rutland , Peter Zijlstra , Sebastian Siewior , Steven Rostedt , Ingo Molnar , Jiri Slaby Subject: [patch added to 3.12-stable] locking/rtmutex: Use READ_ONCE() in rt_mutex_owner() Date: Mon, 2 Jan 2017 13:45:36 +0100 Message-Id: <20170102124541.18653-2-jslaby@suse.cz> In-Reply-To: <20170102124541.18653-1-jslaby@suse.cz> References: <20170102124541.18653-1-jslaby@suse.cz> Sender: stable-owner@vger.kernel.org List-ID: From: Thomas Gleixner This patch has been added to the 3.12 stable tree. If you have any objections, please let us know. =============== commit 1be5d4fa0af34fb7bafa205aeb59f5c7cc7a089d upstream. While debugging the rtmutex unlock vs. dequeue race Will suggested to use READ_ONCE() in rt_mutex_owner() as it might race against the cmpxchg_release() in unlock_rt_mutex_safe(). Will: "It's a minor thing which will most likely not matter in practice" Careful search did not unearth an actual problem in todays code, but it's better to be safe than surprised. Suggested-by: Will Deacon Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) Cc: David Daney Cc: Linus Torvalds Cc: Mark Rutland Cc: Peter Zijlstra Cc: Sebastian Siewior Cc: Steven Rostedt Link: http://lkml.kernel.org/r/20161130210030.431379999@linutronix.de Signed-off-by: Ingo Molnar Signed-off-by: Jiri Slaby --- kernel/rtmutex_common.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/rtmutex_common.h b/kernel/rtmutex_common.h index 53a66c85261b..1823c094fe96 100644 --- a/kernel/rtmutex_common.h +++ b/kernel/rtmutex_common.h @@ -96,8 +96,9 @@ task_top_pi_waiter(struct task_struct *p) static inline struct task_struct *rt_mutex_owner(struct rt_mutex *lock) { - return (struct task_struct *) - ((unsigned long)lock->owner & ~RT_MUTEX_OWNER_MASKALL); + unsigned long owner = (unsigned long) READ_ONCE(lock->owner); + + return (struct task_struct *) (owner & ~RT_MUTEX_OWNER_MASKALL); } /* -- 2.11.0