Skip to contentSkip to conversation

Patch "tracing: Move mutex to protect against resetting of seq data" has been added to the 4.7-stable tree

PATCH [email protected] 1 participant 1 message Sep 27, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

tracing: Move mutex to protect against resetting of seq data

to the 4.7-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
tracing-move-mutex-to-protect-against-resetting-of-seq-data.patch
and it can be found in the queue-4.7 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 1245800c0f96eb6ebb368593e251d66c01e61022 Mon Sep 17 00:00:00 2001

From: "Steven Rostedt (Red Hat)" <[email protected]>
Date: Fri, 23 Sep 2016 22:57:13 -0400
Subject: tracing: Move mutex to protect against resetting of seq data

From: Steven Rostedt (Red Hat) <[email protected]>

commit 1245800c0f96eb6ebb368593e251d66c01e61022 upstream.

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")
---
 kernel/trace/trace.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
kernel/trace/trace.c +8 -7
@@ -4890,19 +4890,20 @@ tracing_read_pipe(struct file *filp, cha
 	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)

Patches currently in stable-queue which might be from [email protected] are

queue-4.7/makefile-mute-warning-for-__builtin_return_address-0-for-tracing-only.patch queue-4.7/disable-frame-address-warning.patch queue-4.7/tracing-move-mutex-to-protect-against-resetting-of-seq-data.patch