Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1490995 > unrolled thread

[PATCH 0/2] [GIT PULL] tracing: A couple of fixes with tracefs

Started bySteven Rostedt <rostedt@goodmis.org>
First post2016-09-26 01:30 +0200
Last post2016-09-26 01:30 +0200
Articles 3 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/2] [GIT PULL] tracing: A couple of fixes with tracefs Steven Rostedt <rostedt@goodmis.org> - 2016-09-26 01:30 +0200
    [PATCH 2/2] fix memory leaks in tracing_buffers_splice_read() Steven Rostedt <rostedt@goodmis.org> - 2016-09-26 01:30 +0200
    [PATCH 1/2] tracing: Move mutex to protect against resetting of seq data Steven Rostedt <rostedt@goodmis.org> - 2016-09-26 01:30 +0200

#1490995 — [PATCH 0/2] [GIT PULL] tracing: A couple of fixes with tracefs

FromSteven Rostedt <rostedt@goodmis.org>
Date2016-09-26 01:30 +0200
Subject[PATCH 0/2] [GIT PULL] tracing: A couple of fixes with tracefs
Message-ID<slr1T-4yi-9@gated-at.bofh.it>
Linus,

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.

Please pull the latest trace-v4.8-rc7 tree, which can be found at:


  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v4.8-rc7

Tag SHA1: 7a41afe1fd2b8a81f979c6e00533b68b07af2519
Head SHA1: 1ae2293dd6d2f5c823cf97e60b70d03631cd622f


Al Viro (1):
      fix memory leaks in tracing_buffers_splice_read()

Steven Rostedt (Red Hat) (1):
      tracing: Move mutex to protect against resetting of seq data

----
 kernel/trace/trace.c | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

[toc] | [next] | [standalone]


#1490998 — [PATCH 2/2] fix memory leaks in tracing_buffers_splice_read()

FromSteven Rostedt <rostedt@goodmis.org>
Date2016-09-26 01:30 +0200
Subject[PATCH 2/2] fix memory leaks in tracing_buffers_splice_read()
Message-ID<slr1U-4yi-15@gated-at.bofh.it>
In reply to#1490995
From: Al Viro <viro@zeniv.linux.org.uk>

Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 kernel/trace/trace.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 8fb4847b0450..77eeab2776ef 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -5930,9 +5930,6 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
 		return -EBUSY;
 #endif
 
-	if (splice_grow_spd(pipe, &spd))
-		return -ENOMEM;
-
 	if (*ppos & (PAGE_SIZE - 1))
 		return -EINVAL;
 
@@ -5942,6 +5939,9 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
 		len &= PAGE_MASK;
 	}
 
+	if (splice_grow_spd(pipe, &spd))
+		return -ENOMEM;
+
  again:
 	trace_access_lock(iter->cpu_file);
 	entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file);
@@ -5999,19 +5999,21 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
 	/* did we read anything? */
 	if (!spd.nr_pages) {
 		if (ret)
-			return ret;
+			goto out;
 
+		ret = -EAGAIN;
 		if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK))
-			return -EAGAIN;
+			goto out;
 
 		ret = wait_on_pipe(iter, true);
 		if (ret)
-			return ret;
+			goto out;
 
 		goto again;
 	}
 
 	ret = splice_to_pipe(pipe, &spd);
+out:
 	splice_shrink_spd(&spd);
 
 	return ret;
-- 
2.8.1

[toc] | [prev] | [next] | [standalone]


#1490999 — [PATCH 1/2] tracing: Move mutex to protect against resetting of seq data

FromSteven Rostedt <rostedt@goodmis.org>
Date2016-09-26 01:30 +0200
Subject[PATCH 1/2] tracing: Move mutex to protect against resetting of seq data
Message-ID<slr1U-4yi-13@gated-at.bofh.it>
In reply to#1490995
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

The iter->seq can be reset outside the protection of the mutex. So can
reading of user data. Move the mutex up to the beginning of the function.

Fixes: d7350c3f45694 ("tracing/core: make the read callbacks reentrants")
Cc: stable@vger.kernel.org # 2.6.30+
Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 8a4bd6b68a0b..8fb4847b0450 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4890,19 +4890,20 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
 	struct trace_iterator *iter = filp->private_data;
 	ssize_t sret;
 
-	/* return any leftover data */
-	sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
-	if (sret != -EBUSY)
-		return sret;
-
-	trace_seq_init(&iter->seq);
-
 	/*
 	 * Avoid more than one consumer on a single file descriptor
 	 * This is just a matter of traces coherency, the ring buffer itself
 	 * is protected.
 	 */
 	mutex_lock(&iter->mutex);
+
+	/* return any leftover data */
+	sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
+	if (sret != -EBUSY)
+		goto out;
+
+	trace_seq_init(&iter->seq);
+
 	if (iter->trace->read) {
 		sret = iter->trace->read(iter, filp, ubuf, cnt, ppos);
 		if (sret)
-- 
2.8.1

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web