From: sashiko-bot@kernel.org
To: "Jiri Olsa" <jolsa@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCHv2 bpf-next 3/3] bpftool: Add tracing_multi link info output
Date: Tue, 23 Jun 2026 14:38:25 +0000 [thread overview]
Message-ID: <20260623143826.336821F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260623142417.275892-4-jolsa@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The patch references non-existent `tracing_multi` fields in `struct bpf_link_info` causing a build failure, and the corresponding kernel `.fill_link_info` callback is missing.
- [Medium] Dynamically allocated memory for `ids`, `addrs`, and `cookies` arrays is leaked if the subsequent `bpf_link_get_info_by_fd()` call fails.
--
commit 1c150871ddc705d0719c83498c9983e353211882
Author: Jiri Olsa <jolsa@kernel.org>
bpftool: Add tracing_multi link info output
This patch adds support to bpftool to display tracing_multi link details.
It updates both the JSON and plain text output formats to show attached
functions, addresses, and cookies.
> diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c
> index bdcd717b0348f..db780ee398206 100644
> --- a/tools/bpf/bpftool/link.c
> +++ b/tools/bpf/bpftool/link.c
[ ... ]
> @@ -1114,6 +1217,39 @@ static int do_show_link(int fd)
> goto again;
> }
> }
> + if (info.type == BPF_LINK_TYPE_TRACING_MULTI &&
> + !info.tracing_multi.ids) {
[Severity: Medium]
Will this break the build? It appears the tracing_multi struct is missing
from the bpf_link_info union in include/uapi/linux/bpf.h.
Also, it seems the kernel side might be missing the .fill_link_info
callback in bpf_tracing_multi_link_lops (in kernel/trace/bpf_trace.c)
to export this data to userspace.
> + count = info.tracing_multi.count;
> + if (count) {
> + ids = calloc(count, sizeof(__u32));
> + if (!ids) {
> + p_err("mem alloc failed");
> + close(fd);
> + return -ENOMEM;
> + }
> + info.tracing_multi.ids = ptr_to_u64(ids);
> +
> + addrs = calloc(count, sizeof(__u64));
> + if (!addrs) {
> + p_err("mem alloc failed");
> + free(ids);
> + close(fd);
> + return -ENOMEM;
> + }
> + info.tracing_multi.addrs = ptr_to_u64(addrs);
> +
> + cookies = calloc(count, sizeof(__u64));
> + if (!cookies) {
> + p_err("mem alloc failed");
> + free(addrs);
> + free(ids);
> + close(fd);
> + return -ENOMEM;
> + }
> + info.tracing_multi.cookies = ptr_to_u64(cookies);
> + goto again;
[Severity: Medium]
If the execution jumps to again: and the subsequent call to
bpf_link_get_info_by_fd() fails, does this leak the memory allocated
for ids, addrs, and cookies?
Looking at the error path earlier in do_show_link():
again:
err = bpf_link_get_info_by_fd(fd, &info, &len);
if (err) {
p_err("can't get link info: %s",
strerror(errno));
close(fd);
return err;
}
It returns immediately without freeing these arrays if the second
syscall fails (e.g., due to a concurrent increase in function count
or link destruction).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260623142417.275892-4-jolsa@kernel.org?part=1
next prev parent reply other threads:[~2026-06-23 14:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 14:24 [PATCHv2 bpf-next 0/3] bpf: tracing_multi link info support Jiri Olsa
2026-06-23 14:24 ` [PATCHv2 bpf-next 1/3] bpf: Add " Jiri Olsa
2026-06-23 15:32 ` Leon Hwang
2026-06-23 21:01 ` Andrii Nakryiko
2026-06-24 9:36 ` Jiri Olsa
2026-06-23 14:24 ` [PATCHv2 bpf-next 2/3] selftests/bpf: Add tracing_multi link info tests Jiri Olsa
2026-06-23 14:39 ` sashiko-bot
2026-06-23 14:24 ` [PATCHv2 bpf-next 3/3] bpftool: Add tracing_multi link info output Jiri Olsa
2026-06-23 14:38 ` sashiko-bot [this message]
2026-06-23 21:11 ` Andrii Nakryiko
2026-06-24 11:32 ` Jiri Olsa
2026-06-23 20:51 ` [PATCHv2 bpf-next 0/3] bpf: tracing_multi link info support Andrii Nakryiko
2026-06-24 9:29 ` Jiri Olsa
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=20260623143826.336821F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox