]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dtrace: armour ustack() against kernel threads, !task->mm, and corrupt usersp.
authorNick Alcock <nick.alcock@oracle.com>
Thu, 10 Oct 2013 23:32:25 +0000 (00:32 +0100)
committerKris Van Hees <kris.van.hees@oracle.com>
Thu, 10 Oct 2013 20:33:19 +0000 (16:33 -0400)
Kernel threads have no userspace stack, by definition: we should not assume they
do.  Further, tasks with no mm (whether because they are kernel threads or for
any other reason) should not be ustack()ed, nor tasks in which find_vma() cannot
find the vma corresponding to the usersp.  (Possible causes for this might be a
task which just smashed its own userspace sp or a task which is in the middle of
exiting or exec()ing.)

Orabug: 17591351

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
dtrace/dtrace_isa.c

index 189d170581697adb3c57336b2e6d1e3bf21f7c3e..732d652e8539e282d1175aa9920e8668e03a81ab 100644 (file)
@@ -284,8 +284,17 @@ void dtrace_getufpstack(uint64_t *pcstack, uint64_t *fpstack,
 {
        struct task_struct      *p = current;
        unsigned long           *sp = (unsigned long *)this_cpu_read(old_rsp);
-       unsigned long           *bos = (unsigned long *)p->mm->start_stack;
-       struct vm_area_struct   *stack_vma = find_vma(p->mm, p->thread.usersp);
+       unsigned long           *bos;
+       struct vm_area_struct   *stack_vma;
+
+       if ((p->mm == NULL) || (p->flags & PF_KTHREAD))
+           return;
+
+       bos = (unsigned long *)p->mm->start_stack;
+       stack_vma = find_vma(p->mm, p->thread.usersp);
+
+       if (stack_vma == NULL)
+           return;
 
        *pcstack++ = (uint64_t)p->pid;
        pcstack_limit--;