aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-09-25 21:40:13 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-09-25 21:40:13 -0400
commit4c04b4b534cbe8c0cc0661e232bbb9708e212bc2 (patch)
tree1e103a03475fbf447dfae4ec874e05778adb5032 /kernel/trace
parent90b75db6498a19da96dac4b55c909ff3721f3045 (diff)
parent1ae2293dd6d2f5c823cf97e60b70d03631cd622f (diff)
Merge tag 'trace-v4.8-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracefs fixes from Steven Rostedt: "Al Viro has been looking at the tracefs code, and has pointed out some issues. This contains one fix by me and one by Al. I'm sure that he'll come up with more but for now I tested these patches and they don't appear to have any negative impact on tracing" * tag 'trace-v4.8-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: fix memory leaks in tracing_buffers_splice_read() tracing: Move mutex to protect against resetting of seq data
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/trace.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index dade4c9559cc..7bc56762ca35 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -5124,19 +5124,20 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
5124 struct trace_iterator *iter = filp->private_data; 5124 struct trace_iterator *iter = filp->private_data;
5125 ssize_t sret; 5125 ssize_t sret;
5126 5126
5127 /* return any leftover data */
5128 sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
5129 if (sret != -EBUSY)
5130 return sret;
5131
5132 trace_seq_init(&iter->seq);
5133
5134 /* 5127 /*
5135 * Avoid more than one consumer on a single file descriptor 5128 * Avoid more than one consumer on a single file descriptor
5136 * This is just a matter of traces coherency, the ring buffer itself 5129 * This is just a matter of traces coherency, the ring buffer itself
5137 * is protected. 5130 * is protected.
5138 */ 5131 */
5139 mutex_lock(&iter->mutex); 5132 mutex_lock(&iter->mutex);
5133
5134 /* return any leftover data */
5135 sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
5136 if (sret != -EBUSY)
5137 goto out;
5138
5139 trace_seq_init(&iter->seq);
5140
5140 if (iter->trace->read) { 5141 if (iter->trace->read) {
5141 sret = iter->trace->read(iter, filp, ubuf, cnt, ppos); 5142 sret = iter->trace->read(iter, filp, ubuf, cnt, ppos);
5142 if (sret) 5143 if (sret)
@@ -6163,9 +6164,6 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
6163 return -EBUSY; 6164 return -EBUSY;
6164#endif 6165#endif
6165 6166
6166 if (splice_grow_spd(pipe, &spd))
6167 return -ENOMEM;
6168
6169 if (*ppos & (PAGE_SIZE - 1)) 6167 if (*ppos & (PAGE_SIZE - 1))
6170 return -EINVAL; 6168 return -EINVAL;
6171 6169
@@ -6175,6 +6173,9 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
6175 len &= PAGE_MASK; 6173 len &= PAGE_MASK;
6176 } 6174 }
6177 6175
6176 if (splice_grow_spd(pipe, &spd))
6177 return -ENOMEM;
6178
6178 again: 6179 again:
6179 trace_access_lock(iter->cpu_file); 6180 trace_access_lock(iter->cpu_file);
6180 entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file); 6181 entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file);
@@ -6232,19 +6233,21 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
6232 /* did we read anything? */ 6233 /* did we read anything? */
6233 if (!spd.nr_pages) { 6234 if (!spd.nr_pages) {
6234 if (ret) 6235 if (ret)
6235 return ret; 6236 goto out;
6236 6237
6238 ret = -EAGAIN;
6237 if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK)) 6239 if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK))
6238 return -EAGAIN; 6240 goto out;
6239 6241
6240 ret = wait_on_pipe(iter, true); 6242 ret = wait_on_pipe(iter, true);
6241 if (ret) 6243 if (ret)
6242 return ret; 6244 goto out;
6243 6245
6244 goto again; 6246 goto again;
6245 } 6247 }
6246 6248
6247 ret = splice_to_pipe(pipe, &spd); 6249 ret = splice_to_pipe(pipe, &spd);
6250out:
6248 splice_shrink_spd(&spd); 6251 splice_shrink_spd(&spd);
6249 6252
6250 return ret; 6253 return ret;