public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtla: Fix segfault on multiple SIGINTs
@ 2026-03-10 16:07 Tomas Glozar
  2026-03-10 16:24 ` Wander Lairson Costa
  0 siblings, 1 reply; 2+ messages in thread
From: Tomas Glozar @ 2026-03-10 16:07 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: John Kacur, Luis Goncalves, Crystal Wood, Costa Shulyupin,
	Wander Lairson Costa, LKML, linux-trace-kernel, Tomas Glozar

Detach stop_trace() from SIGINT/SIGALRM on tool clean-up to prevent it
from crashing RTLA by accessing freed memory.

This prevents a crash when multiple SIGINTs are received.

Fixes: d6899e560366 ("rtla/timerlat_hist: Abort event processing on second signal")
Fixes: 80967b354a76 ("rtla/timerlat_top: Abort event processing on second signal")
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
---
 tools/tracing/rtla/src/common.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/common.c
index ceff76a62a30..51cdf86d60d0 100644
--- a/tools/tracing/rtla/src/common.c
+++ b/tools/tracing/rtla/src/common.c
@@ -39,6 +39,18 @@ static void set_signals(struct common_params *params)
 	}
 }
 
+/*
+ * unset_signals - unsets the signals to stop the tool
+ */
+static void unset_signals(struct common_params *params)
+{
+	signal(SIGINT, SIG_DFL);
+	if (params->duration) {
+		alarm(0);
+		signal(SIGALRM, SIG_DFL);
+	}
+}
+
 /*
  * common_parse_options - parse common command line options
  *
@@ -284,7 +296,7 @@ int run_tool(struct tool_ops *ops, int argc, char *argv[])
 
 	retval = ops->main(tool);
 	if (retval)
-		goto out_trace;
+		goto out_signals;
 
 	if (params->user_workload && !params->user.stopped_running) {
 		params->user.should_run = 0;
@@ -306,6 +318,8 @@ int run_tool(struct tool_ops *ops, int argc, char *argv[])
 	if (ops->analyze)
 		ops->analyze(tool, stopped);
 
+out_signals:
+	unset_signals(params);
 out_trace:
 	trace_events_destroy(&tool->record->trace, params->events);
 	params->events = NULL;
-- 
2.53.0


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

* Re: [PATCH] rtla: Fix segfault on multiple SIGINTs
  2026-03-10 16:07 [PATCH] rtla: Fix segfault on multiple SIGINTs Tomas Glozar
@ 2026-03-10 16:24 ` Wander Lairson Costa
  0 siblings, 0 replies; 2+ messages in thread
From: Wander Lairson Costa @ 2026-03-10 16:24 UTC (permalink / raw)
  To: Tomas Glozar
  Cc: Steven Rostedt, John Kacur, Luis Goncalves, Crystal Wood,
	Costa Shulyupin, LKML, linux-trace-kernel

On Tue, Mar 10, 2026 at 05:07:25PM +0100, Tomas Glozar wrote:
> Detach stop_trace() from SIGINT/SIGALRM on tool clean-up to prevent it
> from crashing RTLA by accessing freed memory.
> 
> This prevents a crash when multiple SIGINTs are received.
> 
> Fixes: d6899e560366 ("rtla/timerlat_hist: Abort event processing on second signal")
> Fixes: 80967b354a76 ("rtla/timerlat_top: Abort event processing on second signal")
> Signed-off-by: Tomas Glozar <tglozar@redhat.com>
> ---

Reviewed-by: Wander Lairson Costa <wander@redhat.com>

[...]


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

end of thread, other threads:[~2026-03-10 16:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-10 16:07 [PATCH] rtla: Fix segfault on multiple SIGINTs Tomas Glozar
2026-03-10 16:24 ` Wander Lairson Costa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox