Skip to content

Commit

Permalink
asm-generic/futex: Re-enable preemption in futex_atomic_cmpxchg_inato…
Browse files Browse the repository at this point in the history
…mic()

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: d9b9ff8 ("sched/preempt, futex: Disable preemption in UP futex_atomic_cmpxchg_inatomic() explicitly")
Signed-off-by: Romain 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>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/1460640963-690-1-git-send-email-romain.perier@free-electrons.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Romain Perier authored and Thomas Gleixner committed Apr 21, 2016
1 parent fe1bce9 commit fba7cd6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions include/asm-generic/futex.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,15 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
u32 val;

preempt_disable();
if (unlikely(get_user(val, uaddr) != 0))
if (unlikely(get_user(val, uaddr) != 0)) {
preempt_enable();
return -EFAULT;
}

if (val == oldval && unlikely(put_user(newval, uaddr) != 0))
if (val == oldval && unlikely(put_user(newval, uaddr) != 0)) {
preempt_enable();
return -EFAULT;
}

*uval = val;
preempt_enable();
Expand Down

0 comments on commit fba7cd6

Please sign in to comment.