[PATCH 1/4] powerpc/kprobes: Disable preemption before invoking probe handler for optprobes
Naveen N. Rao
naveen.n.rao at linux.vnet.ibm.com
Fri Oct 27 22:27:18 AEDT 2017
On 2017/10/25 02:18AM, Masami Hiramatsu wrote:
> On Mon, 23 Oct 2017 22:07:38 +0530
> "Naveen N. Rao" <naveen.n.rao at linux.vnet.ibm.com> wrote:
>
> > Per Documentation/kprobes.txt, probe handlers need to be invoked with
> > preemption disabled. Update optimized_callback() to do so. Also move
> > get_kprobe_ctlblk() invocation post preemption disable, since it
> > accesses pre-cpu data.
> >
> > This was not an issue so far since optprobes wasn't selected if
> > CONFIG_PREEMPT was enabled. Commit a30b85df7d599f ("kprobes: Use
> > synchronize_rcu_tasks() for optprobe with CONFIG_PREEMPT=y") changes
> > this.
>
> Actually, if you local_irq_save(), it also disables preempt. So unless you
> enables irqs, it should be safe.
I think we still need to disable preemption explicitly (at least on
powerpc, disabling irqs doesn't increment preempt count). See commit
6baea433bc84cd ("powerpc/jprobes: Disable preemption when triggered
through ftrace") for example.
We need to ensure preempt count is properly balanced for our usage
across KPROBES_ON_FTRACE, OPTPROBES and POTS (plain old trap system ;-)
>
> Acked-by: Masami Hiramatsu <mhiramat at kernel.org>
Thanks for the review!
- Naveen
More information about the Linuxppc-dev
mailing list