From: sashiko-bot@kernel.org
To: "Xu Kuohai" <xukuohai@huaweicloud.com>
Cc: bpf@vger.kernel.org
Subject: Re: [RFC PATCH bpf-next 02/12] libbpf: Introduce bpf SDT probe macros
Date: Sat, 27 Jun 2026 15:01:23 +0000 [thread overview]
Message-ID: <20260627150124.4D3D41F000E9@smtp.kernel.org> (raw)
In-Reply-To: <8d42452bd09872847be4c1953e4e1362db898d9a.1782571533.git.xukuohai@huawei.com>
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] Hardcoded named labels in inline assembly break compilation during routine compiler optimizations.
- [High] Missing `static` keyword on dummy type-checking variables causes linker errors.
- [High] Missing `"memory"` clobber in inline assembly allows the compiler to reorder memory operations past the probe site.
- [Medium] Macro local variable names (`__a0`, `__a1`, etc.) are insufficiently obfuscated, leading to variable shadowing and trace data corruption.
- [Low] BPF subsystem multi-line comment style violation.
--
commit 225a1b2d44558cc189a9e559d3f30514eab101a7
Author: Xu Kuohai <xukuohai@huawei.com>
libbpf: Introduce bpf SDT probe macros
Introduce macros to declare and define bpf SDT probes. The declaration is
used to generate BTF ID of FUNC_PROTO for each probe site, so the probe
sites can be validated by the kernel, and observer programs can be attached
to the FUNC_PROTO like normal tracing programs.
> diff --git a/tools/lib/bpf/bpf_sdt.h b/tools/lib/bpf/bpf_sdt.h
> new file mode 100644
> index 0000000000000..23f84460aa368
> --- /dev/null
> +++ b/tools/lib/bpf/bpf_sdt.h
[ ... ]
> +#define BPF_SDT_DECLARE1(name, t0) \
> + ___sdt_decl_attr(name, 1) \
> + static void (*const __sdt_type_##name)(t0); \
> + ___sdt_chk_attr t0 __sdt_chk_##name##_0
[Severity: High]
Could this missing static keyword cause linker errors?
If a developer places BPF_SDT_DECLARE<N> in a shared header included in
multiple translation units, modern compilers defaulting to -fno-common might
throw multiple strong definition errors for these dummy variables since they
lack the static keyword.
[ ... ]
> +/* probe macros, 0-5 arguments
> + *
> + * Each probe emits a NOP (goto +0) in the program stream plus a
> + * .bpf_sdt_notes entry. The entry begins with the ___sdt_jt_<name>
[Severity: Low]
This isn't a bug, but the BPF subsystem multi-line comment style requires
the opening /* to be on its own line.
> + * label so that libbpf can locate each entry boundary at load time.
> + * One BPF_SDT_PROBE<N> invocation per probe name is required; invoking
> + * the same name twice produces a duplicate symbol.
> + */
> +#define BPF_SDT_PROBE(name) \
> +({ \
> + asm volatile( \
> + "0:\n" \
> + "goto +0\n" \
> + ".pushsection .bpf_sdt_notes,\"\",@progbits\n" \
> + "___sdt_jt_" #name ":\n" \
[Severity: High]
Does this inline assembly block need a "memory" clobber?
Without it, could the compiler reorder memory operations past the probe
site, causing attached observer programs to read stale or uncommitted state
when triggered?
[Severity: High]
Can the fixed label ___sdt_jt_ #name cause a build failure?
If the compiler unrolls a loop containing this macro or inlines an
__always_inline caller multiple times, it seems the assembler would
encounter multiple identical labels and fail with a redefinition error.
[ ... ]
> +#define BPF_SDT_PROBE2(name, a, b) \
> +({ \
> + _Static_assert(__builtin_types_compatible_p(typeof(a), \
> + typeof(__sdt_chk_##name##_0)), \
> + "BPF_SDT_PROBE2: arg0 type mismatch"); \
> + _Static_assert(sizeof(typeof(a)) <= 8, \
> + "BPF_SDT_PROBE2: arg0 too large, use pointer"); \
> + _Static_assert(__builtin_types_compatible_p(typeof(b), \
> + typeof(__sdt_chk_##name##_1)), \
> + "BPF_SDT_PROBE2: arg1 type mismatch"); \
> + _Static_assert(sizeof(typeof(b)) <= 8, \
> + "BPF_SDT_PROBE2: arg1 too large, use pointer"); \
> + typeof(a) __a0 = (a); \
> + typeof(b) __a1 = (b); \
[Severity: Medium]
Can these local variable names silently shadow caller variables?
If a caller passes a variable named __a0 as the second argument (b), does
the declaration of __a1 capture the macro's newly declared __a0 instead of
the caller's variable, resulting in the probe recording the first argument
twice?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1782571533.git.xukuohai@huawei.com?part=2
next prev parent reply other threads:[~2026-06-27 15:01 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-27 22:51 [RFC PATCH bpf-next 00/12] bpf: Introduce static-defined tracing probe for BPF Xu Kuohai
2026-06-27 20:51 ` [syzbot ci] " syzbot ci
2026-06-27 22:51 ` [RFC PATCH bpf-next 01/12] libbpf: Prepare bpf SDT probe section for the linker Xu Kuohai
2026-06-27 17:05 ` sashiko-bot
2026-06-27 22:51 ` [RFC PATCH bpf-next 02/12] libbpf: Introduce bpf SDT probe macros Xu Kuohai
2026-06-27 15:01 ` sashiko-bot [this message]
2026-06-27 22:51 ` [RFC PATCH bpf-next 03/12] libbpf: Add bpf_sdt_notes section parser Xu Kuohai
2026-06-27 15:03 ` sashiko-bot
2026-06-27 22:51 ` [RFC PATCH bpf-next 04/12] bpf: Create insn_array map for bpf SDT probe Xu Kuohai
2026-06-27 15:18 ` sashiko-bot
2026-06-27 15:34 ` bot+bpf-ci
2026-06-27 22:51 ` [RFC PATCH bpf-next 05/12] bpf: Collect SDT probe BTF IDs from BTF decl tags Xu Kuohai
2026-06-27 15:20 ` sashiko-bot
2026-06-27 15:34 ` bot+bpf-ci
2026-06-27 22:51 ` [RFC PATCH bpf-next 06/12] bpf: Add type check for SDT probe site Xu Kuohai
2026-06-27 15:04 ` sashiko-bot
2026-06-27 15:22 ` bot+bpf-ci
2026-06-27 22:51 ` [RFC PATCH bpf-next 07/12] bpf: Record probe name in SDT map Xu Kuohai
2026-06-27 15:06 ` sashiko-bot
2026-06-27 22:51 ` [RFC PATCH bpf-next 08/12] libbpf: Add libbpf support to load SDT observer program Xu Kuohai
2026-06-27 15:12 ` sashiko-bot
2026-06-27 22:51 ` [RFC PATCH bpf-next 09/12] bpf: Add kernel " Xu Kuohai
2026-06-27 15:12 ` sashiko-bot
2026-06-27 15:22 ` bot+bpf-ci
2026-06-27 22:51 ` [RFC PATCH bpf-next 10/12] bpf: Support attach and detach for " Xu Kuohai
2026-06-27 17:12 ` sashiko-bot
2026-06-27 22:51 ` [RFC PATCH bpf-next 11/12] bpf, x86: Add JIT support SDT for probe Xu Kuohai
2026-06-27 15:13 ` sashiko-bot
2026-06-27 15:22 ` bot+bpf-ci
2026-06-27 22:51 ` [RFC PATCH bpf-next 12/12] selftests/bpf: Add tests for bpf SDT probe Xu Kuohai
2026-06-27 15:25 ` sashiko-bot
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=20260627150124.4D3D41F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=xukuohai@huaweicloud.com \
/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.