]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/kprobes: Skip livepatch_handler() for jprobes
authorNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Thu, 1 Jun 2017 10:48:17 +0000 (16:18 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 16 Jun 2017 09:49:43 +0000 (19:49 +1000)
commit32f73e5bf9ce8e313edafeb9afc4c876f71cc301
tree0dec69ce1815755aec7d8cd7f4c1cdd33226b37f
parent5ba15a065d5588673821b5b37f38d5ee377db3e0
powerpc/kprobes: Skip livepatch_handler() for jprobes

ftrace_caller() depends on a modified regs->nip to detect if a certain
function has been livepatched. However, with KPROBES_ON_FTRACE, it is
possible for regs->nip to have been modified by the kprobes pre_handler
(jprobes, for instance). In this case, we do not want to invoke the
livepatch_handler so as not to consume the livepatch stack.

To distinguish between the two (kprobes and livepatch), we check if
there is an active kprobe on the current function. If there is, then we
know for sure that it must have modified the NIP as we don't support
livepatching a kprobe'd function. In this case, we simply skip the
livepatch_handler and branch to the new NIP. Otherwise, the
livepatch_handler is invoked.

Fixes: 21c3eaecc12d ("powerpc/kprobes: Add support for KPROBES_ON_FTRACE")
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/kprobes.h
arch/powerpc/kernel/kprobes.c
arch/powerpc/kernel/trace/ftrace_64_mprofile.S