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/parisc | |
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/parisc')
-rw-r--r-- | arch/parisc/include/asm/futex.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/arch/parisc/include/asm/futex.h b/arch/parisc/include/asm/futex.h index 0c705c3a55ef..4c6d8672325b 100644 --- a/arch/parisc/include/asm/futex.h +++ b/arch/parisc/include/asm/futex.h | |||
@@ -51,10 +51,10 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | |||
51 | 51 | ||
52 | /* Non-atomic version */ | 52 | /* Non-atomic version */ |
53 | static inline int | 53 | static inline int |
54 | futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | 54 | futex_atomic_cmpxchg_inatomic(int *uval, int __user *uaddr, |
55 | int oldval, int newval) | ||
55 | { | 56 | { |
56 | int err = 0; | 57 | int val; |
57 | int uval; | ||
58 | 58 | ||
59 | /* futex.c wants to do a cmpxchg_inatomic on kernel NULL, which is | 59 | /* futex.c wants to do a cmpxchg_inatomic on kernel NULL, which is |
60 | * our gateway page, and causes no end of trouble... | 60 | * our gateway page, and causes no end of trouble... |
@@ -65,12 +65,12 @@ futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | |||
65 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 65 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) |
66 | return -EFAULT; | 66 | return -EFAULT; |
67 | 67 | ||
68 | err = get_user(uval, uaddr); | 68 | if (get_user(val, uaddr)) |
69 | if (err) return -EFAULT; | 69 | return -EFAULT; |
70 | if (uval == oldval) | 70 | if (val == oldval && put_user(newval, uaddr)) |
71 | err = put_user(newval, uaddr); | 71 | return -EFAULT; |
72 | if (err) return -EFAULT; | 72 | *uval = val; |
73 | return uval; | 73 | return 0; |
74 | } | 74 | } |
75 | 75 | ||
76 | #endif /*__KERNEL__*/ | 76 | #endif /*__KERNEL__*/ |