[PATCH] kprobes: fix race in aggregate kprobe registration

Ananth N Mavinakayanahalli
2005-12-06T05:15:33Z

From: Ananth N Mavinakayanahalli <ananth@in.ibm.com>

When registering multiple kprobes at the same address, we leave a small
window where the kprobe hlist will not contain a reference to the
registered kprobe, leading to potentially, a system crash if the
breakpoint is hit on another processor.

Patch below changes the order of hlist updation to make sure that there
is always a reference to the kprobe at the location.

Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Acked-by: Prasanna S Panchamukhi <prasanna@in.ibm.com>
Acked-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
---

kernel/kprobes.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6.15-rc5/kernel/kprobes.c
===================================================================
--- linux-2.6.15-rc5.orig/kernel/kprobes.c
+++ linux-2.6.15-rc5/kernel/kprobes.c
@@ -400,9 +400,9 @@ static inline void add_aggr_kprobe(struc
list_add_rcu(&p->list, &ap->list);

INIT_HLIST_NODE(&ap->hlist);
- hlist_del_rcu(&p->hlist);
hlist_add_head_rcu(&ap->hlist,
&kprobe_table[hash_ptr(ap->addr, KPROBE_HASH_BITS)]);
+ hlist_del_rcu(&p->hlist);
}

/*