diff options
Diffstat (limited to 'kernel/futex.c')
-rw-r--r-- | kernel/futex.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/kernel/futex.c b/kernel/futex.c index 8af10027514b..4fe790e89d0f 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
@@ -439,13 +439,20 @@ static void free_pi_state(struct futex_pi_state *pi_state) | |||
439 | static struct task_struct * futex_find_get_task(pid_t pid) | 439 | static struct task_struct * futex_find_get_task(pid_t pid) |
440 | { | 440 | { |
441 | struct task_struct *p; | 441 | struct task_struct *p; |
442 | const struct cred *cred = current_cred(), *pcred; | ||
442 | 443 | ||
443 | rcu_read_lock(); | 444 | rcu_read_lock(); |
444 | p = find_task_by_vpid(pid); | 445 | p = find_task_by_vpid(pid); |
445 | if (!p || ((current->euid != p->euid) && (current->euid != p->uid))) | 446 | if (!p) { |
446 | p = ERR_PTR(-ESRCH); | 447 | p = ERR_PTR(-ESRCH); |
447 | else | 448 | } else { |
448 | get_task_struct(p); | 449 | pcred = __task_cred(p); |
450 | if (cred->euid != pcred->euid && | ||
451 | cred->euid != pcred->uid) | ||
452 | p = ERR_PTR(-ESRCH); | ||
453 | else | ||
454 | get_task_struct(p); | ||
455 | } | ||
449 | 456 | ||
450 | rcu_read_unlock(); | 457 | rcu_read_unlock(); |
451 | 458 | ||
@@ -1829,6 +1836,7 @@ sys_get_robust_list(int pid, struct robust_list_head __user * __user *head_ptr, | |||
1829 | { | 1836 | { |
1830 | struct robust_list_head __user *head; | 1837 | struct robust_list_head __user *head; |
1831 | unsigned long ret; | 1838 | unsigned long ret; |
1839 | const struct cred *cred = current_cred(), *pcred; | ||
1832 | 1840 | ||
1833 | if (!futex_cmpxchg_enabled) | 1841 | if (!futex_cmpxchg_enabled) |
1834 | return -ENOSYS; | 1842 | return -ENOSYS; |
@@ -1844,8 +1852,10 @@ sys_get_robust_list(int pid, struct robust_list_head __user * __user *head_ptr, | |||
1844 | if (!p) | 1852 | if (!p) |
1845 | goto err_unlock; | 1853 | goto err_unlock; |
1846 | ret = -EPERM; | 1854 | ret = -EPERM; |
1847 | if ((current->euid != p->euid) && (current->euid != p->uid) && | 1855 | pcred = __task_cred(p); |
1848 | !capable(CAP_SYS_PTRACE)) | 1856 | if (cred->euid != pcred->euid && |
1857 | cred->euid != pcred->uid && | ||
1858 | !capable(CAP_SYS_PTRACE)) | ||
1849 | goto err_unlock; | 1859 | goto err_unlock; |
1850 | head = p->robust_list; | 1860 | head = p->robust_list; |
1851 | rcu_read_unlock(); | 1861 | rcu_read_unlock(); |