Skip to content

Commit 173c204

Browse files
beaubelgraverostedt
authored andcommitted
user_events: Fix potential uninitialized pointer while parsing field
Ensure name is initialized by default to NULL to prevent possible edge cases that could lead to it being left uninitialized. Add an explicit check for NULL name to ensure edge boundaries. Link: https://lore.kernel.org/bpf/20220224105334.GA2248@kili/ Link: https://lore.kernel.org/linux-trace-devel/20220224181637.2129-1-beaub@linux.microsoft.com Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 9f8e5ae commit 173c204

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

kernel/trace/trace_events_user.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ static int user_event_parse_field(char *field, struct user_event *user,
362362
*field++ = '\0';
363363
depth++;
364364
parse:
365+
name = NULL;
366+
365367
while ((part = strsep(&field, " ")) != NULL) {
366368
switch (depth++) {
367369
case FIELD_DEPTH_TYPE:
@@ -382,7 +384,7 @@ static int user_event_parse_field(char *field, struct user_event *user,
382384
}
383385
}
384386

385-
if (depth < FIELD_DEPTH_SIZE)
387+
if (depth < FIELD_DEPTH_SIZE || !name)
386388
return -EINVAL;
387389

388390
if (depth == FIELD_DEPTH_SIZE)

0 commit comments

Comments
 (0)