From: Leon Hwang <leon.hwang@linux.dev>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 07/13] bpf: Add tracing_multi link info support for bpf progs
Date: Wed, 12 Aug 2026 12:05:37 +0800 [thread overview]
Message-ID: <85f244d7-32d0-4d0a-bd44-a7972a09575d@linux.dev> (raw)
In-Reply-To: <20260809151726.269221F000E9@smtp.kernel.org>
On 9/8/26 23:17, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [Medium] Out-of-bounds Read / Uninitialized Memory Leak in sym_name_trim_prefix()
> - [Medium] UAPI Anti-Pattern: Usage of C bitfields in UAPI headers
> --
>
> --- Patch [7]: [PATCH bpf-next 07/13] bpf: Add tracing_multi link info support for bpf progs ---
> commit 65386c192a0d673092c95f3f31578ae7c4d19498
> Author: Leon Hwang <leon.hwang@linux.dev>
> Subject: bpf: Add tracing_multi link info support for bpf progs
>
> This commit adds tracing_multi link info support for BPF programs. It
> updates the bpf_link_info structure and extends bpftool to show function
> BTF IDs and program IDs.
>
>> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
>> index 6fa93a6ff54f2..e0c8ea5ed2c8f 100644
>> --- a/include/uapi/linux/bpf.h
>> +++ b/include/uapi/linux/bpf.h
>> @@ -6890,10 +6890,12 @@ struct bpf_link_info {
>> __u32 attach_type;
>> __u32 count; /* in/out: tracing_multi target count */
>> __u32 btf_obj_id;
>> - __u32 :32;
>> + __u32 tgt_progs:1;
>> + __u32 :31;
>
> [Severity: Medium]
> Could this cause endianness issues since C bitfield layout is
> implementation-defined?
>
> The established Linux UAPI standard is to use a __u32 flags field with
> bitmask macros instead of C bitfields to ensure portability across
> architectures and cross-platform tools. (This also applies to the mirrored
> header in tools/include/uapi/linux/bpf.h).
>
Correct.
Will use the bit mask style by changing '__u32 :32' to '__u32 flags' and
adding BPF_F_TRACING_MULTI_TGT_PROGS.
> [ ... ]
>
>> diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c
>> index 088d1d206065f..d5c5ec433350b 100644
>> --- a/tools/bpf/bpftool/link.c
>> +++ b/tools/bpf/bpftool/link.c
> [ ... ]
>> +#define BPF_PROG_PREFIX "bpf_prog_"
>> +#define BPF_PROG_PREFIX_LEN (sizeof(BPF_PROG_PREFIX) - 1)
>> +
>> +static const char *
>> +sym_name_trim_prefix(struct kernel_sym *sym, bool is_prog)
>> +{
>> + int prefix_len;
>> +
>> + if (!is_prog)
>> + return sym->name;
>> +
>> + /* Ref kernel/bpf/core.c::bpf_prog_ksym_set_name() */
>> + prefix_len = BPF_PROG_PREFIX_LEN;
>> + prefix_len += BPF_TAG_SIZE * 2;
>> + prefix_len += 1; /* skip the '_' */
>> + return sym->name + prefix_len;
>
> [Severity: Medium]
> Does this code read past the null terminator for unnamed BPF programs?
>
> When processing an unnamed BPF program (e.g., exported in kallsyms as
> bpf_prog_9a7f9e3ab6f138ab), the sym->name buffer contains exactly 25
> characters. Here, prefix_len is calculated as 26 (9 + 16 + 1).
>
> This offset advances the pointer past the null terminator into
> uninitialized heap memory, which is then passed to the JSON string writer
> when calling jsonw_string_field() later in show_tracing_multi_json().
>
Correct.
According to bpf_prog_ksym_set_name(), will check "sym->name[prefix_len]
!= '\0'" before "+= 1".
Thanks,
Leon
next prev parent reply other threads:[~2026-08-12 4:05 UTC|newest]
Thread overview: 34+ 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-12 4:02 ` Leon Hwang
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-12 4:03 ` Leon Hwang
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-12 4:03 ` Leon Hwang
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-12 4:04 ` Leon Hwang
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-12 4:05 ` Leon Hwang [this message]
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-12 4:06 ` Leon Hwang
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-12 4:06 ` Leon Hwang
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-12 4:07 ` Leon Hwang
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
2026-08-12 4:08 ` Leon Hwang
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=85f244d7-32d0-4d0a-bd44-a7972a09575d@linux.dev \
--to=leon.hwang@linux.dev \
--cc=bpf@vger.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