Skip to content

Commit

Permalink
tracing: Get trace_array reference for available_tracers files
Browse files Browse the repository at this point in the history
As instances may have different tracers available, we need to look at the
trace_array descriptor that shows the list of the available tracers for the
instance. But there's a race between opening the file and an admin
deleting the instance. The trace_array_get() needs to be called before
accessing the trace_array.

Cc: [email protected]
Fixes: 607e2ea ("tracing: Set up infrastructure to allow tracers for instances")
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
  • Loading branch information
rostedt committed Oct 13, 2019
1 parent 9ef1669 commit 194c2c7
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -4355,16 +4355,29 @@ static int show_traces_open(struct inode *inode, struct file *file)
if (tracing_disabled)
return -ENODEV;

if (trace_array_get(tr) < 0)
return -ENODEV;

ret = seq_open(file, &show_traces_seq_ops);
if (ret)
if (ret) {
trace_array_put(tr);
return ret;
}

m = file->private_data;
m->private = tr;

return 0;
}

static int show_traces_release(struct inode *inode, struct file *file)
{
struct trace_array *tr = inode->i_private;

trace_array_put(tr);
return seq_release(inode, file);
}

static ssize_t
tracing_write_stub(struct file *filp, const char __user *ubuf,
size_t count, loff_t *ppos)
Expand Down Expand Up @@ -4395,8 +4408,8 @@ static const struct file_operations tracing_fops = {
static const struct file_operations show_traces_fops = {
.open = show_traces_open,
.read = seq_read,
.release = seq_release,
.llseek = seq_lseek,
.release = show_traces_release,
};

static ssize_t
Expand Down

0 comments on commit 194c2c7

Please sign in to comment.