Skip to content

Commit

Permalink
stacktrace: Force USER_DS for stack_trace_save_user()
Browse files Browse the repository at this point in the history
When walking userspace stacks, USER_DS needs to be set, otherwise
access_ok() will not function as expected.

Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
Reported-by: Eiichi Tsukata <devel@etsukata.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Vegard Nossum <vegard.nossum@oracle.com>
Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Link: https://lkml.kernel.org/r/20190718085754.GM3402@hirez.programming.kicks-ass.net
  • Loading branch information
Peter Zijlstra authored and Thomas Gleixner committed Jul 18, 2019
1 parent 8e14479 commit cac9b9a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kernel/stacktrace.c
Expand Up @@ -226,12 +226,17 @@ unsigned int stack_trace_save_user(unsigned long *store, unsigned int size)
.store = store,
.size = size,
};
mm_segment_t fs;

/* Trace user stack if not a kernel thread */
if (current->flags & PF_KTHREAD)
return 0;

fs = get_fs();
set_fs(USER_DS);
arch_stack_walk_user(consume_entry, &c, task_pt_regs(current));
set_fs(fs);

return c.len;
}
#endif
Expand Down

0 comments on commit cac9b9a

Please sign in to comment.