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)
This patch is needed for both 2.6.35-rc3 and 2.6.35-rc3-tip
---
kernel/trace/trace_kprobe.c +3 -0
@@ -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 ; }
Quoted 25 lines · Srikar Dronamraju
Comment in
unregister_trace_probe()saysprobe_lockwill be held when it gets called. However there is a case where it might called without theprobe_lockbeing held. Also since we are traversing theprobe_listand deleting an element from theprobe_list,probe_lockshould 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 <[email protected]>---
kernel/trace/trace_kprobe.c +1
-0@@ -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) {
kernel/trace/trace_kprobe.c static int create_trace_probe(int argc, char **argv) · line 284
Quoted 10 lines
kernel/trace/trace_kprobe.c +2
-0+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?
Quoted 15 lines
Quoted 15 lines
kernel/trace/trace_kprobe.c +2
-0@@ -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 ; }
Quoted 8 lines
kernel/trace/trace_kprobe.c static int create_trace_probe(int argc, char **argv) · line 284
Quoted 6 lines
kernel/trace/trace_kprobe.c +1
-0/* 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
Quoted 11 lines · Peter Zijlstra
Quoted 10 lines · Srikar Dronamraju
Comment in
unregister_trace_probe()saysprobe_lockwill be held when it gets called. However there is a case where it might called without theprobe_lockbeing held. Also since we are traversing theprobe_listand deleting an element from theprobe_list,probe_lockshould 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
Quoted 19 lines
Quoted 19 lines
Signed-off-by Srikar Dronamraju <[email protected]>---
kernel/trace/trace_kprobe.c +2
-0@@ -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 ; }
Quoted 8 lines
kernel/trace/trace_kprobe.c static int create_trace_probe(int argc, char **argv) · line 284
Quoted 6 lines
kernel/trace/trace_kprobe.c +1
-0/* 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
Masami Hiramatsu
Acked-byQuoted 6 lines · Srikar Dronamraju
Comment in
unregister_trace_probe()saysprobe_lockwill be held when it gets called. However there is a case where it might called without theprobe_lockbeing held. Also since we are traversing theprobe_listand deleting an element from theprobe_list,probe_lockshould be held.
Quoted 6 lines
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 <[email protected]>
Ah, right! That's definately needed.
Thank you!
Quoted 24 lines
---
kernel/trace/trace_kprobe.c +3
-0@@ -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 ; }
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
Quoted 46 lines
Quoted 6 lines · Srikar Dronamraju
Comment in
unregister_trace_probe()saysprobe_lockwill be held when it gets called. However there is a case where it might called without theprobe_lockbeing held. Also since we are traversing theprobe_listand deleting an element from theprobe_list,probe_lockshould be held.Quoted 6 lines
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 <[email protected]>Ah, right! That's definately needed.
Acked-by Masami Hiramatsu <[email protected]>Thank you!
Quoted 24 lines
---
kernel/trace/trace_kprobe.c +3
-0@@ -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 ; }
[tip:perf/core] tracing/kprobes: unregister_trace_probe needs to be called under mutex
In reply to Srikar DronamrajuCommit-ID: 9da79ab83ee33ddc1fdd0858fd3d70925a1bde99 Gitweb: http://git.kernel.org/tip/9da79ab83ee33ddc1fdd0858fd3d70925a1bde99 Author: Srikar Dronamraju <[email protected]> AuthorDate: Wed, 30 Jun 2010 14:15:48 +0530 Committer: Arnaldo Carvalho de Melo <[email protected]> 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)
LKML-Reference: <[email protected]>
--- kernel/trace/trace_kprobe.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
kernel/trace/trace_kprobe.c +3 -0
@@ -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 ; }