LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH RT] arm/futex: disable preemption during futex_atomic_cmpxchg_inatomic()
@ 2015-02-18 13:48 Sebastian Andrzej Siewior
0 siblings, 0 replies; only message in thread
From: Sebastian Andrzej Siewior @ 2015-02-18 13:48 UTC (permalink / raw)
To: linux-rt-users; +Cc: linux-kernel, tglx, Sebastian Andrzej Siewior
The ARM UP implementation of futex_atomic_cmpxchg_inatomic() assumes that
pagefault_disable() inherits a preempt disabled section. This assumtion
is true for mainline but -RT reverts this and allows preemption in
pagefault disabled regions.
The code sequence of futex_atomic_cmpxchg_inatomic():
| x = *futex;
| if (x == oldval)
| *futex = newval;
The problem occurs if the code is preempted after reading the futex value or
after comparing it with x. While preempted, the futex owner has to be
scheduled which then releases the lock (in userland because it has no waiter
yet). Once the code is back on the CPU, it overwrites the futex value
with with the old PID and the waiter bit set.
The workaround is to explicit disable code preemption to avoid the
described race window.
Debugged-by: Thomas Gleixner <firstname.lastname@example.org>
Signed-off-by: Sebastian Andrzej Siewior <email@example.com>
arch/arm/include/asm/futex.h | 4 ++++
1 file changed, 4 insertions(+)
@@ -93,6 +93,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval,
if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
"1: " TUSER(ldr) " %1, [%4]\n"
" teq %1, %2\n"
@@ -104,6 +106,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval,
: "cc", "memory");
*uval = val;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-02-18 13:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-18 13:48 [PATCH RT] arm/futex: disable preemption during futex_atomic_cmpxchg_inatomic() Sebastian Andrzej Siewior
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).