tracing/probes: cleanup: Set trace_probe::nr_args at trace_probe_init
BugLink: https://bugs.launchpad.net/bugs/2097575 [ Upstream commit 035ba76014c096316fa809a46ce0a1b9af1cde0d ] Instead of incrementing the trace_probe::nr_args, init it at trace_probe_init(). Without this change, there is no way to get the number of trace_probe arguments while parsing it. This is a cleanup, so the behavior is not changed. Link: https://lore.kernel.org/all/170952363585.229804.13060759900346411951.stgit@devnote2/ Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Stable-dep-of: 373b9338c972 ("uprobe: avoid out-of-bounds memory access of fetching args") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
This commit is contained in:
committed by
Stefan Bader
parent
fb43612791
commit
0df75aa8fb
@@ -1383,9 +1383,6 @@ int traceprobe_parse_probe_arg(struct trace_probe *tp, int i, const char *arg,
|
||||
struct probe_arg *parg = &tp->args[i];
|
||||
const char *body;
|
||||
|
||||
/* Increment count for freeing args in error case */
|
||||
tp->nr_args++;
|
||||
|
||||
body = strchr(arg, '=');
|
||||
if (body) {
|
||||
if (body - arg > MAX_ARG_NAME_LEN) {
|
||||
@@ -1770,7 +1767,7 @@ void trace_probe_cleanup(struct trace_probe *tp)
|
||||
}
|
||||
|
||||
int trace_probe_init(struct trace_probe *tp, const char *event,
|
||||
const char *group, bool alloc_filter)
|
||||
const char *group, bool alloc_filter, int nargs)
|
||||
{
|
||||
struct trace_event_call *call;
|
||||
size_t size = sizeof(struct trace_probe_event);
|
||||
@@ -1806,6 +1803,11 @@ int trace_probe_init(struct trace_probe *tp, const char *event,
|
||||
goto error;
|
||||
}
|
||||
|
||||
tp->nr_args = nargs;
|
||||
/* Make sure pointers in args[] are NULL */
|
||||
if (nargs)
|
||||
memset(tp->args, 0, sizeof(tp->args[0]) * nargs);
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
|
||||
Reference in New Issue
Block a user