mm: Change vm_is_stack_for_task() to vm_is_stack_for_current()
Asking for a non-current task's stack can't be done without races unless the task is frozen in kernel mode. As far as I know, vm_is_stack_for_task() never had a safe non-current use case. The __unused annotation is because some KSTK_ESP implementations ignore their parameter, which IMO is further justification for this patch. Signed-off-by: Andy Lutomirski <luto@kernel.org> Acked-by: Thomas Gleixner <tglx@linutronix.de> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Jann Horn <jann@thejh.net> Cc: Kees Cook <keescook@chromium.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Linux API <linux-api@vger.kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Tycho Andersen <tycho.andersen@canonical.com> Link: http://lkml.kernel.org/r/4c3f68f426e6c061ca98b4fc7ef85ffbb0a25b0c.1475257877.git.luto@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Родитель
b18cb64ead
Коммит
d17af5056c
|
@ -1391,7 +1391,7 @@ static inline int stack_guard_page_end(struct vm_area_struct *vma,
|
||||||
!vma_growsup(vma->vm_next, addr);
|
!vma_growsup(vma->vm_next, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int vma_is_stack_for_task(struct vm_area_struct *vma, struct task_struct *t);
|
int vma_is_stack_for_current(struct vm_area_struct *vma);
|
||||||
|
|
||||||
extern unsigned long move_page_tables(struct vm_area_struct *vma,
|
extern unsigned long move_page_tables(struct vm_area_struct *vma,
|
||||||
unsigned long old_addr, struct vm_area_struct *new_vma,
|
unsigned long old_addr, struct vm_area_struct *new_vma,
|
||||||
|
|
|
@ -230,8 +230,10 @@ void __vma_link_list(struct mm_struct *mm, struct vm_area_struct *vma,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the vma is being used as a stack by this task */
|
/* Check if the vma is being used as a stack by this task */
|
||||||
int vma_is_stack_for_task(struct vm_area_struct *vma, struct task_struct *t)
|
int vma_is_stack_for_current(struct vm_area_struct *vma)
|
||||||
{
|
{
|
||||||
|
struct task_struct * __maybe_unused t = current;
|
||||||
|
|
||||||
return (vma->vm_start <= KSTK_ESP(t) && vma->vm_end >= KSTK_ESP(t));
|
return (vma->vm_start <= KSTK_ESP(t) && vma->vm_end >= KSTK_ESP(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3557,7 +3557,7 @@ static int selinux_file_mprotect(struct vm_area_struct *vma,
|
||||||
} else if (!vma->vm_file &&
|
} else if (!vma->vm_file &&
|
||||||
((vma->vm_start <= vma->vm_mm->start_stack &&
|
((vma->vm_start <= vma->vm_mm->start_stack &&
|
||||||
vma->vm_end >= vma->vm_mm->start_stack) ||
|
vma->vm_end >= vma->vm_mm->start_stack) ||
|
||||||
vma_is_stack_for_task(vma, current))) {
|
vma_is_stack_for_current(vma))) {
|
||||||
rc = current_has_perm(current, PROCESS__EXECSTACK);
|
rc = current_has_perm(current, PROCESS__EXECSTACK);
|
||||||
} else if (vma->vm_file && vma->anon_vma) {
|
} else if (vma->vm_file && vma->anon_vma) {
|
||||||
/*
|
/*
|
||||||
|
|
Загрузка…
Ссылка в новой задаче