Skip to content

Commit 436fc28

Browse files
Steven Rostedtrostedt
authored andcommitted
tracing: Fix returning of duplicate data after EOF in trace_pipe_raw
The trace_pipe_raw handler holds a cached page from the time the file is opened to the time it is closed. The cached page is used to handle the case of the user space buffer being smaller than what was read from the ring buffer. The left over buffer is held in the cache so that the next read will continue where the data left off. After EOF is returned (no more data in the buffer), the index of the cached page is set to zero. If a user app reads the page again after EOF, the check in the buffer will see that the cached page is less than page size and will return the cached page again. This will cause reading the trace_pipe_raw again after EOF to return duplicate data, making the output look like the time went backwards but instead data is just repeated. The fix is to not reset the index right after all data is read from the cache, but to reset it after all data is read and more data exists in the ring buffer. Cc: stable <stable@kernel.org> Reported-by: Jeremy Eder <jeder@redhat.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 9b5f8b3 commit 436fc28

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎kernel/trace/trace.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3903,8 +3903,6 @@ tracing_buffers_read(struct file *filp, char __user *ubuf,
39033903
if (info->read < PAGE_SIZE)
39043904
goto read;
39053905

3906-
info->read = 0;
3907-
39083906
trace_access_lock(info->cpu);
39093907
ret = ring_buffer_read_page(info->tr->buffer,
39103908
&info->spare,
@@ -3914,6 +3912,8 @@ tracing_buffers_read(struct file *filp, char __user *ubuf,
39143912
if (ret < 0)
39153913
return 0;
39163914

3915+
info->read = 0;
3916+
39173917
read:
39183918
size = PAGE_SIZE - info->read;
39193919
if (size > count)

0 commit comments

Comments
 (0)