[PATCH 1/2] ppc64 kprobes: correct kprobe registration return values

From: Paul Mackerras
Date: Tue Jun 07 2005 - 06:10:36 EST


From: Ananth N Mavinakayanahalli <ananth@xxxxxxxxxx>

Add stricter checks during kprobe registration. Return correct error value
so insmod doesn't succeed. Also printk reason for registration failure.

Signed-off-by: Ananth N Mavinakayanahalli <ananth@xxxxxxxxxx>
Signed-off-by: Paul Mackerras <paulus@xxxxxxxxx>
---

Index: linux-2.6.12-rc5/arch/ppc64/kernel/kprobes.c
===================================================================
--- linux-2.6.12-rc5.orig/arch/ppc64/kernel/kprobes.c 2005-05-27 14:35:12.000000000 -0400
+++ linux-2.6.12-rc5/arch/ppc64/kernel/kprobes.c 2005-05-27 14:40:42.000000000 -0400
@@ -45,12 +45,17 @@ static kprobe_opcode_t stepped_insn;

int arch_prepare_kprobe(struct kprobe *p)
{
+ int ret = 0;
kprobe_opcode_t insn = *p->addr;

- if (IS_MTMSRD(insn) || IS_RFID(insn))
- /* cannot put bp on RFID/MTMSRD */
- return 1;
- return 0;
+ if ((unsigned long)p->addr & 0x03) {
+ printk("Attempt to register kprobe at an unaligned address\n");
+ ret = -EINVAL;
+ } else if (IS_MTMSRD(insn) || IS_RFID(insn)) {
+ printk("Cannot register a kprobe on rfid or mtmsrd\n");
+ ret = -EINVAL;
+ }
+ return ret;
}

void arch_copy_kprobe(struct kprobe *p)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/