Commit 83c089a3 authored by Romain Perier's avatar Romain Perier Committed by Kamal Mostafa

asm-generic/futex: Re-enable preemption in futex_atomic_cmpxchg_inatomic()

commit fba7cd68 upstream.

The recent decoupling of pagefault disable and preempt disable added an
explicit preempt_disable/enable() pair to the futex_atomic_cmpxchg_inatomic()
implementation in asm-generic/futex.h. But it forgot to add preempt_enable()
calls to the error handling code pathes, which results in a preemption count
imbalance.

This is observable on boot when the test for atomic_cmpxchg() is calling
futex_atomic_cmpxchg_inatomic() on a NULL pointer.

Add the missing preempt_enable() calls to the error handling code pathes.

[ tglx: Massaged changelog ]

Fixes: d9b9ff8c ("sched/preempt, futex: Disable preemption in UP futex_atomic_cmpxchg_inatomic() explicitly")
Signed-off-by: default avatarRomain Perier <romain.perier@free-electrons.com>
Cc: linux-arch@vger.kernel.org
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1460640963-690-1-git-send-email-romain.perier@free-electrons.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent b209872b
...@@ -108,11 +108,15 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, ...@@ -108,11 +108,15 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
u32 val; u32 val;
preempt_disable(); preempt_disable();
if (unlikely(get_user(val, uaddr) != 0)) if (unlikely(get_user(val, uaddr) != 0)) {
preempt_enable();
return -EFAULT; return -EFAULT;
}
if (val == oldval && unlikely(put_user(newval, uaddr) != 0)) if (val == oldval && unlikely(put_user(newval, uaddr) != 0)) {
preempt_enable();
return -EFAULT; return -EFAULT;
}
*uval = val; *uval = val;
preempt_enable(); preempt_enable();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment