[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230120135525.25561-1-hernan.poncedeleon@huaweicloud.com>
Date: Fri, 20 Jan 2023 14:55:25 +0100
From: Hernan Ponce de Leon <hernan.poncedeleon@...weicloud.com>
To: peterz@...radead.org, mingo@...hat.com, will@...nel.org,
longman@...hat.com, boqun.feng@...il.com, akpm@...l.org,
arjan@...ux.intel.com, tglx@...utronix.de, joel@...lfernandes.org,
paulmck@...nel.org, stern@...land.harvard.edu,
diogo.behrens@...wei.com, jonas.oberhauser@...wei.com
Cc: linux-kernel@...r.kernel.org,
Hernan Ponce de Leon <hernanl.leon@...wei.com>,
stable@...r.kernel.org
Subject: [PATCH] Fix data race in mark_rt_mutex_waiters
From: Hernan Ponce de Leon <hernanl.leon@...wei.com>
Following the defition of data race in
tools/memory-model/linux-kernel.cat the dartagnan tool
https://github.com/hernanponcedeleon/Dat3M
reported a race between mark_rt_mutex_waiters and rt_mutex_cmpxchg_release.
Commit 23f78d4a03c5 ("[PATCH] pi-futex: rt mutex core")
later removed in commit d0aa7a70bf03 ("futex_requeue_pi optimization")
and reverted in commit bd197234b0a6
("Revert "futex_requeue_pi optimization"")
The original commit introduced the data race.
Cc: stable@...r.kernel.org # v2.6.18.x
Fixes: 23f78d4a03c5 ("[PATCH] pi-futex: rt mutex core")
Signed-off-by: Hernan Ponce de Leon <hernanl.leon@...wei.com>
---
kernel/locking/rtmutex.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 010cf4e6d0b8..7ed9472edd48 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -235,7 +235,7 @@ static __always_inline void mark_rt_mutex_waiters(struct rt_mutex_base *lock)
unsigned long owner, *p = (unsigned long *) &lock->owner;
do {
- owner = *p;
+ owner = READ_ONCE(*p);
} while (cmpxchg_relaxed(p, owner,
owner | RT_MUTEX_HAS_WAITERS) != owner);
--
2.25.1
Powered by blists - more mailing lists