summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorWander Lairson Costa <wander@redhat.com>2026-01-06 08:49:48 -0300
committerSasha Levin <sashal@kernel.org>2026-03-04 07:20:21 -0500
commit36bb4cbab3e92905d76e2e868353d969feabfc34 (patch)
tree0a80ab6edcbe9ec7ff8a0351c0950d05e3a7bf34 /tools
parente00c9a4ec84c0bb067833b34202f457badbbc1c1 (diff)
rtla: Fix NULL pointer dereference in actions_parse
[ Upstream commit a0890f9dbd24b302d327fe7dad9b9c5be0e278aa ] The actions_parse() function uses strtok() to tokenize the trigger string, but does not check if the returned token is NULL before passing it to strcmp(). If the trigger parameter is an empty string or contains only delimiter characters, strtok() returns NULL, causing strcmp() to dereference a NULL pointer and crash the program. This issue can be triggered by malformed user input or edge cases in trigger string parsing. Add a NULL check immediately after the strtok() call to validate that a token was successfully extracted before using it. If no token is found, the function now returns -1 to indicate a parsing error. Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260106133655.249887-13-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/tracing/rtla/src/actions.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/tracing/rtla/src/actions.c b/tools/tracing/rtla/src/actions.c
index 8945aee58d51..15986505b437 100644
--- a/tools/tracing/rtla/src/actions.c
+++ b/tools/tracing/rtla/src/actions.c
@@ -141,6 +141,8 @@ actions_parse(struct actions *self, const char *trigger, const char *tracefn)
strcpy(trigger_c, trigger);
token = strtok(trigger_c, ",");
+ if (!token)
+ return -1;
if (strcmp(token, "trace") == 0)
type = ACTION_TRACE_OUTPUT;