On Mon, 7 Oct 2024 15:11:15 +0100
Leo Yan <leo.yan@arm.com> wrote:
> In the kernel, the probe group string length is limited up to
> MAX_EVENT_NAME_LEN (including the NULL terminator).
This looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thank you,
>
> Check for this limitation and report an error if it is exceeded.
>
> Signed-off-by: Leo Yan <leo.yan@arm.com>
> ---
> tools/perf/util/probe-event.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index cad11d95af4f..71acea07cb46 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -2872,6 +2872,13 @@ static int probe_trace_event__set_name(struct probe_trace_event *tev,
> else
> group = PERFPROBE_GROUP;
>
> + if (strlen(group) >= MAX_EVENT_NAME_LEN) {
> + pr_err("Probe group string='%s' is too long (>= %d bytes)\n",
> + group, MAX_EVENT_NAME_LEN);
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> /* Get an unused new event name */
> ret = get_new_event_name(buf, MAX_EVENT_NAME_LEN, event, namelist,
> tev->point.retprobe, allow_suffix);
> --
> 2.34.1
>
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>