From: Steven Rostedt (Red Hat) Date: Thu, 14 Mar 2013 17:50:56 +0000 (-0400) Subject: tracing: Protect tracer flags with trace_types_lock X-Git-Tag: v3.8.5~59 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=61ff05825e3bac02538a50f1b15c41b005e33d29;p=users%2Fjedix%2Flinux-maple.git tracing: Protect tracer flags with trace_types_lock commit 69d34da2984c95b33ea21518227e1f9470f11d95 upstream. 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. Signed-off-by: Steven Rostedt Signed-off-by: Greg Kroah-Hartman --- diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 30d9b71d5256..744f2d4f2a7e 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2871,6 +2871,8 @@ static int trace_set_options(char *option) cmp += 2; } + mutex_lock(&trace_types_lock); + for (i = 0; trace_options[i]; i++) { if (strcmp(cmp, trace_options[i]) == 0) { set_tracer_flags(1 << i, !neg); @@ -2879,11 +2881,10 @@ static int trace_set_options(char *option) } /* If no option could be set, test the specific tracer options */ - if (!trace_options[i]) { - mutex_lock(&trace_types_lock); + if (!trace_options[i]) ret = set_tracer_option(current_trace, cmp, neg); - mutex_unlock(&trace_types_lock); - } + + mutex_unlock(&trace_types_lock); return ret; } @@ -4641,7 +4642,10 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt, if (val != 0 && val != 1) return -EINVAL; + + mutex_lock(&trace_types_lock); set_tracer_flags(1 << index, val); + mutex_unlock(&trace_types_lock); *ppos += cnt;