This is the mail archive of the
systemtap@sources.redhat.com
mailing list for the systemtap project.
Re: [PATCH] Kprobes: Oops! in unregister_kprobe()
- From: Jim Keniston <jkenisto at us dot ibm dot com>
- To: prasanna at in dot ibm dot com
- Cc: SystemTAP <systemtap at sources dot redhat dot com>
- Date: 11 Apr 2005 10:42:12 -0700
- Subject: Re: [PATCH] Kprobes: Oops! in unregister_kprobe()
- Organization:
- References: <20050411145719.GA18812@in.ibm.com>
On Mon, 2005-04-11 at 07:57, Prasanna S Panchamukhi wrote:
> Hi,
>
> Please find the patch below to fix Oops! in unregister_kprobe().
> Please let me know if you any issues.
>
> Thanks
> Prasanna
>
>
> kernel oops! when unregister_kprobe() is called on a non-registered
> kprobe. This patch fixes the above problem by checking if the probe exists
> before unregistering.
>
> Signed-off-by: Prasanna S Panchamukhi <prasanna@in.ibm.com>
>
>
> ---
>
> linux-2.6.12-rc2-prasanna/kernel/kprobes.c | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletion(-)
>
> diff -puN kernel/kprobes.c~kprobes-unregister-oops-fix kernel/kprobes.c
> --- linux-2.6.12-rc2/kernel/kprobes.c~kprobes-unregister-oops-fix 2005-04-11 17:23:34.000000000 +0530
> +++ linux-2.6.12-rc2-prasanna/kernel/kprobes.c 2005-04-11 17:32:50.000000000 +0530
> @@ -110,13 +110,17 @@ rm_kprobe:
> void unregister_kprobe(struct kprobe *p)
> {
> unsigned long flags;
> - arch_remove_kprobe(p);
> spin_lock_irqsave(&kprobe_lock, flags);
> + if (!get_kprobe(p->addr)) {
> + spin_unlock_irqrestore(&kprobe_lock, flags);
> + return;
> + }
> *p->addr = p->opcode;
> hlist_del(&p->hlist);
> flush_icache_range((unsigned long) p->addr,
> (unsigned long) p->addr + sizeof(kprobe_opcode_t));
> spin_unlock_irqrestore(&kprobe_lock, flags);
> + arch_remove_kprobe(p);
> }
This bug is a byproduct of the x86_64 wart described in
http://sourceware.org/ml/systemtap/2005-q2/msg00059.html.
Jim