Re: [PATCH] Don't oops when unregistering unknown kprobes
From: Frederik Deweerdt
Date: Tue Apr 26 2005 - 16:41:50 EST
Le 26/04/05 21:57 +0530, Prasanna S Panchamukhi écrivit:
> This is wrong. You should call get_kprobe() with spin_lock().
>
Right, corrected patch attached. It also sets flags to zero.
Signed-off-by: Frederik Deweerdt <frederik.deweerdt@xxxxxxxxxxx>
Regards,
Frederik
--
o----------------------------------------------o
| http://open-news.net : l'info alternative |
| Tech - Sciences - Politique - International |
o----------------------------------------------o
--- linux-2.6.12-rc3/kernel/kprobes.c 2005-04-26 16:35:22.000000000 +0200
+++ linux-2.6.12-rc3-devel/kernel/kprobes.c 2005-04-26 23:18:47.000000000 +0200
@@ -106,13 +106,22 @@ rm_kprobe:
void unregister_kprobe(struct kprobe *p)
{
- unsigned long flags;
+ unsigned long flags = 0;
+
+ spin_lock_irqsave(&kprobe_lock, flags);
+ if (!get_kprobe(p)) {
+ printk(KERN_WARNING "Warning: Attempt to unregister "
+ "unknown kprobe (addr:0x%lx)\n",
+ (unsigned long) p);
+ goto out;
+ }
arch_remove_kprobe(p);
spin_lock_irqsave(&kprobe_lock, flags);
*p->addr = p->opcode;
hlist_del(&p->hlist);
flush_icache_range((unsigned long) p->addr,
(unsigned long) p->addr + sizeof(kprobe_opcode_t));
+out:
spin_unlock_irqrestore(&kprobe_lock, flags);
}