diff options
author | Michel Lespinasse <walken@google.com> | 2011-03-10 21:48:51 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2011-03-11 06:23:08 -0500 |
commit | 37a9d912b24f96a0591773e6e6c3642991ae5a70 (patch) | |
tree | 5c4d5b9a52e2c533269e589115afbd25b6c8534b /arch/ia64/include | |
parent | 522d7decc0370070448a8c28982c8dfd8970489e (diff) |
futex: Sanitize cmpxchg_futex_value_locked API
The cmpxchg_futex_value_locked API was funny in that it returned either
the original, user-exposed futex value OR an error code such as -EFAULT.
This was confusing at best, and could be a source of livelocks in places
that retry the cmpxchg_futex_value_locked after trying to fix the issue
by running fault_in_user_writeable().
This change makes the cmpxchg_futex_value_locked API more similar to the
get_futex_value_locked one, returning an error code and updating the
original value through a reference argument.
Signed-off-by: Michel Lespinasse <walken@google.com>
Acked-by: Chris Metcalf <cmetcalf@tilera.com> [tile]
Acked-by: Tony Luck <tony.luck@intel.com> [ia64]
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Michal Simek <monstr@monstr.eu> [microblaze]
Acked-by: David Howells <dhowells@redhat.com> [frv]
Cc: Darren Hart <darren@dvhart.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
LKML-Reference: <20110311024851.GC26122@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/ia64/include')
-rw-r--r-- | arch/ia64/include/asm/futex.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/arch/ia64/include/asm/futex.h b/arch/ia64/include/asm/futex.h index c7f0f062239c..b0728404dad0 100644 --- a/arch/ia64/include/asm/futex.h +++ b/arch/ia64/include/asm/futex.h | |||
@@ -100,23 +100,26 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | |||
100 | } | 100 | } |
101 | 101 | ||
102 | static inline int | 102 | static inline int |
103 | futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | 103 | futex_atomic_cmpxchg_inatomic(int *uval, int __user *uaddr, |
104 | int oldval, int newval) | ||
104 | { | 105 | { |
105 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 106 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) |
106 | return -EFAULT; | 107 | return -EFAULT; |
107 | 108 | ||
108 | { | 109 | { |
109 | register unsigned long r8 __asm ("r8"); | 110 | register unsigned long r8 __asm ("r8") = 0; |
111 | unsigned long prev; | ||
110 | __asm__ __volatile__( | 112 | __asm__ __volatile__( |
111 | " mf;; \n" | 113 | " mf;; \n" |
112 | " mov ar.ccv=%3;; \n" | 114 | " mov ar.ccv=%3;; \n" |
113 | "[1:] cmpxchg4.acq %0=[%1],%2,ar.ccv \n" | 115 | "[1:] cmpxchg4.acq %0=[%1],%2,ar.ccv \n" |
114 | " .xdata4 \"__ex_table\", 1b-., 2f-. \n" | 116 | " .xdata4 \"__ex_table\", 1b-., 2f-. \n" |
115 | "[2:]" | 117 | "[2:]" |
116 | : "=r" (r8) | 118 | : "=r" (prev) |
117 | : "r" (uaddr), "r" (newval), | 119 | : "r" (uaddr), "r" (newval), |
118 | "rO" ((long) (unsigned) oldval) | 120 | "rO" ((long) (unsigned) oldval) |
119 | : "memory"); | 121 | : "memory"); |
122 | *uval = prev; | ||
120 | return r8; | 123 | return r8; |
121 | } | 124 | } |
122 | } | 125 | } |