diff options
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r-- | fs/proc/base.c | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index f38da6bda269..773469703c62 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -536,29 +536,15 @@ static int proc_fd_access_allowed(struct inode *inode) | |||
536 | { | 536 | { |
537 | struct task_struct *task; | 537 | struct task_struct *task; |
538 | int allowed = 0; | 538 | int allowed = 0; |
539 | /* Allow access to a task's file descriptors if either we may | 539 | /* Allow access to a task's file descriptors if it is us or we |
540 | * use ptrace attach to the process and find out that | 540 | * may use ptrace attach to the process and find out that |
541 | * information, or if the task cannot possibly be ptraced | 541 | * information. |
542 | * allow access if we have the proper capability. | ||
543 | */ | 542 | */ |
544 | task = get_proc_task(inode); | 543 | task = get_proc_task(inode); |
545 | if (task == current) | 544 | if (task) { |
546 | allowed = 1; | 545 | allowed = ptrace_may_attach(task); |
547 | if (task && !allowed) { | ||
548 | int alive; | ||
549 | |||
550 | task_lock(task); | ||
551 | alive = !!task->mm; | ||
552 | task_unlock(task); | ||
553 | if (alive) | ||
554 | /* For a living task obey ptrace_may_attach */ | ||
555 | allowed = ptrace_may_attach(task); | ||
556 | else | ||
557 | /* For a special task simply check the capability */ | ||
558 | allowed = capable(CAP_SYS_PTRACE); | ||
559 | } | ||
560 | if (task) | ||
561 | put_task_struct(task); | 546 | put_task_struct(task); |
547 | } | ||
562 | return allowed; | 548 | return allowed; |
563 | } | 549 | } |
564 | 550 | ||