diff options
author | Beau Belgrave <beaub@linux.microsoft.com> | 2022-02-24 19:16:37 +0100 |
---|---|---|
committer | Steven Rostedt (Google) <rostedt@goodmis.org> | 2022-03-10 23:41:18 +0100 |
commit | 173c2049d12b441b498d6423276f5dd76b1e637b (patch) | |
tree | bdaf00f8e1dc79f5c3c68612eb44ffa48efef2e4 /kernel/trace/trace_events_user.c | |
parent | tracing: Fix allocation of last_cmd in last_cmd_set() (diff) | |
download | linux-173c2049d12b441b498d6423276f5dd76b1e637b.tar.xz linux-173c2049d12b441b498d6423276f5dd76b1e637b.zip |
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>
Diffstat (limited to 'kernel/trace/trace_events_user.c')
-rw-r--r-- | kernel/trace/trace_events_user.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index 2b5e9fdb63a0..9a6191a6a786 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -362,6 +362,8 @@ skip_next: *field++ = '\0'; depth++; parse: + name = NULL; + while ((part = strsep(&field, " ")) != NULL) { switch (depth++) { case FIELD_DEPTH_TYPE: @@ -382,7 +384,7 @@ parse: } } - if (depth < FIELD_DEPTH_SIZE) + if (depth < FIELD_DEPTH_SIZE || !name) return -EINVAL; if (depth == FIELD_DEPTH_SIZE) |