This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: [PATCH][kprobe]disallow kprobes on emulate_step function
- From: Ananth N Mavinakayanahalli <ananth at in dot ibm dot com>
- To: "Gui,Jian" <guij at cn dot ibm dot com>
- Cc: prasanna at in dot ibm dot com, systemtap at sources dot redhat dot com
- Date: Tue, 31 Oct 2006 15:21:18 +0530
- Subject: Re: [PATCH][kprobe]disallow kprobes on emulate_step function
- References: <454713AF.9030307@cn.ltcfwd.linux.ibm.com>
- Reply-to: ananth at in dot ibm dot com
On Tue, Oct 31, 2006 at 05:13:19PM +0800, Gui,Jian wrote:
> Probing on emulate_step function will crash 2.6.18.1 when it is
> triggered. This problem is powerpc dependent.
>
> When kprobe is triggered, emulate_step is on its kernel path and
> will cause recursive kprobe fault. This patch can disallow
> kprobes on emulate_step function.
Looks good, but not complete :-) Even branch_taken() needs to be
__kprobes as emulate_step() calls it.
Please add that and feel free to post the patch to linuxppc-dev
for upstream inclusion.
Ananth
>
>
> diff -Nur linux-2.6.18.1/arch/powerpc/lib/sstep.c
> new/arch/powerpc/lib/sstep.c
> --- linux-2.6.18.1/arch/powerpc/lib/sstep.c 2006-10-13
> 23:34:03.000000000 -0400
> +++ new/arch/powerpc/lib/sstep.c 2006-10-31 06:14:44.000000000
> -0500
> @@ -9,6 +9,7 @@
> * 2 of the License, or (at your option) any later version.
> */
> #include <linux/kernel.h>
> +#include <linux/kprobes.h>
> #include <linux/ptrace.h>
> #include <asm/sstep.h>
> #include <asm/processor.h>
> @@ -51,7 +52,7 @@
> * or -1 if the instruction is one that should not be stepped,
> * such as an rfid, or a mtmsrd that would clear MSR_RI.
> */
> -int emulate_step(struct pt_regs *regs, unsigned int instr)
> +int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr)
> {
> unsigned int opcode, rd;
> unsigned long int imm;