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>
{
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--;