From: sashiko-bot@kernel.org
To: "Leon Hwang" <leon.hwang@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 12/13] selftests/bpf: Add tracing_multi bpf prog link info test
Date: Sun, 09 Aug 2026 15:29:39 +0000 [thread overview]
Message-ID: <20260809152940.0EFDF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260809150111.45000-13-leon.hwang@linux.dev>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Missing array sorting in user-space targets leads to flaky test
- [Medium] Uninitialized stack variable `fids` passed to kernel
--
--- Patch [12]: [PATCH bpf-next 12/13] selftests/bpf: Add tracing_multi bpf prog link info test ---
commit 5ee3239754522a052ad0eb2cf3e2485319bff581
Author: Leon Hwang <leon.hwang@linux.dev>
selftests/bpf: Add tracing_multi bpf prog link info test
Verify the link info works well for bpf prog targets of tracing_multi link.
> diff --git a/tools/testing/selftests/bpf/prog_tests/fill_link_info.c b/tools/testing/selftests/bpf/prog_tests/fill_link_info.c
> index 0918321c8e63d..a5f8bfcb1e07a 100644
> --- a/tools/testing/selftests/bpf/prog_tests/fill_link_info.c
> +++ b/tools/testing/selftests/bpf/prog_tests/fill_link_info.c
[ ... ]
> @@ -467,13 +489,48 @@ static int setup_tmulti_targets(const struct bpf_program *prog,
> return -1;
> }
>
> +static int setup_tmulti_bpf_prog_targets(const struct bpf_program *prog, int token_fd,
> + const __u64 *cookies,
> + const struct bpf_program * const *target_progs,
> + struct tmulti_target *targets,
> + __u32 *btf_obj_id)
> +{
[ ... ]
> + targets[i].cookie = cookies[i];
> + targets[i].id = prog_info.id;
> + targets[i].func_btf_id = func_btf_id;
> + }
> +
> + return setup_tmulti_btf_obj_id(prog, btf_obj_id);
> +}
[Severity: Medium]
Will this lead to flaky tests? The kernel sorts the tracing_multi targets by a
computed key during attachment.
When returning link info, the arrays are returned in this sorted order, and
verify_tracing_multi_link_info() asserts that they perfectly match the targets
array at the exact same indexes.
However, unlike setup_tmulti_targets(), this function does not call qsort() on
the targets array. If ID allocation wraps around or another process allocates
IDs concurrently, this might fail non-deterministically.
> +
> static int verify_tracing_multi_link_info(int fd, const struct bpf_program *prog,
> const struct tmulti_target *targets,
> - __u32 btf_obj_id, bool has_cookies)
> + __u32 btf_obj_id, __u32 count,
> + bool has_cookies, bool tgt_progs)
> {
> +#define TMULTI_CNT (TRACING_MULTI_CNT > TRACING_MULTI_BPF_CNT ? \
> + TRACING_MULTI_CNT : TRACING_MULTI_BPF_CNT)
> enum bpf_attach_type attach_type = bpf_program__expected_attach_type(prog);
> - __u64 addrs[TRACING_MULTI_CNT], cookies[TRACING_MULTI_CNT];
> - __u32 ids[TRACING_MULTI_CNT];
> + __u64 addrs[TMULTI_CNT], cookies[TMULTI_CNT];
> + __u32 ids[TMULTI_CNT], fids[TMULTI_CNT];
> struct bpf_link_info info;
> __u32 len = sizeof(info);
> int err, i;
[ ... ]
> memset(ids, 0, sizeof(ids));
> memset(cookies, 0, sizeof(cookies));
> @@ -496,7 +555,8 @@ static int verify_tracing_multi_link_info(int fd, const struct bpf_program *prog
> info.tracing_multi.ids = ptr_to_u64(ids);
> info.tracing_multi.addrs = ptr_to_u64(addrs);
> info.tracing_multi.cookies = has_cookies ? ptr_to_u64(cookies) : 0;
> - info.tracing_multi.count = TRACING_MULTI_CNT;
> + info.tracing_multi.func_btf_ids = tgt_progs ? ptr_to_u64(fids) : 0;
> + info.tracing_multi.count = count;
>
> err = bpf_link_get_info_by_fd(fd, &info, &len);
[Severity: Medium]
Does this code leave the fids array uninitialized?
The other stack arrays (ids, cookies, addrs) are explicitly cleared with
memset() before being passed to the bpf_link_get_info_by_fd() syscall, but
fids is not. This could potentially cause issues with uninitialized memory.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260809150111.45000-1-leon.hwang@linux.dev?part=12
next prev parent reply other threads:[~2026-08-09 15:29 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-09 15:00 [PATCH bpf-next 00/13] bpf: Add tracing_multi link support for bpf progs Leon Hwang
2026-08-09 15:00 ` [PATCH bpf-next 01/13] bpf: Initialize ftrace_managed in bpf_trampoline_get Leon Hwang
2026-08-09 15:01 ` [PATCH bpf-next 02/13] bpf: Factor out update_fentry_multi helper Leon Hwang
2026-08-09 15:14 ` sashiko-bot
2026-08-09 15:01 ` [PATCH bpf-next 03/13] bpf: Drop unnecessary ftrace_location() in update_fentry_multi() Leon Hwang
2026-08-09 15:01 ` [PATCH bpf-next 04/13] bpf: Add tracing_multi link support for bpf progs Leon Hwang
2026-08-09 15:33 ` sashiko-bot
2026-08-10 13:13 ` Jiri Olsa
2026-08-11 6:12 ` Leon Hwang
2026-08-09 15:01 ` [PATCH bpf-next 05/13] libbpf: " Leon Hwang
2026-08-09 15:21 ` sashiko-bot
2026-08-09 15:01 ` [PATCH bpf-next 06/13] bpf: Add tracing_multi link fdinfo " Leon Hwang
2026-08-09 16:20 ` bot+bpf-ci
2026-08-09 15:01 ` [PATCH bpf-next 07/13] bpf: Add tracing_multi link info " Leon Hwang
2026-08-09 15:17 ` sashiko-bot
2026-08-09 15:01 ` [PATCH bpf-next 08/13] selftests/bpf: Add tracing_multi bpf prog attach test Leon Hwang
2026-08-09 15:01 ` [PATCH bpf-next 09/13] selftests/bpf: Add tracing_multi bpf prog attach failure tests Leon Hwang
2026-08-09 15:17 ` sashiko-bot
2026-08-09 15:01 ` [PATCH bpf-next 10/13] selftests/bpf: Add tracing_multi bpf prog cookie test Leon Hwang
2026-08-09 16:20 ` bot+bpf-ci
2026-08-09 15:01 ` [PATCH bpf-next 11/13] selftests/bpf: Add tracing_multi bpf prog rollback test Leon Hwang
2026-08-09 15:21 ` sashiko-bot
2026-08-09 15:01 ` [PATCH bpf-next 12/13] selftests/bpf: Add tracing_multi bpf prog link info test Leon Hwang
2026-08-09 15:29 ` sashiko-bot [this message]
2026-08-09 15:01 ` [PATCH bpf-next 13/13] selftests/bpf: Test tailcall with fentry.multi Leon Hwang
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=20260809152940.0EFDF1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=leon.hwang@linux.dev \
--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.