diff options
| author | Andy Lutomirski <luto@kernel.org> | 2016-09-30 13:58:58 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2016-10-20 03:21:41 -0400 |
| commit | d17af5056cf9e9fc05e68832f7c15687fcc12281 (patch) | |
| tree | 5849ec3001300e88b215f9d4e47e6b2b18e335fa | |
| parent | b18cb64ead400c01bf1580eeba330ace51f8087d (diff) | |
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>
| -rw-r--r-- | include/linux/mm.h | 2 | ||||
| -rw-r--r-- | mm/util.c | 4 | ||||
| -rw-r--r-- | security/selinux/hooks.c | 2 |
3 files changed, 5 insertions, 3 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index e9caec6a51e9..a658a5167bce 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
| @@ -1391,7 +1391,7 @@ static inline int stack_guard_page_end(struct vm_area_struct *vma, | |||
| 1391 | !vma_growsup(vma->vm_next, addr); | 1391 | !vma_growsup(vma->vm_next, addr); |
| 1392 | } | 1392 | } |
| 1393 | 1393 | ||
| 1394 | int vma_is_stack_for_task(struct vm_area_struct *vma, struct task_struct *t); | 1394 | int vma_is_stack_for_current(struct vm_area_struct *vma); |
| 1395 | 1395 | ||
| 1396 | extern unsigned long move_page_tables(struct vm_area_struct *vma, | 1396 | extern unsigned long move_page_tables(struct vm_area_struct *vma, |
| 1397 | unsigned long old_addr, struct vm_area_struct *new_vma, | 1397 | 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, | |||
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | /* Check if the vma is being used as a stack by this task */ | 232 | /* Check if the vma is being used as a stack by this task */ |
| 233 | int vma_is_stack_for_task(struct vm_area_struct *vma, struct task_struct *t) | 233 | int vma_is_stack_for_current(struct vm_area_struct *vma) |
| 234 | { | 234 | { |
| 235 | struct task_struct * __maybe_unused t = current; | ||
| 236 | |||
| 235 | return (vma->vm_start <= KSTK_ESP(t) && vma->vm_end >= KSTK_ESP(t)); | 237 | return (vma->vm_start <= KSTK_ESP(t) && vma->vm_end >= KSTK_ESP(t)); |
| 236 | } | 238 | } |
| 237 | 239 | ||
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 085057936287..09fd6108e421 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
| @@ -3557,7 +3557,7 @@ static int selinux_file_mprotect(struct vm_area_struct *vma, | |||
| 3557 | } else if (!vma->vm_file && | 3557 | } else if (!vma->vm_file && |
| 3558 | ((vma->vm_start <= vma->vm_mm->start_stack && | 3558 | ((vma->vm_start <= vma->vm_mm->start_stack && |
| 3559 | vma->vm_end >= vma->vm_mm->start_stack) || | 3559 | vma->vm_end >= vma->vm_mm->start_stack) || |
| 3560 | vma_is_stack_for_task(vma, current))) { | 3560 | vma_is_stack_for_current(vma))) { |
| 3561 | rc = current_has_perm(current, PROCESS__EXECSTACK); | 3561 | rc = current_has_perm(current, PROCESS__EXECSTACK); |
| 3562 | } else if (vma->vm_file && vma->anon_vma) { | 3562 | } else if (vma->vm_file && vma->anon_vma) { |
| 3563 | /* | 3563 | /* |
