public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kprobes: fix race in aggregate kprobe registration
@ 2005-12-06  5:17 Ananth N Mavinakayanahalli
  2005-12-06 21:18 ` Keshavamurthy Anil S
  2005-12-07 17:25 ` Keshavamurthy Anil S
  0 siblings, 2 replies; 5+ messages in thread
From: Ananth N Mavinakayanahalli @ 2005-12-06  5:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, prasanna, anil.s.keshavamurthy

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);
 }
 
 /*

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kprobes: fix race in aggregate kprobe registration
  2005-12-06  5:17 [PATCH] kprobes: fix race in aggregate kprobe registration Ananth N Mavinakayanahalli
@ 2005-12-06 21:18 ` Keshavamurthy Anil S
  2005-12-07  3:30   ` Ananth N Mavinakayanahalli
  2005-12-07 17:25 ` Keshavamurthy Anil S
  1 sibling, 1 reply; 5+ messages in thread
From: Keshavamurthy Anil S @ 2005-12-06 21:18 UTC (permalink / raw)
  To: Ananth N Mavinakayanahalli
  Cc: linux-kernel, akpm, prasanna, anil.s.keshavamurthy

On Tue, Dec 06, 2005 at 10:47:11AM +0530, Ananth N Mavinakayanahalli wrote:
> 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.

Hi Ananth,
	How do you like this patch? Here the old entry
will be replace with the new entry automically. 

Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>

 kernel/kprobes.c |    5 +----
 1 files changed, 1 insertion(+), 4 deletions(-)

Index: linux-2.6.15-rc5-mm1/kernel/kprobes.c
===================================================================
--- linux-2.6.15-rc5-mm1.orig/kernel/kprobes.c
+++ linux-2.6.15-rc5-mm1/kernel/kprobes.c
@@ -399,10 +399,7 @@ static inline void add_aggr_kprobe(struc
 	INIT_LIST_HEAD(&ap->list);
 	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_replace_rcu(&p->hlist, &ap->hlist);
 }
 
 /*

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kprobes: fix race in aggregate kprobe registration
  2005-12-06 21:18 ` Keshavamurthy Anil S
@ 2005-12-07  3:30   ` Ananth N Mavinakayanahalli
  2005-12-07  9:54     ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Ananth N Mavinakayanahalli @ 2005-12-07  3:30 UTC (permalink / raw)
  To: Keshavamurthy Anil S; +Cc: linux-kernel, akpm, prasanna

On Tue, Dec 06, 2005 at 01:18:24PM -0800, Keshavamurthy Anil S wrote:
> On Tue, Dec 06, 2005 at 10:47:11AM +0530, Ananth N Mavinakayanahalli wrote:
> > 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.
> 
> Hi Ananth,
> 	How do you like this patch? Here the old entry
> will be replace with the new entry automically. 

Your patch looks better.

Andrew,
Anil's patch depends on the list.h updates currently in -mm

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

> 
>  kernel/kprobes.c |    5 +----
>  1 files changed, 1 insertion(+), 4 deletions(-)
> 
> Index: linux-2.6.15-rc5-mm1/kernel/kprobes.c
> ===================================================================
> --- linux-2.6.15-rc5-mm1.orig/kernel/kprobes.c
> +++ linux-2.6.15-rc5-mm1/kernel/kprobes.c
> @@ -399,10 +399,7 @@ static inline void add_aggr_kprobe(struc
>  	INIT_LIST_HEAD(&ap->list);
>  	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_replace_rcu(&p->hlist, &ap->hlist);
>  }
>  
>  /*

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kprobes: fix race in aggregate kprobe registration
  2005-12-07  3:30   ` Ananth N Mavinakayanahalli
@ 2005-12-07  9:54     ` Andrew Morton
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2005-12-07  9:54 UTC (permalink / raw)
  To: ananth; +Cc: anil.s.keshavamurthy, linux-kernel, prasanna

Ananth N Mavinakayanahalli <ananth@in.ibm.com> wrote:
>
> > Hi Ananth,
>  > 	How do you like this patch? Here the old entry
>  > will be replace with the new entry automically. 
> 
>  Your patch looks better.
> 
>  Andrew,
>  Anil's patch depends on the list.h updates currently in -mm
> 
>  > Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
>  Acked-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>

Am feeling particularly uncreative.  Please resend with a changelog.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] kprobes: fix race in aggregate kprobe registration
  2005-12-06  5:17 [PATCH] kprobes: fix race in aggregate kprobe registration Ananth N Mavinakayanahalli
  2005-12-06 21:18 ` Keshavamurthy Anil S
@ 2005-12-07 17:25 ` Keshavamurthy Anil S
  1 sibling, 0 replies; 5+ messages in thread
From: Keshavamurthy Anil S @ 2005-12-07 17:25 UTC (permalink / raw)
  To: Ananth N Mavinakayanahalli, akpm
  Cc: linux-kernel, akpm, prasanna, anil.s.keshavamurthy

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 now automically relpace the old kprobe with the new
kprobe from the hash list.

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

 kernel/kprobes.c |    5 +----
 1 files changed, 1 insertion(+), 4 deletions(-)

Index: linux-2.6.15-rc5-mm1/kernel/kprobes.c
===================================================================
--- linux-2.6.15-rc5-mm1.orig/kernel/kprobes.c
+++ linux-2.6.15-rc5-mm1/kernel/kprobes.c
@@ -399,10 +399,7 @@ static inline void add_aggr_kprobe(struc
 	INIT_LIST_HEAD(&ap->list);
 	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_replace_rcu(&p->hlist, &ap->hlist);
 }
 
 /*

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-12-07 17:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-06  5:17 [PATCH] kprobes: fix race in aggregate kprobe registration Ananth N Mavinakayanahalli
2005-12-06 21:18 ` Keshavamurthy Anil S
2005-12-07  3:30   ` Ananth N Mavinakayanahalli
2005-12-07  9:54     ` Andrew Morton
2005-12-07 17:25 ` Keshavamurthy Anil S

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox