diff options
| -rw-r--r-- | kernel/futex.c | 64 |
1 files changed, 30 insertions, 34 deletions
diff --git a/kernel/futex.c b/kernel/futex.c index 40a8777a27d..38cf606a2d7 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
| @@ -283,8 +283,7 @@ again: | |||
| 283 | return 0; | 283 | return 0; |
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | static inline | 286 | static inline void put_futex_key(union futex_key *key) |
| 287 | void put_futex_key(int fshared, union futex_key *key) | ||
| 288 | { | 287 | { |
| 289 | drop_futex_key_refs(key); | 288 | drop_futex_key_refs(key); |
| 290 | } | 289 | } |
| @@ -907,7 +906,7 @@ static int futex_wake(u32 __user *uaddr, int fshared, int nr_wake, u32 bitset) | |||
| 907 | } | 906 | } |
| 908 | 907 | ||
| 909 | spin_unlock(&hb->lock); | 908 | spin_unlock(&hb->lock); |
| 910 | put_futex_key(fshared, &key); | 909 | put_futex_key(&key); |
| 911 | out: | 910 | out: |
| 912 | return ret; | 911 | return ret; |
| 913 | } | 912 | } |
| @@ -965,8 +964,8 @@ retry_private: | |||
| 965 | if (!fshared) | 964 | if (!fshared) |
| 966 | goto retry_private; | 965 | goto retry_private; |
| 967 | 966 | ||
| 968 | put_futex_key(fshared, &key2); | 967 | put_futex_key(&key2); |
| 969 | put_futex_key(fshared, &key1); | 968 | put_futex_key(&key1); |
| 970 | goto retry; | 969 | goto retry; |
| 971 | } | 970 | } |
| 972 | 971 | ||
| @@ -996,9 +995,9 @@ retry_private: | |||
| 996 | 995 | ||
| 997 | double_unlock_hb(hb1, hb2); | 996 | double_unlock_hb(hb1, hb2); |
| 998 | out_put_keys: | 997 | out_put_keys: |
| 999 | put_futex_key(fshared, &key2); | 998 | put_futex_key(&key2); |
| 1000 | out_put_key1: | 999 | out_put_key1: |
| 1001 | put_futex_key(fshared, &key1); | 1000 | put_futex_key(&key1); |
| 1002 | out: | 1001 | out: |
| 1003 | return ret; | 1002 | return ret; |
| 1004 | } | 1003 | } |
| @@ -1219,8 +1218,8 @@ retry_private: | |||
| 1219 | if (!fshared) | 1218 | if (!fshared) |
| 1220 | goto retry_private; | 1219 | goto retry_private; |
| 1221 | 1220 | ||
| 1222 | put_futex_key(fshared, &key2); | 1221 | put_futex_key(&key2); |
| 1223 | put_futex_key(fshared, &key1); | 1222 | put_futex_key(&key1); |
| 1224 | goto retry; | 1223 | goto retry; |
| 1225 | } | 1224 | } |
| 1226 | if (curval != *cmpval) { | 1225 | if (curval != *cmpval) { |
| @@ -1260,8 +1259,8 @@ retry_private: | |||
| 1260 | break; | 1259 | break; |
| 1261 | case -EFAULT: | 1260 | case -EFAULT: |
| 1262 | double_unlock_hb(hb1, hb2); | 1261 | double_unlock_hb(hb1, hb2); |
| 1263 | put_futex_key(fshared, &key2); | 1262 | put_futex_key(&key2); |
| 1264 | put_futex_key(fshared, &key1); | 1263 | put_futex_key(&key1); |
| 1265 | ret = fault_in_user_writeable(uaddr2); | 1264 | ret = fault_in_user_writeable(uaddr2); |
| 1266 | if (!ret) | 1265 | if (!ret) |
| 1267 | goto retry; | 1266 | goto retry; |
| @@ -1269,8 +1268,8 @@ retry_private: | |||
| 1269 | case -EAGAIN: | 1268 | case -EAGAIN: |
| 1270 | /* The owner was exiting, try again. */ | 1269 | /* The owner was exiting, try again. */ |
| 1271 | double_unlock_hb(hb1, hb2); | 1270 | double_unlock_hb(hb1, hb2); |
| 1272 | put_futex_key(fshared, &key2); | 1271 | put_futex_key(&key2); |
| 1273 | put_futex_key(fshared, &key1); | 1272 | put_futex_key(&key1); |
| 1274 | cond_resched(); | 1273 | cond_resched(); |
| 1275 | goto retry; | 1274 | goto retry; |
| 1276 | default: | 1275 | default: |
| @@ -1352,9 +1351,9 @@ out_unlock: | |||
| 1352 | drop_futex_key_refs(&key1); | 1351 | drop_futex_key_refs(&key1); |
| 1353 | 1352 | ||
| 1354 | out_put_keys: | 1353 | out_put_keys: |
| 1355 | put_futex_key(fshared, &key2); | 1354 | put_futex_key(&key2); |
| 1356 | out_put_key1: | 1355 | out_put_key1: |
| 1357 | put_futex_key(fshared, &key1); | 1356 | put_futex_key(&key1); |
| 1358 | out: | 1357 | out: |
| 1359 | if (pi_state != NULL) | 1358 | if (pi_state != NULL) |
| 1360 | free_pi_state(pi_state); | 1359 | free_pi_state(pi_state); |
| @@ -1494,7 +1493,7 @@ static void unqueue_me_pi(struct futex_q *q) | |||
| 1494 | * private futexes. | 1493 | * private futexes. |
| 1495 | */ | 1494 | */ |
| 1496 | static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, | 1495 | static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, |
| 1497 | struct task_struct *newowner, int fshared) | 1496 | struct task_struct *newowner) |
| 1498 | { | 1497 | { |
| 1499 | u32 newtid = task_pid_vnr(newowner) | FUTEX_WAITERS; | 1498 | u32 newtid = task_pid_vnr(newowner) | FUTEX_WAITERS; |
| 1500 | struct futex_pi_state *pi_state = q->pi_state; | 1499 | struct futex_pi_state *pi_state = q->pi_state; |
| @@ -1600,7 +1599,6 @@ static long futex_wait_restart(struct restart_block *restart); | |||
| 1600 | /** | 1599 | /** |
| 1601 | * fixup_owner() - Post lock pi_state and corner case management | 1600 | * fixup_owner() - Post lock pi_state and corner case management |
| 1602 | * @uaddr: user address of the futex | 1601 | * @uaddr: user address of the futex |
| 1603 | * @fshared: whether the futex is shared (1) or not (0) | ||
| 1604 | * @q: futex_q (contains pi_state and access to the rt_mutex) | 1602 | * @q: futex_q (contains pi_state and access to the rt_mutex) |
| 1605 | * @locked: if the attempt to take the rt_mutex succeeded (1) or not (0) | 1603 | * @locked: if the attempt to take the rt_mutex succeeded (1) or not (0) |
| 1606 | * | 1604 | * |
| @@ -1613,8 +1611,7 @@ static long futex_wait_restart(struct restart_block *restart); | |||
| 1613 | * 0 - success, lock not taken | 1611 | * 0 - success, lock not taken |
| 1614 | * <0 - on error (-EFAULT) | 1612 | * <0 - on error (-EFAULT) |
| 1615 | */ | 1613 | */ |
| 1616 | static int fixup_owner(u32 __user *uaddr, int fshared, struct futex_q *q, | 1614 | static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked) |
| 1617 | int locked) | ||
| 1618 | { | 1615 | { |
| 1619 | struct task_struct *owner; | 1616 | struct task_struct *owner; |
| 1620 | int ret = 0; | 1617 | int ret = 0; |
| @@ -1625,7 +1622,7 @@ static int fixup_owner(u32 __user *uaddr, int fshared, struct futex_q *q, | |||
| 1625 | * did a lock-steal - fix up the PI-state in that case: | 1622 | * did a lock-steal - fix up the PI-state in that case: |
| 1626 | */ | 1623 | */ |
| 1627 | if (q->pi_state->owner != current) | 1624 | if (q->pi_state->owner != current) |
| 1628 | ret = fixup_pi_state_owner(uaddr, q, current, fshared); | 1625 | ret = fixup_pi_state_owner(uaddr, q, current); |
| 1629 | goto out; | 1626 | goto out; |
| 1630 | } | 1627 | } |
| 1631 | 1628 | ||
| @@ -1652,7 +1649,7 @@ static int fixup_owner(u32 __user *uaddr, int fshared, struct futex_q *q, | |||
| 1652 | * lock. Fix the state up. | 1649 | * lock. Fix the state up. |
| 1653 | */ | 1650 | */ |
| 1654 | owner = rt_mutex_owner(&q->pi_state->pi_mutex); | 1651 | owner = rt_mutex_owner(&q->pi_state->pi_mutex); |
| 1655 | ret = fixup_pi_state_owner(uaddr, q, owner, fshared); | 1652 | ret = fixup_pi_state_owner(uaddr, q, owner); |
| 1656 | goto out; | 1653 | goto out; |
| 1657 | } | 1654 | } |
| 1658 | 1655 | ||
| @@ -1772,7 +1769,7 @@ retry_private: | |||
| 1772 | if (!fshared) | 1769 | if (!fshared) |
| 1773 | goto retry_private; | 1770 | goto retry_private; |
| 1774 | 1771 | ||
| 1775 | put_futex_key(fshared, &q->key); | 1772 | put_futex_key(&q->key); |
| 1776 | goto retry; | 1773 | goto retry; |
| 1777 | } | 1774 | } |
| 1778 | 1775 | ||
| @@ -1783,7 +1780,7 @@ retry_private: | |||
| 1783 | 1780 | ||
| 1784 | out: | 1781 | out: |
| 1785 | if (ret) | 1782 | if (ret) |
| 1786 | put_futex_key(fshared, &q->key); | 1783 | put_futex_key(&q->key); |
| 1787 | return ret; | 1784 | return ret; |
| 1788 | } | 1785 | } |
| 1789 | 1786 | ||
| @@ -1941,7 +1938,7 @@ retry_private: | |||
| 1941 | * exit to complete. | 1938 | * exit to complete. |
| 1942 | */ | 1939 | */ |
| 1943 | queue_unlock(&q, hb); | 1940 | queue_unlock(&q, hb); |
| 1944 | put_futex_key(fshared, &q.key); | 1941 | put_futex_key(&q.key); |
| 1945 | cond_resched(); | 1942 | cond_resched(); |
| 1946 | goto retry; | 1943 | goto retry; |
| 1947 | default: | 1944 | default: |
| @@ -1971,7 +1968,7 @@ retry_private: | |||
| 1971 | * Fixup the pi_state owner and possibly acquire the lock if we | 1968 | * Fixup the pi_state owner and possibly acquire the lock if we |
| 1972 | * haven't already. | 1969 | * haven't already. |
| 1973 | */ | 1970 | */ |
| 1974 | res = fixup_owner(uaddr, fshared, &q, !ret); | 1971 | res = fixup_owner(uaddr, &q, !ret); |
| 1975 | /* | 1972 | /* |
| 1976 | * If fixup_owner() returned an error, proprogate that. If it acquired | 1973 | * If fixup_owner() returned an error, proprogate that. If it acquired |
| 1977 | * the lock, clear our -ETIMEDOUT or -EINTR. | 1974 | * the lock, clear our -ETIMEDOUT or -EINTR. |
| @@ -1995,7 +1992,7 @@ out_unlock_put_key: | |||
| 1995 | queue_unlock(&q, hb); | 1992 | queue_unlock(&q, hb); |
| 1996 | 1993 | ||
| 1997 | out_put_key: | 1994 | out_put_key: |
| 1998 | put_futex_key(fshared, &q.key); | 1995 | put_futex_key(&q.key); |
| 1999 | out: | 1996 | out: |
| 2000 | if (to) | 1997 | if (to) |
| 2001 | destroy_hrtimer_on_stack(&to->timer); | 1998 | destroy_hrtimer_on_stack(&to->timer); |
| @@ -2011,7 +2008,7 @@ uaddr_faulted: | |||
| 2011 | if (!fshared) | 2008 | if (!fshared) |
| 2012 | goto retry_private; | 2009 | goto retry_private; |
| 2013 | 2010 | ||
| 2014 | put_futex_key(fshared, &q.key); | 2011 | put_futex_key(&q.key); |
| 2015 | goto retry; | 2012 | goto retry; |
| 2016 | } | 2013 | } |
| 2017 | 2014 | ||
| @@ -2093,14 +2090,14 @@ retry: | |||
| 2093 | 2090 | ||
| 2094 | out_unlock: | 2091 | out_unlock: |
| 2095 | spin_unlock(&hb->lock); | 2092 | spin_unlock(&hb->lock); |
| 2096 | put_futex_key(fshared, &key); | 2093 | put_futex_key(&key); |
| 2097 | 2094 | ||
| 2098 | out: | 2095 | out: |
| 2099 | return ret; | 2096 | return ret; |
| 2100 | 2097 | ||
| 2101 | pi_faulted: | 2098 | pi_faulted: |
| 2102 | spin_unlock(&hb->lock); | 2099 | spin_unlock(&hb->lock); |
| 2103 | put_futex_key(fshared, &key); | 2100 | put_futex_key(&key); |
| 2104 | 2101 | ||
| 2105 | ret = fault_in_user_writeable(uaddr); | 2102 | ret = fault_in_user_writeable(uaddr); |
| 2106 | if (!ret) | 2103 | if (!ret) |
| @@ -2273,8 +2270,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared, | |||
| 2273 | */ | 2270 | */ |
| 2274 | if (q.pi_state && (q.pi_state->owner != current)) { | 2271 | if (q.pi_state && (q.pi_state->owner != current)) { |
| 2275 | spin_lock(q.lock_ptr); | 2272 | spin_lock(q.lock_ptr); |
| 2276 | ret = fixup_pi_state_owner(uaddr2, &q, current, | 2273 | ret = fixup_pi_state_owner(uaddr2, &q, current); |
| 2277 | fshared); | ||
| 2278 | spin_unlock(q.lock_ptr); | 2274 | spin_unlock(q.lock_ptr); |
| 2279 | } | 2275 | } |
| 2280 | } else { | 2276 | } else { |
| @@ -2293,7 +2289,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared, | |||
| 2293 | * Fixup the pi_state owner and possibly acquire the lock if we | 2289 | * Fixup the pi_state owner and possibly acquire the lock if we |
| 2294 | * haven't already. | 2290 | * haven't already. |
| 2295 | */ | 2291 | */ |
| 2296 | res = fixup_owner(uaddr2, fshared, &q, !ret); | 2292 | res = fixup_owner(uaddr2, &q, !ret); |
| 2297 | /* | 2293 | /* |
| 2298 | * If fixup_owner() returned an error, proprogate that. If it | 2294 | * If fixup_owner() returned an error, proprogate that. If it |
| 2299 | * acquired the lock, clear -ETIMEDOUT or -EINTR. | 2295 | * acquired the lock, clear -ETIMEDOUT or -EINTR. |
| @@ -2324,9 +2320,9 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared, | |||
| 2324 | } | 2320 | } |
| 2325 | 2321 | ||
| 2326 | out_put_keys: | 2322 | out_put_keys: |
| 2327 | put_futex_key(fshared, &q.key); | 2323 | put_futex_key(&q.key); |
| 2328 | out_key2: | 2324 | out_key2: |
| 2329 | put_futex_key(fshared, &key2); | 2325 | put_futex_key(&key2); |
| 2330 | 2326 | ||
| 2331 | out: | 2327 | out: |
| 2332 | if (to) { | 2328 | if (to) { |
