aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/futex.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/futex.c')
-rw-r--r--kernel/futex.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/kernel/futex.c b/kernel/futex.c
index 206d4c906885..002aa189eb09 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -409,13 +409,20 @@ static void free_pi_state(struct futex_pi_state *pi_state)
409static struct task_struct * futex_find_get_task(pid_t pid) 409static struct task_struct * futex_find_get_task(pid_t pid)
410{ 410{
411 struct task_struct *p; 411 struct task_struct *p;
412 const struct cred *cred = current_cred(), *pcred;
412 413
413 rcu_read_lock(); 414 rcu_read_lock();
414 p = find_task_by_vpid(pid); 415 p = find_task_by_vpid(pid);
415 if (!p || ((current->euid != p->euid) && (current->euid != p->uid))) 416 if (!p) {
416 p = ERR_PTR(-ESRCH); 417 p = ERR_PTR(-ESRCH);
417 else 418 } else {
418 get_task_struct(p); 419 pcred = __task_cred(p);
420 if (cred->euid != pcred->euid &&
421 cred->euid != pcred->uid)
422 p = ERR_PTR(-ESRCH);
423 else
424 get_task_struct(p);
425 }
419 426
420 rcu_read_unlock(); 427 rcu_read_unlock();
421 428
@@ -1755,6 +1762,7 @@ sys_get_robust_list(int pid, struct robust_list_head __user * __user *head_ptr,
1755{ 1762{
1756 struct robust_list_head __user *head; 1763 struct robust_list_head __user *head;
1757 unsigned long ret; 1764 unsigned long ret;
1765 const struct cred *cred = current_cred(), *pcred;
1758 1766
1759 if (!futex_cmpxchg_enabled) 1767 if (!futex_cmpxchg_enabled)
1760 return -ENOSYS; 1768 return -ENOSYS;
@@ -1770,8 +1778,10 @@ sys_get_robust_list(int pid, struct robust_list_head __user * __user *head_ptr,
1770 if (!p) 1778 if (!p)
1771 goto err_unlock; 1779 goto err_unlock;
1772 ret = -EPERM; 1780 ret = -EPERM;
1773 if ((current->euid != p->euid) && (current->euid != p->uid) && 1781 pcred = __task_cred(p);
1774 !capable(CAP_SYS_PTRACE)) 1782 if (cred->euid != pcred->euid &&
1783 cred->euid != pcred->uid &&
1784 !capable(CAP_SYS_PTRACE))
1775 goto err_unlock; 1785 goto err_unlock;
1776 head = p->robust_list; 1786 head = p->robust_list;
1777 rcu_read_unlock(); 1787 rcu_read_unlock();