aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2013-03-14 13:50:56 -0400
committerSteven Rostedt <rostedt@goodmis.org>2013-03-14 13:50:56 -0400
commit69d34da2984c95b33ea21518227e1f9470f11d95 (patch)
treed7e414084fd0d64d6e7dd87f7d2e42961c323764 /kernel/trace/trace.c
parent740466bc89ad8bd5afcc8de220f715f62b21e365 (diff)
tracing: Protect tracer flags with trace_types_lock
Seems that the tracer flags have never been protected from synchronous writes. Luckily, admins don't usually modify the tracing flags via two different tasks. But if scripts were to be used to modify them, then they could get corrupted. Move the trace_types_lock that protects against tracers changing to also protect the flags being set. Cc: stable@vger.kernel.org Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 53df2839bb93..00daf5f8c50b 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2916,6 +2916,8 @@ static int trace_set_options(char *option)
2916 cmp += 2; 2916 cmp += 2;
2917 } 2917 }
2918 2918
2919 mutex_lock(&trace_types_lock);
2920
2919 for (i = 0; trace_options[i]; i++) { 2921 for (i = 0; trace_options[i]; i++) {
2920 if (strcmp(cmp, trace_options[i]) == 0) { 2922 if (strcmp(cmp, trace_options[i]) == 0) {
2921 set_tracer_flags(1 << i, !neg); 2923 set_tracer_flags(1 << i, !neg);
@@ -2924,11 +2926,10 @@ static int trace_set_options(char *option)
2924 } 2926 }
2925 2927
2926 /* If no option could be set, test the specific tracer options */ 2928 /* If no option could be set, test the specific tracer options */
2927 if (!trace_options[i]) { 2929 if (!trace_options[i])
2928 mutex_lock(&trace_types_lock);
2929 ret = set_tracer_option(current_trace, cmp, neg); 2930 ret = set_tracer_option(current_trace, cmp, neg);
2930 mutex_unlock(&trace_types_lock); 2931
2931 } 2932 mutex_unlock(&trace_types_lock);
2932 2933
2933 return ret; 2934 return ret;
2934} 2935}
@@ -4781,7 +4782,10 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
4781 4782
4782 if (val != 0 && val != 1) 4783 if (val != 0 && val != 1)
4783 return -EINVAL; 4784 return -EINVAL;
4785
4786 mutex_lock(&trace_types_lock);
4784 set_tracer_flags(1 << index, val); 4787 set_tracer_flags(1 << index, val);
4788 mutex_unlock(&trace_types_lock);
4785 4789
4786 *ppos += cnt; 4790 *ppos += cnt;
4787 4791