This is the mail archive of the
systemtap@sources.redhat.com
mailing list for the systemtap project.
[PATCH 1/2] kprobes: return correct error value on kprobe registration failure
- From: Ananth N Mavinakayanahalli <ananth at in dot ibm dot com>
- To: linuxppc64-dev at ozlabs dot org
- Cc: anton at samba dot org, paulus at samba dot org, systemtap at sources dot redhat dot com
- Date: Fri, 27 May 2005 11:37:44 -0400
- Subject: [PATCH 1/2] kprobes: return correct error value on kprobe registration failure
- Reply-to: ananth at in dot ibm dot com
Hi,
This patch adds stricter checks during kprobe registration. We weren't
returning a correct value on a registration request at an invalid
address.
Please apply.
Regards,
Ananth
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@in.ibm.com>
arch/ppc64/kernel/kprobes.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
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)