Skip to contentSkip to conversation

disallow kprobes on emulate_step and branch_taken

PATCH New Gui,Jian 1 participant 1 message Nov 1, 2006 PowerPC

lore
Share & tools
lore

Gui,Jian

author
#0 lore raw

PATCH 1/1 disallow kprobes on emulate_step and branch_taken

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. And branch_taken() is called in emulate_step(). This patch can disallow kprobes on both of them.

arch/powerpc/lib/sstep.c 2006-11-01 08:50:19.000000000 -0500 renamed from arch/powerpc/lib/sstep.c 2006-11-01 08:45:06.000000000 -0500 +3 -2
diff -Nur orig/arch/powerpc/lib/sstep.c linux-2.6.18.1/arch/powerpc/lib/sstep.c
@@ -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>
@@ -25,7 +26,7 @@
 /*
  * Determine whether a conditional branch instruction would branch.
  */
-static int branch_taken(unsigned int instr, struct pt_regs *regs)
+static int __kprobes branch_taken(unsigned int instr, struct pt_regs *regs)
 {
        unsigned int bo = (instr >> 21) & 0x1f;
        unsigned int bi;
@@ -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;