linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] rtla: Fix crash due to NULL record dereference
@ 2025-03-22 18:34 Costa Shulyupin
  2025-03-25 15:48 ` Tomas Glozar
  0 siblings, 1 reply; 2+ messages in thread
From: Costa Shulyupin @ 2025-03-22 18:34 UTC (permalink / raw)
  To: Steven Rostedt, Daniel Bristot de Oliveira, Costa Shulyupin,
	Tomas Glozar, John Kacur, Luis Claudio R. Goncalves, Eder Zulian,
	Dan Carpenter, Gabriele Monaco, linux-trace-kernel, linux-kernel

The previous patch introduced a crash by dereferencing record,
which can be NULL.

Add checks to prevent the crash.

Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
---
 tools/tracing/rtla/src/osnoise_hist.c  | 3 ++-
 tools/tracing/rtla/src/osnoise_top.c   | 3 ++-
 tools/tracing/rtla/src/timerlat_hist.c | 3 ++-
 tools/tracing/rtla/src/timerlat_top.c  | 3 ++-
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index 7c6ef67ef3e6c..f94c7c049406d 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -983,7 +983,8 @@ int osnoise_hist_main(int argc, char *argv[])
 
 	if (osnoise_trace_is_off(tool, record)) {
 		printf("rtla osnoise hit stop tracing\n");
-		save_trace_to_file(record->trace.inst, params->trace_output);
+		if (record)
+			save_trace_to_file(record->trace.inst, params->trace_output);
 	}
 
 out_hist:
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 0eeefbbbf3173..003c0f76b1ada 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -813,7 +813,8 @@ int osnoise_top_main(int argc, char **argv)
 
 	if (osnoise_trace_is_off(tool, record)) {
 		printf("osnoise hit stop tracing\n");
-		save_trace_to_file(record->trace.inst, params->trace_output);
+		if (record)
+			save_trace_to_file(record->trace.inst, params->trace_output);
 	}
 
 out_top:
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index 93d0c9e450204..f91efe8804586 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -1473,7 +1473,8 @@ int timerlat_hist_main(int argc, char *argv[])
 		if (!params->no_aa)
 			timerlat_auto_analysis(params->stop_us, params->stop_total_us);
 
-		save_trace_to_file(record->trace.inst, params->trace_output);
+		if (record)
+			save_trace_to_file(record->trace.inst, params->trace_output);
 	}
 
 out_hist:
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index 3894ac37d81ca..f082f8b91afef 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -1295,7 +1295,8 @@ int timerlat_top_main(int argc, char *argv[])
 		if (!params->no_aa)
 			timerlat_auto_analysis(params->stop_us, params->stop_total_us);
 
-		save_trace_to_file(record->trace.inst, params->trace_output);
+		if (record)
+			save_trace_to_file(record->trace.inst, params->trace_output);
 	} else if (params->aa_only) {
 		/*
 		 * If the trace did not stop with --aa-only, at least print the
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] rtla: Fix crash due to NULL record dereference
  2025-03-22 18:34 [PATCH v1] rtla: Fix crash due to NULL record dereference Costa Shulyupin
@ 2025-03-25 15:48 ` Tomas Glozar
  0 siblings, 0 replies; 2+ messages in thread
From: Tomas Glozar @ 2025-03-25 15:48 UTC (permalink / raw)
  To: Costa Shulyupin
  Cc: Steven Rostedt, Daniel Bristot de Oliveira, John Kacur,
	Luis Claudio R. Goncalves, Eder Zulian, Dan Carpenter,
	Gabriele Monaco, linux-trace-kernel, linux-kernel

so 22. 3. 2025 v 19:40 odesílatel Costa Shulyupin
<costa.shul@redhat.com> napsal:
>
> The previous patch introduced a crash by dereferencing record,
> which can be NULL.
>
> Add checks to prevent the crash.
>
> Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>

This is a duplicate of my fix [1]. I added a NULL check inside the
function and made the callers pass NULL if the record instance is not
initialized.

[1] https://lore.kernel.org/linux-trace-kernel/20250313141034.299117-1-tglozar@redhat.com/

Tomas


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-03-25 15:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-22 18:34 [PATCH v1] rtla: Fix crash due to NULL record dereference Costa Shulyupin
2025-03-25 15:48 ` Tomas Glozar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).