]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.1.1/tracing-fix-returning-of-duplicate-data-after-eof-in-trace_pipe_raw.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.1.1 / tracing-fix-returning-of-duplicate-data-after-eof-in-trace_pipe_raw.patch
1 From 436fc280261dcfce5af38f08b89287750dc91cd2 Mon Sep 17 00:00:00 2001
2 From: Steven Rostedt <srostedt@redhat.com>
3 Date: Fri, 14 Oct 2011 10:44:25 -0400
4 Subject: tracing: Fix returning of duplicate data after EOF in trace_pipe_raw
5
6 From: Steven Rostedt <srostedt@redhat.com>
7
8 commit 436fc280261dcfce5af38f08b89287750dc91cd2 upstream.
9
10 The trace_pipe_raw handler holds a cached page from the time the file
11 is opened to the time it is closed. The cached page is used to handle
12 the case of the user space buffer being smaller than what was read from
13 the ring buffer. The left over buffer is held in the cache so that the
14 next read will continue where the data left off.
15
16 After EOF is returned (no more data in the buffer), the index of
17 the cached page is set to zero. If a user app reads the page again
18 after EOF, the check in the buffer will see that the cached page
19 is less than page size and will return the cached page again. This
20 will cause reading the trace_pipe_raw again after EOF to return
21 duplicate data, making the output look like the time went backwards
22 but instead data is just repeated.
23
24 The fix is to not reset the index right after all data is read
25 from the cache, but to reset it after all data is read and more
26 data exists in the ring buffer.
27
28 Reported-by: Jeremy Eder <jeder@redhat.com>
29 Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
30 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
31
32 ---
33 kernel/trace/trace.c | 4 ++--
34 1 file changed, 2 insertions(+), 2 deletions(-)
35
36 --- a/kernel/trace/trace.c
37 +++ b/kernel/trace/trace.c
38 @@ -3808,8 +3808,6 @@ tracing_buffers_read(struct file *filp,
39 if (info->read < PAGE_SIZE)
40 goto read;
41
42 - info->read = 0;
43 -
44 trace_access_lock(info->cpu);
45 ret = ring_buffer_read_page(info->tr->buffer,
46 &info->spare,
47 @@ -3819,6 +3817,8 @@ tracing_buffers_read(struct file *filp,
48 if (ret < 0)
49 return 0;
50
51 + info->read = 0;
52 +
53 read:
54 size = PAGE_SIZE - info->read;
55 if (size > count)