[GIT PULL] tracing: Fixes in RTLA tool and reading the ring buffer

Steven Rostedt posted 1 patch 1 year, 5 months ago
kernel/trace/trace.c                 |  2 +-
tools/tracing/rtla/src/osnoise_top.c | 11 ++++-------
2 files changed, 5 insertions(+), 8 deletions(-)
[GIT PULL] tracing: Fixes in RTLA tool and reading the ring buffer
Posted by Steven Rostedt 1 year, 5 months ago

Linus,

A couple of fixes for tracing:

- Prevent a NULL pointer dereference in the error path of RTLA tool

- Fix an infinite loop bug when reading from the ring buffer when closed.
  If there's a thread trying to read the ring buffer and it gets closed
  by another thread, the one reading will go into an infinite loop
  when the buffer is empty instead of exiting back to user space.


Please pull the latest trace-v6.11-rc3 tree, which can be found at:


  git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace-v6.11-rc3

Tag SHA1: 436b8a891cd73d07847c86cd55ff7f8f17f47dfe
Head SHA1: 90574d2a675947858b47008df8d07f75ea50d0d0


Dan Carpenter (1):
      rtla/osnoise: Prevent NULL dereference in error handling

Steven Rostedt (1):
      tracing: Return from tracing_buffers_read() if the file has been closed

----
 kernel/trace/trace.c                 |  2 +-
 tools/tracing/rtla/src/osnoise_top.c | 11 ++++-------
 2 files changed, 5 insertions(+), 8 deletions(-)
---------------------------
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 10cd38bce2f1..ebe7ce2f5f4a 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -7956,7 +7956,7 @@ tracing_buffers_read(struct file *filp, char __user *ubuf,
 	trace_access_unlock(iter->cpu_file);
 
 	if (ret < 0) {
-		if (trace_empty(iter)) {
+		if (trace_empty(iter) && !iter->closed) {
 			if ((filp->f_flags & O_NONBLOCK))
 				return -EAGAIN;
 
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index f594a44df840..2f756628613d 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -651,8 +651,10 @@ struct osnoise_tool *osnoise_init_top(struct osnoise_top_params *params)
 		return NULL;
 
 	tool->data = osnoise_alloc_top(nr_cpus);
-	if (!tool->data)
-		goto out_err;
+	if (!tool->data) {
+		osnoise_destroy_tool(tool);
+		return NULL;
+	}
 
 	tool->params = params;
 
@@ -660,11 +662,6 @@ struct osnoise_tool *osnoise_init_top(struct osnoise_top_params *params)
 				   osnoise_top_handler, NULL);
 
 	return tool;
-
-out_err:
-	osnoise_free_top(tool->data);
-	osnoise_destroy_tool(tool);
-	return NULL;
 }
 
 static int stop_tracing;
Re: [GIT PULL] tracing: Fixes in RTLA tool and reading the ring buffer
Posted by pr-tracker-bot@kernel.org 1 year, 5 months ago
The pull request you sent on Fri, 16 Aug 2024 10:23:05 -0400:

> git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git trace-v6.11-rc3

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/4a621e291000c3756c353c5671ade4837ba68e3e

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html