linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bugfix] unregister_trace_probe needs to be called under mutex
@ 2010-06-30  8:45 Srikar Dronamraju
  2010-06-30  9:44 ` Peter Zijlstra
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Srikar Dronamraju @ 2010-06-30  8:45 UTC (permalink / raw)
  To: Ingo Molnar, Masami Hiramatsu; +Cc: Linus Torvalds, Srikar Dronamraju, LKML

Comment in unregister_trace_probe() says probe_lock will be held
when it gets called. However there is a case where it might called
without the probe_lock being held. Also since we are traversing the
probe_list and deleting an element from the probe_list, probe_lock
should be held.

This was first pointed in uprobes traceevent review by Frederic
Weisbecker here.  (http://lkml.org/lkml/2010/5/12/106)

This patch is needed for both 2.6.35-rc3 and 2.6.35-rc3-tip

Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
---

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 4f11a56..67670cd 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -269,14 +269,17 @@ static int create_trace_probe(int argc, char **argv)
 			pr_info("Delete command needs an event name.\n");
 			return -EINVAL;
 		}
+		mutex_lock(&probe_lock);
 		tp = find_probe_event(event, group);
 		if (!tp) {
+			mutex_unlock(&probe_lock);
 			pr_info("Event %s/%s doesn't exist.\n", group, event);
 			return -ENOENT;
 		}
 		/* delete an event */
 		unregister_trace_probe(tp);
 		free_trace_probe(tp);
+		mutex_unlock(&probe_lock);
 		return 0;
 	}
 

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

* Re: [Bugfix] unregister_trace_probe needs to be called under mutex
  2010-06-30  8:45 [Bugfix] unregister_trace_probe needs to be called under mutex Srikar Dronamraju
@ 2010-06-30  9:44 ` Peter Zijlstra
  2010-06-30 10:49   ` Srikar Dronamraju
  2010-06-30 16:00   ` Steven Rostedt
  2010-07-01  1:09 ` Masami Hiramatsu
  2010-08-05  8:01 ` [tip:perf/core] tracing/kprobes: " tip-bot for Srikar Dronamraju
  2 siblings, 2 replies; 7+ messages in thread
From: Peter Zijlstra @ 2010-06-30  9:44 UTC (permalink / raw)
  To: Srikar Dronamraju
  Cc: Ingo Molnar, Masami Hiramatsu, Linus Torvalds, LKML, Steven Rostedt

On Wed, 2010-06-30 at 14:15 +0530, Srikar Dronamraju wrote:
> Comment in unregister_trace_probe() says probe_lock will be held
> when it gets called. However there is a case where it might called
> without the probe_lock being held. Also since we are traversing the
> probe_list and deleting an element from the probe_list, probe_lock
> should be held.
> 
> This was first pointed in uprobes traceevent review by Frederic
> Weisbecker here.  (http://lkml.org/lkml/2010/5/12/106)
> 
> This patch is needed for both 2.6.35-rc3 and 2.6.35-rc3-tip
> 
> Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> ---
> 
> diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> index 4f11a56..67670cd 100644
> --- a/kernel/trace/trace_kprobe.c
> +++ b/kernel/trace/trace_kprobe.c
> @@ -269,14 +269,17 @@ static int create_trace_probe(int argc, char **argv)
>  			pr_info("Delete command needs an event name.\n");
>  			return -EINVAL;
>  		}
> +		mutex_lock(&probe_lock);
>  		tp = find_probe_event(event, group);
>  		if (!tp) {
> +			mutex_unlock(&probe_lock);
>  			pr_info("Event %s/%s doesn't exist.\n", group, event);
>  			return -ENOENT;
>  		}
>  		/* delete an event */
>  		unregister_trace_probe(tp);
>  		free_trace_probe(tp);
> +		mutex_unlock(&probe_lock);
>  		return 0;
>  	}

Shouldn't all that go through steven's ->reg() interface?

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

* Re: [Bugfix] unregister_trace_probe needs to be called under mutex
  2010-06-30  9:44 ` Peter Zijlstra
@ 2010-06-30 10:49   ` Srikar Dronamraju
  2010-06-30 16:00   ` Steven Rostedt
  1 sibling, 0 replies; 7+ messages in thread
From: Srikar Dronamraju @ 2010-06-30 10:49 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Ingo Molnar, Masami Hiramatsu, Linus Torvalds, LKML, Steven Rostedt

> > diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> > index 4f11a56..67670cd 100644
> > --- a/kernel/trace/trace_kprobe.c
> > +++ b/kernel/trace/trace_kprobe.c
> > @@ -269,14 +269,17 @@ static int create_trace_probe(int argc, char **argv)
> >  			pr_info("Delete command needs an event name.\n");
> >  			return -EINVAL;
> >  		}
> > +		mutex_lock(&probe_lock);
> >  		tp = find_probe_event(event, group);
> >  		if (!tp) {
> > +			mutex_unlock(&probe_lock);
> >  			pr_info("Event %s/%s doesn't exist.\n", group, event);
> >  			return -ENOENT;
> >  		}
> >  		/* delete an event */
> >  		unregister_trace_probe(tp);
> >  		free_trace_probe(tp);
> > +		mutex_unlock(&probe_lock);
> >  		return 0;
> >  	}
> 
> Shouldn't all that go through steven's ->reg() interface?

Currently the ->reg() interface does a enable/disable of the
probe_events. Infact the reg callback gets set in
register_trace_probe() function which inturn gets called from the
create_trace_probe().

Do we have plans to move probe_events creation to ->reg()
interface?

--
Regards
Srikar


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

* Re: [Bugfix] unregister_trace_probe needs to be called under mutex
  2010-06-30  9:44 ` Peter Zijlstra
  2010-06-30 10:49   ` Srikar Dronamraju
@ 2010-06-30 16:00   ` Steven Rostedt
  1 sibling, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2010-06-30 16:00 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Srikar Dronamraju, Ingo Molnar, Masami Hiramatsu, Linus Torvalds, LKML

