tracing: add protection around modify trace event fields
authorSteven Rostedt <srostedt@redhat.com>
Mon, 2 Mar 2009 16:49:04 +0000 (11:49 -0500)
committerSteven Rostedt <srostedt@redhat.com>
Mon, 2 Mar 2009 16:49:04 +0000 (11:49 -0500)
The trace event objects are currently not proctected against
reentrancy. This patch adds a mutex around the modifications of
the trace event fields.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
kernel/trace/trace_events.c

index 1d07f800a9ce14c22977b45fe5b47f1e3b1d656c..26069fa6b3b00858dc9d1fa0bfcb6d242a1bda36 100644 (file)
@@ -14,6 +14,8 @@
 
 #define TRACE_SYSTEM "TRACE_SYSTEM"
 
+static DEFINE_MUTEX(event_mutex);
+
 #define events_for_each(event)                                         \
        for (event = __start_ftrace_events;                             \
             (unsigned long)event < (unsigned long)__stop_ftrace_events; \
@@ -104,6 +106,7 @@ static int ftrace_set_clr_event(char *buf, int set)
                        event = NULL;
        }
 
+       mutex_lock(&event_mutex);
        events_for_each(call) {
 
                if (!call->name)
@@ -124,6 +127,8 @@ static int ftrace_set_clr_event(char *buf, int set)
 
                ret = 0;
        }
+       mutex_unlock(&event_mutex);
+
        return ret;
 }
 
@@ -324,7 +329,9 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
        switch (val) {
        case 0:
        case 1:
+               mutex_lock(&event_mutex);
                ftrace_event_enable_disable(call, val);
+               mutex_unlock(&event_mutex);
                break;
 
        default:
This page took 0.031381 seconds and 5 git commands to generate.