]> Pileus Git - ~andy/linux/commit
tracing: Add trace_array_get/put() to event handling
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>
Tue, 2 Jul 2013 19:30:53 +0000 (15:30 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Tue, 2 Jul 2013 21:13:34 +0000 (17:13 -0400)
commit8e2e2fa47129532a30cff6c25a47078dc97d9260
tree6cc93f432b3186200c7afeaca1a432e497ad949c
parent7b85af63034818e43aee6c1d7bf1c7c6796a9073
tracing: Add trace_array_get/put() to event handling

Commit a695cb58162 "tracing: Prevent deleting instances when they are being read"
tried to fix a race between deleting a trace instance and reading contents
of a trace file. But it wasn't good enough. The following could crash the kernel:

 # cd /sys/kernel/debug/tracing/instances
 # ( while :; do mkdir foo; rmdir foo; done ) &
 # ( while :; do echo 1 > foo/events/sched/sched_switch 2> /dev/null; done ) &

Luckily this can only be done by root user, but it should be fixed regardless.

The problem is that a delete of the file can happen after the write to the event
is opened, but before the enabling happens.

The solution is to make sure the trace_array is available before succeeding in
opening for write, and incerment the ref counter while opened.

Now the instance can be deleted when the events are writing to the buffer,
but the deletion of the instance will disable all events before the instance
is actually deleted.

Cc: stable@vger.kernel.org # 3.10
Reported-by: Alexander Lam <azl@google.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/trace.h
kernel/trace/trace_events.c