On Wed, 2010-06-30 at 11:44 +0200, Peter Zijlstra wrote:
> On Wed, 2010-06-30 at 14:15 +0530, Srikar Dronamraju wrote:
> > Comment in unregister_trace_probe() says probe_lock will be held
> > when it gets called. However there is a case where it might called
> > without the probe_lock being held. Also since we are traversing the
> > probe_list and deleting an element from the probe_list, probe_lock
> > should be held.
> > 
> > This was first pointed in uprobes traceevent review by Frederic
> > Weisbecker here.  (http://lkml.org/lkml/2010/5/12/106)
> > 
> > This patch is needed for both 2.6.35-rc3 and 2.6.35-rc3-tip

Acked-by: Steven Rostedt <rostedt@goodmis.org>

> > 
> > Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> > ---
> > 
> > diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> > index 4f11a56..67670cd 100644
> > --- a/kernel/trace/trace_kprobe.c
> > +++ b/kernel/trace/trace_kprobe.c
> > @@ -269,14 +269,17 @@ static int create_trace_probe(int argc, char **argv)
> >  			pr_info("Delete command needs an event name.\n");
> >  			return -EINVAL;
> >  		}
> > +		mutex_lock(&probe_lock);
> >  		tp = find_probe_event(event, group);
> >  		if (!tp) {
> > +			mutex_unlock(&probe_lock);
> >  			pr_info("Event %s/%s doesn't exist.\n", group, event);
> >  			return -ENOENT;
> >  		}
> >  		/* delete an event */
> >  		unregister_trace_probe(tp);
> >  		free_trace_probe(tp);
> > +		mutex_unlock(&probe_lock);
> >  		return 0;
> >  	}
> 
> Shouldn't all that go through steven's ->reg() interface?

Nah, this is specific to the kprobe code. Has really nothing to do with
the ->reg() interface.

-- Steve



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

* Re: [Bugfix] unregister_trace_probe needs to be called under mutex
  2010-06-30  8:45 [Bugfix] unregister_trace_probe needs to be called under mutex Srikar Dronamraju
  2010-06-30  9:44 ` Peter Zijlstra
@ 2010-07-01  1:09 ` Masami Hiramatsu
  2010-07-06  5:08   ` Srikar Dronamraju
  2010-08-05  8:01 ` [tip:perf/core] tracing/kprobes: " tip-bot for Srikar Dronamraju
  2 siblings, 1 reply; 7+ messages in thread
From: Masami Hiramatsu @ 2010-07-01  1:09 UTC (permalink / raw)
  To: Srikar Dronamraju; +Cc: Ingo Molnar, Linus Torvalds, LKML

Srikar Dronamraju wrote:
> Comment in unregister_trace_probe() says probe_lock will be held
> when it gets called. However there is a case where it might called
> without the probe_lock being held. Also since we are traversing the
> probe_list and deleting an element from the probe_list, probe_lock
> should be held.
> 
> This was first pointed in uprobes traceevent review by Frederic
> Weisbecker here.  (http://lkml.org/lkml/2010/5/12/106)
> 
> This patch is needed for both 2.6.35-rc3 and 2.6.35-rc3-tip
> 
> Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>

Ah, right! That's definately needed.

Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

Thank you!


> ---
> 
> diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> index 4f11a56..67670cd 100644
> --- a/kernel/trace/trace_kprobe.c
> +++ b/kernel/trace/trace_kprobe.c
> @@ -269,14 +269,17 @@ static int create_trace_probe(int argc, char **argv)
>  			pr_info("Delete command needs an event name.\n");
>  			return -EINVAL;
>  		}
> +		mutex_lock(&probe_lock);
>  		tp = find_probe_event(event, group);
>  		if (!tp) {
> +			mutex_unlock(&probe_lock);
>  			pr_info("Event %s/%s doesn't exist.\n", group, event);
>  			return -ENOENT;
>  		}
>  		/* delete an event */
>  		unregister_trace_probe(tp);
>  		free_trace_probe(tp);
> +		mutex_unlock(&probe_lock);
>  		return 0;
>  	}
>  


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

