Re: [PATCH -tip V2] [BUGFIX] kprobes/x86: Do not jump-optimize kprobes on irq entry code
From: Masami Hiramatsu
Date: Tue Jul 25 2017 - 09:46:03 EST
On Tue, 25 Jul 2017 12:40:05 +0200
Ingo Molnar <mingo@xxxxxxxxxx> wrote:
>
> * Masami Hiramatsu <mhiramat@xxxxxxxxxx> wrote:
>
> > Since the kernel segment registers are not prepared at the
> > entry of irq-entry code, if a kprobe on such code is
> > jump-optimized, accessing per-cpu variables may cause
> > kernel panic.
> > However, if the kprobe is not optimized, it kicks int3
> > exception and set segment registers correctly.
> >
> > This checks probe-address and if it is in irq-entry code,
> > it prohibits optimizing such kprobes. This means we can
> > continuously probing such interrupt handlers by kprobes
> > but it is not optimized anymore.
> >
> > Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
> > Reported-by: Francis Deslauriers <francis.deslauriers@xxxxxxxxxxxx>
> > Tested-by: Francis Deslauriers <francis.deslauriers@xxxxxxxxxxxx>
> > ---
> > Changes in V2:
> > - Make changes in kprobe/opt.c local, not involving unwind,
> > since it requires CONFIG_FRAME_POINTER=y (Thanks Mathieu!)
>
> This patch doesn't even build on x86-64 defconfig ...
>
> arch/x86/kernel/kprobes/opt.c: In function ‘can_optimize’:
> arch/x86/kernel/kprobes/opt.c:259:32: error: ‘__irqentry_text_start’ undeclared
> (first use in this function)
> ((paddr >= (unsigned long)__irqentry_text_start) &&
> ^~~~~~~~~~~~~~~~~~~~~
Oops, yes, hmm, I missed below ifdef...
#if defined(CONFIG_FUNCTION_GRAPH_TRACER) || defined(CONFIG_KASAN)
Or, I think we can define those as NULL in interrupt.h.
Thanks,
>
> Thanks,
>
> Ingo
--
Masami Hiramatsu <mhiramat@xxxxxxxxxx>