diff options
Diffstat (limited to 'kernel/futex.c')
-rw-r--r-- | kernel/futex.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/kernel/futex.c b/kernel/futex.c index e45a65e41686..32710451dc20 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
@@ -53,6 +53,9 @@ | |||
53 | #include <linux/signal.h> | 53 | #include <linux/signal.h> |
54 | #include <linux/module.h> | 54 | #include <linux/module.h> |
55 | #include <linux/magic.h> | 55 | #include <linux/magic.h> |
56 | #include <linux/pid.h> | ||
57 | #include <linux/nsproxy.h> | ||
58 | |||
56 | #include <asm/futex.h> | 59 | #include <asm/futex.h> |
57 | 60 | ||
58 | #include "rtmutex_common.h" | 61 | #include "rtmutex_common.h" |
@@ -443,8 +446,7 @@ static struct task_struct * futex_find_get_task(pid_t pid) | |||
443 | struct task_struct *p; | 446 | struct task_struct *p; |
444 | 447 | ||
445 | rcu_read_lock(); | 448 | rcu_read_lock(); |
446 | p = find_task_by_pid(pid); | 449 | p = find_task_by_vpid(pid); |
447 | |||
448 | if (!p || ((current->euid != p->euid) && (current->euid != p->uid))) | 450 | if (!p || ((current->euid != p->euid) && (current->euid != p->uid))) |
449 | p = ERR_PTR(-ESRCH); | 451 | p = ERR_PTR(-ESRCH); |
450 | else | 452 | else |
@@ -653,7 +655,7 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this) | |||
653 | if (!(uval & FUTEX_OWNER_DIED)) { | 655 | if (!(uval & FUTEX_OWNER_DIED)) { |
654 | int ret = 0; | 656 | int ret = 0; |
655 | 657 | ||
656 | newval = FUTEX_WAITERS | new_owner->pid; | 658 | newval = FUTEX_WAITERS | task_pid_vnr(new_owner); |
657 | 659 | ||
658 | curval = cmpxchg_futex_value_locked(uaddr, uval, newval); | 660 | curval = cmpxchg_futex_value_locked(uaddr, uval, newval); |
659 | 661 | ||
@@ -1106,7 +1108,7 @@ static void unqueue_me_pi(struct futex_q *q) | |||
1106 | static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, | 1108 | static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, |
1107 | struct task_struct *curr) | 1109 | struct task_struct *curr) |
1108 | { | 1110 | { |
1109 | u32 newtid = curr->pid | FUTEX_WAITERS; | 1111 | u32 newtid = task_pid_vnr(curr) | FUTEX_WAITERS; |
1110 | struct futex_pi_state *pi_state = q->pi_state; | 1112 | struct futex_pi_state *pi_state = q->pi_state; |
1111 | u32 uval, curval, newval; | 1113 | u32 uval, curval, newval; |
1112 | int ret; | 1114 | int ret; |
@@ -1368,7 +1370,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1368 | * (by doing a 0 -> TID atomic cmpxchg), while holding all | 1370 | * (by doing a 0 -> TID atomic cmpxchg), while holding all |
1369 | * the locks. It will most likely not succeed. | 1371 | * the locks. It will most likely not succeed. |
1370 | */ | 1372 | */ |
1371 | newval = current->pid; | 1373 | newval = task_pid_vnr(current); |
1372 | 1374 | ||
1373 | curval = cmpxchg_futex_value_locked(uaddr, 0, newval); | 1375 | curval = cmpxchg_futex_value_locked(uaddr, 0, newval); |
1374 | 1376 | ||
@@ -1379,7 +1381,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1379 | * Detect deadlocks. In case of REQUEUE_PI this is a valid | 1381 | * Detect deadlocks. In case of REQUEUE_PI this is a valid |
1380 | * situation and we return success to user space. | 1382 | * situation and we return success to user space. |
1381 | */ | 1383 | */ |
1382 | if (unlikely((curval & FUTEX_TID_MASK) == current->pid)) { | 1384 | if (unlikely((curval & FUTEX_TID_MASK) == task_pid_vnr(current))) { |
1383 | ret = -EDEADLK; | 1385 | ret = -EDEADLK; |
1384 | goto out_unlock_release_sem; | 1386 | goto out_unlock_release_sem; |
1385 | } | 1387 | } |
@@ -1408,7 +1410,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1408 | */ | 1410 | */ |
1409 | if (unlikely(ownerdied || !(curval & FUTEX_TID_MASK))) { | 1411 | if (unlikely(ownerdied || !(curval & FUTEX_TID_MASK))) { |
1410 | /* Keep the OWNER_DIED bit */ | 1412 | /* Keep the OWNER_DIED bit */ |
1411 | newval = (curval & ~FUTEX_TID_MASK) | current->pid; | 1413 | newval = (curval & ~FUTEX_TID_MASK) | task_pid_vnr(current); |
1412 | ownerdied = 0; | 1414 | ownerdied = 0; |
1413 | lock_taken = 1; | 1415 | lock_taken = 1; |
1414 | } | 1416 | } |
@@ -1587,7 +1589,7 @@ retry: | |||
1587 | /* | 1589 | /* |
1588 | * We release only a lock we actually own: | 1590 | * We release only a lock we actually own: |
1589 | */ | 1591 | */ |
1590 | if ((uval & FUTEX_TID_MASK) != current->pid) | 1592 | if ((uval & FUTEX_TID_MASK) != task_pid_vnr(current)) |
1591 | return -EPERM; | 1593 | return -EPERM; |
1592 | /* | 1594 | /* |
1593 | * First take all the futex related locks: | 1595 | * First take all the futex related locks: |
@@ -1608,7 +1610,7 @@ retry_unlocked: | |||
1608 | * anyone else up: | 1610 | * anyone else up: |
1609 | */ | 1611 | */ |
1610 | if (!(uval & FUTEX_OWNER_DIED)) | 1612 | if (!(uval & FUTEX_OWNER_DIED)) |
1611 | uval = cmpxchg_futex_value_locked(uaddr, current->pid, 0); | 1613 | uval = cmpxchg_futex_value_locked(uaddr, task_pid_vnr(current), 0); |
1612 | 1614 | ||
1613 | 1615 | ||
1614 | if (unlikely(uval == -EFAULT)) | 1616 | if (unlikely(uval == -EFAULT)) |
@@ -1617,7 +1619,7 @@ retry_unlocked: | |||
1617 | * Rare case: we managed to release the lock atomically, | 1619 | * Rare case: we managed to release the lock atomically, |
1618 | * no need to wake anyone else up: | 1620 | * no need to wake anyone else up: |
1619 | */ | 1621 | */ |
1620 | if (unlikely(uval == current->pid)) | 1622 | if (unlikely(uval == task_pid_vnr(current))) |
1621 | goto out_unlock; | 1623 | goto out_unlock; |
1622 | 1624 | ||
1623 | /* | 1625 | /* |
@@ -1854,7 +1856,7 @@ sys_get_robust_list(int pid, struct robust_list_head __user * __user *head_ptr, | |||
1854 | 1856 | ||
1855 | ret = -ESRCH; | 1857 | ret = -ESRCH; |
1856 | rcu_read_lock(); | 1858 | rcu_read_lock(); |
1857 | p = find_task_by_pid(pid); | 1859 | p = find_task_by_vpid(pid); |
1858 | if (!p) | 1860 | if (!p) |
1859 | goto err_unlock; | 1861 | goto err_unlock; |
1860 | ret = -EPERM; | 1862 | ret = -EPERM; |
@@ -1887,7 +1889,7 @@ retry: | |||
1887 | if (get_user(uval, uaddr)) | 1889 | if (get_user(uval, uaddr)) |
1888 | return -1; | 1890 | return -1; |
1889 | 1891 | ||
1890 | if ((uval & FUTEX_TID_MASK) == curr->pid) { | 1892 | if ((uval & FUTEX_TID_MASK) == task_pid_vnr(curr)) { |
1891 | /* | 1893 | /* |
1892 | * Ok, this dying thread is truly holding a futex | 1894 | * Ok, this dying thread is truly holding a futex |
1893 | * of interest. Set the OWNER_DIED bit atomically | 1895 | * of interest. Set the OWNER_DIED bit atomically |