* Re: [Bugfix] unregister_trace_probe needs to be called under mutex
  2010-07-01  1:09 ` Masami Hiramatsu
@ 2010-07-06  5:08   ` Srikar Dronamraju
  0 siblings, 0 replies; 7+ messages in thread
From: Srikar Dronamraju @ 2010-07-06  5:08 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Linus Torvalds, LKML, Peter Zijlstra, Steven Rostedt, Masami Hiramatsu

Ingo, 

Any particular reason to not pick this patch?

Steven Rostedt and Masami Hiramatsu agree that this patch needs to be
pushed in.

--
Thanks and Regards
Srikar

> Srikar Dronamraju wrote:
> > Comment in unregister_trace_probe() says probe_lock will be held
> > when it gets called. However there is a case where it might called
> > without the probe_lock being held. Also since we are traversing the
> > probe_list and deleting an element from the probe_list, probe_lock
> > should be held.
> > 
> > This was first pointed in uprobes traceevent review by Frederic
> > Weisbecker here.  (http://lkml.org/lkml/2010/5/12/106)
> > 
> > This patch is needed for both 2.6.35-rc3 and 2.6.35-rc3-tip
> > 
> > Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> 
> Ah, right! That's definately needed.
> 
> Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> 
> Thank you!
> 
> 
> > ---
> > 
> > diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> > index 4f11a56..67670cd 100644
> > --- a/kernel/trace/trace_kprobe.c
> > +++ b/kernel/trace/trace_kprobe.c
> > @@ -269,14 +269,17 @@ static int create_trace_probe(int argc, char **argv)
> >  			pr_info("Delete command needs an event name.\n");
> >  			return -EINVAL;
> >  		}
> > +		mutex_lock(&probe_lock);
> >  		tp = find_probe_event(event, group);
> >  		if (!tp) {
> > +			mutex_unlock(&probe_lock);
> >  			pr_info("Event %s/%s doesn't exist.\n", group, event);
> >  			return -ENOENT;
> >  		}
> >  		/* delete an event */
> >  		unregister_trace_probe(tp);
> >  		free_trace_probe(tp);
> > +		mutex_unlock(&probe_lock);
> >  		return 0;
> >  	}
> >  
> 

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

* [tip:perf/core] tracing/kprobes: unregister_trace_probe needs to be called under mutex
  2010-06-30  8:45 [Bugfix] unregister_trace_probe needs to be called under mutex Srikar Dronamraju
  2010-06-30  9:44 ` Peter Zijlstra
  2010-07-01  1:09 ` Masami Hiramatsu
@ 2010-08-05  8:01 ` tip-bot for Srikar Dronamraju
  2 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Srikar Dronamraju @ 2010-08-05  8:01 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, masami.hiramatsu.pt, rostedt,
	srikar, tglx, mingo

Commit-ID:  9da79ab83ee33ddc1fdd0858fd3d70925a1bde99
Gitweb:     http://git.kernel.org/tip/9da79ab83ee33ddc1fdd0858fd3d70925a1bde99
Author:     Srikar Dronamraju <srikar@linux.vnet.ibm.com>
AuthorDate: Wed, 30 Jun 2010 14:15:48 +0530
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 4 Aug 2010 12:41:23 -0300

tracing/kprobes: unregister_trace_probe needs to be called under mutex

Comment in unregister_trace_probe() says probe_lock will be held when it
gets called. However there is a case where it might called without the
probe_lock being held. Also since we are traversing the probe_list and
deleting an element from the probe_list, probe_lock should be held.

This was first pointed in uprobes traceevent review by Frederic
Weisbecker here.  (http://lkml.org/lkml/2010/5/12/106)

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <20100630084548.GA10325@linux.vnet.ibm.com>
Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 kernel/trace/trace_kprobe.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 1b79d1c..8b27c98 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -925,14 +925,17 @@ static int create_trace_probe(int argc, char **argv)
 			pr_info("Delete command needs an event name.\n");
 			return -EINVAL;
 		}
+		mutex_lock(&probe_lock);
 		tp = find_probe_event(event, group);
 		if (!tp) {
+			mutex_unlock(&probe_lock);
 			pr_info("Event %s/%s doesn't exist.\n", group, event);
 			return -ENOENT;
 		}
 		/* delete an event */
 		unregister_trace_probe(tp);
 		free_trace_probe(tp);
+		mutex_unlock(&probe_lock);
 		return 0;
 	}
 

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

end of thread, other threads:[~2010-08-05  8:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-30  8:45 [Bugfix] unregister_trace_probe needs to be called under mutex Srikar Dronamraju
2010-06-30  9:44 ` Peter Zijlstra
2010-06-30 10:49   ` Srikar Dronamraju
2010-06-30 16:00   ` Steven Rostedt
2010-07-01  1:09 ` Masami Hiramatsu
2010-07-06  5:08   ` Srikar Dronamraju
2010-08-05  8:01 ` [tip:perf/core] tracing/kprobes: " tip-bot for Srikar Dronamraju

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).