Re: [PATCH 0/2] kprobes: Fix kretprobe incorrect stacking order problem

From: Andrea Righi
Date: Mon Jan 07 2019 - 14:52:15 EST


On Mon, Jan 07, 2019 at 02:27:49PM -0500, Steven Rostedt wrote:
> On Mon, 7 Jan 2019 19:34:44 +0100
> Andrea Righi <righi.andrea@xxxxxxxxx> wrote:
>
> > On Mon, Jan 07, 2019 at 10:31:34PM +0900, Masami Hiramatsu wrote:
> > ...
> > > BTW, this is not all of issues. To remove CONFIG_KPROBE_EVENTS_ON_NOTRACE
> > > I'm trying to find out other notrace functions which can cause
> > > kernel crash by probing. Mostly done on x86, so I'll post it
> > > after this series.
> >
> > Not sure if you found it already, but it looks like some of the
> > _raw_spin_lock/unlock* functions (when they're not inlined) are causing
> > the same problem (or something similar), I can deadlock the system by
> > doing this for example:
> >
> > echo "r:event_1 __fdget" >> kprobe_events
> > echo "r:event_2 _raw_spin_lock_irqsave" >> kprobe_events
> > echo 1 > events/kprobes/enable
> > [DEADLOCK]
> >
> > Sending the following just in case...
> >
>
> Ug, kretprobe calls spinlocks in the callback? I wonder if we can
> remove them.
>
> I'm guessing this is a different issue than the one that this patch
> fixes. This sounds like we are calling kretprobe from kretprobe?
>
> -- Steve

kretprobe_trampoline()
-> trampoline_handler()
-> kretprobe_hash_lock()
-> raw_spin_lock_irqsave()

If we put a kretprobe to raw_spin_lock_irqsave() it looks like
kretprobe is going to call kretprobe...

-Andrea