aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/futex.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/futex.c')
-rw-r--r--kernel/futex.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/kernel/futex.c b/kernel/futex.c
index e45a65e41686..86b2600381b6 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,7 +446,8 @@ 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_pid_ns(pid,
450 current->nsproxy->pid_ns);
447 451
448 if (!p || ((current->euid != p->euid) && (current->euid != p->uid))) 452 if (!p || ((current->euid != p->euid) && (current->euid != p->uid)))
449 p = ERR_PTR(-ESRCH); 453 p = ERR_PTR(-ESRCH);
@@ -653,7 +657,7 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this)
653 if (!(uval & FUTEX_OWNER_DIED)) { 657 if (!(uval & FUTEX_OWNER_DIED)) {
654 int ret = 0; 658 int ret = 0;
655 659
656 newval = FUTEX_WAITERS | new_owner->pid; 660 newval = FUTEX_WAITERS | task_pid_vnr(new_owner);
657 661
658 curval = cmpxchg_futex_value_locked(uaddr, uval, newval); 662 curval = cmpxchg_futex_value_locked(uaddr, uval, newval);
659 663
@@ -1106,7 +1110,7 @@ static void unqueue_me_pi(struct futex_q *q)
1106static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, 1110static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q,
1107 struct task_struct *curr) 1111 struct task_struct *curr)
1108{ 1112{
1109 u32 newtid = curr->pid | FUTEX_WAITERS; 1113 u32 newtid = task_pid_vnr(curr) | FUTEX_WAITERS;
1110 struct futex_pi_state *pi_state = q->pi_state; 1114 struct futex_pi_state *pi_state = q->pi_state;
1111 u32 uval, curval, newval; 1115 u32 uval, curval, newval;
1112 int ret; 1116 int ret;
@@ -1368,7 +1372,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
1368 * (by doing a 0 -> TID atomic cmpxchg), while holding all 1372 * (by doing a 0 -> TID atomic cmpxchg), while holding all
1369 * the locks. It will most likely not succeed. 1373 * the locks. It will most likely not succeed.
1370 */ 1374 */
1371 newval = current->pid; 1375 newval = task_pid_vnr(current);
1372 1376
1373 curval = cmpxchg_futex_value_locked(uaddr, 0, newval); 1377 curval = cmpxchg_futex_value_locked(uaddr, 0, newval);
1374 1378
@@ -1379,7 +1383,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 1383 * Detect deadlocks. In case of REQUEUE_PI this is a valid
1380 * situation and we return success to user space. 1384 * situation and we return success to user space.
1381 */ 1385 */
1382 if (unlikely((curval & FUTEX_TID_MASK) == current->pid)) { 1386 if (unlikely((curval & FUTEX_TID_MASK) == task_pid_vnr(current))) {
1383 ret = -EDEADLK; 1387 ret = -EDEADLK;
1384 goto out_unlock_release_sem; 1388 goto out_unlock_release_sem;
1385 } 1389 }
@@ -1408,7 +1412,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
1408 */ 1412 */
1409 if (unlikely(ownerdied || !(curval & FUTEX_TID_MASK))) { 1413 if (unlikely(ownerdied || !(curval & FUTEX_TID_MASK))) {
1410 /* Keep the OWNER_DIED bit */ 1414 /* Keep the OWNER_DIED bit */
1411 newval = (curval & ~FUTEX_TID_MASK) | current->pid; 1415 newval = (curval & ~FUTEX_TID_MASK) | task_pid_vnr(current);
1412 ownerdied = 0; 1416 ownerdied = 0;
1413 lock_taken = 1; 1417 lock_taken = 1;
1414 } 1418 }
@@ -1587,7 +1591,7 @@ retry:
1587 /* 1591 /*
1588 * We release only a lock we actually own: 1592 * We release only a lock we actually own:
1589 */ 1593 */
1590 if ((uval & FUTEX_TID_MASK) != current->pid) 1594 if ((uval & FUTEX_TID_MASK) != task_pid_vnr(current))
1591 return -EPERM; 1595 return -EPERM;
1592 /* 1596 /*
1593 * First take all the futex related locks: 1597 * First take all the futex related locks:
@@ -1608,7 +1612,7 @@ retry_unlocked:
1608 * anyone else up: 1612 * anyone else up:
1609 */ 1613 */
1610 if (!(uval & FUTEX_OWNER_DIED)) 1614 if (!(uval & FUTEX_OWNER_DIED))
1611 uval = cmpxchg_futex_value_locked(uaddr, current->pid, 0); 1615 uval = cmpxchg_futex_value_locked(uaddr, task_pid_vnr(current), 0);
1612 1616
1613 1617
1614 if (unlikely(uval == -EFAULT)) 1618 if (unlikely(uval == -EFAULT))
@@ -1617,7 +1621,7 @@ retry_unlocked:
1617 * Rare case: we managed to release the lock atomically, 1621 * Rare case: we managed to release the lock atomically,
1618 * no need to wake anyone else up: 1622 * no need to wake anyone else up:
1619 */ 1623 */
1620 if (unlikely(uval == current->pid)) 1624 if (unlikely(uval == task_pid_vnr(current)))
1621 goto out_unlock; 1625 goto out_unlock;
1622 1626
1623 /* 1627 /*
@@ -1854,7 +1858,8 @@ sys_get_robust_list(int pid, struct robust_list_head __user * __user *head_ptr,
1854 1858
1855 ret = -ESRCH; 1859 ret = -ESRCH;
1856 rcu_read_lock(); 1860 rcu_read_lock();
1857 p = find_task_by_pid(pid); 1861 p = find_task_by_pid_ns(pid,
1862 current->nsproxy->pid_ns);
1858 if (!p) 1863 if (!p)
1859 goto err_unlock; 1864 goto err_unlock;
1860 ret = -EPERM; 1865 ret = -EPERM;
@@ -1887,7 +1892,7 @@ retry:
1887 if (get_user(uval, uaddr)) 1892 if (get_user(uval, uaddr))
1888 return -1; 1893 return -1;
1889 1894
1890 if ((uval & FUTEX_TID_MASK) == curr->pid) { 1895 if ((uval & FUTEX_TID_MASK) == task_pid_vnr(curr)) {
1891 /* 1896 /*
1892 * Ok, this dying thread is truly holding a futex 1897 * Ok, this dying thread is truly holding a futex
1893 * of interest. Set the OWNER_DIED bit atomically 1898 * of interest. Set the OWNER_DIED bit atomically