diff options
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 051f090d40c1..1b2ef3c23ae4 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -647,6 +647,26 @@ struct mm_struct *get_task_mm(struct task_struct *task) | |||
647 | } | 647 | } |
648 | EXPORT_SYMBOL_GPL(get_task_mm); | 648 | EXPORT_SYMBOL_GPL(get_task_mm); |
649 | 649 | ||
650 | struct mm_struct *mm_access(struct task_struct *task, unsigned int mode) | ||
651 | { | ||
652 | struct mm_struct *mm; | ||
653 | int err; | ||
654 | |||
655 | err = mutex_lock_killable(&task->signal->cred_guard_mutex); | ||
656 | if (err) | ||
657 | return ERR_PTR(err); | ||
658 | |||
659 | mm = get_task_mm(task); | ||
660 | if (mm && mm != current->mm && | ||
661 | !ptrace_may_access(task, mode)) { | ||
662 | mmput(mm); | ||
663 | mm = ERR_PTR(-EACCES); | ||
664 | } | ||
665 | mutex_unlock(&task->signal->cred_guard_mutex); | ||
666 | |||
667 | return mm; | ||
668 | } | ||
669 | |||
650 | /* Please note the differences between mmput and mm_release. | 670 | /* Please note the differences between mmput and mm_release. |
651 | * mmput is called whenever we stop holding onto a mm_struct, | 671 | * mmput is called whenever we stop holding onto a mm_struct, |
652 | * error success whatever. | 672 | * error success whatever. |