From: sashiko-bot@kernel.org
To: "Jiri Olsa" <jolsa@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 3/3] bpftool: Add tracing_multi link info output
Date: Sun, 21 Jun 2026 20:56:27 +0000 [thread overview]
Message-ID: <20260621205628.2920D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260621204524.61067-4-jolsa@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Repeated parsing of `/proc/kallsyms` in an O(N) loop when symbol loading fails.
--
commit 0f11f8e705a95b6aa483a05374ffb9b22bcb78c0
Author: Jiri Olsa <jolsa@kernel.org>
bpftool: Add tracing_multi link info output
This commit adds bpftool support to show tracing_multi link details for both
plain and JSON outputs.
> diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c
> index bdcd717b0348f..58dadee984a07 100644
> --- a/tools/bpf/bpftool/link.c
> +++ b/tools/bpf/bpftool/link.c
> @@ -377,6 +377,31 @@ static __u64 *u64_to_arr(__u64 val)
> return (__u64 *) u64_to_ptr(val);
> }
>
> +static __u32 *u64_to_u32_arr(__u64 val)
> +{
> + return (__u32 *)u64_to_ptr(val);
> +}
> +
> +static struct kernel_sym *find_kernel_sym_by_addr(__u64 addr, bool is_ibt_enabled)
> +{
> + struct kernel_sym *sym;
> +
> + if (!addr)
> + return NULL;
> +
> + /* Load it once for all. */
> + if (!dd.sym_count)
> + kernel_syms_load(&dd);
> + if (!dd.sym_count)
> + return NULL;
> +
> + sym = kernel_syms_search(&dd, addr);
> + if (!sym && is_ibt_enabled && addr >= 4)
> + sym = kernel_syms_search(&dd, addr - 4);
> +
> + return sym;
> +}
[ ... ]
> @@ -403,6 +428,43 @@ show_uprobe_multi_json(struct bpf_link_info *info, json_writer_t *wtr)
> jsonw_end_array(json_wtr);
> }
>
> +static void
> +show_tracing_multi_json(struct bpf_link_info *info, json_writer_t *wtr)
> +{
> + bool is_ibt_enabled = is_x86_ibt_enabled();
> + __u32 i;
> +
> + show_link_attach_type_json(info->tracing_multi.attach_type, wtr);
> + jsonw_uint_field(wtr, "func_cnt", info->tracing_multi.count);
> + jsonw_uint_field(wtr, "obj_id", info->tracing_multi.obj_id);
> + jsonw_name(wtr, "funcs");
> +
> + jsonw_start_array(wtr);
> +
> + for (i = 0; i < info->tracing_multi.count; i++) {
> + __u64 addr = u64_to_arr(info->tracing_multi.addrs)[i];
> + struct kernel_sym *sym;
> +
> + sym = find_kernel_sym_by_addr(addr, is_ibt_enabled);
[Severity: Medium]
If kernel_syms_load() fails (for example, due to kernel.kptr_restrict or
a lack of read permissions for /proc/kallsyms), dd.sym_count remains 0.
Since find_kernel_sym_by_addr() checks !dd.sym_count to decide whether to load
symbols, won't this cause /proc/kallsyms to be repeatedly opened and parsed on
every iteration of this loop if the initial load fails?
This loop occurs here in show_tracing_multi_json() as well as in
show_tracing_multi_plain(). For tracing_multi links with potentially thousands
of targets, could this result in a significant performance hang for bpftool?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260621204524.61067-1-jolsa@kernel.org?part=3
prev parent reply other threads:[~2026-06-21 20:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-21 20:45 [PATCH bpf-next 0/3] bpf: tracing_multi link info support Jiri Olsa
2026-06-21 20:45 ` [PATCH bpf-next 1/3] bpf: Add " Jiri Olsa
2026-06-21 20:45 ` [PATCH bpf-next 2/3] selftests/bpf: Add tracing_multi link info tests Jiri Olsa
2026-06-21 20:53 ` sashiko-bot
2026-06-21 21:31 ` bot+bpf-ci
2026-06-21 20:45 ` [PATCH bpf-next 3/3] bpftool: Add tracing_multi link info output Jiri Olsa
2026-06-21 20:56 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260621205628.2920D1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=jolsa@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.