Re: [PATCH] x86/stacktrace: Do not access user space memory unnecessarily

From: Steven Rostedt
Date: Tue Jul 02 2019 - 11:34:00 EST


On Tue, 2 Jul 2019 16:14:05 +0200 (CEST)
Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:

> On Tue, 2 Jul 2019, Peter Zijlstra wrote:
>
> > On Tue, Jul 02, 2019 at 02:31:51PM +0900, Eiichi Tsukata wrote:
> > > Put the boundary check before it accesses user space to prevent unnecessary
> > > access which might crash the machine.
> > >
> > > Especially, ftrace preemptirq/irq_disable event with user stack trace
> > > option can trigger SEGV in pid 1 which leads to panic.

Note, I'm only able to trigger this crash with the irq_disable event.
The irq_enable and preempt_disable/enable events work just fine. This
leads me to believe that the TRACE_IRQS_OFF macro (which uses a thunk
trampoline) may have some issues and is probably the place to look at.

-- Steve

>
> It triggers segfaults in random user processes which is bad enough.
>
> And even with that 'fix' applied I can see random segfaults just less
> frequent.
>
> > > RIP: 0033:0x55be7ad1c89f
> > > Code: Bad RIP value.
> >
> > ^^^ that's weird, no amount of unwinding should affect regs->ip.
>
>