Skip to content

Commit be8058f

Browse files
rtla: Fix segfault on multiple SIGINTs
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: d6899e5 ("rtla/timerlat_hist: Abort event processing on second signal") Fixes: 80967b3 ("rtla/timerlat_top: Abort event processing on second signal") Reviewed-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260310160725.144443-1-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
1 parent 99261cc commit be8058f

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

tools/tracing/rtla/src/common.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ static void set_signals(struct common_params *params)
4141
}
4242
}
4343

44+
/*
45+
* unset_signals - unsets the signals to stop the tool
46+
*/
47+
static void unset_signals(struct common_params *params)
48+
{
49+
signal(SIGINT, SIG_DFL);
50+
if (params->duration) {
51+
alarm(0);
52+
signal(SIGALRM, SIG_DFL);
53+
}
54+
}
55+
4456
/*
4557
* getopt_auto - auto-generates optstring from long_options
4658
*/
@@ -351,7 +363,7 @@ int run_tool(struct tool_ops *ops, int argc, char *argv[])
351363

352364
retval = ops->main(tool);
353365
if (retval)
354-
goto out_trace;
366+
goto out_signals;
355367

356368
if (params->user_workload && !params->user.stopped_running) {
357369
params->user.should_run = 0;
@@ -373,6 +385,8 @@ int run_tool(struct tool_ops *ops, int argc, char *argv[])
373385
if (ops->analyze)
374386
ops->analyze(tool, stopped);
375387

388+
out_signals:
389+
unset_signals(params);
376390
out_trace:
377391
trace_events_destroy(&tool->record->trace, params->events);
378392
params->events = NULL;

0 commit comments

Comments
 (0)