diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2013-07-01 22:50:29 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2013-07-02 09:58:11 -0400 |
commit | ff451961a8b2a17667a7bfa39c86fb9b351445db (patch) | |
tree | 03f82366f860605664b4a7fe11a97f57fc0632a8 /kernel/kmod.c | |
parent | a82274151af2b075163e3c42c828529dee311487 (diff) | |
download | op-kernel-dev-ff451961a8b2a17667a7bfa39c86fb9b351445db.zip op-kernel-dev-ff451961a8b2a17667a7bfa39c86fb9b351445db.tar.gz |
tracing: Add trace_array_get/put() to handle instance refs better
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 cat foo/trace &> /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 reader starts
to open the file but before it grabs the trace_types_mutex.
The solution is to validate the trace array before using it. If the trace
array does not exist in the list of trace arrays, then it returns -ENODEV.
There's a possibility that a trace_array could be deleted and a new one
created and the open would open its file instead. But that is very minor as
it will just return the data of the new trace array, it may confuse the user
but it will not crash the system. As this can only be done by root anyway,
the race will only occur if root is deleting what its trying to read at
the same time.
Cc: stable@vger.kernel.org # 3.10
Reported-by: Alexander Lam <azl@google.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/kmod.c')
0 files changed, 0 insertions, 0 deletions