On Thu, Jul 18, 2019 at 10:57:54AM +0200, Peter Zijlstra wrote: > On Wed, Jul 17, 2019 at 10:09:45AM +0200, Vegard Nossum wrote: > > On 7/17/19 10:07 AM, Peter Zijlstra wrote: > > > > Does something like the below help? > > > Yes. > > Thanks! > > --- > Subject: stacktrace: Force USER_DS for stack_trace_save_user() > From: Peter Zijlstra <pet...@infradead.org> > Date: Thu Jul 18 10:47:47 CEST 2019 > > When walking userspace stacks, we should set USER_DS, otherwise > access_ok() will not function as expected. > > Reported-by: Vegard Nossum <vegard.nos...@oracle.com> > Tested-by: Vegard Nossum <vegard.nos...@oracle.com> > Reported-by: Eiichi Tsukata <de...@etsukata.com> > Signed-off-by: Peter Zijlstra (Intel) <pet...@infradead.org>
Reviewed-by: Joel Fernandes (Google) <j...@joelfernandes.org> thanks, - Joel > --- > --- a/kernel/stacktrace.c > +++ b/kernel/stacktrace.c > @@ -226,12 +226,17 @@ unsigned int stack_trace_save_user(unsig > .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