tracing: Fix race between deleting buffer and setting events
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>
Tue, 2 Jul 2013 18:48:23 +0000 (14:48 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jul 2013 21:07:43 +0000 (14:07 -0700)
commit68cebd265c91873277cf100e7ac1d047c6598ddf
tree40e9d76980fa3df077908b1401fec8e4d97e7cec
parent6492334c86dfb441af456337dc3217c2a430f141
tracing: Fix race between deleting buffer and setting events

commit 2a6c24afab70dbcfee49f4c76e1511eec1a3298b upstream.

While analyzing the code, I discovered that there's a potential race between
deleting a trace instance and setting events. There are a few races that can
occur if events are being traced as the buffer is being deleted. Mostly the
problem comes with freeing the descriptor used by the trace event callback.
To prevent problems like this, the events are disabled before the buffer is
deleted. The problem with the current solution is that the event_mutex is let
go between disabling the events and freeing the files, which means that the events
could be enabled again while the freeing takes place.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/trace/trace_events.c