Skip to content
/ linux Public

Commit 2727242

Browse files
walacSasha Levin
authored andcommitted
rtla: Fix NULL pointer dereference in actions_parse
[ Upstream commit a0890f9 ] 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>
1 parent 1260bee commit 2727242

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/tracing/rtla/src/actions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ actions_parse(struct actions *self, const char *trigger, const char *tracefn)
141141

142142
strcpy(trigger_c, trigger);
143143
token = strtok(trigger_c, ",");
144+
if (!token)
145+
return -1;
144146

145147
if (strcmp(token, "trace") == 0)
146148
type = ACTION_TRACE_OUTPUT;

0 commit comments

Comments
 (0)