diff options
Diffstat (limited to 'kernel/futex.c')
-rw-r--r-- | kernel/futex.c | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/kernel/futex.c b/kernel/futex.c index 72efa1e4359..e2b0fb9a0b3 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
@@ -59,6 +59,7 @@ | |||
59 | #include <linux/magic.h> | 59 | #include <linux/magic.h> |
60 | #include <linux/pid.h> | 60 | #include <linux/pid.h> |
61 | #include <linux/nsproxy.h> | 61 | #include <linux/nsproxy.h> |
62 | #include <linux/ptrace.h> | ||
62 | 63 | ||
63 | #include <asm/futex.h> | 64 | #include <asm/futex.h> |
64 | 65 | ||
@@ -2443,40 +2444,31 @@ SYSCALL_DEFINE3(get_robust_list, int, pid, | |||
2443 | { | 2444 | { |
2444 | struct robust_list_head __user *head; | 2445 | struct robust_list_head __user *head; |
2445 | unsigned long ret; | 2446 | unsigned long ret; |
2446 | const struct cred *cred = current_cred(), *pcred; | 2447 | struct task_struct *p; |
2447 | 2448 | ||
2448 | if (!futex_cmpxchg_enabled) | 2449 | if (!futex_cmpxchg_enabled) |
2449 | return -ENOSYS; | 2450 | return -ENOSYS; |
2450 | 2451 | ||
2452 | WARN_ONCE(1, "deprecated: get_robust_list will be deleted in 2013.\n"); | ||
2453 | |||
2454 | rcu_read_lock(); | ||
2455 | |||
2456 | ret = -ESRCH; | ||
2451 | if (!pid) | 2457 | if (!pid) |
2452 | head = current->robust_list; | 2458 | p = current; |
2453 | else { | 2459 | else { |
2454 | struct task_struct *p; | ||
2455 | |||
2456 | ret = -ESRCH; | ||
2457 | rcu_read_lock(); | ||
2458 | p = find_task_by_vpid(pid); | 2460 | p = find_task_by_vpid(pid); |
2459 | if (!p) | 2461 | if (!p) |
2460 | goto err_unlock; | 2462 | goto err_unlock; |
2461 | ret = -EPERM; | ||
2462 | pcred = __task_cred(p); | ||
2463 | /* If victim is in different user_ns, then uids are not | ||
2464 | comparable, so we must have CAP_SYS_PTRACE */ | ||
2465 | if (cred->user->user_ns != pcred->user->user_ns) { | ||
2466 | if (!ns_capable(pcred->user->user_ns, CAP_SYS_PTRACE)) | ||
2467 | goto err_unlock; | ||
2468 | goto ok; | ||
2469 | } | ||
2470 | /* If victim is in same user_ns, then uids are comparable */ | ||
2471 | if (cred->euid != pcred->euid && | ||
2472 | cred->euid != pcred->uid && | ||
2473 | !ns_capable(pcred->user->user_ns, CAP_SYS_PTRACE)) | ||
2474 | goto err_unlock; | ||
2475 | ok: | ||
2476 | head = p->robust_list; | ||
2477 | rcu_read_unlock(); | ||
2478 | } | 2463 | } |
2479 | 2464 | ||
2465 | ret = -EPERM; | ||
2466 | if (!ptrace_may_access(p, PTRACE_MODE_READ)) | ||
2467 | goto err_unlock; | ||
2468 | |||
2469 | head = p->robust_list; | ||
2470 | rcu_read_unlock(); | ||
2471 | |||
2480 | if (put_user(sizeof(*head), len_ptr)) | 2472 | if (put_user(sizeof(*head), len_ptr)) |
2481 | return -EFAULT; | 2473 | return -EFAULT; |
2482 | return put_user(head, head_ptr); | 2474 | return put_user(head, head_ptr); |